Commit 22e50bab69b2b5a8ac370f380da0eb399b38be7c
1 parent
00dce643
feat(wms):增加商品分类、商品品牌。
Showing
19 changed files
with
884 additions
and
0 deletions
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemBrandController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item; | ||
| 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.item.vo.brand.WmsItemBrandPageReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandRespVO; | ||
| 11 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandSaveReqVO; | ||
| 12 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; | ||
| 13 | +import cn.iocoder.yudao.module.wms.service.md.item.WmsItemBrandService; | ||
| 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/item-brand") | ||
| 33 | +@Validated | ||
| 34 | +public class WmsItemBrandController { | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private WmsItemBrandService brandService; | ||
| 38 | + | ||
| 39 | + @PostMapping("/create") | ||
| 40 | + @Operation(summary = "创建商品品牌") | ||
| 41 | + @PreAuthorize("@ss.hasPermission('wms:item-brand:create')") | ||
| 42 | + public CommonResult<Long> createItemBrand(@Valid @RequestBody WmsItemBrandSaveReqVO createReqVO) { | ||
| 43 | + return success(brandService.createItemBrand(createReqVO)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @PutMapping("/update") | ||
| 47 | + @Operation(summary = "更新商品品牌") | ||
| 48 | + @PreAuthorize("@ss.hasPermission('wms:item-brand:update')") | ||
| 49 | + public CommonResult<Boolean> updateItemBrand(@Valid @RequestBody WmsItemBrandSaveReqVO updateReqVO) { | ||
| 50 | + brandService.updateItemBrand(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:item-brand:delete')") | ||
| 58 | + public CommonResult<Boolean> deleteItemBrand(@RequestParam("id") Long id) { | ||
| 59 | + brandService.deleteItemBrand(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:item-brand:query')") | ||
| 67 | + public CommonResult<WmsItemBrandRespVO> getItemBrand(@RequestParam("id") Long id) { | ||
| 68 | + WmsItemBrandDO brand = brandService.getItemBrand(id); | ||
| 69 | + return success(BeanUtils.toBean(brand, WmsItemBrandRespVO.class)); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @GetMapping("/page") | ||
| 73 | + @Operation(summary = "获得商品品牌分页") | ||
| 74 | + @PreAuthorize("@ss.hasPermission('wms:item-brand:query')") | ||
| 75 | + public CommonResult<PageResult<WmsItemBrandRespVO>> getItemBrandPage(@Valid WmsItemBrandPageReqVO pageReqVO) { | ||
| 76 | + PageResult<WmsItemBrandDO> pageResult = brandService.getItemBrandPage(pageReqVO); | ||
| 77 | + return success(BeanUtils.toBean(pageResult, WmsItemBrandRespVO.class)); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @GetMapping("/simple-list") | ||
| 81 | + @Operation(summary = "获得商品品牌精简列表", description = "主要用于前端下拉") | ||
| 82 | + @PreAuthorize("@ss.hasPermission('wms:item-brand:query')") | ||
| 83 | + public CommonResult<List<WmsItemBrandRespVO>> getItemBrandSimpleList() { | ||
| 84 | + List<WmsItemBrandDO> list = brandService.getItemBrandList(); | ||
| 85 | + return success(BeanUtils.toBean(list, WmsItemBrandRespVO.class)); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @GetMapping("/export-excel") | ||
| 89 | + @Operation(summary = "导出商品品牌 Excel") | ||
| 90 | + @PreAuthorize("@ss.hasPermission('wms:item-brand:export')") | ||
| 91 | + @ApiAccessLog(operateType = EXPORT) | ||
| 92 | + public void exportItemBrandExcel(@Valid WmsItemBrandPageReqVO pageReqVO, | ||
| 93 | + HttpServletResponse response) throws IOException { | ||
| 94 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 95 | + List<WmsItemBrandDO> list = brandService.getItemBrandPage(pageReqVO).getList(); | ||
| 96 | + ExcelUtils.write(response, "商品品牌.xls", "数据", WmsItemBrandRespVO.class, | ||
| 97 | + BeanUtils.toBean(list, WmsItemBrandRespVO.class)); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemCategoryController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryListReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryRespVO; | ||
| 7 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategorySaveReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; | ||
| 9 | +import cn.iocoder.yudao.module.wms.service.md.item.WmsItemCategoryService; | ||
| 10 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 11 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 12 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 13 | +import jakarta.annotation.Resource; | ||
| 14 | +import jakarta.validation.Valid; | ||
| 15 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 16 | +import org.springframework.validation.annotation.Validated; | ||
| 17 | +import org.springframework.web.bind.annotation.*; | ||
| 18 | + | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 21 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 22 | + | ||
| 23 | +@Tag(name = "管理后台 - WMS 商品分类") | ||
| 24 | +@RestController | ||
| 25 | +@RequestMapping("/wms/item-category") | ||
| 26 | +@Validated | ||
| 27 | +public class WmsItemCategoryController { | ||
| 28 | + | ||
| 29 | + @Resource | ||
| 30 | + private WmsItemCategoryService categoryService; | ||
| 31 | + | ||
| 32 | + @PostMapping("/create") | ||
| 33 | + @Operation(summary = "创建商品分类") | ||
| 34 | + @PreAuthorize("@ss.hasPermission('wms:item-category:create')") | ||
| 35 | + public CommonResult<Long> createItemCategory(@Valid @RequestBody WmsItemCategorySaveReqVO createReqVO) { | ||
| 36 | + return success(categoryService.createItemCategory(createReqVO)); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @PutMapping("/update") | ||
| 40 | + @Operation(summary = "更新商品分类") | ||
| 41 | + @PreAuthorize("@ss.hasPermission('wms:item-category:update')") | ||
| 42 | + public CommonResult<Boolean> updateItemCategory(@Valid @RequestBody WmsItemCategorySaveReqVO updateReqVO) { | ||
| 43 | + categoryService.updateItemCategory(updateReqVO); | ||
| 44 | + return success(true); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @DeleteMapping("/delete") | ||
| 48 | + @Operation(summary = "删除商品分类") | ||
| 49 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 50 | + @PreAuthorize("@ss.hasPermission('wms:item-category:delete')") | ||
| 51 | + public CommonResult<Boolean> deleteItemCategory(@RequestParam("id") Long id) { | ||
| 52 | + categoryService.deleteItemCategory(id); | ||
| 53 | + return success(true); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @GetMapping("/get") | ||
| 57 | + @Operation(summary = "获得商品分类") | ||
| 58 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 59 | + @PreAuthorize("@ss.hasPermission('wms:item-category:query')") | ||
| 60 | + public CommonResult<WmsItemCategoryRespVO> getItemCategory(@RequestParam("id") Long id) { | ||
| 61 | + WmsItemCategoryDO category = categoryService.getItemCategory(id); | ||
| 62 | + return success(BeanUtils.toBean(category, WmsItemCategoryRespVO.class)); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @GetMapping("/list") | ||
| 66 | + @Operation(summary = "获得商品分类列表") | ||
| 67 | + @PreAuthorize("@ss.hasPermission('wms:item-category:query')") | ||
| 68 | + public CommonResult<List<WmsItemCategoryRespVO>> getItemCategoryList(@Valid WmsItemCategoryListReqVO listReqVO) { | ||
| 69 | + List<WmsItemCategoryDO> list = categoryService.getItemCategoryList(listReqVO); | ||
| 70 | + return success(BeanUtils.toBean(list, WmsItemCategoryRespVO.class)); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @GetMapping("/simple-list") | ||
| 74 | + @Operation(summary = "获得商品分类精简列表", description = "主要用于前端下拉") | ||
| 75 | + @PreAuthorize("@ss.hasPermission('wms:item-category:query')") | ||
| 76 | + public CommonResult<List<WmsItemCategoryRespVO>> getItemCategorySimpleList() { | ||
| 77 | + List<WmsItemCategoryDO> list = categoryService.getItemCategoryList(new WmsItemCategoryListReqVO()); | ||
| 78 | + return success(BeanUtils.toBean(list, WmsItemCategoryRespVO.class)); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - WMS 商品品牌分页 Request VO") | ||
| 10 | +@Data | ||
| 11 | +@EqualsAndHashCode(callSuper = true) | ||
| 12 | +@ToString(callSuper = true) | ||
| 13 | +public class WmsItemBrandPageReqVO extends PageParam { | ||
| 14 | + | ||
| 15 | + @Schema(description = "品牌名称", example = "华为") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand; | ||
| 2 | + | ||
| 3 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | +import cn.idev.excel.annotation.ExcelProperty; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - WMS 商品品牌 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ExcelIgnoreUnannotated | ||
| 13 | +public class WmsItemBrandRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 16 | + @ExcelProperty("编号") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "华为") | ||
| 20 | + @ExcelProperty("品牌名称") | ||
| 21 | + private String name; | ||
| 22 | + | ||
| 23 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 24 | + @ExcelProperty("创建时间") | ||
| 25 | + private LocalDateTime createTime; | ||
| 26 | + | ||
| 27 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import jakarta.validation.constraints.Size; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - WMS 商品品牌新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class WmsItemBrandSaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "编号", example = "1024") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "华为") | ||
| 16 | + @NotEmpty(message = "品牌名称不能为空") | ||
| 17 | + @Size(max = 30, message = "品牌名称长度不能超过 30 个字符") | ||
| 18 | + private String name; | ||
| 19 | + | ||
| 20 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategoryListReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - WMS 商品分类列表 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class WmsItemCategoryListReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "父级编号", example = "1") | ||
| 13 | + private Long parentId; | ||
| 14 | + | ||
| 15 | + @Schema(description = "分类名称", example = "原料") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | + @Schema(description = "状态", example = "0") | ||
| 19 | + @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}") | ||
| 20 | + private Integer status; | ||
| 21 | + | ||
| 22 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategoryRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - WMS 商品分类 Response VO") | ||
| 9 | +@Data | ||
| 10 | +public class WmsItemCategoryRespVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 16 | + private Long parentId; | ||
| 17 | + | ||
| 18 | + @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "原料") | ||
| 19 | + private String name; | ||
| 20 | + | ||
| 21 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 22 | + private Integer sort; | ||
| 23 | + | ||
| 24 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 25 | + private Integer status; | ||
| 26 | + | ||
| 27 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 28 | + private LocalDateTime createTime; | ||
| 29 | + | ||
| 30 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategorySaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import jakarta.validation.constraints.NotEmpty; | ||
| 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 WmsItemCategorySaveReqVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "编号", example = "1024") | ||
| 16 | + private Long id; | ||
| 17 | + | ||
| 18 | + @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 19 | + @NotNull(message = "父级编号不能为空") | ||
| 20 | + private Long parentId; | ||
| 21 | + | ||
| 22 | + @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "原料") | ||
| 23 | + @NotEmpty(message = "分类名称不能为空") | ||
| 24 | + @Size(max = 30, message = "分类名称长度不能超过 30 个字符") | ||
| 25 | + private String name; | ||
| 26 | + | ||
| 27 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 28 | + @NotNull(message = "排序不能为空") | ||
| 29 | + private Integer sort; | ||
| 30 | + | ||
| 31 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 32 | + @NotNull(message = "状态不能为空") | ||
| 33 | + @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}") | ||
| 34 | + private Integer status; | ||
| 35 | + | ||
| 36 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseAreaController.java
| 1 | package cn.iocoder.yudao.module.wms.controller.admin.md.warehouse; | 1 | package cn.iocoder.yudao.module.wms.controller.admin.md.warehouse; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +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.CommonResult; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 8 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 10 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 8 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaPageReqVO; | 11 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaPageReqVO; |
| 9 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaRespVO; | 12 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaRespVO; |
| 10 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaSaveReqVO; | 13 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaSaveReqVO; |
| @@ -16,15 +19,18 @@ import io.swagger.v3.oas.annotations.Operation; | @@ -16,15 +19,18 @@ import io.swagger.v3.oas.annotations.Operation; | ||
| 16 | import io.swagger.v3.oas.annotations.Parameter; | 19 | import io.swagger.v3.oas.annotations.Parameter; |
| 17 | import io.swagger.v3.oas.annotations.tags.Tag; | 20 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 18 | import jakarta.annotation.Resource; | 21 | import jakarta.annotation.Resource; |
| 22 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 19 | import jakarta.validation.Valid; | 23 | import jakarta.validation.Valid; |
| 20 | import org.springframework.security.access.prepost.PreAuthorize; | 24 | import org.springframework.security.access.prepost.PreAuthorize; |
| 21 | import org.springframework.validation.annotation.Validated; | 25 | import org.springframework.validation.annotation.Validated; |
| 22 | import org.springframework.web.bind.annotation.*; | 26 | import org.springframework.web.bind.annotation.*; |
| 23 | 27 | ||
| 28 | +import java.io.IOException; | ||
| 24 | import java.util.Collections; | 29 | import java.util.Collections; |
| 25 | import java.util.List; | 30 | import java.util.List; |
| 26 | import java.util.Map; | 31 | import java.util.Map; |
| 27 | 32 | ||
| 33 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | ||
| 28 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 34 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 29 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 35 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 30 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getFirst; | 36 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getFirst; |
| @@ -90,6 +96,18 @@ public class WmsWarehouseAreaController { | @@ -90,6 +96,18 @@ public class WmsWarehouseAreaController { | ||
| 90 | return success(buildWarehouseAreaRespVOList(list)); | 96 | return success(buildWarehouseAreaRespVOList(list)); |
| 91 | } | 97 | } |
| 92 | 98 | ||
| 99 | + @GetMapping("/export-excel") | ||
| 100 | + @Operation(summary = "导出库区 Excel") | ||
| 101 | + @PreAuthorize("@ss.hasPermission('wms:warehouse-area:export')") | ||
| 102 | + @ApiAccessLog(operateType = EXPORT) | ||
| 103 | + public void exportWarehouseAreaExcel(@Valid WmsWarehouseAreaPageReqVO pageReqVO, | ||
| 104 | + HttpServletResponse response) throws IOException { | ||
| 105 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 106 | + List<WmsWarehouseAreaDO> list = warehouseAreaService.getWarehouseAreaPage(pageReqVO).getList(); | ||
| 107 | + ExcelUtils.write(response, "库区.xls", "数据", WmsWarehouseAreaRespVO.class, | ||
| 108 | + buildWarehouseAreaRespVOList(list)); | ||
| 109 | + } | ||
| 110 | + | ||
| 93 | // ==================== 拼接 VO ==================== | 111 | // ==================== 拼接 VO ==================== |
| 94 | 112 | ||
| 95 | private WmsWarehouseAreaRespVO buildWarehouseAreaRespVO(WmsWarehouseAreaDO area) { | 113 | private WmsWarehouseAreaRespVO buildWarehouseAreaRespVO(WmsWarehouseAreaDO area) { |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseController.java
| 1 | package cn.iocoder.yudao.module.wms.controller.admin.md.warehouse; | 1 | package cn.iocoder.yudao.module.wms.controller.admin.md.warehouse; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 6 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehousePageReqVO; | 9 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehousePageReqVO; |
| 7 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehouseRespVO; | 10 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehouseRespVO; |
| 8 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehouseSaveReqVO; | 11 | import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehouseSaveReqVO; |
| @@ -12,13 +15,16 @@ import io.swagger.v3.oas.annotations.Operation; | @@ -12,13 +15,16 @@ import io.swagger.v3.oas.annotations.Operation; | ||
| 12 | import io.swagger.v3.oas.annotations.Parameter; | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 13 | import io.swagger.v3.oas.annotations.tags.Tag; | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 14 | import jakarta.annotation.Resource; | 17 | import jakarta.annotation.Resource; |
| 18 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 15 | import jakarta.validation.Valid; | 19 | import jakarta.validation.Valid; |
| 16 | import org.springframework.security.access.prepost.PreAuthorize; | 20 | import org.springframework.security.access.prepost.PreAuthorize; |
| 17 | import org.springframework.validation.annotation.Validated; | 21 | import org.springframework.validation.annotation.Validated; |
| 18 | import org.springframework.web.bind.annotation.*; | 22 | import org.springframework.web.bind.annotation.*; |
| 19 | 23 | ||
| 24 | +import java.io.IOException; | ||
| 20 | import java.util.List; | 25 | import java.util.List; |
| 21 | 26 | ||
| 27 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | ||
| 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 28 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 23 | 29 | ||
| 24 | @Tag(name = "管理后台 - WMS 仓库") | 30 | @Tag(name = "管理后台 - WMS 仓库") |
| @@ -79,4 +85,16 @@ public class WmsWarehouseController { | @@ -79,4 +85,16 @@ public class WmsWarehouseController { | ||
| 79 | return success(BeanUtils.toBean(list, WmsWarehouseRespVO.class)); | 85 | return success(BeanUtils.toBean(list, WmsWarehouseRespVO.class)); |
| 80 | } | 86 | } |
| 81 | 87 | ||
| 88 | + @GetMapping("/export-excel") | ||
| 89 | + @Operation(summary = "导出仓库 Excel") | ||
| 90 | + @PreAuthorize("@ss.hasPermission('wms:warehouse:export')") | ||
| 91 | + @ApiAccessLog(operateType = EXPORT) | ||
| 92 | + public void exportWarehouseExcel(@Valid WmsWarehousePageReqVO pageReqVO, | ||
| 93 | + HttpServletResponse response) throws IOException { | ||
| 94 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 95 | + List<WmsWarehouseDO> list = warehouseService.getWarehousePage(pageReqVO).getList(); | ||
| 96 | + ExcelUtils.write(response, "仓库.xls", "数据", WmsWarehouseRespVO.class, | ||
| 97 | + BeanUtils.toBean(list, WmsWarehouseRespVO.class)); | ||
| 98 | + } | ||
| 99 | + | ||
| 82 | } | 100 | } |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/item/WmsItemBrandDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.dal.dataobject.md.item; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import lombok.*; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * WMS 商品品牌 DO | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +@TableName("wms_item_brand") | ||
| 15 | +@KeySequence("wms_item_brand_seq") | ||
| 16 | +@Data | ||
| 17 | +@EqualsAndHashCode(callSuper = true) | ||
| 18 | +@ToString(callSuper = true) | ||
| 19 | +@Builder | ||
| 20 | +@NoArgsConstructor | ||
| 21 | +@AllArgsConstructor | ||
| 22 | +public class WmsItemBrandDO extends BaseDO { | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 主键编号 | ||
| 26 | + */ | ||
| 27 | + @TableId | ||
| 28 | + private Long id; | ||
| 29 | + /** | ||
| 30 | + * 品牌名称 | ||
| 31 | + */ | ||
| 32 | + private String name; | ||
| 33 | + | ||
| 34 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/item/WmsItemCategoryDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.dal.dataobject.md.item; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 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_item_category") | ||
| 16 | +@KeySequence("wms_item_category_seq") | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class WmsItemCategoryDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 父级编号 - 根节点 | ||
| 27 | + */ | ||
| 28 | + public static final Long PARENT_ID_ROOT = 0L; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 主键编号 | ||
| 32 | + */ | ||
| 33 | + @TableId | ||
| 34 | + private Long id; | ||
| 35 | + /** | ||
| 36 | + * 父级编号 | ||
| 37 | + * | ||
| 38 | + * 关联 {@link #id} | ||
| 39 | + */ | ||
| 40 | + private Long parentId; | ||
| 41 | + /** | ||
| 42 | + * 分类名称 | ||
| 43 | + */ | ||
| 44 | + private String name; | ||
| 45 | + /** | ||
| 46 | + * 排序 | ||
| 47 | + */ | ||
| 48 | + private Integer sort; | ||
| 49 | + /** | ||
| 50 | + * 状态 | ||
| 51 | + * | ||
| 52 | + * 枚举 {@link CommonStatusEnum} | ||
| 53 | + */ | ||
| 54 | + private Integer status; | ||
| 55 | + | ||
| 56 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemBrandMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.dal.mysql.md.item; | ||
| 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.item.vo.brand.WmsItemBrandPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * WMS 商品品牌 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface WmsItemBrandMapper extends BaseMapperX<WmsItemBrandDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<WmsItemBrandDO> selectPage(WmsItemBrandPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<WmsItemBrandDO>() | ||
| 20 | + .likeIfPresent(WmsItemBrandDO::getName, reqVO.getName()) | ||
| 21 | + .orderByDesc(WmsItemBrandDO::getId)); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemCategoryMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.dal.mysql.md.item; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryListReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; | ||
| 7 | +import org.apache.ibatis.annotations.Mapper; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * WMS 商品分类 Mapper | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@Mapper | ||
| 17 | +public interface WmsItemCategoryMapper extends BaseMapperX<WmsItemCategoryDO> { | ||
| 18 | + | ||
| 19 | + default List<WmsItemCategoryDO> selectList(WmsItemCategoryListReqVO reqVO) { | ||
| 20 | + return selectList(new LambdaQueryWrapperX<WmsItemCategoryDO>() | ||
| 21 | + .eqIfPresent(WmsItemCategoryDO::getParentId, reqVO.getParentId()) | ||
| 22 | + .likeIfPresent(WmsItemCategoryDO::getName, reqVO.getName()) | ||
| 23 | + .eqIfPresent(WmsItemCategoryDO::getStatus, reqVO.getStatus()) | ||
| 24 | + .orderByAsc(WmsItemCategoryDO::getSort) | ||
| 25 | + .orderByAsc(WmsItemCategoryDO::getId)); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + default WmsItemCategoryDO selectByParentIdAndName(Long parentId, String name) { | ||
| 29 | + return selectOne(WmsItemCategoryDO::getParentId, parentId, WmsItemCategoryDO::getName, name); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + default Long selectCountByParentId(Long parentId) { | ||
| 33 | + return selectCount(WmsItemCategoryDO::getParentId, parentId); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java
| @@ -23,4 +23,15 @@ public interface ErrorCodeConstants { | @@ -23,4 +23,15 @@ public interface ErrorCodeConstants { | ||
| 23 | ErrorCode WAREHOUSE_AREA_NAME_DUPLICATE = new ErrorCode(1_060_101_001, "库区名称重复"); | 23 | ErrorCode WAREHOUSE_AREA_NAME_DUPLICATE = new ErrorCode(1_060_101_001, "库区名称重复"); |
| 24 | ErrorCode WAREHOUSE_AREA_CODE_DUPLICATE = new ErrorCode(1_060_101_002, "库区编号重复"); | 24 | ErrorCode WAREHOUSE_AREA_CODE_DUPLICATE = new ErrorCode(1_060_101_002, "库区编号重复"); |
| 25 | 25 | ||
| 26 | + // ========== WMS 基础数据-商品分类 1-060-102-000 ========== | ||
| 27 | + ErrorCode ITEM_CATEGORY_NOT_EXISTS = new ErrorCode(1_060_102_000, "商品分类不存在"); | ||
| 28 | + ErrorCode ITEM_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_060_102_001, "商品分类名称重复"); | ||
| 29 | + ErrorCode ITEM_CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_060_102_002, "父商品分类不存在"); | ||
| 30 | + ErrorCode ITEM_CATEGORY_PARENT_ERROR = new ErrorCode(1_060_102_003, "不能设置自己为父商品分类"); | ||
| 31 | + ErrorCode ITEM_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_060_102_004, "不能设置自己的子商品分类为父商品分类"); | ||
| 32 | + ErrorCode ITEM_CATEGORY_HAS_CHILDREN = new ErrorCode(1_060_102_005, "删除失败!请先删除该分类下的子分类!"); | ||
| 33 | + | ||
| 34 | + // ========== WMS 基础数据-商品品牌 1-060-103-000 ========== | ||
| 35 | + ErrorCode ITEM_BRAND_NOT_EXISTS = new ErrorCode(1_060_103_000, "商品品牌不存在"); | ||
| 36 | + | ||
| 26 | } | 37 | } |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.md.item; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; | ||
| 7 | +import jakarta.validation.Valid; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * WMS 商品品牌 Service 接口 | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +public interface WmsItemBrandService { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 创建商品品牌 | ||
| 20 | + * | ||
| 21 | + * @param createReqVO 创建信息 | ||
| 22 | + * @return 编号 | ||
| 23 | + */ | ||
| 24 | + Long createItemBrand(@Valid WmsItemBrandSaveReqVO createReqVO); | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 更新商品品牌 | ||
| 28 | + * | ||
| 29 | + * @param updateReqVO 更新信息 | ||
| 30 | + */ | ||
| 31 | + void updateItemBrand(@Valid WmsItemBrandSaveReqVO updateReqVO); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 删除商品品牌 | ||
| 35 | + * | ||
| 36 | + * @param id 编号 | ||
| 37 | + */ | ||
| 38 | + void deleteItemBrand(Long id); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 校验商品品牌存在 | ||
| 42 | + * | ||
| 43 | + * @param id 编号 | ||
| 44 | + * @return 商品品牌 | ||
| 45 | + */ | ||
| 46 | + WmsItemBrandDO validateItemBrandExists(Long id); | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 获得商品品牌 | ||
| 50 | + * | ||
| 51 | + * @param id 编号 | ||
| 52 | + * @return 商品品牌 | ||
| 53 | + */ | ||
| 54 | + WmsItemBrandDO getItemBrand(Long id); | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 获得商品品牌分页 | ||
| 58 | + * | ||
| 59 | + * @param pageReqVO 分页查询 | ||
| 60 | + * @return 商品品牌分页 | ||
| 61 | + */ | ||
| 62 | + PageResult<WmsItemBrandDO> getItemBrandPage(WmsItemBrandPageReqVO pageReqVO); | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 获得商品品牌列表 | ||
| 66 | + * | ||
| 67 | + * @return 商品品牌列表 | ||
| 68 | + */ | ||
| 69 | + List<WmsItemBrandDO> getItemBrandList(); | ||
| 70 | + | ||
| 71 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.md.item; | ||
| 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.item.vo.brand.WmsItemBrandPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandSaveReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; | ||
| 8 | +import cn.iocoder.yudao.module.wms.dal.mysql.md.item.WmsItemBrandMapper; | ||
| 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.ITEM_BRAND_NOT_EXISTS; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * WMS 商品品牌 Service 实现类 | ||
| 20 | + * | ||
| 21 | + * @author 芋道源码 | ||
| 22 | + */ | ||
| 23 | +@Service | ||
| 24 | +@Validated | ||
| 25 | +public class WmsItemBrandServiceImpl implements WmsItemBrandService { | ||
| 26 | + | ||
| 27 | + @Resource | ||
| 28 | + private WmsItemBrandMapper brandMapper; | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public Long createItemBrand(WmsItemBrandSaveReqVO createReqVO) { | ||
| 32 | + WmsItemBrandDO brand = BeanUtils.toBean(createReqVO, WmsItemBrandDO.class); | ||
| 33 | + brandMapper.insert(brand); | ||
| 34 | + return brand.getId(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void updateItemBrand(WmsItemBrandSaveReqVO updateReqVO) { | ||
| 39 | + // 校验存在 | ||
| 40 | + validateItemBrandExists(updateReqVO.getId()); | ||
| 41 | + | ||
| 42 | + // 更新 | ||
| 43 | + WmsItemBrandDO updateObj = BeanUtils.toBean(updateReqVO, WmsItemBrandDO.class); | ||
| 44 | + brandMapper.updateById(updateObj); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @Override | ||
| 48 | + public void deleteItemBrand(Long id) { | ||
| 49 | + // 校验存在 | ||
| 50 | + validateItemBrandExists(id); | ||
| 51 | + | ||
| 52 | + // 删除 | ||
| 53 | + brandMapper.deleteById(id); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public WmsItemBrandDO validateItemBrandExists(Long id) { | ||
| 58 | + WmsItemBrandDO brand = brandMapper.selectById(id); | ||
| 59 | + if (brand == null) { | ||
| 60 | + throw exception(ITEM_BRAND_NOT_EXISTS); | ||
| 61 | + } | ||
| 62 | + return brand; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public WmsItemBrandDO getItemBrand(Long id) { | ||
| 67 | + return brandMapper.selectById(id); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public PageResult<WmsItemBrandDO> getItemBrandPage(WmsItemBrandPageReqVO pageReqVO) { | ||
| 72 | + return brandMapper.selectPage(pageReqVO); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public List<WmsItemBrandDO> getItemBrandList() { | ||
| 77 | + return brandMapper.selectList(); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemCategoryService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.md.item; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryListReqVO; | ||
| 4 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategorySaveReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; | ||
| 6 | +import jakarta.validation.Valid; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * WMS 商品分类 Service 接口 | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +public interface WmsItemCategoryService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 创建商品分类 | ||
| 19 | + * | ||
| 20 | + * @param createReqVO 创建信息 | ||
| 21 | + * @return 编号 | ||
| 22 | + */ | ||
| 23 | + Long createItemCategory(@Valid WmsItemCategorySaveReqVO createReqVO); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新商品分类 | ||
| 27 | + * | ||
| 28 | + * @param updateReqVO 更新信息 | ||
| 29 | + */ | ||
| 30 | + void updateItemCategory(@Valid WmsItemCategorySaveReqVO updateReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除商品分类 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void deleteItemCategory(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 校验商品分类存在 | ||
| 41 | + * | ||
| 42 | + * @param id 编号 | ||
| 43 | + * @return 商品分类 | ||
| 44 | + */ | ||
| 45 | + WmsItemCategoryDO validateItemCategoryExists(Long id); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 获得商品分类 | ||
| 49 | + * | ||
| 50 | + * @param id 编号 | ||
| 51 | + * @return 商品分类 | ||
| 52 | + */ | ||
| 53 | + WmsItemCategoryDO getItemCategory(Long id); | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * 获得商品分类列表 | ||
| 57 | + * | ||
| 58 | + * @param listReqVO 查询条件 | ||
| 59 | + * @return 商品分类列表 | ||
| 60 | + */ | ||
| 61 | + List<WmsItemCategoryDO> getItemCategoryList(WmsItemCategoryListReqVO listReqVO); | ||
| 62 | + | ||
| 63 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemCategoryServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.md.item; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 4 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryListReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategorySaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; | ||
| 7 | +import cn.iocoder.yudao.module.wms.dal.mysql.md.item.WmsItemCategoryMapper; | ||
| 8 | +import jakarta.annotation.Resource; | ||
| 9 | +import org.springframework.stereotype.Service; | ||
| 10 | +import org.springframework.validation.annotation.Validated; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | +import java.util.Objects; | ||
| 14 | + | ||
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 16 | +import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.*; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * WMS 商品分类 Service 实现类 | ||
| 20 | + * | ||
| 21 | + * @author 芋道源码 | ||
| 22 | + */ | ||
| 23 | +@Service | ||
| 24 | +@Validated | ||
| 25 | +public class WmsItemCategoryServiceImpl implements WmsItemCategoryService { | ||
| 26 | + | ||
| 27 | + @Resource | ||
| 28 | + private WmsItemCategoryMapper categoryMapper; | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public Long createItemCategory(WmsItemCategorySaveReqVO createReqVO) { | ||
| 32 | + // 校验数据 | ||
| 33 | + validateCategorySaveData(createReqVO); | ||
| 34 | + | ||
| 35 | + // 插入 | ||
| 36 | + WmsItemCategoryDO category = BeanUtils.toBean(createReqVO, WmsItemCategoryDO.class); | ||
| 37 | + categoryMapper.insert(category); | ||
| 38 | + return category.getId(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public void updateItemCategory(WmsItemCategorySaveReqVO updateReqVO) { | ||
| 43 | + // 校验存在 | ||
| 44 | + validateItemCategoryExists(updateReqVO.getId()); | ||
| 45 | + // 校验数据 | ||
| 46 | + validateCategorySaveData(updateReqVO); | ||
| 47 | + | ||
| 48 | + // 更新 | ||
| 49 | + WmsItemCategoryDO updateObj = BeanUtils.toBean(updateReqVO, WmsItemCategoryDO.class); | ||
| 50 | + categoryMapper.updateById(updateObj); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + private void validateCategorySaveData(WmsItemCategorySaveReqVO reqVO) { | ||
| 54 | + validateCategoryNameUnique(reqVO.getId(), reqVO.getParentId(), reqVO.getName()); | ||
| 55 | + validateParentCategory(reqVO.getId(), reqVO.getParentId()); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + private void validateCategoryNameUnique(Long id, Long parentId, String name) { | ||
| 59 | + WmsItemCategoryDO category = categoryMapper.selectByParentIdAndName(parentId, name); | ||
| 60 | + if (category == null) { | ||
| 61 | + return; | ||
| 62 | + } | ||
| 63 | + // 如果 id 为空,说明不用比较是否为相同 id 的商品分类 | ||
| 64 | + if (id == null) { | ||
| 65 | + throw exception(ITEM_CATEGORY_NAME_DUPLICATE); | ||
| 66 | + } | ||
| 67 | + if (!Objects.equals(category.getId(), id)) { | ||
| 68 | + throw exception(ITEM_CATEGORY_NAME_DUPLICATE); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + private void validateParentCategory(Long id, Long parentId) { | ||
| 73 | + if (parentId == null || WmsItemCategoryDO.PARENT_ID_ROOT.equals(parentId)) { | ||
| 74 | + return; | ||
| 75 | + } | ||
| 76 | + // 1. 不能设置自己为父分类 | ||
| 77 | + if (Objects.equals(parentId, id)) { | ||
| 78 | + throw exception(ITEM_CATEGORY_PARENT_ERROR); | ||
| 79 | + } | ||
| 80 | + // 2. 父分类不存在 | ||
| 81 | + WmsItemCategoryDO parentCategory = categoryMapper.selectById(parentId); | ||
| 82 | + if (parentCategory == null) { | ||
| 83 | + throw exception(ITEM_CATEGORY_PARENT_NOT_EXISTS); | ||
| 84 | + } | ||
| 85 | + // 3. 递归校验父分类,如果父分类是自己的子分类,则报错,避免形成环路 | ||
| 86 | + if (id == null) { // id 为空,说明新增,不需要考虑环路 | ||
| 87 | + return; | ||
| 88 | + } | ||
| 89 | + for (int i = 0; i < Short.MAX_VALUE; i++) { | ||
| 90 | + // 3.1 校验环路 | ||
| 91 | + parentId = parentCategory.getParentId(); | ||
| 92 | + if (Objects.equals(id, parentId)) { | ||
| 93 | + throw exception(ITEM_CATEGORY_PARENT_IS_CHILD); | ||
| 94 | + } | ||
| 95 | + // 3.2 继续递归上级父分类 | ||
| 96 | + if (parentId == null || WmsItemCategoryDO.PARENT_ID_ROOT.equals(parentId)) { | ||
| 97 | + break; | ||
| 98 | + } | ||
| 99 | + parentCategory = categoryMapper.selectById(parentId); | ||
| 100 | + if (parentCategory == null) { | ||
| 101 | + break; | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + @Override | ||
| 107 | + public void deleteItemCategory(Long id) { | ||
| 108 | + // 校验存在 | ||
| 109 | + validateItemCategoryExists(id); | ||
| 110 | + // 有子分类不能删 | ||
| 111 | + if (categoryMapper.selectCountByParentId(id) > 0) { | ||
| 112 | + throw exception(ITEM_CATEGORY_HAS_CHILDREN); | ||
| 113 | + } | ||
| 114 | + // TODO 商品管理实现后,校验分类下不存在商品后再删除 | ||
| 115 | + | ||
| 116 | + // 删除 | ||
| 117 | + categoryMapper.deleteById(id); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + @Override | ||
| 121 | + public WmsItemCategoryDO validateItemCategoryExists(Long id) { | ||
| 122 | + WmsItemCategoryDO category = categoryMapper.selectById(id); | ||
| 123 | + if (category == null) { | ||
| 124 | + throw exception(ITEM_CATEGORY_NOT_EXISTS); | ||
| 125 | + } | ||
| 126 | + return category; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + @Override | ||
| 130 | + public WmsItemCategoryDO getItemCategory(Long id) { | ||
| 131 | + return categoryMapper.selectById(id); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + @Override | ||
| 135 | + public List<WmsItemCategoryDO> getItemCategoryList(WmsItemCategoryListReqVO listReqVO) { | ||
| 136 | + return categoryMapper.selectList(listReqVO); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | +} |