feat: bug修复

This commit is contained in:
2024-02-26 21:50:29 +08:00
parent 85d0b1e6c9
commit e13b3f7c2d
13 changed files with 226 additions and 27 deletions

View File

@@ -3,7 +3,9 @@ package com.landaiqing.subject.application.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.landaiqing.subject.application.convert.SubjectCategoryDTOConverter;
import com.landaiqing.subject.application.convert.SubjectLabelDTOConverter;
import com.landaiqing.subject.application.dto.SubjectCategoryDTO;
import com.landaiqing.subject.application.dto.SubjectLabelDTO;
import com.landaiqing.subject.common.entity.Result;
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
import com.landaiqing.subject.domain.service.SubjectCategoryDomainService;
@@ -12,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;
/**
@@ -152,4 +155,37 @@ public class SubjectCategoryController {
}
}
/**
* @description: 查询分类及标签一次性
* @param: [subjectCategoryDTO]
* @return: com.landaiqing.subject.common.entity.Result<java.util.List < com.landaiqing.subject.application.dto.SubjectCategoryDTO>>
* @author landaiqing
* @date: 2024/2/26 20:43
*/
@PostMapping("/queryCategoryAndLabel")
public Result<List<SubjectCategoryDTO>> queryCategoryAndLabel(@RequestBody SubjectCategoryDTO subjectCategoryDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SubjectCategoryController.queryCategoryAndLabel.dto:{}"
, JSON.toJSONString(subjectCategoryDTO));
}
Preconditions.checkNotNull(subjectCategoryDTO.getId(), "分类id不能为空");
SubjectCategoryBO subjectCategoryBO = SubjectCategoryDTOConverter.INSTANCE.
convertDtoToCategoryBO(subjectCategoryDTO);
List<SubjectCategoryBO> subjectCategoryBOList = subjectCategoryDomainService.queryCategoryAndLabel(subjectCategoryBO);
List<SubjectCategoryDTO> dtoList = new LinkedList<>();
subjectCategoryBOList.forEach(bo -> {
SubjectCategoryDTO dto = SubjectCategoryDTOConverter.INSTANCE.convertBoToCategoryDTO(bo);
List<SubjectLabelDTO> labelDTOList = SubjectLabelDTOConverter.INSTANCE.convertBOToLabelDTOList(bo.getLabelBOList());
dto.setLabelDTOList(labelDTOList);
dtoList.add(dto);
});
return Result.ok(dtoList);
} catch (Exception e) {
log.error("SubjectCategoryController.queryCategoryAndLabel.error:{}", e.getMessage(), e);
return Result.fail("查询失败");
}
}
}

View File

@@ -20,6 +20,7 @@ public interface SubjectCategoryDTOConverter {
SubjectCategoryBO convertDtoToCategoryBO(SubjectCategoryDTO subjectCategoryDTO);
SubjectCategoryDTO convertBoToCategoryDTO(SubjectCategoryBO subjectCategoryBO);
List<SubjectCategoryDTO> convertBoToCategoryDTOList(List<SubjectCategoryBO> subjectCategoryDTO);
}

View File

@@ -42,7 +42,10 @@ public class SubjectCategoryDTO implements Serializable {
* 数量
*/
private Integer count;
/**
* 标签信息
*/
private List<SubjectLabelDTO> labelDTOList;
}