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

@@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 题目分类(SubjectCategory)实体类
@@ -33,7 +34,15 @@ public class SubjectCategoryBO implements Serializable {
* 父级id
*/
private Long parentId;
/**
* 数量
*/
private Integer count;
/**
* 变迁bo数量
*/
private List<SubjectLabelBO> labelBOList;
}

View File

@@ -35,4 +35,12 @@ public interface SubjectCategoryDomainService {
* @date: 2024/2/14 14:58
*/
Boolean delete(SubjectCategoryBO subjectCategoryBO);
/**
* @description: 查询及标签
* @param: [subjectCategoryBO]
* @return: java.util.List<com.landaiqing.subject.domain.entity.SubjectCategoryBO>
* @author landaiqing
* @date: 2024/2/26 21:14
*/
List<SubjectCategoryBO> queryCategoryAndLabel(SubjectCategoryBO subjectCategoryBO);
}

View File

@@ -5,14 +5,23 @@ import com.landaiqing.subject.common.enums.CategoryTypeEnum;
import com.landaiqing.subject.common.enums.IsDeletedFlagEnum;
import com.landaiqing.subject.domain.convert.SubjectCategoryConverter;
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
import com.landaiqing.subject.domain.entity.SubjectLabelBO;
import com.landaiqing.subject.domain.service.SubjectCategoryDomainService;
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
import com.landaiqing.subject.infra.basic.entity.SubjectLabel;
import com.landaiqing.subject.infra.basic.entity.SubjectMapping;
import com.landaiqing.subject.infra.basic.service.SubjectCategoryService;
import com.landaiqing.subject.infra.basic.service.SubjectLabelService;
import com.landaiqing.subject.infra.basic.service.SubjectMappingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
@Slf4j
@@ -20,6 +29,11 @@ public class SubjectCategoryDomainServiceImpl implements SubjectCategoryDomainSe
@Resource
private SubjectCategoryService subjectCategoryService;
@Resource
private SubjectMappingService subjectMappingService;
@Resource
private SubjectLabelService subjectLabelService;
/**
* @description: 新增分类
* @param: [subjectCategoryBO]
@@ -56,6 +70,10 @@ public class SubjectCategoryDomainServiceImpl implements SubjectCategoryDomainSe
if (log.isInfoEnabled()) {
log.info("SubjectCategoryController.queryPrimaryCategory.boList:{}", JSON.toJSONString(boList));
}
boList.forEach(bo -> {
Integer subjectCount = subjectCategoryService.querySubjectCount(bo.getId());
bo.setCount(subjectCount);
});
return boList;
}
@@ -87,4 +105,49 @@ public class SubjectCategoryDomainServiceImpl implements SubjectCategoryDomainSe
int count = subjectCategoryService.update(subjectCategory);
return count > 0;
}
/**
* @description: 查询分类及标签
* @param: [subjectCategoryBO]
* @return: java.util.List<com.landaiqing.subject.domain.entity.SubjectCategoryBO>
* @author landaiqing
* @date: 2024/2/26 20:46
*/
@Override
public List<SubjectCategoryBO> queryCategoryAndLabel(SubjectCategoryBO subjectCategoryBO) {
// 查询当前分类下的所以的分类
SubjectCategory subjectCategory = new SubjectCategory();
subjectCategory.setParentId(subjectCategoryBO.getId());
subjectCategory.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
List<SubjectCategory> subjectCategoryList = subjectCategoryService.queryCategory(subjectCategory);
if (log.isInfoEnabled()) {
log.info("SubjectCategoryController.queryCategoryAndLabel.subjectCategoryList:{}"
, JSON.toJSONString(subjectCategoryList));
}
List<SubjectCategoryBO> categoryBOList = SubjectCategoryConverter.INSTANCE.convertBoToCategory(subjectCategoryList);
// 一次获取标签信息
categoryBOList.forEach(category -> {
SubjectMapping subjectMapping = new SubjectMapping();
subjectMapping.setCategoryId(category.getId());
List<SubjectMapping> mappingList = subjectMappingService.queryLabelId(subjectMapping);
if (CollectionUtils.isEmpty(mappingList)) {
return;
}
List<Long> labelIdList = mappingList.stream().map(SubjectMapping::getLabelId).collect(Collectors.toList());
List<SubjectLabel> subjectLabelList = subjectLabelService.batchQueryById(labelIdList);
List<SubjectLabelBO> labelBOList = new LinkedList<>();
subjectLabelList.forEach(label -> {
SubjectLabelBO subjectLabelBO = new SubjectLabelBO();
subjectLabelBO.setId(label.getId());
subjectLabelBO.setLabelName(label.getLabelName());
subjectLabelBO.setCategoryId(label.getCategoryId());
subjectLabelBO.setSortNum(label.getSortNum());
labelBOList.add(subjectLabelBO);
});
category.setLabelBOList(labelBOList);
});
return categoryBOList;
}
}