✨ ERP:增加供应商的实现
parent
46d26659bf
commit
bfe3dc95fe
@ -0,0 +1,102 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.purchase;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierRespVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO;
|
||||
import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - ERP 供应商")
|
||||
@RestController
|
||||
@RequestMapping("/erp/supplier")
|
||||
@Validated
|
||||
public class ErpSupplierController {
|
||||
|
||||
@Resource
|
||||
private ErpSupplierService supplierService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建供应商")
|
||||
@PreAuthorize("@ss.hasPermission('erp:supplier:create')")
|
||||
public CommonResult<Long> createSupplier(@Valid @RequestBody ErpSupplierSaveReqVO createReqVO) {
|
||||
return success(supplierService.createSupplier(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新供应商")
|
||||
@PreAuthorize("@ss.hasPermission('erp:supplier:update')")
|
||||
public CommonResult<Boolean> updateSupplier(@Valid @RequestBody ErpSupplierSaveReqVO updateReqVO) {
|
||||
supplierService.updateSupplier(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除供应商")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('erp:supplier:delete')")
|
||||
public CommonResult<Boolean> deleteSupplier(@RequestParam("id") Long id) {
|
||||
supplierService.deleteSupplier(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得供应商")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('erp:supplier:query')")
|
||||
public CommonResult<ErpSupplierRespVO> getSupplier(@RequestParam("id") Long id) {
|
||||
ErpSupplierDO supplier = supplierService.getSupplier(id);
|
||||
return success(BeanUtils.toBean(supplier, ErpSupplierRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得供应商分页")
|
||||
@PreAuthorize("@ss.hasPermission('erp:supplier:query')")
|
||||
public CommonResult<PageResult<ErpSupplierRespVO>> getSupplierPage(@Valid ErpSupplierPageReqVO pageReqVO) {
|
||||
PageResult<ErpSupplierDO> pageResult = supplierService.getSupplierPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ErpSupplierRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得供应商精简列表", description = "只包含被开启的供应商,主要用于前端的下拉选项")
|
||||
public CommonResult<List<ErpSupplierRespVO>> getSupplierSimpleList() {
|
||||
List<ErpSupplierDO> list = supplierService.getSupplierListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(convertList(list, supplier -> new ErpSupplierRespVO().setId(supplier.getId()).setName(supplier.getName())));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出供应商 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('erp:supplier:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportSupplierExcel(@Valid ErpSupplierPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ErpSupplierDO> list = supplierService.getSupplierPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "供应商.xls", "数据", ErpSupplierRespVO.class,
|
||||
BeanUtils.toBean(list, ErpSupplierRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - ERP 供应商分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ErpSupplierPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "供应商名称", example = "芋道源码")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "手机号码", example = "15601691300")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "联系电话", example = "18818288888")
|
||||
private String telephone;
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - ERP 供应商 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ErpSupplierRespVO {
|
||||
|
||||
@Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17791")
|
||||
@ExcelProperty("供应商编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||
@ExcelProperty("供应商名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "联系人", example = "芋艿")
|
||||
@ExcelProperty("联系人")
|
||||
private String contact;
|
||||
|
||||
@Schema(description = "手机号码", example = "15601691300")
|
||||
@ExcelProperty("手机号码")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "联系电话", example = "18818288888")
|
||||
@ExcelProperty("联系电话")
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "电子邮箱", example = "76853@qq.com")
|
||||
@ExcelProperty("电子邮箱")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "传真", example = "20 7123 4567")
|
||||
@ExcelProperty("传真")
|
||||
private String fax;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "开启状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "纳税人识别号", example = "91130803MA098BY05W")
|
||||
@ExcelProperty("纳税人识别号")
|
||||
private String taxNo;
|
||||
|
||||
@Schema(description = "税率", example = "10")
|
||||
@ExcelProperty("税率")
|
||||
private BigDecimal taxPercent;
|
||||
|
||||
@Schema(description = "开户行", example = "张三")
|
||||
@ExcelProperty("开户行")
|
||||
private String bankName;
|
||||
|
||||
@Schema(description = "开户账号", example = "622908212277228617")
|
||||
@ExcelProperty("开户账号")
|
||||
private String bankAccount;
|
||||
|
||||
@Schema(description = "开户地址", example = "兴业银行浦东支行")
|
||||
@ExcelProperty("开户地址")
|
||||
private String bankAddress;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - ERP 供应商新增/修改 Request VO")
|
||||
@Data
|
||||
public class ErpSupplierSaveReqVO {
|
||||
|
||||
@Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17791")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||
@NotEmpty(message = "供应商名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "联系人", example = "芋艿")
|
||||
private String contact;
|
||||
|
||||
@Schema(description = "手机号码", example = "15601691300")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "联系电话", example = "18818288888")
|
||||
@Telephone
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "电子邮箱", example = "76853@qq.com")
|
||||
@Email
|
||||
private String email;
|
||||
|
||||
@Schema(description = "传真", example = "20 7123 4567")
|
||||
private String fax;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "开启状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "纳税人识别号", example = "91130803MA098BY05W")
|
||||
private String taxNo;
|
||||
|
||||
@Schema(description = "税率", example = "10")
|
||||
private BigDecimal taxPercent;
|
||||
|
||||
@Schema(description = "开户行", example = "张三")
|
||||
private String bankName;
|
||||
|
||||
@Schema(description = "开户账号", example = "622908212277228617")
|
||||
private String bankAccount;
|
||||
|
||||
@Schema(description = "开户地址", example = "兴业银行浦东支行")
|
||||
private String bankAddress;
|
||||
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package cn.iocoder.yudao.module.erp.dal.dataobject.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* ERP 供应商 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("erp_supplier")
|
||||
@KeySequence("erp_supplier_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ErpSupplierDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 供应商编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 供应商名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String contact;
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String telephone;
|
||||
/**
|
||||
* 电子邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 传真
|
||||
*/
|
||||
private String fax;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 开启状态
|
||||
*
|
||||
* 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 纳税人识别号
|
||||
*/
|
||||
private String taxNo;
|
||||
/**
|
||||
* 税率
|
||||
*/
|
||||
private BigDecimal taxPercent;
|
||||
/**
|
||||
* 开户行
|
||||
*/
|
||||
private String bankName;
|
||||
/**
|
||||
* 开户账号
|
||||
*/
|
||||
private String bankAccount;
|
||||
/**
|
||||
* 开户地址
|
||||
*/
|
||||
private String bankAddress;
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.erp.dal.mysql.purchase;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ERP 供应商 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ErpSupplierMapper extends BaseMapperX<ErpSupplierDO> {
|
||||
|
||||
default PageResult<ErpSupplierDO> selectPage(ErpSupplierPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ErpSupplierDO>()
|
||||
.likeIfPresent(ErpSupplierDO::getName, reqVO.getName())
|
||||
.likeIfPresent(ErpSupplierDO::getMobile, reqVO.getMobile())
|
||||
.likeIfPresent(ErpSupplierDO::getTelephone, reqVO.getTelephone())
|
||||
.orderByDesc(ErpSupplierDO::getId));
|
||||
}
|
||||
|
||||
default List<ErpSupplierDO> selectListByStatus(Integer status) {
|
||||
return selectList(ErpSupplierDO::getStatus, status);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package cn.iocoder.yudao.module.erp.service.purchase;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
/**
|
||||
* ERP 供应商 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface ErpSupplierService {
|
||||
|
||||
/**
|
||||
* 创建供应商
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createSupplier(@Valid ErpSupplierSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新供应商
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateSupplier(@Valid ErpSupplierSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除供应商
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteSupplier(Long id);
|
||||
|
||||
/**
|
||||
* 获得供应商
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 供应商
|
||||
*/
|
||||
ErpSupplierDO getSupplier(Long id);
|
||||
|
||||
/**
|
||||
* 校验供应商
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 供应商
|
||||
*/
|
||||
ErpSupplierDO validateSupplier(Long id);
|
||||
|
||||
/**
|
||||
* 获得供应商列表
|
||||
*
|
||||
* @param ids 编号列表
|
||||
* @return 供应商列表
|
||||
*/
|
||||
List<ErpSupplierDO> getSupplierList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得供应商 Map
|
||||
*
|
||||
* @param ids 编号列表
|
||||
* @return 供应商 Map
|
||||
*/
|
||||
default Map<Long, ErpSupplierDO> getSupplierMap(Collection<Long> ids) {
|
||||
return convertMap(getSupplierList(ids), ErpSupplierDO::getId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得供应商分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 供应商分页
|
||||
*/
|
||||
PageResult<ErpSupplierDO> getSupplierPage(ErpSupplierPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得指定状态的供应商列表
|
||||
*
|
||||
* @param status 状态
|
||||
* @return 供应商列表
|
||||
*/
|
||||
List<ErpSupplierDO> getSupplierListByStatus(Integer status);
|
||||
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package cn.iocoder.yudao.module.erp.service.purchase;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO;
|
||||
import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* ERP 供应商 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ErpSupplierServiceImpl implements ErpSupplierService {
|
||||
|
||||
@Resource
|
||||
private ErpSupplierMapper supplierMapper;
|
||||
|
||||
@Override
|
||||
public Long createSupplier(ErpSupplierSaveReqVO createReqVO) {
|
||||
ErpSupplierDO supplier = BeanUtils.toBean(createReqVO, ErpSupplierDO.class);
|
||||
supplierMapper.insert(supplier);
|
||||
return supplier.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSupplier(ErpSupplierSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateSupplierExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ErpSupplierDO updateObj = BeanUtils.toBean(updateReqVO, ErpSupplierDO.class);
|
||||
supplierMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSupplier(Long id) {
|
||||
// 校验存在
|
||||
validateSupplierExists(id);
|
||||
// 删除
|
||||
supplierMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateSupplierExists(Long id) {
|
||||
if (supplierMapper.selectById(id) == null) {
|
||||
throw exception(SUPPLIER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErpSupplierDO getSupplier(Long id) {
|
||||
return supplierMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErpSupplierDO validateSupplier(Long id) {
|
||||
ErpSupplierDO supplier = supplierMapper.selectById(id);
|
||||
if (supplier == null) {
|
||||
throw exception(WAREHOUSE_NOT_EXISTS);
|
||||
}
|
||||
if (CommonStatusEnum.isDisable(supplier.getStatus())) {
|
||||
throw exception(WAREHOUSE_NOT_ENABLE, supplier.getName());
|
||||
}
|
||||
return supplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ErpSupplierDO> getSupplierList(Collection<Long> ids) {
|
||||
return supplierMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ErpSupplierDO> getSupplierPage(ErpSupplierPageReqVO pageReqVO) {
|
||||
return supplierMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ErpSupplierDO> getSupplierListByStatus(Integer status) {
|
||||
return supplierMapper.selectListByStatus(status);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue