From 5db4d269ae769aca815370a2a4555746f4348d71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com>
Date: Tue, 4 Jan 2022 23:44:24 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=95=86=E5=93=81=E3=80=81?=
=?UTF-8?q?=E5=88=86=E7=B1=BB=E3=80=81=E5=B1=9E=E6=80=A7=E3=80=81=E5=BA=93?=
=?UTF-8?q?=E5=AD=98=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/admin/AttributeController.java | 7 ++-
.../controller/admin/CategoryController.java | 49 ++++++++++---------
.../pms/controller/admin/GoodsController.java | 28 +++++------
...roller.java => AppCategoryController.java} | 2 +-
...ontroller.java => AppGoodsController.java} | 2 +-
...ontroller.java => AppStockController.java} | 2 +-
.../mall/pms/service/IPmsCategoryService.java | 4 +-
.../service/impl/PmsAttributeServiceImpl.java | 6 +--
.../service/impl/PmsCategoryServiceImpl.java | 24 +++++----
.../com/youlai/common/domain/ValueLabel.java | 6 +--
.../common/redis/cache/RedisCacheConfig.java | 3 --
11 files changed, 70 insertions(+), 63 deletions(-)
rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/{CategoryController.java => AppCategoryController.java} (96%)
rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/{GoodsController.java => AppGoodsController.java} (99%)
rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/{StockController.java => AppStockController.java} (98%)
rename mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/CascadeVO.java => youlai-common/common-core/src/main/java/com/youlai/common/domain/ValueLabel.java (75%)
diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttributeController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttributeController.java
index aa8eced48..eed7ce77b 100644
--- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttributeController.java
+++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/AttributeController.java
@@ -16,9 +16,12 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
- * @author haoxr
+ * 系统管理_商品属性控制器
+ *
+ * @author haoxr
+ * @date 2022/1/1
*/
-@Api(tags = "系统管理端-属性信息")
+@Api(tags = "系统管理_商品属性")
@RestController
@RequestMapping("/api/v1/attributes")
@Slf4j
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 f08c03cfb..f54e1d566 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
@@ -1,5 +1,6 @@
package com.youlai.mall.pms.controller.admin;
+import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.youlai.common.result.Result;
@@ -11,18 +12,21 @@ import com.youlai.mall.pms.service.IPmsCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
/**
- * @author haoxr
+ * * 系统管理_商品分类控制器
+ *
+ * @author haoxr
+ * @date 2022/01/01
*/
-@Api(tags = "系统管理端-分类信息")
+@Api(tags = "系统管理_商品分类")
@RestController
@RequestMapping("/api/v1/categories")
@AllArgsConstructor
@@ -31,62 +35,61 @@ public class CategoryController {
private IPmsCategoryService iPmsCategoryService;
private IPmsAttributeService iPmsAttributeService;
-
- @ApiOperation(value = "分类列表")
+ @ApiOperation(value = "商品分类列表")
@GetMapping
public Result> list() {
List list = iPmsCategoryService.listCategory(null);
return Result.success(list);
}
-
- @ApiOperation(value = "分类级联列表")
+ @ApiOperation(value = "商品分类级联列表")
@GetMapping("/cascade")
- public Result cascadeCategoryList() {
+ public Result listCascadeCategory() {
List list = iPmsCategoryService.listCascadeCategory();
return Result.success(list);
}
-
- @ApiOperation(value = "分类详情")
- @ApiImplicitParam(name = "id", value = "商品分类id", required = true, paramType = "path", dataType = "Long")
+ @ApiOperation(value = "商品分类详情")
@GetMapping("/{id}")
- public Result detail(@PathVariable Integer id) {
+ public Result detail(
+ @ApiParam("商品分类ID") @PathVariable Long id
+ ) {
PmsCategory category = iPmsCategoryService.getById(id);
return Result.success(category);
}
- @ApiOperation(value = "新增分类")
+ @ApiOperation(value = "新增商品分类")
@PostMapping
- public Result add(@RequestBody PmsCategory category) {
+ public Result addCategory(@RequestBody PmsCategory category) {
Long id = iPmsCategoryService.saveCategory(category);
return Result.success(id);
}
- @ApiOperation(value = "修改分类")
+ @ApiOperation(value = "修改商品分类")
@PutMapping(value = "/{id}")
- public Result update(@PathVariable Long id, @RequestBody PmsCategory category) {
+ public Result update(
+ @ApiParam("商品分类ID") @PathVariable Long id,
+ @RequestBody PmsCategory category
+ ) {
category.setId(id);
id = iPmsCategoryService.saveCategory(category);
return Result.success(id);
}
- @ApiOperation(value = "删除分类")
+ @ApiOperation(value = "删除商品分类")
@ApiImplicitParam(name = "ids", value = "id集合,以英文逗号','分隔", required = true, paramType = "query", dataType = "String")
@DeleteMapping("/{ids}")
- @CacheEvict(value = "pms",key = "'categoryList'")
+ @CacheEvict(value = "pms", key = "'categoryList'")
public Result delete(@PathVariable String ids) {
List categoryIds = Arrays.asList(ids.split(","));
- Optional.ofNullable(categoryIds).ifPresent(categoryIdList -> {
- categoryIdList.forEach(categoryId -> iPmsAttributeService.remove(new LambdaQueryWrapper().eq(PmsAttribute::getCategoryId, categoryId)));
- });
+ iPmsAttributeService.remove(new LambdaQueryWrapper().in(CollectionUtil.isNotEmpty(categoryIds), PmsAttribute::getCategoryId, categoryIds));
boolean result = iPmsCategoryService.removeByIds(categoryIds);
return Result.judge(result);
}
- @ApiOperation(value = "选择性修改分类")
+ @ApiOperation(value = "选择性修改商品分类")
@PatchMapping(value = "/{id}")
- @CacheEvict(value = "pms",key = "'categoryList'")
+ @CacheEvict(value = "pms", key = "'categoryList'")
public Result patch(@PathVariable Long id, @RequestBody PmsCategory category) {
LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(PmsCategory::getId, id);
updateWrapper.set(category.getVisible() != null, PmsCategory::getVisible, category.getVisible());
diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/GoodsController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/GoodsController.java
index c9f83648f..f2fcc1a81 100644
--- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/GoodsController.java
+++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/GoodsController.java
@@ -8,19 +8,20 @@ import com.youlai.mall.pms.pojo.dto.admin.GoodsFormDTO;
import com.youlai.mall.pms.pojo.entity.PmsSpu;
import com.youlai.mall.pms.pojo.vo.admin.GoodsDetailVO;
import com.youlai.mall.pms.service.IPmsSpuService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
+
import java.util.Arrays;
import java.util.stream.Collectors;
/**
+ * 系统管理_商品信息
+ *
* @author haoxr
- */
-@Api(tags = "系统管理端-商品信息")
+ * @date 2021/1/4
+ **/
+@Api(tags = "系统管理_商品信息")
@RestController
@RequestMapping("/api/v1/goods")
@AllArgsConstructor
@@ -29,15 +30,14 @@ public class GoodsController {
private IPmsSpuService iPmsSpuService;
@ApiOperation(value = "商品分页列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Long"),
- @ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType = "Long"),
- @ApiImplicitParam(name = "categoryId", value = "分类ID", paramType = "query", dataType = "Long"),
- @ApiImplicitParam(name = "name", value = "商品名称", paramType = "query", dataType = "String")
- })
@GetMapping("/page")
- public Result list(Integer page, Integer limit, String name, Long categoryId) {
- IPage result = iPmsSpuService.list(new Page<>(page, limit), name, categoryId);
+ public Result list(
+ @ApiParam("页码") long pageNum,
+ @ApiParam("每页数量") long pageSize,
+ @ApiParam("商品分类ID") Long categoryId,
+ @ApiParam("商品名称") String name
+ ) {
+ IPage result = iPmsSpuService.list(new Page<>(pageNum, pageSize), name, categoryId);
return Result.success(result.getRecords(), result.getTotal());
}
diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/CategoryController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppCategoryController.java
similarity index 96%
rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/CategoryController.java
rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppCategoryController.java
index 62df9d471..4d1ba08ff 100644
--- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/CategoryController.java
+++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppCategoryController.java
@@ -22,7 +22,7 @@ import java.util.List;
@RequestMapping("/app-api/v1/categories")
@Slf4j
@AllArgsConstructor
-public class CategoryController {
+public class AppCategoryController {
private IPmsCategoryService iPmsCategoryService;
diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/GoodsController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppGoodsController.java
similarity index 99%
rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/GoodsController.java
rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppGoodsController.java
index 7336d8f43..df4710a7b 100644
--- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/GoodsController.java
+++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppGoodsController.java
@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
@RestController(value = "appGoodsController")
@RequestMapping("/app-api/v1/goods")
@AllArgsConstructor
-public class GoodsController {
+public class AppGoodsController {
private IGoodsService goodsService;
diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/StockController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppStockController.java
similarity index 98%
rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/StockController.java
rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppStockController.java
index 2b4be4038..1d9a18766 100644
--- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/StockController.java
+++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/AppStockController.java
@@ -18,7 +18,7 @@ import java.util.List;
@RestController(value = "appStockController")
@RequestMapping("/app-api/v1/stocks")
@AllArgsConstructor
-public class StockController {
+public class AppStockController {
private IPmsSkuService iPmsSkuService;
diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsCategoryService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsCategoryService.java
index da869097a..c7e80ce86 100644
--- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsCategoryService.java
+++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsCategoryService.java
@@ -2,7 +2,7 @@ package com.youlai.mall.pms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.mall.pms.pojo.entity.PmsCategory;
-import com.youlai.mall.pms.pojo.vo.CascadeVO;
+import com.youlai.common.domain.ValueLabel;
import com.youlai.mall.pms.pojo.vo.CategoryVO;
import java.util.List;
@@ -28,7 +28,7 @@ public interface IPmsCategoryService extends IService {
* 分类列表(级联)
* @return
*/
- List listCascadeCategory();
+ List listCascadeCategory();
/**
diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsAttributeServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsAttributeServiceImpl.java
index aacd72c6e..f3011bd89 100644
--- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsAttributeServiceImpl.java
+++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsAttributeServiceImpl.java
@@ -22,7 +22,7 @@ public class PmsAttributeServiceImpl extends ServiceImpl formIds = attributeForm.getAttributes().stream()
.filter(item -> item.getId() != null)
@@ -31,7 +31,7 @@ public class PmsAttributeServiceImpl extends ServiceImpl dbIds = this.list(new LambdaQueryWrapper()
.eq(PmsAttribute::getCategoryId, categoryId)
- .eq(PmsAttribute::getType, attributeForm.getType())
+ .eq(PmsAttribute::getType, attributeType)
.select(PmsAttribute::getId)).stream()
.map(item -> item.getId())
.collect(Collectors.toList());
@@ -52,7 +52,7 @@ public class PmsAttributeServiceImpl extends ServiceImpl attributeList = new ArrayList<>();
formAttributes.forEach(item -> {
- PmsAttribute attribute = PmsAttribute.builder().id(item.getId()).categoryId(categoryId).type(type).name(item.getName()).build();
+ PmsAttribute attribute = PmsAttribute.builder().id(item.getId()).categoryId(categoryId).type(attributeType).name(item.getName()).build();
attributeList.add(attribute);
});
boolean result = this.saveOrUpdateBatch(attributeList);
diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsCategoryServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsCategoryServiceImpl.java
index f5d7f525c..b50714264 100644
--- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsCategoryServiceImpl.java
+++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsCategoryServiceImpl.java
@@ -6,12 +6,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.common.constant.GlobalConstants;
import com.youlai.mall.pms.pojo.entity.PmsCategory;
import com.youlai.mall.pms.mapper.PmsCategoryMapper;
-import com.youlai.mall.pms.pojo.vo.CascadeVO;
+import com.youlai.common.domain.ValueLabel;
import com.youlai.mall.pms.service.IPmsCategoryService;
import com.youlai.mall.pms.pojo.vo.CategoryVO;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -32,11 +33,14 @@ public class PmsCategoryServiceImpl extends ServiceImpl listCategory(Long parentId) {
- List categoryList = this.list(new LambdaQueryWrapper()
- .eq(PmsCategory::getVisible, GlobalConstants.STATUS_YES).orderByDesc(PmsCategory::getSort));
+ List categoryList = this.list(
+ new LambdaQueryWrapper()
+ .eq(PmsCategory::getVisible, GlobalConstants.STATUS_YES)
+ .orderByDesc(PmsCategory::getSort)
+ );
List list = recursionTree(parentId != null ? parentId : 0l, categoryList);
return list;
}
@@ -65,28 +69,28 @@ public class PmsCategoryServiceImpl extends ServiceImpl listCascadeCategory() {
+ public List listCascadeCategory() {
List categoryList = this.list(
new LambdaQueryWrapper()
.eq(PmsCategory::getVisible, GlobalConstants.STATUS_YES)
.orderByAsc(PmsCategory::getSort)
);
- List list = recursionCascade(0l, categoryList);
+ List list = recursionCascade(0l, categoryList);
return list;
}
- private List recursionCascade(Long parentId, List categoryList) {
- List list = new ArrayList<>();
+ private List recursionCascade(Long parentId, List categoryList) {
+ List list = new ArrayList<>();
Optional.ofNullable(categoryList)
.ifPresent(categories ->
categories.stream().filter(category ->
category.getParentId().equals(parentId))
.forEach(category -> {
- CascadeVO categoryVO = new CascadeVO()
+ ValueLabel categoryVO = new ValueLabel()
.setLabel(category.getName())
.setValue(category.getId());
BeanUtil.copyProperties(category, categoryVO);
- List children = recursionCascade(category.getId(), categoryList);
+ List children = recursionCascade(category.getId(), categoryList);
categoryVO.setChildren(children);
list.add(categoryVO);
})
diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/CascadeVO.java b/youlai-common/common-core/src/main/java/com/youlai/common/domain/ValueLabel.java
similarity index 75%
rename from mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/CascadeVO.java
rename to youlai-common/common-core/src/main/java/com/youlai/common/domain/ValueLabel.java
index 435326c25..42d9c5259 100644
--- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/CascadeVO.java
+++ b/youlai-common/common-core/src/main/java/com/youlai/common/domain/ValueLabel.java
@@ -1,4 +1,4 @@
-package com.youlai.mall.pms.pojo.vo;
+package com.youlai.common.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
@@ -11,12 +11,12 @@ import java.util.List;
*/
@Data
@Accessors(chain = true)
-public class CascadeVO {
+public class ValueLabel {
private Long value;
private String label;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
- private List children;
+ private List children;
}
diff --git a/youlai-common/common-redis/src/main/java/com/youlai/common/redis/cache/RedisCacheConfig.java b/youlai-common/common-redis/src/main/java/com/youlai/common/redis/cache/RedisCacheConfig.java
index 8206d9a85..b9c16312e 100644
--- a/youlai-common/common-redis/src/main/java/com/youlai/common/redis/cache/RedisCacheConfig.java
+++ b/youlai-common/common-redis/src/main/java/com/youlai/common/redis/cache/RedisCacheConfig.java
@@ -34,9 +34,6 @@ public class RedisCacheConfig {
if (redisProperties.getTimeToLive() != null) {
config = config.entryTtl(redisProperties.getTimeToLive());
}
- if (redisProperties.getKeyPrefix() != null) {
- config = config.prefixKeysWith(redisProperties.getKeyPrefix());
- }
if (!redisProperties.isCacheNullValues()) {
config = config.disableCachingNullValues();
}