feat: 实现供应商管理模块
- 新增供应商管理功能 - 数据库表:asset_supplier(27个字段) - 基本信息:供应商编码、名称、类型、合作状态等 - 开票信息:税号、开票地址、账号、开户行等 - 完整的 CRUD 接口 - 后端代码 - Controller/Service/Mapper/VO/DO 完整实现 - 支持多条件分页查询 - 字段验证(手机号、邮箱格式) - 供应商编码唯一性约束 - API 接口 - POST /asset/supplier/create - 创建供应商 - PUT /asset/supplier/update - 更新供应商 - DELETE /asset/supplier/delete - 删除供应商 - GET /asset/supplier/get - 获取供应商详情 - GET /asset/supplier/page - 分页查询供应商 - 查询功能 - 供应商编码精确查询 - 合作状态多选筛选 - 供应商名称模糊查询 - 供应商类型多选筛选 - 区域多选筛选 - 城市精确查询 - 创建者筛选 - 菜单和权限 - 供应商管理菜单 - 5个按钮权限(查询、创建、更新、删除、导出) - 文档 - 供应商管理模块开发总结 - 数据库初始化脚本
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierPageReqVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierRespVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierSaveReqVO;
|
||||
import cn.iocoder.yudao.module.asset.convert.supplier.SupplierConvert;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.supplier.SupplierDO;
|
||||
import cn.iocoder.yudao.module.asset.service.supplier.SupplierService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 供应商信息 Controller
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Tag(name = "管理后台 - 供应商信息")
|
||||
@RestController
|
||||
@RequestMapping("/asset/supplier")
|
||||
@Validated
|
||||
public class SupplierController {
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建供应商")
|
||||
@PreAuthorize("@ss.hasPermission('asset:supplier:create')")
|
||||
public CommonResult<Long> createSupplier(@Valid @RequestBody SupplierSaveReqVO createReqVO) {
|
||||
return success(supplierService.createSupplier(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新供应商")
|
||||
@PreAuthorize("@ss.hasPermission('asset:supplier:update')")
|
||||
public CommonResult<Boolean> updateSupplier(@Valid @RequestBody SupplierSaveReqVO updateReqVO) {
|
||||
supplierService.updateSupplier(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除供应商")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset: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 = "1")
|
||||
@PreAuthorize("@ss.hasPermission('asset:supplier:query')")
|
||||
public CommonResult<SupplierRespVO> getSupplier(@RequestParam("id") Long id) {
|
||||
SupplierDO supplier = supplierService.getSupplier(id);
|
||||
return success(SupplierConvert.INSTANCE.convert(supplier));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得供应商分页")
|
||||
@PreAuthorize("@ss.hasPermission('asset:supplier:query')")
|
||||
public CommonResult<PageResult<SupplierRespVO>> getSupplierPage(@Valid SupplierPageReqVO pageReqVO) {
|
||||
PageResult<SupplierDO> pageResult = supplierService.getSupplierPage(pageReqVO);
|
||||
return success(SupplierConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.supplier.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 供应商信息 Base VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class SupplierBaseVO {
|
||||
|
||||
@Schema(description = "供应商编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "GYS-2025-001")
|
||||
@NotBlank(message = "供应商编码不能为空")
|
||||
private String supplierCode;
|
||||
|
||||
@Schema(description = "合作状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "已合作")
|
||||
@NotBlank(message = "合作状态不能为空")
|
||||
private String coopStatus;
|
||||
|
||||
@Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "嘉兴某某加氢站")
|
||||
@NotBlank(message = "供应商名称不能为空")
|
||||
private String supplierName;
|
||||
|
||||
@Schema(description = "供应商类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "加氢站")
|
||||
@NotBlank(message = "供应商类型不能为空")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "省份", example = "浙江省")
|
||||
private String province;
|
||||
|
||||
@Schema(description = "城市", example = "嘉兴市")
|
||||
private String city;
|
||||
|
||||
@Schema(description = "详细地址", example = "浙江省嘉兴市南湖区科技大道1号")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "区域", example = "华东")
|
||||
private String region;
|
||||
|
||||
@Schema(description = "联系人", example = "张三")
|
||||
private String contact;
|
||||
|
||||
@Schema(description = "联系手机", example = "13800138001")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
||||
private String contactMobile;
|
||||
|
||||
@Schema(description = "联系电话", example = "0571-88888888")
|
||||
private String contactPhone;
|
||||
|
||||
@Schema(description = "邮箱", example = "zhangsan@example.com")
|
||||
@Email(message = "邮箱格式不正确")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "统一社会信用代码/身份证号", example = "91330400MA2XXXXX1")
|
||||
private String creditCodeOrId;
|
||||
|
||||
@Schema(description = "备注", example = "")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "税号", example = "91330400MA2XXXXX1")
|
||||
private String taxId;
|
||||
|
||||
@Schema(description = "开票地址", example = "浙江省嘉兴市南湖区科技大道1号")
|
||||
private String invoiceAddress;
|
||||
|
||||
@Schema(description = "开票电话", example = "0571-88888888")
|
||||
private String invoicePhone;
|
||||
|
||||
@Schema(description = "账号", example = "6222021234567890123")
|
||||
private String account;
|
||||
|
||||
@Schema(description = "开户行", example = "中国工商银行嘉兴分行")
|
||||
private String openingBank;
|
||||
|
||||
@Schema(description = "邮寄地址", example = "浙江省嘉兴市南湖区科技大道1号")
|
||||
private String mailingAddress;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.supplier.vo;
|
||||
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 供应商信息 - 分页查询 Request VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Schema(description = "管理后台 - 供应商信息分页查询 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SupplierPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "供应商编码", example = "GYS-2025-001")
|
||||
private String supplierCode;
|
||||
|
||||
@Schema(description = "合作状态列表", example = "[\"已合作\", \"洽谈中\"]")
|
||||
private List<String> coopStatus;
|
||||
|
||||
@Schema(description = "供应商名称(模糊查询)", example = "加氢站")
|
||||
private String supplierName;
|
||||
|
||||
@Schema(description = "供应商类型列表", example = "[\"加氢站\", \"充电站\"]")
|
||||
private List<String> type;
|
||||
|
||||
@Schema(description = "区域列表", example = "[\"华东\", \"华南\"]")
|
||||
private List<String> region;
|
||||
|
||||
@Schema(description = "城市", example = "嘉兴市")
|
||||
private String city;
|
||||
|
||||
@Schema(description = "创建者", example = "admin")
|
||||
private String creator;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.supplier.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 供应商信息 - 响应 VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Schema(description = "管理后台 - 供应商信息 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SupplierRespVO extends SupplierBaseVO {
|
||||
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建者", example = "admin")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新者", example = "admin")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.asset.controller.admin.supplier.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 供应商信息 - 创建/更新 Request VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Schema(description = "管理后台 - 供应商信息创建/更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SupplierSaveReqVO extends SupplierBaseVO {
|
||||
|
||||
@Schema(description = "主键ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.asset.convert.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierRespVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierSaveReqVO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.supplier.SupplierDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 供应商信息 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SupplierConvert {
|
||||
|
||||
SupplierConvert INSTANCE = Mappers.getMapper(SupplierConvert.class);
|
||||
|
||||
SupplierDO convert(SupplierSaveReqVO bean);
|
||||
|
||||
SupplierRespVO convert(SupplierDO bean);
|
||||
|
||||
PageResult<SupplierRespVO> convertPage(PageResult<SupplierDO> page);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package cn.iocoder.yudao.module.asset.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.*;
|
||||
|
||||
/**
|
||||
* 供应商信息 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("asset_supplier")
|
||||
@KeySequence("asset_supplier_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SupplierDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 供应商编码
|
||||
*/
|
||||
private String supplierCode;
|
||||
|
||||
/**
|
||||
* 合作状态
|
||||
*/
|
||||
private String coopStatus;
|
||||
|
||||
/**
|
||||
* 供应商名称
|
||||
*/
|
||||
private String supplierName;
|
||||
|
||||
/**
|
||||
* 供应商类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 区域
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String contact;
|
||||
|
||||
/**
|
||||
* 联系手机
|
||||
*/
|
||||
private String contactMobile;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String contactPhone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 统一社会信用代码/身份证号
|
||||
*/
|
||||
private String creditCodeOrId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 税号
|
||||
*/
|
||||
private String taxId;
|
||||
|
||||
/**
|
||||
* 开票地址
|
||||
*/
|
||||
private String invoiceAddress;
|
||||
|
||||
/**
|
||||
* 开票电话
|
||||
*/
|
||||
private String invoicePhone;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 开户行
|
||||
*/
|
||||
private String openingBank;
|
||||
|
||||
/**
|
||||
* 邮寄地址
|
||||
*/
|
||||
private String mailingAddress;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.asset.dal.mysql.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierPageReqVO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.supplier.SupplierDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 供应商信息 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SupplierMapper extends BaseMapperX<SupplierDO> {
|
||||
|
||||
default PageResult<SupplierDO> selectPage(SupplierPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<SupplierDO>()
|
||||
.eqIfPresent(SupplierDO::getSupplierCode, reqVO.getSupplierCode())
|
||||
.inIfPresent(SupplierDO::getCoopStatus, reqVO.getCoopStatus())
|
||||
.likeIfPresent(SupplierDO::getSupplierName, reqVO.getSupplierName())
|
||||
.inIfPresent(SupplierDO::getType, reqVO.getType())
|
||||
.inIfPresent(SupplierDO::getRegion, reqVO.getRegion())
|
||||
.eqIfPresent(SupplierDO::getCity, reqVO.getCity())
|
||||
.eqIfPresent(SupplierDO::getCreator, reqVO.getCreator())
|
||||
.orderByDesc(SupplierDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,4 +20,7 @@ public interface ErrorCodeConstants {
|
||||
// ========== 客户管理 1-008-003-000 ==========
|
||||
ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_008_003_000, "客户不存在");
|
||||
|
||||
// ========== 供应商管理 1-008-004-000 ==========
|
||||
ErrorCode SUPPLIER_NOT_EXISTS = new ErrorCode(1_008_004_000, "供应商不存在");
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.asset.service.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierPageReqVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierSaveReqVO;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.supplier.SupplierDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* 供应商信息 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SupplierService {
|
||||
|
||||
/**
|
||||
* 创建供应商
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createSupplier(@Valid SupplierSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新供应商
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateSupplier(@Valid SupplierSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除供应商
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteSupplier(Long id);
|
||||
|
||||
/**
|
||||
* 获得供应商
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 供应商
|
||||
*/
|
||||
SupplierDO getSupplier(Long id);
|
||||
|
||||
/**
|
||||
* 获得供应商分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 供应商分页
|
||||
*/
|
||||
PageResult<SupplierDO> getSupplierPage(SupplierPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package cn.iocoder.yudao.module.asset.service.supplier;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierPageReqVO;
|
||||
import cn.iocoder.yudao.module.asset.controller.admin.supplier.vo.SupplierSaveReqVO;
|
||||
import cn.iocoder.yudao.module.asset.convert.supplier.SupplierConvert;
|
||||
import cn.iocoder.yudao.module.asset.dal.dataobject.supplier.SupplierDO;
|
||||
import cn.iocoder.yudao.module.asset.dal.mysql.supplier.SupplierMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.asset.enums.ErrorCodeConstants.SUPPLIER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 供应商信息 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class SupplierServiceImpl implements SupplierService {
|
||||
|
||||
@Resource
|
||||
private SupplierMapper supplierMapper;
|
||||
|
||||
@Override
|
||||
public Long createSupplier(SupplierSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
SupplierDO supplier = SupplierConvert.INSTANCE.convert(createReqVO);
|
||||
supplierMapper.insert(supplier);
|
||||
|
||||
log.info("[createSupplier][创建供应商成功,ID:{},供应商编码:{},供应商名称:{}]",
|
||||
supplier.getId(), supplier.getSupplierCode(), supplier.getSupplierName());
|
||||
|
||||
return supplier.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSupplier(SupplierSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateSupplierExists(updateReqVO.getId());
|
||||
|
||||
// 更新
|
||||
SupplierDO updateObj = SupplierConvert.INSTANCE.convert(updateReqVO);
|
||||
supplierMapper.updateById(updateObj);
|
||||
|
||||
log.info("[updateSupplier][更新供应商成功,ID:{},供应商编码:{},供应商名称:{}]",
|
||||
updateObj.getId(), updateObj.getSupplierCode(), updateObj.getSupplierName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSupplier(Long id) {
|
||||
// 校验存在
|
||||
validateSupplierExists(id);
|
||||
|
||||
// 删除
|
||||
supplierMapper.deleteById(id);
|
||||
|
||||
log.info("[deleteSupplier][删除供应商成功,ID:{}]", id);
|
||||
}
|
||||
|
||||
private void validateSupplierExists(Long id) {
|
||||
if (supplierMapper.selectById(id) == null) {
|
||||
throw exception(SUPPLIER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SupplierDO getSupplier(Long id) {
|
||||
return supplierMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SupplierDO> getSupplierPage(SupplierPageReqVO pageReqVO) {
|
||||
return supplierMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user