Compare commits

..

3 Commits

Author SHA1 Message Date
清晨
5011984747 feat(category): 增加按祖级 ID 查询分类信息功能- 新增 categoryByAncestors 接口,根据祖级 ID 获取分类信息列表
- 在 TzCategory 模型中添加 ancestors 字段,用于存储祖级列表
- 在 TzCategoryService接口中添加 listByAncestors 方法
- 在 TzCategoryServiceImpl 中实现 listByAncestors 方法
- 更新相关 BO 和 VO 类,支持 ancestors 字段
2025-05-12 16:06:05 +08:00
清晨
1d180d33a9 refactor(mall): 优化分类服务接口实现
- 移除了 PdfUtil 类中的未使用代码- 简化了 TzCategoryServiceImpl 中的分类添加逻辑- 增加了 TzCategoryServiceImpl 中根据父级 ID 查询子类信息的方法注释
2025-05-12 14:44:09 +08:00
清晨
ad2776df97 refactor(mall): 更新数据库配置并优化类目查询逻辑
- 更新 ruoyi-admin 和 ruoyi-mall-api 项目的数据库配置,使用新的数据库连接信息
- 修改 TzCategoryServiceImpl 中的 listByParentId 方法,增加对子集状态的查询条件
2025-05-12 10:02:27 +08:00
11 changed files with 61 additions and 30 deletions

View File

@@ -52,9 +52,9 @@ spring:
# url: jdbc:mysql://localhost:3306/jcs?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: root
# password: root
url: jdbc:mysql://erp9.52o.site:13308/jcs20250106?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: jcs20250106
password: esXkafdSMsxRAkNe
url: jdbc:mysql://erp9.52o.site:13308/jcs20250512?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: jcs20250512
password: rdnGT3TFYFnMzstX
# 从库数据源
slave:
lazy: false

View File

@@ -55,9 +55,9 @@ spring:
# url: jdbc:mysql://localhost:3306/cailiao?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: root
# password: root
url: jdbc:mysql://124.223.56.113:13306/cailiao1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: cailiao1
password: j5RcfMwRG2WMHyAC
url: jdbc:mysql://erp9.52o.site:13308/jcs20250512?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: jcs20250512
password: rdnGT3TFYFnMzstX
# 从库数据源
slave:
lazy: false

View File

