From 31578685d1667165c0a3cc8bb779fad3de9f6e75 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Sun, 6 Jul 2025 16:06:34 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=95=86=E5=93=81=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E4=B8=89=E7=BA=A7=E8=8F=9C=E5=8D=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mall-common/pom.xml | 8 ++++---- .../src/main/resources/application-routes.yaml | 2 ++ .../com/mall/product/MallProductApplication.java | 3 ++- .../com/mall/product/domain/entity/Category.java | 6 ++---- .../service/ext/CategoryServiceImplExt.java | 11 +++++++++++ .../service/impl/CategoryServiceImpl.java | 11 +++-------- .../src/main/resources/application-dev.yml | 16 ++++++++++++++-- mall-product/src/main/resources/application.yaml | 10 +++------- 8 files changed, 41 insertions(+), 26 deletions(-) diff --git a/mall-common/pom.xml b/mall-common/pom.xml index 49d85f9..1e6424b 100644 --- a/mall-common/pom.xml +++ b/mall-common/pom.xml @@ -46,10 +46,10 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery - - - - + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + diff --git a/mall-gateway/src/main/resources/application-routes.yaml b/mall-gateway/src/main/resources/application-routes.yaml index 61d442f..da5ca6d 100644 --- a/mall-gateway/src/main/resources/application-routes.yaml +++ b/mall-gateway/src/main/resources/application-routes.yaml @@ -19,6 +19,8 @@ spring: uri: lb://service-product predicates: - Path=/api/product/** + filters: + # - RewritePath=/api/(?.*),/xxx/$\{segment} - id: route-order uri: lb://service-order predicates: diff --git a/mall-product/src/main/java/com/mall/product/MallProductApplication.java b/mall-product/src/main/java/com/mall/product/MallProductApplication.java index 61d6f1c..bc41712 100644 --- a/mall-product/src/main/java/com/mall/product/MallProductApplication.java +++ b/mall-product/src/main/java/com/mall/product/MallProductApplication.java @@ -3,12 +3,13 @@ package com.mall.product; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @ComponentScan(basePackages = {"com.mall.product", "com.mall.common",}) @EnableDiscoveryClient -// @RefreshScope +@RefreshScope // @EnableFeignClients public class MallProductApplication { public static void main(String[] args) { diff --git a/mall-product/src/main/java/com/mall/product/domain/entity/Category.java b/mall-product/src/main/java/com/mall/product/domain/entity/Category.java index e46553d..d558ee6 100644 --- a/mall-product/src/main/java/com/mall/product/domain/entity/Category.java +++ b/mall-product/src/main/java/com/mall/product/domain/entity/Category.java @@ -1,10 +1,7 @@ package com.mall.product.domain.entity; import com.alibaba.nacos.shaded.com.google.common.collect.Lists; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; @@ -33,6 +30,7 @@ public class Category { private Integer catLevel; @Schema(name = "showStatus", title = "是否显示[0-不显示,1显示]") + @TableLogic(value = "1", delval = "0") private Integer showStatus; @Schema(name = "sort", title = "排序") diff --git a/mall-product/src/main/java/com/mall/product/service/ext/CategoryServiceImplExt.java b/mall-product/src/main/java/com/mall/product/service/ext/CategoryServiceImplExt.java index 010c1f5..683a6a9 100644 --- a/mall-product/src/main/java/com/mall/product/service/ext/CategoryServiceImplExt.java +++ b/mall-product/src/main/java/com/mall/product/service/ext/CategoryServiceImplExt.java @@ -1,4 +1,15 @@ package com.mall.product.service.ext; +import com.mall.product.domain.entity.Category; + +import java.util.List; + public class CategoryServiceImplExt { + + public static List getCategoryTreeChildrenList(Category category, List categoryList) { + return categoryList.stream() + .filter(item -> item.getParentCid().equals(category.getCatId())) + .toList(); + } + } diff --git a/mall-product/src/main/java/com/mall/product/service/impl/CategoryServiceImpl.java b/mall-product/src/main/java/com/mall/product/service/impl/CategoryServiceImpl.java index bbad4b2..ed8bfbf 100644 --- a/mall-product/src/main/java/com/mall/product/service/impl/CategoryServiceImpl.java +++ b/mall-product/src/main/java/com/mall/product/service/impl/CategoryServiceImpl.java @@ -13,10 +13,11 @@ import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import static com.mall.product.service.ext.CategoryServiceImplExt.getCategoryTreeChildrenList; + /** *

* 商品三级分类 服务实现类 @@ -79,6 +80,7 @@ public class CategoryServiceImpl extends ServiceImpl i */ @Override public void deleteCategory(List ids) { + // baseMapper.removeByIdsByIds(ids); removeByIds(ids); } @@ -96,11 +98,4 @@ public class CategoryServiceImpl extends ServiceImpl i .toList(); } - private List getCategoryTreeChildrenList(Category category, List categoryList) { - List voList = new ArrayList<>(); - - categoryList.stream().filter(item -> item.getCatId().equals(category.getParentCid())) - .forEach(voList::add); - return voList; - } } \ No newline at end of file diff --git a/mall-product/src/main/resources/application-dev.yml b/mall-product/src/main/resources/application-dev.yml index adb72ec..3191688 100644 --- a/mall-product/src/main/resources/application-dev.yml +++ b/mall-product/src/main/resources/application-dev.yml @@ -6,8 +6,20 @@ datasource: username: gulimall password: "0212Gulimall" -nacos: - server-addr: bunny-web.site:8848 +spring: + cloud: + nacos: + server-addr: bunny-web.site:8848 + config: + import-check: + enabled: true + server-addr: bunny-web.site:8848 + namespace: 510385f8-19a5-4eb4-8cfb-da1e13b9de09 + group: DEFAULT_GROUP + + config: + import: + - nacos:mall-product.yml logging: file: diff --git a/mall-product/src/main/resources/application.yaml b/mall-product/src/main/resources/application.yaml index 303063a..a5a84b0 100644 --- a/mall-product/src/main/resources/application.yaml +++ b/mall-product/src/main/resources/application.yaml @@ -17,13 +17,6 @@ spring: maximum-pool-size: 20 connection-timeout: 30000 - cloud: - nacos: - server-addr: ${nacos.server-addr} - - jackson: - date-format: yyyy-MM-dd HH:mm:ss - mybatis-plus: mapper-locations: classpath:/mapper/*.xml global-config: @@ -31,3 +24,6 @@ mybatis-plus: id-type: auto logic-delete-value: 1 logic-not-delete-value: 0 + + jackson: + date-format: yyyy-MM-dd HH:mm:ss \ No newline at end of file