fix: SubjectLabel
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package com.landaiqing.subject.domain.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.landaiqing.subject.common.enums.CategoryTypeEnum;
|
||||
import com.landaiqing.subject.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.subject.domain.convert.SubjectLabelConverter;
|
||||
import com.landaiqing.subject.domain.entity.SubjectLabelBO;
|
||||
import com.landaiqing.subject.domain.service.SubjectLabelDomainService;
|
||||
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;
|
||||
@@ -27,6 +30,9 @@ public class SubjectLabelDomainServiceImpl implements SubjectLabelDomainService
|
||||
@Resource
|
||||
private SubjectMappingService subjectMappingService;
|
||||
|
||||
@Resource
|
||||
private SubjectCategoryService subjectCategoryService;
|
||||
|
||||
/**
|
||||
* @description: 新增标签
|
||||
* @param: [subjectLabelBO]
|
||||
@@ -63,13 +69,14 @@ public class SubjectLabelDomainServiceImpl implements SubjectLabelDomainService
|
||||
int count = subjectLabelService.update(subjectLabel);
|
||||
return count > 0;
|
||||
}
|
||||
/**
|
||||
* @description: 删除标签
|
||||
* @param: [subjectLabelBO]
|
||||
* @return: java.lang.Boolean
|
||||
|
||||
/**
|
||||
* @description: 删除标签
|
||||
* @param: [subjectLabelBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 18:58
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
public Boolean delete(SubjectLabelBO subjectLabelBO) {
|
||||
if (log.isInfoEnabled()) {
|
||||
@@ -81,28 +88,38 @@ public class SubjectLabelDomainServiceImpl implements SubjectLabelDomainService
|
||||
int count = subjectLabelService.update(subjectLabel);
|
||||
return count > 0;
|
||||
}
|
||||
/**
|
||||
* @description: 查询分类下的标签
|
||||
* @param: [subjectLabelBO]
|
||||
* @return: java.util.List<com.landaiqing.subject.domain.entity.SubjectLabelBO>
|
||||
|
||||
/**
|
||||
* @description: 查询分类下的标签
|
||||
* @param: [subjectLabelBO]
|
||||
* @return: java.util.List<com.landaiqing.subject.domain.entity.SubjectLabelBO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 19:08
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
public List<SubjectLabelBO> queryLabelByCategoryId(SubjectLabelBO subjectLabelBO) {
|
||||
//如果当前分类是1级分类,则查询所有标签
|
||||
SubjectCategory subjectCategory = subjectCategoryService.queryById(subjectLabelBO.getCategoryId());
|
||||
if(CategoryTypeEnum.PRIMARY.getCode()==subjectCategory.getCategoryType()){
|
||||
SubjectLabel subjectLabel=new SubjectLabel();
|
||||
subjectLabel.setCategoryId(subjectLabelBO.getCategoryId());
|
||||
List<SubjectLabel> labelList= subjectLabelService.queryByCondition(subjectLabel);
|
||||
List<SubjectLabelBO> boList = SubjectLabelConverter.INSTANCE.convertLabelToBoList(labelList);
|
||||
return boList;
|
||||
}
|
||||
Long categoryId = subjectLabelBO.getCategoryId();
|
||||
SubjectMapping subjectMapping=new SubjectMapping();
|
||||
SubjectMapping subjectMapping = new SubjectMapping();
|
||||
subjectMapping.setCategoryId(categoryId);
|
||||
subjectMapping.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
List<SubjectMapping> mappingList= subjectMappingService.queryLabelId(subjectMapping);
|
||||
if(CollectionUtils.isEmpty(mappingList)){
|
||||
List<SubjectMapping> mappingList = subjectMappingService.queryLabelId(subjectMapping);
|
||||
if (CollectionUtils.isEmpty(mappingList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Long> labelIdList = mappingList.stream().map(SubjectMapping::getLabelId).collect(Collectors.toList());
|
||||
List<SubjectLabel> labelList= subjectLabelService.batchQueryById(labelIdList);
|
||||
List<SubjectLabelBO> boList=new LinkedList<>();
|
||||
labelList.forEach(label->{
|
||||
SubjectLabelBO bo=new SubjectLabelBO();
|
||||
List<SubjectLabel> labelList = subjectLabelService.batchQueryById(labelIdList);
|
||||
List<SubjectLabelBO> boList = new LinkedList<>();
|
||||
labelList.forEach(label -> {
|
||||
SubjectLabelBO bo = new SubjectLabelBO();
|
||||
bo.setId(label.getId());
|
||||
bo.setLabelName(label.getLabelName());
|
||||
bo.setCategoryId(categoryId);
|
||||
|
Reference in New Issue
Block a user