diff --git a/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/filter/DubboProviderRouterTagFilter.java b/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/filter/DubboProviderRouterTagFilter.java index 7051e16f..a7dc1162 100644 --- a/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/filter/DubboProviderRouterTagFilter.java +++ b/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/filter/DubboProviderRouterTagFilter.java @@ -11,6 +11,7 @@ import org.apache.dubbo.rpc.cluster.router.tag.TagRouter; /** * 基于 Dubbo 标签路由规则(http://dubbo.apache.org/zh-cn/docs/user/demos/routing-rule.html),实现如下功能: * 1. 本地开发调试时,在带有 Dubbo Tag 的情况下,优先调用指定 Tag 的服务提供者。这样,我们可以将本地启动的服务提供者打上相应的 Tag,即可优先调用本地; + * 并且,前端在调用开发环境上的 Dubbo 服务时,因为不带有 Dubbo Tag,所以不会调用到后端开发本地启动的 Dubbo 服务提供者; * 2. TODO 优化点:蓝绿发布、灰度发布 * * 实现逻辑为: diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProducctCategoryController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProducctCategoryController.http new file mode 100644 index 00000000..7badf277 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProducctCategoryController.http @@ -0,0 +1,7 @@ +### /product-category/tree 成功 +GET {{baseUrl}}/product-category/tree +Content-Type: application/x-www-form-urlencoded +Authorization: Bearer {{accessToken}} +dubbo-tag: {{dubboTag}} + +### diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductCategoryController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductCategoryController.java index 5b12cfa7..97b9d617 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductCategoryController.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductCategoryController.java @@ -2,19 +2,19 @@ package cn.iocoder.mall.managementweb.controller.product; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.managementweb.controller.product.vo.category.ProductCategoryCreateReqVO; +import cn.iocoder.mall.managementweb.controller.product.vo.category.ProductCategoryTreeNodeRespVO; import cn.iocoder.mall.managementweb.controller.product.vo.category.ProductCategoryUpdateReqVO; import cn.iocoder.mall.managementweb.manager.product.ProductCategoryManager; +import cn.iocoder.security.annotations.RequiresPermissions; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.List; import static cn.iocoder.common.framework.vo.CommonResult.success; @@ -22,7 +22,7 @@ import static cn.iocoder.common.framework.vo.CommonResult.success; * 商品分类 Controller */ @RestController -@RequestMapping("/product_category") +@RequestMapping("/product-category") @Api(tags = "商品分类") @Validated public class ProductCategoryController { @@ -32,12 +32,14 @@ public class ProductCategoryController { @PostMapping("/create") @ApiOperation("创建商品分类") + @RequiresPermissions("product:category:create") public CommonResult createProductCategory(@Valid ProductCategoryCreateReqVO createVO) { return success(productCategoryManager.createProductCategory(createVO)); } @PostMapping("/update") @ApiOperation("更新商品分类") + @RequiresPermissions("product:category:update") public CommonResult updateProductCategory(@Valid ProductCategoryUpdateReqVO updateVO) { productCategoryManager.updateProductCategory(updateVO); return success(true); @@ -45,10 +47,18 @@ public class ProductCategoryController { @PostMapping("/delete") @ApiOperation("删除商品分类") + @RequiresPermissions("product:category:delete") @ApiImplicitParam(name = "productCategoryId", value = "商品分类编号", required = true) public CommonResult deleteProductCategory(@RequestParam("productCategoryId") Integer productCategoryId) { productCategoryManager.deleteProductCategory(productCategoryId); return success(true); } + @GetMapping("/tree") + @ApiOperation("获得资源树") + @RequiresPermissions("product:category:tree") + public CommonResult> treeProductCategory() { + return success(productCategoryManager.treeProductCategory()); + } + } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/category/ProductCategoryRespVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/category/ProductCategoryRespVO.java index e345d0cd..3f50c153 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/category/ProductCategoryRespVO.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/category/ProductCategoryRespVO.java @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Date; + @ApiModel("商品分类 Response VO") @Data public class ProductCategoryRespVO { @@ -22,5 +24,7 @@ public class ProductCategoryRespVO { private Integer sort; @ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") private Integer status; + @ApiModelProperty(value = "创建时间", required = true) + private Date createTime; } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/category/ProductCategoryTreeNodeRespVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/category/ProductCategoryTreeNodeRespVO.java index 503e3edd..4f06f3ca 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/category/ProductCategoryTreeNodeRespVO.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/category/ProductCategoryTreeNodeRespVO.java @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Date; import java.util.List; @ApiModel("商品分类 Response VO") @@ -24,6 +25,8 @@ public class ProductCategoryTreeNodeRespVO { private Integer sort; @ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举") private Integer status; + @ApiModelProperty(value = "创建时间", required = true) + private Date createTime; /** * 子节点 diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/dto/ProductCategoryListQueryReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/dto/ProductCategoryListQueryReqDTO.java index c45856da..649ef358 100644 --- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/dto/ProductCategoryListQueryReqDTO.java +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/dto/ProductCategoryListQueryReqDTO.java @@ -3,12 +3,14 @@ package cn.iocoder.mall.productservice.rpc.category.dto; import lombok.Data; import lombok.experimental.Accessors; +import java.io.Serializable; + /** * 商品分类列表查询 DTO */ @Data @Accessors(chain = true) -public class ProductCategoryListQueryReqDTO { +public class ProductCategoryListQueryReqDTO implements Serializable { /** * 父编号 diff --git a/product-service-project/product-service-app/src/main/resources/application-dev.yaml b/product-service-project/product-service-app/src/main/resources/application-dev.yaml index cfae12b0..10c3b0e7 100644 --- a/product-service-project/product-service-app/src/main/resources/application-dev.yaml +++ b/product-service-project/product-service-app/src/main/resources/application-dev.yaml @@ -1,7 +1,7 @@ spring: # 数据源配置项 datasource: - url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8 driver-class-name: com.mysql.jdbc.Driver username: root password: 3WLiVUBEwTbvAfsh diff --git a/product-service-project/product-service-app/src/main/resources/application-local.yaml b/product-service-project/product-service-app/src/main/resources/application-local.yaml index 1b5420be..47a56028 100644 --- a/product-service-project/product-service-app/src/main/resources/application-local.yaml +++ b/product-service-project/product-service-app/src/main/resources/application-local.yaml @@ -1,7 +1,7 @@ spring: # 数据源配置项 datasource: - url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8 driver-class-name: com.mysql.jdbc.Driver username: root password: 3WLiVUBEwTbvAfsh diff --git a/product-service-project/product-service-app/src/main/resources/application.yaml b/product-service-project/product-service-app/src/main/resources/application.yaml index f1cb94c4..8a7aff7e 100644 --- a/product-service-project/product-service-app/src/main/resources/application.yaml +++ b/product-service-project/product-service-app/src/main/resources/application.yaml @@ -34,25 +34,7 @@ dubbo: provider: filter: -exception validation: true # 开启 Provider 参数校验 - OAuth2Rpc: - version: 1.0.0 - AdminRpc: - version: 1.0.0 - ResourceRpc: - version: 1.0.0 - RoleRpc: - version: 1.0.0 - PermissionRpc: - version: 1.0.0 - DepartmentRpc: - version: 1.0.0 - DataDictRpc: - version: 1.0.0 - ProductExceptionLogRpc: - version: 1.0.0 - ProductAccessLogRpc: - version: 1.0.0 - ErrorCodeRpc: + ProductCategoryRpc: version: 1.0.0 # Dubbo 服务消费者的配置 consumer: