From 88a3cd8d02e5fe4be62a9ab461a06db78994ae7f Mon Sep 17 00:00:00 2001 From: jiangweifan Date: Sat, 9 May 2020 23:36:17 +0800 Subject: [PATCH] =?UTF-8?q?system=E5=8F=8Aproduct=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/dao/product/ProductCategoryMapper.java | 1 + .../biz/dataobject/product/ProductCategoryDO.java | 2 ++ .../biz/service/product/ProductCategoryService.java | 10 ++++++---- .../product/impl/ProductCategoryServiceImpl.java | 13 +++++-------- .../admins/AdminsProductCategoryController.java | 6 +++--- .../AuthorizationCheckPermissionsRequest.java | 3 ++- .../OAuth2AccessTokenAuthenticateRequest.java | 3 ++- .../rpc/request/systemlog/AccessLogAddRequest.java | 3 ++- .../request/systemlog/ExceptionLogAddRequest.java | 3 ++- .../system/rpc/response/admin/AdminResponse.java | 4 +++- .../response/oauth2/OAuth2AccessTokenResponse.java | 3 ++- .../mall/system/rpc/response/user/UserResponse.java | 4 +++- 12 files changed, 33 insertions(+), 22 deletions(-) diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductCategoryMapper.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductCategoryMapper.java index 7c9ac8fae..93843e69e 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductCategoryMapper.java +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductCategoryMapper.java @@ -3,6 +3,7 @@ package cn.iocoder.mall.product.biz.dao.product; import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO; import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Update; import org.springframework.stereotype.Repository; /** diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductCategoryDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductCategoryDO.java index 94cab4e03..118850000 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductCategoryDO.java +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductCategoryDO.java @@ -1,6 +1,7 @@ package cn.iocoder.mall.product.biz.dataobject.product; import cn.iocoder.mall.mybatis.dataobject.DeletableDO; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.experimental.Accessors; @@ -9,6 +10,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) +@TableName("product_category") public class ProductCategoryDO extends DeletableDO { /** diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductCategoryService.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductCategoryService.java index 624ae9689..e05b48b98 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductCategoryService.java +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductCategoryService.java @@ -5,6 +5,8 @@ import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateStatusDTO; + +import javax.validation.Valid; import java.util.List; @@ -26,26 +28,26 @@ public interface ProductCategoryService { * @param productCategoryAddDTO * @return */ - ProductCategoryBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO); + ProductCategoryBO addProductCategory(@Valid ProductCategoryAddDTO productCategoryAddDTO); /** * 更新商品分类 * @param productCategoryUpdateDTO * @return */ - Boolean updateProductCategory(ProductCategoryUpdateDTO productCategoryUpdateDTO); + Boolean updateProductCategory(@Valid ProductCategoryUpdateDTO productCategoryUpdateDTO); /** * 更新商品分类状态 * @param productCategoryUpdateStatusDTO * @return */ - Boolean updateProductCategoryStatus(ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO); + Boolean updateProductCategoryStatus(@Valid ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO); /** * 删除商品分类 * @param productCategoryDeleteDTO * @return */ - Boolean deleteProductCategory(ProductCategoryDeleteDTO productCategoryDeleteDTO); + Boolean deleteProductCategory(@Valid ProductCategoryDeleteDTO productCategoryDeleteDTO); } diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductCategoryServiceImpl.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductCategoryServiceImpl.java index 180bbbe82..6a9e63cab 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductCategoryServiceImpl.java +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductCategoryServiceImpl.java @@ -49,7 +49,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { * @return */ @Override - public ProductCategoryBO addProductCategory(@Valid ProductCategoryAddDTO productCategoryAddDTO) { + public ProductCategoryBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO) { // 校验父分类 validParent(productCategoryAddDTO.getPid()); // 保存到数据库 @@ -69,7 +69,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { * @return */ @Override - public Boolean updateProductCategory(@Valid ProductCategoryUpdateDTO productCategoryUpdateDTO) { + public Boolean updateProductCategory(ProductCategoryUpdateDTO productCategoryUpdateDTO) { // 校验当前分类是否存在 if (productCategoryMapper.selectById(productCategoryUpdateDTO.getId()) == null) { throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS); @@ -98,7 +98,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { * @return */ @Override - public Boolean updateProductCategoryStatus(@Valid ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO) { + public Boolean updateProductCategoryStatus(ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO) { Integer productCategoryId = productCategoryUpdateStatusDTO.getId(); Integer status = productCategoryUpdateStatusDTO.getStatus(); // 校验商品分类是否存在 @@ -128,7 +128,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { * @return */ @Override - public Boolean deleteProductCategory(@Valid ProductCategoryDeleteDTO productCategoryDeleteDTO) { + public Boolean deleteProductCategory(ProductCategoryDeleteDTO productCategoryDeleteDTO) { Integer productCategoryId = productCategoryDeleteDTO.getId(); // 校验分类是否存在 ProductCategoryDO productCategory = productCategoryMapper.selectById(productCategoryId); @@ -148,10 +148,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { } // TODO 伟帆 补充只有不存在商品才可以删除 // 标记删除商品分类 - ProductCategoryDO updateProductCategory = new ProductCategoryDO() - .setId(productCategoryId); - updateProductCategory.setDeleted(DeletedStatusEnum.DELETED_YES.getValue()); - productCategoryMapper.updateById(updateProductCategory); + productCategoryMapper.deleteById(productCategoryId); // TODO 伟帆 操作日志 return true; } diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductCategoryController.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductCategoryController.java index 3ce92f8de..c2246e1d7 100644 --- a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductCategoryController.java +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductCategoryController.java @@ -69,7 +69,7 @@ public class AdminsProductCategoryController { @PostMapping("/add") @ApiOperation(value = "创建商品分类") - public CommonResult add(@RequestBody AdminsProductCategoryAddRequest adminsProductCategoryAddRequest) { + public CommonResult add(AdminsProductCategoryAddRequest adminsProductCategoryAddRequest) { // 转换 ProductCategoryAddDTO 对象 ProductCategoryAddDTO productCategoryAddDTO = ProductCategoryConvert.INSTANCE.convertToAddDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryAddRequest); // 创建商品分类 @@ -80,7 +80,7 @@ public class AdminsProductCategoryController { @PostMapping("/update") @ApiOperation(value = "更新商品分类") - public CommonResult update(@RequestBody AdminsProductCategoryUpdateRequest adminsProductCategoryUpdateRequest) { + public CommonResult update(AdminsProductCategoryUpdateRequest adminsProductCategoryUpdateRequest) { // 创建 ProductCategoryUpdateDTO 对象 ProductCategoryUpdateDTO productCategoryUpdateDTO = ProductCategoryConvert.INSTANCE.convertToUpdateDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryUpdateRequest); // 更新商品分类 @@ -89,7 +89,7 @@ public class AdminsProductCategoryController { @PostMapping("/update_status") @ApiOperation(value = "更新商品分类状态") - public CommonResult updateStatus(@RequestBody AdminsProductCategoryUpdateStatusRequest adminsProductCategoryUpdateStatusRequest) { + public CommonResult updateStatus(AdminsProductCategoryUpdateStatusRequest adminsProductCategoryUpdateStatusRequest) { // 创建 ProductCategoryUpdateStatusDTO 对象 ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO = ProductCategoryConvert.INSTANCE.convertToUpdateStatusDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryUpdateStatusRequest); diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/authorization/AuthorizationCheckPermissionsRequest.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/authorization/AuthorizationCheckPermissionsRequest.java index 1dd1b51b0..e618b135a 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/authorization/AuthorizationCheckPermissionsRequest.java +++ b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/authorization/AuthorizationCheckPermissionsRequest.java @@ -4,6 +4,7 @@ import lombok.Data; import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; +import java.io.Serializable; import java.util.List; /** @@ -11,7 +12,7 @@ import java.util.List; */ @Data @Accessors(chain = true) -public class AuthorizationCheckPermissionsRequest { +public class AuthorizationCheckPermissionsRequest implements Serializable { @NotNull(message = "账号不能为空") private Integer accountId; diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/oauth2/OAuth2AccessTokenAuthenticateRequest.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/oauth2/OAuth2AccessTokenAuthenticateRequest.java index 240f9f7d7..81fccf98c 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/oauth2/OAuth2AccessTokenAuthenticateRequest.java +++ b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/oauth2/OAuth2AccessTokenAuthenticateRequest.java @@ -4,13 +4,14 @@ import lombok.Data; import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; +import java.io.Serializable; /** * OAuth2 模块 - 访问令牌认证 Request */ @Data @Accessors(chain = true) -public class OAuth2AccessTokenAuthenticateRequest { +public class OAuth2AccessTokenAuthenticateRequest implements Serializable { @NotNull(message = "访问令牌不能为空") private String accessToken; diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/AccessLogAddRequest.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/AccessLogAddRequest.java index b58cfa6f0..1cf91c23b 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/AccessLogAddRequest.java +++ b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/AccessLogAddRequest.java @@ -4,6 +4,7 @@ import lombok.Data; import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; +import java.io.Serializable; import java.util.Date; /** @@ -11,7 +12,7 @@ import java.util.Date; */ @Data @Accessors(chain = true) -public class AccessLogAddRequest { +public class AccessLogAddRequest implements Serializable { /** * 用户编号 - 空 diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/ExceptionLogAddRequest.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/ExceptionLogAddRequest.java index 8a1e3adf8..920fdef31 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/ExceptionLogAddRequest.java +++ b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/ExceptionLogAddRequest.java @@ -4,6 +4,7 @@ import lombok.Data; import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; +import java.io.Serializable; import java.util.Date; /** @@ -11,7 +12,7 @@ import java.util.Date; */ @Data @Accessors(chain = true) -public class ExceptionLogAddRequest { +public class ExceptionLogAddRequest implements Serializable { /** * 账号编号 diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/admin/AdminResponse.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/admin/AdminResponse.java index bb29aac0a..8de29ee01 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/admin/AdminResponse.java +++ b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/admin/AdminResponse.java @@ -3,12 +3,14 @@ package cn.iocoder.mall.system.rpc.response.admin; import lombok.Data; import lombok.experimental.Accessors; +import java.io.Serializable; + /** * Admin 模块 - Admin 信息 Response */ @Data @Accessors(chain = true) -public class AdminResponse { +public class AdminResponse implements Serializable { /** * 管理员编号 diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/oauth2/OAuth2AccessTokenResponse.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/oauth2/OAuth2AccessTokenResponse.java index 176034c5c..eb397077a 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/oauth2/OAuth2AccessTokenResponse.java +++ b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/oauth2/OAuth2AccessTokenResponse.java @@ -3,6 +3,7 @@ package cn.iocoder.mall.system.rpc.response.oauth2; import lombok.Data; import lombok.experimental.Accessors; +import java.io.Serializable; import java.util.Date; /** @@ -10,7 +11,7 @@ import java.util.Date; */ @Data @Accessors(chain = true) -public class OAuth2AccessTokenResponse { +public class OAuth2AccessTokenResponse implements Serializable { /** * 访问令牌 diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/user/UserResponse.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/user/UserResponse.java index 4fae0b885..8e3c06688 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/user/UserResponse.java +++ b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/response/user/UserResponse.java @@ -3,12 +3,14 @@ package cn.iocoder.mall.system.rpc.response.user; import lombok.Data; import lombok.experimental.Accessors; +import java.io.Serializable; + /** * User 模块 - User 信息 Response */ @Data @Accessors(chain = true) -public class UserResponse { +public class UserResponse implements Serializable { /** * 用户编号