@@ -8,6 +8,9 @@ import com.aspose.words.SaveFormat;
import java.io.*;
/**
* @author Maosw
*/
public class PdfUtil {

View File

@@ -215,13 +215,21 @@ public class ApiProdController {
}
@GetMapping("/categoryInfo")
@Operation(summary = "分类信息列表", description = "获取所有的产品分类信息顶级分类的parentId为0,默认为顶级分类")
@Operation(summary = "根据父级ID获取分类信息列表", description = "获取所有的产品分类信息顶级分类的parentId为0,默认为顶级分类")
@Parameter(name = "parentId", description = "分类ID")
public ServerResponseEntity<List<TzCategoryVo>> categoryInfo(@RequestParam(value = "parentId", defaultValue = "0") Long parentId) {
List<TzCategoryVo> categories = categoryService.listByParentId(parentId);
return ServerResponseEntity.success(categories);
}
@GetMapping("/categoryByAncestors")
@Operation(summary = "根据祖级ID获取分类信息列表", description = "获取所有的产品分类信息顶级分类的ancestors为0,默认为顶级分类")
@Parameter(name = "ancestors", description = "祖级ID")
public ServerResponseEntity<List<TzCategoryVo>> categoryByAncestors(@RequestParam(value = "ancestors", defaultValue = "0") Long ancestors) {
List<TzCategoryVo> categories = categoryService.listByAncestors(ancestors);
return ServerResponseEntity.success(categories);
}
@PostMapping("/searchProdPage")
@Operation(summary = "分页排序搜索商品", description = "根据商品名搜索")
@Parameters({@Parameter(name = "categoryId", description = "分类ID"),@Parameter(name = "prodName", description = "商品名"), @Parameter(name = "floor", description = "是否特价 1是 2", required = true),@Parameter(name = "sort", description = "排序(0综合 1价格排序 2热门 3新品)", required = true), @Parameter(name = "orderBy", description = "排序(0升序 1降序)--sort选择1时必传")})

View File

@@ -52,9 +52,9 @@ spring:
# url: jdbc:mysql://localhost:3306/jcs?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: root
# password: root
url: jdbc:mysql://erp9.52o.site:13308/jcs20250106?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: jcs20250106
password: esXkafdSMsxRAkNe
url: jdbc:mysql://erp9.52o.site:13308/jcs20250512?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: jcs20250512
password: rdnGT3TFYFnMzstX
# 从库数据源
slave:
lazy: false

View File

@@ -55,9 +55,9 @@ spring:
# url: jdbc:mysql://localhost:3306/cailiao?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: root
# password: root
url: jdbc:mysql://localhost:3306/jcs?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: root
url: jdbc:mysql://erp9.52o.site:13308/jcs20250512?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: jcs20250512
password: rdnGT3TFYFnMzstX
# 从库数据源
slave:
lazy: false

View File

@@ -30,9 +30,9 @@ public class TzCategory extends BaseEntity {
private Long categoryId;
/**
* 店铺ID
* 祖级列表
*/
private Long shopId;
private String ancestors;
/**
* 父节点

View File

@@ -30,9 +30,9 @@ public class TzCategoryBo extends BaseEntity {
private Long categoryId;
/**
* 店铺ID
* 祖级列表
*/
private Long shopId;
private String ancestors;
/**
* 父节点

View File

@@ -33,10 +33,10 @@ public class TzCategoryVo implements Serializable {
private Long categoryId;
/**
* 店铺ID
* 祖级列表
*/
@ExcelProperty(value = "店铺ID")
private Long shopId;
@ExcelProperty(value = "祖级列表")
private String ancestors;
/**
* 父节点

View File

@@ -68,4 +68,11 @@ public interface ITzCategoryService {
* @return
*/
List<TzCategoryVo> categoryAll();
/**
* 分类信息列表
* @param ancestors
* @return
*/
List<TzCategoryVo> listByAncestors(Long ancestors);
}

View File

@@ -75,14 +75,14 @@ public class TzCategoryServiceImpl implements ITzCategoryService {
bo.setGrade(category.getGrade()+1);
category.setSubset(1);
baseMapper.updateById(category);
bo.setAncestors(category.getAncestors()+StringUtils.SEPARATOR+category.getCategoryId());
}else{
bo.setAncestors("0");
}
bo.setRecTime(new Date());
TzCategory add = MapstructUtils.convert(bo, TzCategory.class);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setCategoryId(add.getCategoryId());
}
return flag;
return baseMapper.insert(add) > 0;
}
/**
@@ -98,13 +98,15 @@ public class TzCategoryServiceImpl implements ITzCategoryService {
bo.setGrade(category.getGrade()+1);
category.setSubset(1);
baseMapper.updateById(category);
bo.setAncestors(category.getAncestors()+StringUtils.SEPARATOR+category.getCategoryId());
}else{
bo.setAncestors("0");
}
TzCategory update = MapstructUtils.convert(bo, TzCategory.class);
return baseMapper.updateById(update) > 0;
}
/**
* 校验并批量删除产品类目信息
*
@@ -117,15 +119,26 @@ public class TzCategoryServiceImpl implements ITzCategoryService {
return baseMapper.deleteByIds(ids) > 0;
}
/**
* 根据父级ID查询子类信息
* @param parentId
*/
@Override
public List<TzCategoryVo> listByParentId(Long parentId) {
return baseMapper.selectVoList(new LambdaQueryWrapper<TzCategory>().eq(TzCategory::getParentId, parentId).eq(TzCategory::getStatus,1));
return baseMapper.selectVoList(new LambdaQueryWrapper<TzCategory>().eq(TzCategory::getParentId, parentId).eq(TzCategory::getStatus,1).eq(TzCategory::getSubset,1));
}
/**
* 分类信息列表
* @param ancestors
*/
@Override
public List<TzCategoryVo> listByAncestors(Long ancestors) {
return baseMapper.selectVoList(new LambdaQueryWrapper<TzCategory>().like(TzCategory::getAncestors, ancestors).eq(TzCategory::getStatus,1).eq(TzCategory::getSubset,1));
}
/**
* 全部分类信息列表
*
* @return
*/
@Override
public List<TzCategoryVo> categoryAll() {