Commit dc8883d3c1128afc5325d0651efe406fea4899d5
1 parent
338d8345
feat(wms):完善往来企业
Showing
10 changed files
with
576 additions
and
2 deletions
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/merchant/WmsMerchantController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.merchant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 8 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 9 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantRespVO; | |
| 11 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; | |
| 12 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; | |
| 13 | +import cn.iocoder.yudao.module.wms.service.md.merchant.WmsMerchantService; | |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import jakarta.servlet.http.HttpServletResponse; | |
| 19 | +import jakarta.validation.Valid; | |
| 20 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 21 | +import org.springframework.validation.annotation.Validated; | |
| 22 | +import org.springframework.web.bind.annotation.*; | |
| 23 | + | |
| 24 | +import java.io.IOException; | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | |
| 28 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 29 | + | |
| 30 | +@Tag(name = "管理后台 - WMS 往来企业") | |
| 31 | +@RestController | |
| 32 | +@RequestMapping("/wms/merchant") | |
| 33 | +@Validated | |
| 34 | +public class WmsMerchantController { | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private WmsMerchantService merchantService; | |
| 38 | + | |
| 39 | + @PostMapping("/create") | |
| 40 | + @Operation(summary = "创建往来企业") | |
| 41 | + @PreAuthorize("@ss.hasPermission('wms:merchant:create')") | |
| 42 | + public CommonResult<Long> createMerchant(@Valid @RequestBody WmsMerchantSaveReqVO createReqVO) { | |
| 43 | + return success(merchantService.createMerchant(createReqVO)); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @PutMapping("/update") | |
| 47 | + @Operation(summary = "更新往来企业") | |
| 48 | + @PreAuthorize("@ss.hasPermission('wms:merchant:update')") | |
| 49 | + public CommonResult<Boolean> updateMerchant(@Valid @RequestBody WmsMerchantSaveReqVO updateReqVO) { | |
| 50 | + merchantService.updateMerchant(updateReqVO); | |
| 51 | + return success(true); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @DeleteMapping("/delete") | |
| 55 | + @Operation(summary = "删除往来企业") | |
| 56 | + @Parameter(name = "id", description = "编号", required = true) | |
| 57 | + @PreAuthorize("@ss.hasPermission('wms:merchant:delete')") | |
| 58 | + public CommonResult<Boolean> deleteMerchant(@RequestParam("id") Long id) { | |
| 59 | + merchantService.deleteMerchant(id); | |
| 60 | + return success(true); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @GetMapping("/get") | |
| 64 | + @Operation(summary = "获得往来企业") | |
| 65 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 66 | + @PreAuthorize("@ss.hasPermission('wms:merchant:query')") | |
| 67 | + public CommonResult<WmsMerchantRespVO> getMerchant(@RequestParam("id") Long id) { | |
| 68 | + WmsMerchantDO merchant = merchantService.getMerchant(id); | |
| 69 | + return success(BeanUtils.toBean(merchant, WmsMerchantRespVO.class)); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @GetMapping("/page") | |
| 73 | + @Operation(summary = "获得往来企业分页") | |
| 74 | + @PreAuthorize("@ss.hasPermission('wms:merchant:query')") | |
| 75 | + public CommonResult<PageResult<WmsMerchantRespVO>> getMerchantPage(@Valid WmsMerchantPageReqVO pageReqVO) { | |
| 76 | + PageResult<WmsMerchantDO> pageResult = merchantService.getMerchantPage(pageReqVO); | |
| 77 | + return success(BeanUtils.toBean(pageResult, WmsMerchantRespVO.class)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @GetMapping("/simple-list") | |
| 81 | + @Operation(summary = "获得往来企业精简列表", description = "主要用于前端下拉") | |
| 82 | + @PreAuthorize("@ss.hasPermission('wms:merchant:query')") | |
| 83 | + public CommonResult<List<WmsMerchantRespVO>> getMerchantSimpleList(@Valid WmsMerchantPageReqVO pageReqVO) { | |
| 84 | + List<WmsMerchantDO> list = merchantService.getMerchantList(pageReqVO); | |
| 85 | + return success(BeanUtils.toBean(list, WmsMerchantRespVO.class)); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @GetMapping("/export-excel") | |
| 89 | + @Operation(summary = "导出往来企业 Excel") | |
| 90 | + @PreAuthorize("@ss.hasPermission('wms:merchant:export')") | |
| 91 | + @ApiAccessLog(operateType = EXPORT) | |
| 92 | + public void exportMerchantExcel(@Valid WmsMerchantPageReqVO pageReqVO, | |
| 93 | + HttpServletResponse response) throws IOException { | |
| 94 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 95 | + List<WmsMerchantDO> list = merchantService.getMerchantPage(pageReqVO).getList(); | |
| 96 | + ExcelUtils.write(response, "往来企业.xls", "数据", WmsMerchantRespVO.class, | |
| 97 | + BeanUtils.toBean(list, WmsMerchantRespVO.class)); | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/merchant/vo/WmsMerchantPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import cn.iocoder.yudao.module.wms.enums.md.WmsMerchantTypeEnum; | |
| 6 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 7 | +import lombok.Data; | |
| 8 | +import lombok.EqualsAndHashCode; | |
| 9 | +import lombok.ToString; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - WMS 往来企业分页 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class WmsMerchantPageReqVO extends PageParam { | |
| 16 | + | |
| 17 | + @Schema(description = "往来企业编号", example = "MER001") | |
| 18 | + private String code; | |
| 19 | + | |
| 20 | + @Schema(description = "往来企业名称", example = "华为") | |
| 21 | + private String name; | |
| 22 | + | |
| 23 | + @Schema(description = "往来企业类型", example = "2") | |
| 24 | + @InEnum(value = WmsMerchantTypeEnum.class, message = "往来企业类型必须是 {value}") | |
| 25 | + private Integer type; | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/merchant/vo/WmsMerchantRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo; | |
| 2 | + | |
| 3 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | |
| 4 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 5 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 6 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 7 | +import cn.iocoder.yudao.module.wms.enums.DictTypeConstants; | |
| 8 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 9 | +import lombok.Data; | |
| 10 | + | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 13 | +@Schema(description = "管理后台 - WMS 往来企业 Response VO") | |
| 14 | +@Data | |
| 15 | +@ExcelIgnoreUnannotated | |
| 16 | +public class WmsMerchantRespVO { | |
| 17 | + | |
| 18 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 19 | + @ExcelProperty("编号") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @Schema(description = "往来企业编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "MER001") | |
| 23 | + @ExcelProperty("往来企业编号") | |
| 24 | + private String code; | |
| 25 | + | |
| 26 | + @Schema(description = "往来企业名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "华为") | |
| 27 | + @ExcelProperty("往来企业名称") | |
| 28 | + private String name; | |
| 29 | + | |
| 30 | + @Schema(description = "往来企业类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 31 | + @ExcelProperty(value = "往来企业类型", converter = DictConvert.class) | |
| 32 | + @DictFormat(DictTypeConstants.MERCHANT_TYPE) | |
| 33 | + private Integer type; | |
| 34 | + | |
| 35 | + @Schema(description = "级别", example = "A") | |
| 36 | + @ExcelProperty("级别") | |
| 37 | + private String level; | |
| 38 | + | |
| 39 | + @Schema(description = "开户行", example = "招商银行") | |
| 40 | + private String bankName; | |
| 41 | + | |
| 42 | + @Schema(description = "银行账户", example = "6225888888888888") | |
| 43 | + private String bankAccount; | |
| 44 | + | |
| 45 | + @Schema(description = "地址", example = "深圳市南山区") | |
| 46 | + private String address; | |
| 47 | + | |
| 48 | + @Schema(description = "手机号", example = "15601691300") | |
| 49 | + private String mobile; | |
| 50 | + | |
| 51 | + @Schema(description = "座机号", example = "0755-88888888") | |
| 52 | + private String telephone; | |
| 53 | + | |
| 54 | + @Schema(description = "联系人", example = "王五") | |
| 55 | + @ExcelProperty("联系人") | |
| 56 | + private String contact; | |
| 57 | + | |
| 58 | + @Schema(description = "Email", example = "wms@example.com") | |
| 59 | + private String email; | |
| 60 | + | |
| 61 | + @Schema(description = "备注", example = "备注") | |
| 62 | + @ExcelProperty("备注") | |
| 63 | + private String remark; | |
| 64 | + | |
| 65 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 66 | + private LocalDateTime createTime; | |
| 67 | + | |
| 68 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/merchant/vo/WmsMerchantSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | +import cn.iocoder.yudao.module.wms.enums.md.WmsMerchantTypeEnum; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import jakarta.validation.constraints.NotBlank; | |
| 7 | +import jakarta.validation.constraints.NotNull; | |
| 8 | +import jakarta.validation.constraints.Size; | |
| 9 | +import lombok.Data; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - WMS 往来企业创建/更新 Request VO") | |
| 12 | +@Data | |
| 13 | +public class WmsMerchantSaveReqVO { | |
| 14 | + | |
| 15 | + @Schema(description = "编号", example = "1024") | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | + @Schema(description = "往来企业编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "MER001") | |
| 19 | + @NotBlank(message = "往来企业编号不能为空") | |
| 20 | + @Size(max = 20, message = "往来企业编号长度不能超过 20 个字符") | |
| 21 | + private String code; | |
| 22 | + | |
| 23 | + @Schema(description = "往来企业名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "华为") | |
| 24 | + @NotBlank(message = "往来企业名称不能为空") | |
| 25 | + @Size(max = 60, message = "往来企业名称长度不能超过 60 个字符") | |
| 26 | + private String name; | |
| 27 | + | |
| 28 | + @Schema(description = "往来企业类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 29 | + @NotNull(message = "往来企业类型不能为空") | |
| 30 | + @InEnum(value = WmsMerchantTypeEnum.class, message = "往来企业类型必须是 {value}") | |
| 31 | + private Integer type; | |
| 32 | + | |
| 33 | + @Schema(description = "级别", example = "A") | |
| 34 | + @Size(max = 10, message = "级别长度不能超过 10 个字符") | |
| 35 | + private String level; | |
| 36 | + | |
| 37 | + @Schema(description = "开户行", example = "招商银行") | |
| 38 | + @Size(max = 255, message = "开户行长度不能超过 255 个字符") | |
| 39 | + private String bankName; | |
| 40 | + | |
| 41 | + @Schema(description = "银行账户", example = "6225888888888888") | |
| 42 | + @Size(max = 40, message = "银行账户长度不能超过 40 个字符") | |
| 43 | + private String bankAccount; | |
| 44 | + | |
| 45 | + @Schema(description = "地址", example = "深圳市南山区") | |
| 46 | + @Size(max = 200, message = "地址长度不能超过 200 个字符") | |
| 47 | + private String address; | |
| 48 | + | |
| 49 | + @Schema(description = "手机号", example = "15601691300") | |
| 50 | + @Size(max = 13, message = "手机号长度不能超过 13 个字符") | |
| 51 | + private String mobile; | |
| 52 | + | |
| 53 | + @Schema(description = "座机号", example = "0755-88888888") | |
| 54 | + @Size(max = 13, message = "座机号长度不能超过 13 个字符") | |
| 55 | + private String telephone; | |
| 56 | + | |
| 57 | + @Schema(description = "联系人", example = "王五") | |
| 58 | + @Size(max = 30, message = "联系人长度不能超过 30 个字符") | |
| 59 | + private String contact; | |
| 60 | + | |
| 61 | + @Schema(description = "Email", example = "wms@example.com") | |
| 62 | + @Size(max = 50, message = "Email 长度不能超过 50 个字符") | |
| 63 | + private String email; | |
| 64 | + | |
| 65 | + @Schema(description = "备注", example = "备注") | |
| 66 | + @Size(max = 255, message = "备注长度不能超过 255 个字符") | |
| 67 | + private String remark; | |
| 68 | + | |
| 69 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/merchant/WmsMerchantDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.wms.enums.md.WmsMerchantTypeEnum; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.*; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * WMS 往来企业 DO | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@TableName("wms_merchant") | |
| 16 | +@KeySequence("wms_merchant_seq") | |
| 17 | +@Data | |
| 18 | +@EqualsAndHashCode(callSuper = true) | |
| 19 | +@ToString(callSuper = true) | |
| 20 | +@Builder | |
| 21 | +@NoArgsConstructor | |
| 22 | +@AllArgsConstructor | |
| 23 | +public class WmsMerchantDO extends BaseDO { | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 主键编号 | |
| 27 | + */ | |
| 28 | + @TableId | |
| 29 | + private Long id; | |
| 30 | + /** | |
| 31 | + * 往来企业编号 | |
| 32 | + */ | |
| 33 | + private String code; | |
| 34 | + /** | |
| 35 | + * 往来企业名称 | |
| 36 | + */ | |
| 37 | + private String name; | |
| 38 | + /** | |
| 39 | + * 往来企业类型 | |
| 40 | + * | |
| 41 | + * DONE @AI:枚举类 | |
| 42 | + * | |
| 43 | + * 枚举 {@link WmsMerchantTypeEnum} | |
| 44 | + */ | |
| 45 | + private Integer type; | |
| 46 | + /** | |
| 47 | + * 级别 | |
| 48 | + */ | |
| 49 | + private String level; | |
| 50 | + /** | |
| 51 | + * 开户行 | |
| 52 | + */ | |
| 53 | + private String bankName; | |
| 54 | + /** | |
| 55 | + * 银行账户 | |
| 56 | + */ | |
| 57 | + private String bankAccount; | |
| 58 | + /** | |
| 59 | + * 地址 | |
| 60 | + */ | |
| 61 | + private String address; | |
| 62 | + /** | |
| 63 | + * 手机号 | |
| 64 | + */ | |
| 65 | + private String mobile; | |
| 66 | + /** | |
| 67 | + * 座机号 | |
| 68 | + */ | |
| 69 | + private String telephone; | |
| 70 | + /** | |
| 71 | + * 联系人 | |
| 72 | + */ | |
| 73 | + private String contact; | |
| 74 | + /** | |
| 75 | ||
| 76 | + */ | |
| 77 | + private String email; | |
| 78 | + /** | |
| 79 | + * 备注 | |
| 80 | + */ | |
| 81 | + private String remark; | |
| 82 | + | |
| 83 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/merchant/WmsMerchantMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.dal.mysql.md.merchant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * WMS 往来企业 Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface WmsMerchantMapper extends BaseMapperX<WmsMerchantDO> { | |
| 19 | + | |
| 20 | + default PageResult<WmsMerchantDO> selectPage(WmsMerchantPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<WmsMerchantDO>() | |
| 22 | + .eqIfPresent(WmsMerchantDO::getCode, reqVO.getCode()) | |
| 23 | + .likeIfPresent(WmsMerchantDO::getName, reqVO.getName()) | |
| 24 | + .eqIfPresent(WmsMerchantDO::getType, reqVO.getType()) | |
| 25 | + .orderByDesc(WmsMerchantDO::getId)); | |
| 26 | + } | |
| 27 | + | |
| 28 | + default List<WmsMerchantDO> selectList(WmsMerchantPageReqVO reqVO) { | |
| 29 | + return selectList(new LambdaQueryWrapperX<WmsMerchantDO>() | |
| 30 | + .eqIfPresent(WmsMerchantDO::getCode, reqVO.getCode()) | |
| 31 | + .likeIfPresent(WmsMerchantDO::getName, reqVO.getName()) | |
| 32 | + .eqIfPresent(WmsMerchantDO::getType, reqVO.getType()) | |
| 33 | + .orderByDesc(WmsMerchantDO::getId)); | |
| 34 | + } | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java
| ... | ... | @@ -43,7 +43,7 @@ public interface ErrorCodeConstants { |
| 43 | 43 | ErrorCode ITEM_SKU_NAME_DUPLICATE = new ErrorCode(1_060_104_003, "商品规格名称【{}】重复"); |
| 44 | 44 | ErrorCode ITEM_SKU_NOT_EXISTS = new ErrorCode(1_060_104_004, "商品规格不存在"); |
| 45 | 45 | |
| 46 | - // ========== WMS 基础数据-供应商 1-060-105-000 ========== | |
| 47 | - ErrorCode MERCHANT_NOT_EXISTS = new ErrorCode(1_060_105_000, "供应商不存在"); | |
| 46 | + // ========== WMS 基础数据-往来企业 1-060-105-000 ========== | |
| 47 | + ErrorCode MERCHANT_NOT_EXISTS = new ErrorCode(1_060_105_000, "往来企业不存在"); | |
| 48 | 48 | |
| 49 | 49 | } | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/md/WmsMerchantTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.enums.md; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.ArrayValuable; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * WMS 往来企业类型枚举 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Getter | |
| 15 | +@AllArgsConstructor | |
| 16 | +public enum WmsMerchantTypeEnum implements ArrayValuable<Integer> { | |
| 17 | + | |
| 18 | + CUSTOMER(1, "客户"), | |
| 19 | + SUPPLIER(2, "供应商"), | |
| 20 | + CUSTOMER_SUPPLIER(3, "客户/供应商"); | |
| 21 | + | |
| 22 | + public static final Integer[] ARRAYS = Arrays.stream(values()).map(WmsMerchantTypeEnum::getType).toArray(Integer[]::new); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 类型 | |
| 26 | + */ | |
| 27 | + private final Integer type; | |
| 28 | + /** | |
| 29 | + * 名称 | |
| 30 | + */ | |
| 31 | + private final String name; | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public Integer[] array() { | |
| 35 | + return ARRAYS; | |
| 36 | + } | |
| 37 | + | |
| 38 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/merchant/WmsMerchantService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.md.merchant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * WMS 往来企业 Service 接口 | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +public interface WmsMerchantService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建往来企业 | |
| 20 | + * | |
| 21 | + * @param createReqVO 创建信息 | |
| 22 | + * @return 编号 | |
| 23 | + */ | |
| 24 | + Long createMerchant(@Valid WmsMerchantSaveReqVO createReqVO); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 更新往来企业 | |
| 28 | + * | |
| 29 | + * @param updateReqVO 更新信息 | |
| 30 | + */ | |
| 31 | + void updateMerchant(@Valid WmsMerchantSaveReqVO updateReqVO); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 删除往来企业 | |
| 35 | + * | |
| 36 | + * @param id 编号 | |
| 37 | + */ | |
| 38 | + void deleteMerchant(Long id); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 校验往来企业存在 | |
| 42 | + * | |
| 43 | + * @param id 编号 | |
| 44 | + * @return 往来企业 | |
| 45 | + */ | |
| 46 | + WmsMerchantDO validateMerchantExists(Long id); | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 获得往来企业 | |
| 50 | + * | |
| 51 | + * @param id 编号 | |
| 52 | + * @return 往来企业 | |
| 53 | + */ | |
| 54 | + WmsMerchantDO getMerchant(Long id); | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 获得往来企业分页 | |
| 58 | + * | |
| 59 | + * @param pageReqVO 分页查询 | |
| 60 | + * @return 往来企业分页 | |
| 61 | + */ | |
| 62 | + PageResult<WmsMerchantDO> getMerchantPage(WmsMerchantPageReqVO pageReqVO); | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * 获得往来企业列表 | |
| 66 | + * | |
| 67 | + * @param pageReqVO 查询条件 | |
| 68 | + * @return 往来企业列表 | |
| 69 | + */ | |
| 70 | + List<WmsMerchantDO> getMerchantList(WmsMerchantPageReqVO pageReqVO); | |
| 71 | + | |
| 72 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/merchant/WmsMerchantServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.md.merchant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; | |
| 7 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; | |
| 8 | +import cn.iocoder.yudao.module.wms.dal.mysql.md.merchant.WmsMerchantMapper; | |
| 9 | +import jakarta.annotation.Resource; | |
| 10 | +import org.springframework.stereotype.Service; | |
| 11 | +import org.springframework.validation.annotation.Validated; | |
| 12 | + | |
| 13 | +import java.util.List; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | +import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.MERCHANT_NOT_EXISTS; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * WMS 往来企业 Service 实现类 | |
| 20 | + * | |
| 21 | + * @author 芋道源码 | |
| 22 | + */ | |
| 23 | +@Service | |
| 24 | +@Validated | |
| 25 | +public class WmsMerchantServiceImpl implements WmsMerchantService { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private WmsMerchantMapper merchantMapper; | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public Long createMerchant(WmsMerchantSaveReqVO createReqVO) { | |
| 32 | + WmsMerchantDO merchant = BeanUtils.toBean(createReqVO, WmsMerchantDO.class); | |
| 33 | + merchantMapper.insert(merchant); | |
| 34 | + return merchant.getId(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void updateMerchant(WmsMerchantSaveReqVO updateReqVO) { | |
| 39 | + // 校验存在 | |
| 40 | + validateMerchantExists(updateReqVO.getId()); | |
| 41 | + | |
| 42 | + // 更新 | |
| 43 | + WmsMerchantDO updateObj = BeanUtils.toBean(updateReqVO, WmsMerchantDO.class); | |
| 44 | + merchantMapper.updateById(updateObj); | |
| 45 | + } | |
| 46 | + | |
| 47 | + @Override | |
| 48 | + public void deleteMerchant(Long id) { | |
| 49 | + // 校验存在 | |
| 50 | + validateMerchantExists(id); | |
| 51 | + // TODO 入库/出库单实现后,校验往来企业不存在业务关联后再删除 | |
| 52 | + | |
| 53 | + // 删除 | |
| 54 | + merchantMapper.deleteById(id); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + public WmsMerchantDO validateMerchantExists(Long id) { | |
| 59 | + WmsMerchantDO merchant = merchantMapper.selectById(id); | |
| 60 | + if (merchant == null) { | |
| 61 | + throw exception(MERCHANT_NOT_EXISTS); | |
| 62 | + } | |
| 63 | + return merchant; | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public WmsMerchantDO getMerchant(Long id) { | |
| 68 | + return merchantMapper.selectById(id); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public PageResult<WmsMerchantDO> getMerchantPage(WmsMerchantPageReqVO pageReqVO) { | |
| 73 | + return merchantMapper.selectPage(pageReqVO); | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public List<WmsMerchantDO> getMerchantList(WmsMerchantPageReqVO pageReqVO) { | |
| 78 | + return merchantMapper.selectList(pageReqVO); | |
| 79 | + } | |
| 80 | + | |
| 81 | +} | ... | ... |