商品服务的三级菜单显示

This commit is contained in:
bunny 2025-07-06 16:06:34 +08:00
parent 369130ee78
commit 31578685d1
8 changed files with 41 additions and 26 deletions

View File

@ -46,10 +46,10 @@
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>com.alibaba.cloud</groupId> -->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>com.alibaba.cloud</groupId> -->
<!-- <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> -->

View File

@ -19,6 +19,8 @@ spring:
uri: lb://service-product
predicates:
- Path=/api/product/**
filters:
# - RewritePath=/api/(?<segment>.*),/xxx/$\{segment}
- id: route-order
uri: lb://service-order
predicates:

View File

@ -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) {

View File

@ -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 = "排序")

View File

@ -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<Category> getCategoryTreeChildrenList(Category category, List<Category> categoryList) {
return categoryList.stream()
.filter(item -> item.getParentCid().equals(category.getCatId()))
.toList();
}
}

View File

@ -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;
/**
* <p>
* 商品三级分类 服务实现类
@ -79,6 +80,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
*/
@Override
public void deleteCategory(List<Long> ids) {
// baseMapper.removeByIdsByIds(ids);
removeByIds(ids);
}
@ -96,11 +98,4 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
.toList();
}
private List<Category> getCategoryTreeChildrenList(Category category, List<Category> categoryList) {
List<Category> voList = new ArrayList<>();
categoryList.stream().filter(item -> item.getCatId().equals(category.getParentCid()))
.forEach(voList::add);
return voList;
}
}

View File

@ -6,8 +6,20 @@ datasource:
username: gulimall
password: "0212Gulimall"
nacos:
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:

View File

@ -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