三级菜单接口

This commit is contained in:
bunny 2025-07-04 00:31:16 +08:00
parent f812c50f04
commit 9dfa357071
12 changed files with 246 additions and 188 deletions

2
.gitignore vendored
View File

@ -27,5 +27,7 @@ target/
/.nb-gradle/
build/
node_modules
### VS Code ###
.vscode/

View File

@ -17,4 +17,10 @@ spring:
- id: qq_route
uri: https://qq.com
predicates:
- Query=url,qq
- Query=url,qq
- id: admin_route
uri: lb://renren-fast
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*),/renren-fast/$\{segment}

View File

@ -1,20 +1,15 @@
package com.xunqi.gulimall.product.controller;
import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xunqi.gulimall.product.entity.PmsCategoryEntity;
import com.xunqi.gulimall.product.service.PmsCategoryService;
import com.xunqi.common.utils.PageUtils;
import com.xunqi.common.utils.R;
import com.xunqi.gulimall.product.entity.PmsCategoryEntity;
import com.xunqi.gulimall.product.service.PmsCategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
@ -26,29 +21,40 @@ import com.xunqi.common.utils.R;
*/
@RestController
@RequestMapping("product/pmscategory")
@RequiredArgsConstructor
public class PmsCategoryController {
@Autowired
private PmsCategoryService pmsCategoryService;
private final PmsCategoryService pmsCategoryService;
/**
* 查询所有分类以及子分类以树形结构展示
*
* @return List<PmsCategoryEntity>
*/
@RequestMapping("list/tree")
public R list() {
List<PmsCategoryEntity> entities = pmsCategoryService.listWithTree();
return R.ok().put("data", entities);
}
/**
* 列表
*/
@RequestMapping("/list")
//@RequiresPermissions("product:pmscategory:list")
public R list(@RequestParam Map<String, Object> params){
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = pmsCategoryService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{catId}")
//@RequiresPermissions("product:pmscategory:info")
public R info(@PathVariable("catId") Long catId){
PmsCategoryEntity pmsCategory = pmsCategoryService.getById(catId);
public R info(@PathVariable("catId") Long catId) {
PmsCategoryEntity pmsCategory = pmsCategoryService.getById(catId);
return R.ok().put("pmsCategory", pmsCategory);
}
@ -58,8 +64,8 @@ public class PmsCategoryController {
*/
@RequestMapping("/save")
//@RequiresPermissions("product:pmscategory:save")
public R save(@RequestBody PmsCategoryEntity pmsCategory){
pmsCategoryService.save(pmsCategory);
public R save(@RequestBody PmsCategoryEntity pmsCategory) {
pmsCategoryService.save(pmsCategory);
return R.ok();
}
@ -69,8 +75,8 @@ public class PmsCategoryController {
*/
@RequestMapping("/update")
//@RequiresPermissions("product:pmscategory:update")
public R update(@RequestBody PmsCategoryEntity pmsCategory){
pmsCategoryService.updateById(pmsCategory);
public R update(@RequestBody PmsCategoryEntity pmsCategory) {
pmsCategoryService.updateById(pmsCategory);
return R.ok();
}
@ -80,8 +86,8 @@ public class PmsCategoryController {
*/
@RequestMapping("/delete")
//@RequiresPermissions("product:pmscategory:delete")
public R delete(@RequestBody Long[] catIds){
pmsCategoryService.removeByIds(Arrays.asList(catIds));
public R delete(@RequestBody Long[] catIds) {
pmsCategoryService.removeByIds(Arrays.asList(catIds));
return R.ok();
}

View File

@ -1,15 +1,16 @@
package com.xunqi.gulimall.product.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import java.util.List;
/**
* 商品三级分类
*
*
* @author Bunny
* @email Bunny@gmail.com
* @date 2025-06-24 20:18:50
@ -17,44 +18,46 @@ import lombok.Data;
@Data
@TableName("pms_category")
public class PmsCategoryEntity implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* 分类id
*/
@TableId
private Long catId;
/**
* 分类名称
*/
private String name;
/**
* 父分类id
*/
private Long parentCid;
/**
* 层级
*/
private Integer catLevel;
/**
* 是否显示[0-不显示1显示]
*/
private Integer showStatus;
/**
* 排序
*/
private Integer sort;
/**
* 图标地址
*/
private String icon;
/**
* 计量单位
*/
private String productUnit;
/**
* 商品数量
*/
private Integer productCount;
/**
* 分类id
*/
@TableId
private Long catId;
/**
* 分类名称
*/
private String name;
/**
* 父分类id
*/
private Long parentCid;
/**
* 层级
*/
private Integer catLevel;
/**
* 是否显示[0-不显示1显示]
*/
private Integer showStatus;
/**
* 排序
*/
private Integer sort;
/**
* 图标地址
*/
private String icon;
/**
* 计量单位
*/
private String productUnit;
/**
* 商品数量
*/
private Integer productCount;
@TableField(exist = false)
private List<PmsCategoryEntity> children;
}

View File

@ -0,0 +1 @@
package com.xunqi.gulimall.product.feign;

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.xunqi.common.utils.PageUtils;
import com.xunqi.gulimall.product.entity.PmsCategoryEntity;
import java.util.List;
import java.util.Map;
/**
@ -16,5 +17,12 @@ import java.util.Map;
public interface PmsCategoryService extends IService<PmsCategoryEntity> {
PageUtils queryPage(Map<String, Object> params);
/**
* 查询所有分类以及子分类以树形结构展示
*
* @return 分类列表
*/
List<PmsCategoryEntity> listWithTree();
}

View File

@ -1,16 +1,20 @@
package com.xunqi.gulimall.product.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xunqi.common.utils.PageUtils;
import com.xunqi.common.utils.Query;
import com.xunqi.gulimall.product.dao.PmsCategoryDao;
import com.xunqi.gulimall.product.entity.PmsCategoryEntity;
import com.xunqi.gulimall.product.service.PmsCategoryService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("pmsCategoryService")
@ -18,12 +22,40 @@ public class PmsCategoryServiceImpl extends ServiceImpl<PmsCategoryDao, PmsCateg
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<PmsCategoryEntity> page = this.page(
IPage<PmsCategoryEntity> page = page(
new Query<PmsCategoryEntity>().getPage(params),
new QueryWrapper<PmsCategoryEntity>()
new QueryWrapper<>()
);
return new PageUtils(page);
}
/**
* 查询所有分类以及子分类以树形结构展示
*
* @return 分类列表
*/
@Override
public List<PmsCategoryEntity> listWithTree() {
// 查询所有的分类
List<PmsCategoryEntity> list = list();
return list.stream()
.filter(entity -> entity.getParentCid().equals(0L))
.peek(entity -> entity.setChildren(getChildren(entity, list)))
.sorted(Comparator.comparingInt(PmsCategoryEntity::getSort))
.collect(Collectors.toList());
}
private List<PmsCategoryEntity> getChildren(PmsCategoryEntity entity, List<PmsCategoryEntity> list) {
List<PmsCategoryEntity> voList = new ArrayList<>();
for (PmsCategoryEntity category : list) {
if (entity.getParentCid().equals(category.getParentCid())) {
voList.add(category);
}
}
return voList;
}
}

View File

@ -3,14 +3,14 @@ server:
spring:
datasource:
username: root
password: "123456"
url: jdbc:mysql://192.168.95.40:3306/gulimall_pms?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
username: gulimall
password: 0212Gulimall
url: jdbc:mysql://rm-bp12z6hlv46vi6g8mro.mysql.rds.aliyuncs.com:3306/gulimall_pms?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
driver-class-name: com.mysql.cj.jdbc.Driver
# cloud:
# nacos:
# discovery:
# server-addr: 127.0.0.1:8848
cloud:
nacos:
discovery:
server-addr: 192.168.95.40:8848
jackson:
date-format: yyyy-MM-dd HH:mm:ss

View File

@ -1,41 +1,41 @@
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.56.10:3306/gulimall_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: root
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
#login-username: admin
#login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-bp12z6hlv46vi6g8mro.mysql.rds.aliyuncs.com:3306/gulimall_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: gulimall
password: 0212Gulimall
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
# Oracle需要打开注释
# validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
# login-username: admin
# login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
##多数据源的配置
#dynamic:
# dynamic:
# datasource:
# slave1:
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver

View File

@ -1,41 +1,41 @@
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/renren_fast?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: renren
password: 123456
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
#login-username: admin
#login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-bp12z6hlv46vi6g8mro.mysql.rds.aliyuncs.com:3306/renren_fast?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: gulimall
password: 0212Gulimall
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
# Oracle需要打开注释
# validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
# login-username: admin
# login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
##多数据源的配置
#dynamic:
# dynamic:
# datasource:
# slave1:
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver

View File

@ -1,41 +1,41 @@
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/renren_fast?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: renren
password: 123456
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
#login-username: admin
#login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-bp12z6hlv46vi6g8mro.mysql.rds.aliyuncs.com:3306/renren_fast?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: gulimall
password: 0212Gulimall
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
# Oracle需要打开注释
# validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
# login-username: admin
# login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
##多数据源的配置
#dynamic:
# dynamic:
# datasource:
# slave1:
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver

View File

@ -10,6 +10,8 @@ server:
context-path: /renren-fast
spring:
application:
name: renren-fast
# 环境 dev|test|prod
profiles:
active: dev
@ -37,30 +39,28 @@ spring:
min-idle: 5 # 连接池中的最小空闲连接
mvc:
throw-exception-if-no-handler-found: true
application:
name: renren-fast
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
server-addr: 192.168.95.40:8848
# resources:
# add-mappings: false
#mybatis
# mybatis
mybatis-plus:
mapper-locations: classpath*:/mapper/**/*.xml
#实体扫描多个package用逗号或者分号分隔
# 实体扫描多个package用逗号或者分号分隔
typeAliasesPackage: io.renren.modules.*.entity
global-config:
#数据库相关配置
# 数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
# 主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: AUTO
logic-delete-value: -1
logic-not-delete-value: 0
banner: false
#原生配置
# 原生配置
configuration:
map-underscore-to-camel-case: true
cache-enabled: false