fix: SubjectLabel
This commit is contained in:
@@ -3,7 +3,6 @@ package com.landaiqing.subject.application.dto;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 题目标签DTO
|
||||
@@ -12,7 +11,7 @@ import java.util.Date;
|
||||
* @since 2024-02-14 17:08:06
|
||||
*/
|
||||
@Data
|
||||
public class SubjectLabelDTO implements Serializable {
|
||||
public class SubjectLabelDTO implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
|
@@ -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);
|
||||
|
@@ -28,7 +28,7 @@ public interface SubjectLabelDao {
|
||||
* @param subjectLabel 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<SubjectLabel> queryAllByLimit(SubjectLabel subjectLabel);
|
||||
List<SubjectLabel> queryByCondition(SubjectLabel subjectLabel);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
|
@@ -49,4 +49,6 @@ public interface SubjectLabelService {
|
||||
boolean deleteById(Long id);
|
||||
|
||||
List<SubjectLabel> batchQueryById(@Param("list") List<Long> labelIdList);
|
||||
|
||||
List<SubjectLabel> queryByCondition(SubjectLabel subjectLabel);
|
||||
}
|
||||
|
@@ -71,4 +71,9 @@ public class SubjectLabelServiceImpl implements SubjectLabelService {
|
||||
public List<SubjectLabel> batchQueryById(List<Long> labelIdList) {
|
||||
return this.subjectLabelDao.batchQueryById(labelIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubjectLabel> queryByCondition(SubjectLabel subjectLabel) {
|
||||
return this.subjectLabelDao.queryByCondition(subjectLabel);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="SubjectLabelMap">
|
||||
<select id="queryByCondition" resultMap="SubjectLabelMap">
|
||||
select
|
||||
id,label_name,sort_num,category_id,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_label
|
||||
@@ -55,7 +55,6 @@
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
limit #{pageable.offset}, #{pageable.pageSize}
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
|
Reference in New Issue
Block a user