提交 31f94cd5 作者: xiaowang

分类新增子分类返回数据,首页保险,软件数据返回

上级 0483baed
...@@ -61,7 +61,7 @@ public class ProductMallController extends BaseController { ...@@ -61,7 +61,7 @@ public class ProductMallController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = CategoryTypeDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CategoryTypeDTO.class)})
@GetMapping("/getPageHomeCategories") @GetMapping("/getPageHomeCategories")
public ResultBody<CategoryTypeDTO> getPageHomeCategories( public ResultBody<CategoryTypeDTO> getPageHomeCategories(
@ApiParam(value = "类型:1:作业服务 2:设备 3:培训 4:产品商城") @RequestParam(value = "type") Integer type) { @ApiParam(value = "类型:1:作业服务 2:设备 3:培训 4:产品商城 5:无人机保险 6:无人机工具软件") @RequestParam(value = "type") Integer type) {
return webDeviceService.getPageHomeCategories(type); return webDeviceService.getPageHomeCategories(type);
} }
......
...@@ -65,5 +65,9 @@ public interface CategoriesDao { ...@@ -65,5 +65,9 @@ public interface CategoriesDao {
int countChildById(Integer id); int countChildById(Integer id);
List<Categories> getSubClassifyList(Integer id); List<Categories> getSubClassifyList(Integer id);
List<Categories> listCategoryByInsurance();
List<Categories> listCategoryBySoftware();
} }
...@@ -7,6 +7,7 @@ import lombok.Data; ...@@ -7,6 +7,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* Auto-generated: 2023-06-08 16:2:43 * Auto-generated: 2023-06-08 16:2:43
...@@ -21,7 +22,9 @@ import java.io.Serializable; ...@@ -21,7 +22,9 @@ import java.io.Serializable;
public class CategoriesInfoListDTO implements Serializable { public class CategoriesInfoListDTO implements Serializable {
private static final long serialVersionUID = -8381856228953745772L; private static final long serialVersionUID = -8381856228953745772L;
private Integer id; private Integer id;
private Integer pid;
private Integer directoryId; private Integer directoryId;
private String name; private String name;
private String icon; private String icon;
private List<CategoriesInfoListDTO> children;
} }
...@@ -358,9 +358,26 @@ public class CategoriesServiceImpl implements CategoriesService { ...@@ -358,9 +358,26 @@ public class CategoriesServiceImpl implements CategoriesService {
.map(AllCategoryDTO::getDirectoryId) .map(AllCategoryDTO::getDirectoryId)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Categories> categoriesList = categoriesDao.selectCategoryByDirectoryId(directoryIdIds); List<Categories> categoriesList = categoriesDao.selectCategoryByDirectoryId(directoryIdIds);
return categoriesList.stream() List<CategoriesInfoListDTO> list = categoriesList.stream()
.map(Categories::buildCategoriesInfoListDTO) .map(Categories::buildCategoriesInfoListDTO)
.collect(Collectors.groupingBy(CategoriesInfoListDTO::getDirectoryId)); .collect(Collectors.toList());
List<Integer> categoryId = list.stream().map(CategoriesInfoListDTO::getId).collect(Collectors.toList());
for (Integer id : categoryId) {
List<Categories> subClassifyList = categoriesDao.getSubClassifyList(id);
if (CollectionUtils.isNotEmpty(subClassifyList)){
List<CategoriesInfoListDTO> childList =
subClassifyList.stream()
.map(Categories::buildCategoriesInfoListDTO)
.collect(Collectors.toList());
for (CategoriesInfoListDTO categories : list) {
if (id.equals(categories.getId())){
categories.setChildren(childList);
break;
}
}
}
}
return list.stream().collect(Collectors.groupingBy(CategoriesInfoListDTO::getDirectoryId));
} }
private void addSubCategories( private void addSubCategories(
......
...@@ -179,14 +179,17 @@ public class WebDeviceServiceImpl implements WebDeviceService { ...@@ -179,14 +179,17 @@ public class WebDeviceServiceImpl implements WebDeviceService {
userIds = Collections.singletonList(-1); userIds = Collections.singletonList(-1);
} }
} }
int count = webDeviceDao.countListWareInfoPage(param.getCategoryId(), userIds, param.getType(),param.getGoodsName()); int count =
webDeviceDao.countListWareInfoPage(
param.getCategoryId(), userIds, param.getType(), param.getGoodsName());
if (count == 0) { if (count == 0) {
return ResultBody.success( return ResultBody.success(
PageResult.buildPage(param.getPageNo(), param.getPageSize(), count)); PageResult.buildPage(param.getPageNo(), param.getPageSize(), count));
} }
int pageNo = param.getPageNo(); int pageNo = param.getPageNo();
param.buildCurrentPage(); param.buildCurrentPage();
List<GoodsInfo> list = webDeviceDao.listWareInfoPage(param, userIds, param.getType(),param.getGoodsName()); List<GoodsInfo> list =
webDeviceDao.listWareInfoPage(param, userIds, param.getType(), param.getGoodsName());
List<LeaseGoodsInfoDTO> pageList = List<LeaseGoodsInfoDTO> pageList =
list.stream().map(GoodsInfo::buildLeaseGoodsInfoDTO).collect(Collectors.toList()); list.stream().map(GoodsInfo::buildLeaseGoodsInfoDTO).collect(Collectors.toList());
if (StringUtils.isBlank(request.getHeader(TokenConstant.TOKEN))) { if (StringUtils.isBlank(request.getHeader(TokenConstant.TOKEN))) {
...@@ -243,11 +246,26 @@ public class WebDeviceServiceImpl implements WebDeviceService { ...@@ -243,11 +246,26 @@ public class WebDeviceServiceImpl implements WebDeviceService {
@Override @Override
public ResultBody getPageHomeCategories(Integer type) { public ResultBody getPageHomeCategories(Integer type) {
List<DirectoryDO> directoryList = categoriesDao.getDirectoryList(type); if (!type.equals(5) || !type.equals(6)) {
if (CollectionUtils.isNotEmpty(directoryList)) { List<DirectoryDO> directoryList = categoriesDao.getDirectoryList(type);
List<Integer> directoryIds = if (CollectionUtils.isNotEmpty(directoryList)) {
directoryList.stream().map(DirectoryDO::getId).collect(Collectors.toList()); List<Integer> directoryIds =
List<Categories> categoriesList = categoriesDao.getCategoriesListByDirectoryIds(directoryIds); directoryList.stream().map(DirectoryDO::getId).collect(Collectors.toList());
List<Categories> categoriesList =
categoriesDao.getCategoriesListByDirectoryIds(directoryIds);
return ResultBody.success(
categoriesList.stream()
.map(Categories::buildCategoryTypeDTO)
.collect(Collectors.toList()));
}
} else if (type.equals(5)) {
List<Categories> categoriesList = categoriesDao.listCategoryByInsurance();
return ResultBody.success(
categoriesList.stream()
.map(Categories::buildCategoryTypeDTO)
.collect(Collectors.toList()));
} else if (type.equals(6)) {
List<Categories> categoriesList = categoriesDao.listCategoryBySoftware();
return ResultBody.success( return ResultBody.success(
categoriesList.stream() categoriesList.stream()
.map(Categories::buildCategoryTypeDTO) .map(Categories::buildCategoryTypeDTO)
......
...@@ -235,6 +235,32 @@ ...@@ -235,6 +235,32 @@
from categories from categories
where parent_id = #{id} where parent_id = #{id}
</select> </select>
<select id="listCategoryByInsurance" resultType="com.mmc.pms.entity.Categories">
SELECT id,
parent_id,
directory_id,
`name`,
icon,
description,
remark,
create_time
FROM categories
WHERE (id = 56
OR parent_id = 56) and is deleted = 0
</select>
<select id="listCategoryBySoftware" resultType="com.mmc.pms.entity.Categories">
SELECT id,
parent_id,
directory_id,
`name`,
icon,
description,
remark,
create_time
FROM categories
WHERE (id = 55
OR parent_id = 55) and is deleted = 0
</select>
<update id="deleteById"> <update id="deleteById">
UPDATE `categories` UPDATE `categories`
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论