diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsCategorySpec.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsCategorySpec.java index f6c4e3548..987ddd05b 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsCategorySpec.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsCategorySpec.java @@ -3,19 +3,19 @@ package com.youlai.mall.pms.pojo.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import com.youlai.common.base.BaseEntity; import lombok.Data; import java.util.ArrayList; import java.util.List; @Data -public class PmsCategorySpec { +public class PmsCategorySpec extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; private Long categoryId; private String name; - private boolean selected; @TableField(exist = false) private List values = new ArrayList<>(); diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttrController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttributeController.java similarity index 86% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttrController.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttributeController.java index 42a2b02f0..33784d383 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttrController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttributeController.java @@ -16,17 +16,17 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.stream.Collectors; -@Api(tags = "【系统管理】分类属性") +@Api(tags = "【系统管理】商品属性") @RestController -@RequestMapping("/admin-api/v1/attrs") +@RequestMapping("/api.admin/v1/attributes") @Slf4j @AllArgsConstructor -public class AttrController { +public class AttributeController { private IPmsCategoryAttrService iPmsCategoryAttrService; - @ApiOperation(value = "分类属性列表", httpMethod = "GET") + @ApiOperation(value = "商品属性列表", httpMethod = "GET") @ApiImplicitParams({ @ApiImplicitParam(name = "categoryId", value = "分类ID", paramType = "query", dataType = "Long") @@ -34,13 +34,14 @@ public class AttrController { @GetMapping public Result list(Long categoryId) { List list = iPmsCategoryAttrService - .list(new LambdaQueryWrapper().eq(PmsCategoryAttr::getCategoryId, categoryId)); + .list(new LambdaQueryWrapper() + .eq(PmsCategoryAttr::getCategoryId, categoryId)); return Result.success(list); } @ApiOperation(value = "新增属性", httpMethod = "POST") - @ApiImplicitParam(name = "attrCategories", value = "实体JSON对象", required = true, paramType = "body", dataType = "PmsAttrCategory") + @ApiImplicitParam(name = "attrCategories", value = "实体JSON对象", required = true, paramType = "body", dataType = "PmsCategoryAttr") @PostMapping public Result saveBatch(@RequestBody List attrCategories) { diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/BrandController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/BrandController.java index 006119b93..857004a8a 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/BrandController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/BrandController.java @@ -23,7 +23,7 @@ import java.util.List; @Api(tags = "【系统管理】品牌接口") @RestController -@RequestMapping("/brands") +@RequestMapping("/api.admin/v1/brands") @Slf4j @AllArgsConstructor public class BrandController { diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/CategoryController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/CategoryController.java index b1b90f181..e346fa416 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/CategoryController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/CategoryController.java @@ -6,7 +6,9 @@ import com.youlai.common.enums.QueryModeEnum; import com.youlai.common.result.Result; import com.youlai.mall.pms.pojo.domain.PmsCategory; import com.youlai.mall.pms.pojo.vo.CategoryVO; +import com.youlai.mall.pms.service.IPmsCategoryAttrService; import com.youlai.mall.pms.service.IPmsCategoryService; +import com.youlai.mall.pms.service.IPmsCategorySpecService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -17,17 +19,22 @@ import org.springframework.web.bind.annotation.*; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; @Api(tags = "【系统管理】商品分类") @RestController -@RequestMapping("/categories") +@RequestMapping("/api.admin/v1/categories") @Slf4j @AllArgsConstructor public class CategoryController { private IPmsCategoryService iPmsCategoryService; + private IPmsCategoryAttrService iPmsCategoryAttrService; + + private IPmsCategorySpecService iPmsCategorySpecService; + @ApiOperation(value = "列表分页", httpMethod = "GET") @ApiImplicitParams({ @ApiImplicitParam(name = "queryMode", paramType = "query", dataType = "String"), @@ -82,22 +89,27 @@ public class CategoryController { @ApiImplicitParam(name = "ids", value = "id集合,以英文逗号','分隔", required = true, paramType = "query", dataType = "String") @DeleteMapping public Result delete(@RequestParam String ids) { - iPmsCategoryService.removeByIds(Arrays.asList(ids.split(",")).stream().map(id -> Long.parseLong(id)).collect(Collectors.toList())); + List idList = Arrays.asList(ids.split(",")); + Optional.ofNullable(idList).ifPresent(list -> { + list.forEach(id -> { + iPmsCategoryAttrService.removeById(id); + iPmsCategorySpecService.removeById(id); + }); + iPmsCategoryService.removeByIds(idList.stream().map(id -> Long.parseLong(id)).collect(Collectors.toList())); + }); return Result.success(); } - @ApiOperation(value = "修改商品分类(部分更新)", httpMethod = "PATCH") + @ApiOperation(value = "修改商品分类", httpMethod = "PATCH") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "用户id", required = true, paramType = "path", dataType = "Long"), @ApiImplicitParam(name = "category", value = "实体JSON对象", required = true, paramType = "body", dataType = "PmsCategory") }) @PatchMapping(value = "/{id}") public Result patch(@PathVariable Integer id, @RequestBody PmsCategory category) { - LambdaUpdateWrapper luw = new LambdaUpdateWrapper().eq(PmsCategory::getId, id); - if (category.getStatus() != null) { // 状态更新 - luw.set(PmsCategory::getStatus, category.getStatus()); - } - boolean update = iPmsCategoryService.update(luw); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(PmsCategory::getId, id); + updateWrapper.set(category.getStatus() != null, PmsCategory::getStatus, category.getStatus()); + boolean update = iPmsCategoryService.update(updateWrapper); return Result.success(update); } } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SkuController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/InventoryController.java similarity index 91% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SkuController.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/InventoryController.java index e2c2a772f..cbd2ddcf8 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SkuController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/InventoryController.java @@ -18,12 +18,12 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/api.admin/v1/inventories") @Slf4j @AllArgsConstructor -public class SkuController { +public class InventoryController { private IPmsSkuService iPmsSkuService; - @ApiOperation(value = "库存明细", httpMethod = "GET") - @ApiImplicitParam(name = "id", value = "商品SKU ID", required = true, paramType = "path", dataType = "Long") + @ApiOperation(value = "商品库存明细", httpMethod = "GET") + @ApiImplicitParam(name = "id", value = "商品SkuID", required = true, paramType = "path", dataType = "Long") @GetMapping("/{id}") public Result detail(@PathVariable Long id) { PmsSku sku = iPmsSkuService.getById(id); diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/ProductController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/ProductController.java index 5e4bfae2a..86810a8a8 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/ProductController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/ProductController.java @@ -96,7 +96,7 @@ public class ProductController { return Result.success(); } - @ApiOperation(value = "修改商品(部分更新)", httpMethod = "PATCH") + @ApiOperation(value = "修改商品", httpMethod = "PATCH") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "用户id", required = true, paramType = "path", dataType = "Long"), @ApiImplicitParam(name = "spu", value = "实体JSON对象", required = true, paramType = "body", dataType = "PmsSpu") @@ -104,9 +104,7 @@ public class ProductController { @PatchMapping(value = "/{id}") public Result patch(@PathVariable Integer id, @RequestBody PmsSpu spu) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(PmsSpu::getId, id); - if (spu.getStatus() != null) { // 状态更新 - updateWrapper.set(PmsSpu::getStatus, spu.getStatus()); - } + updateWrapper.set(spu.getStatus() != null, PmsSpu::getStatus, spu.getStatus()); boolean update = iPmsSpuService.update(updateWrapper); return Result.success(update); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SpecificationController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SpecificationController.java index 891634b36..f3a946d0a 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SpecificationController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SpecificationController.java @@ -18,7 +18,7 @@ import java.util.stream.Collectors; @Api(tags = "【系统管理】商品规格") @RestController -@RequestMapping("/admin-api/v1/specifications") +@RequestMapping("/api.admin/v1/specifications") @Slf4j @AllArgsConstructor public class SpecificationController { @@ -32,7 +32,8 @@ public class SpecificationController { @GetMapping public Result list(Long categoryId) { List list = iPmsCategorySpecService - .list(new LambdaQueryWrapper().eq(PmsCategorySpec::getCategoryId, categoryId)); + .list(new LambdaQueryWrapper() + .eq(PmsCategorySpec::getCategoryId, categoryId)); return Result.success(list); }