feat: 修改模块名称
This commit is contained in:
39
qing-yu-club-subject/qing-yu-club-domain/pom.xml
Normal file
39
qing-yu-club-subject/qing-yu-club-domain/pom.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-subject</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-domain</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-domain</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-infra</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -0,0 +1,15 @@
|
||||
package com.landaiqing.subject.domain.convert;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectBrief;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface BriefSubjectConverter {
|
||||
|
||||
BriefSubjectConverter INSTANCE = Mappers.getMapper(BriefSubjectConverter.class);
|
||||
|
||||
SubjectBrief convertBoToEntity(SubjectInfoBO subjectInfoBO);
|
||||
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.landaiqing.subject.domain.convert;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectJudge;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface JudgeSubjectConverter {
|
||||
|
||||
JudgeSubjectConverter INSTANCE = Mappers.getMapper(JudgeSubjectConverter.class);
|
||||
|
||||
List<SubjectAnswerBO> convertEntityToBoList(List<SubjectJudge> subjectJudgeList);
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.landaiqing.subject.domain.convert;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectMultiple;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MultipleSubjectConverter {
|
||||
|
||||
MultipleSubjectConverter INSTANCE = Mappers.getMapper(MultipleSubjectConverter.class);
|
||||
|
||||
SubjectMultiple convertBoToEntity(SubjectAnswerBO subjectAnswerBO);
|
||||
|
||||
List<SubjectAnswerBO> convertEntityToBoList(List<SubjectMultiple> subjectMultipleList);
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.landaiqing.subject.domain.convert;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectInfo;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectRadio;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface RadioSubjectConverter {
|
||||
RadioSubjectConverter INSTANCE = Mappers.getMapper(RadioSubjectConverter.class);
|
||||
|
||||
SubjectRadio convertBoToEntity(SubjectAnswerBO subjectAnswerBO);
|
||||
List<SubjectAnswerBO> convertEntityToBoList(List<SubjectRadio> subjectRadioList);
|
||||
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.landaiqing.subject.domain.convert;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SubjectCategoryConverter {
|
||||
SubjectCategoryConverter INSTANCE = Mappers.getMapper(SubjectCategoryConverter.class);
|
||||
|
||||
SubjectCategory convertBoToCategory(SubjectCategoryBO subjectCategoryBO);
|
||||
List<SubjectCategoryBO> convertBoToCategory(List<SubjectCategory> categoryList);
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.landaiqing.subject.domain.convert;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectOptionBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectInfo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SubjectInfoConverter {
|
||||
SubjectInfoConverter INSTANCE = Mappers.getMapper(SubjectInfoConverter.class);
|
||||
|
||||
SubjectInfo convertBoToInfo(SubjectInfoBO subjectInfoBO);
|
||||
SubjectInfoBO convertOptionToBO(SubjectOptionBO subjectOptionBO);
|
||||
SubjectInfoBO convertOptionAndInfoToBO(SubjectOptionBO subjectOptionBO,SubjectInfo subjectInfo);
|
||||
List<SubjectInfoBO> convertListInfoBoToBO(List<SubjectInfo> subjectInfoList);
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.landaiqing.subject.domain.convert;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectLabelBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectLabel;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SubjectLabelConverter {
|
||||
SubjectLabelConverter INSTANCE = Mappers.getMapper(SubjectLabelConverter.class);
|
||||
|
||||
SubjectLabel convertBoToLabel(SubjectLabelBO subjectLabelBO);
|
||||
List<SubjectLabelBO> convertLabelToBoList(List<SubjectLabel> subjectLabelList);
|
||||
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.landaiqing.subject.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 题目答案DTO
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-02-14 16:59:04
|
||||
*/
|
||||
@Data
|
||||
public class SubjectAnswerBO implements Serializable {
|
||||
/**
|
||||
* 答案选项标识
|
||||
*/
|
||||
private Integer optionType;
|
||||
/**
|
||||
* 答案
|
||||
*/
|
||||
private String optionContent;
|
||||
/**
|
||||
* 是否正确
|
||||
*/
|
||||
private Integer isCorrect;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,39 @@
|
||||
package com.landaiqing.subject.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 题目分类(SubjectCategory)实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-02-07 16:17:17
|
||||
*/
|
||||
@Data
|
||||
public class SubjectCategoryBO implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String categoryName;
|
||||
/**
|
||||
* 分类类型
|
||||
*/
|
||||
private Integer categoryType;
|
||||
/**
|
||||
* 图标连接
|
||||
*/
|
||||
private String imageUrl;
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,81 @@
|
||||
package com.landaiqing.subject.domain.entity;
|
||||
|
||||
import com.landaiqing.subject.common.entity.PageInfo;
|
||||
import com.landaiqing.subject.common.entity.PageResult;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目BO
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-02-14 16:59:04
|
||||
*/
|
||||
@Data
|
||||
public class SubjectInfoBO extends PageInfo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 题目名称
|
||||
*/
|
||||
private String subjectName;
|
||||
/**
|
||||
* 题目难度
|
||||
*/
|
||||
private Integer subjectDifficult;
|
||||
/**
|
||||
* 出题人名
|
||||
*/
|
||||
private String settleName;
|
||||
/**
|
||||
* 题目类型 1单选 2多选 3判断 4简答
|
||||
*/
|
||||
private Integer subjectType;
|
||||
/**
|
||||
* 题目分数
|
||||
*/
|
||||
private Integer subjectScore;
|
||||
/**
|
||||
* 题目解析
|
||||
*/
|
||||
private String subjectParse;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 题目答案
|
||||
*/
|
||||
private String subjectAnswer;
|
||||
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private List<Integer> categoryIds;
|
||||
|
||||
/**
|
||||
* 标签名称
|
||||
*/
|
||||
private List<String> labelName;
|
||||
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
private List<Integer> labelIds;
|
||||
/**
|
||||
* 答案选项
|
||||
*/
|
||||
private List<SubjectAnswerBO> optionList;
|
||||
|
||||
|
||||
private Long categoryId;
|
||||
private Long labelId;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.landaiqing.subject.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 题目标签Bo
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-02-14 17:08:06
|
||||
*/
|
||||
@Data
|
||||
public class SubjectLabelBO implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 标签分类
|
||||
*/
|
||||
private String labelName;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sortNum;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,27 @@
|
||||
package com.landaiqing.subject.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目dto
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Data
|
||||
public class SubjectOptionBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 题目答案
|
||||
*/
|
||||
private String subjectAnswer;
|
||||
|
||||
/**
|
||||
* 答案选项
|
||||
*/
|
||||
private List<SubjectAnswerBO> optionList;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,50 @@
|
||||
package com.landaiqing.subject.domain.handler.subject;
|
||||
|
||||
import com.landaiqing.subject.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.subject.common.enums.SubjectInfoTypeEnum;
|
||||
import com.landaiqing.subject.domain.convert.BriefSubjectConverter;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectOptionBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectBrief;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectBriefService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Classname RadioTypeHandler
|
||||
* @BelongsProject: qing-yu-club
|
||||
* @BelongsPackage: com.landaiqing.subject.domain.handler.subject
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-15 15:59
|
||||
* @Description: 简答题目的策略类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class BriefTypeHandler implements SubjectTypeHandler {
|
||||
|
||||
@Resource
|
||||
private SubjectBriefService subjectBriefService;
|
||||
@Override
|
||||
public SubjectInfoTypeEnum getHandlerType() {
|
||||
return SubjectInfoTypeEnum.BRIEF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(SubjectInfoBO subjectInfoBO) {
|
||||
//简答题目的插入
|
||||
SubjectBrief subjectBrief = BriefSubjectConverter.INSTANCE.convertBoToEntity(subjectInfoBO);
|
||||
subjectBrief.setSubjectId(subjectInfoBO.getId().intValue());
|
||||
subjectBrief.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
subjectBriefService.insert(subjectBrief);
|
||||
}
|
||||
@Override
|
||||
public SubjectOptionBO query(int subjectId) {
|
||||
SubjectBrief subjectBrief = new SubjectBrief();
|
||||
subjectBrief.setSubjectId(subjectId);
|
||||
SubjectBrief result = subjectBriefService.queryByCondition(subjectBrief);
|
||||
SubjectOptionBO subjectOptionBO = new SubjectOptionBO();
|
||||
subjectOptionBO.setSubjectAnswer(result.getSubjectAnswer());
|
||||
return subjectOptionBO;
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package com.landaiqing.subject.domain.handler.subject;
|
||||
|
||||
import com.landaiqing.subject.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.subject.common.enums.SubjectInfoTypeEnum;
|
||||
import com.landaiqing.subject.domain.convert.JudgeSubjectConverter;
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectOptionBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectJudge;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectJudgeService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @Classname RadioTypeHandler
|
||||
* @BelongsProject: qing-yu-club
|
||||
* @BelongsPackage: com.landaiqing.subject.domain.handler.subject
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-15 15:59
|
||||
* @Description: 判断题目的策略类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class JudgeTypeHandler implements SubjectTypeHandler {
|
||||
|
||||
@Resource
|
||||
private SubjectJudgeService subjectJudgeService;
|
||||
@Override
|
||||
public SubjectInfoTypeEnum getHandlerType() {
|
||||
return SubjectInfoTypeEnum.JUDGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(SubjectInfoBO subjectInfoBO) {
|
||||
//判断题目的插入
|
||||
SubjectJudge subjectJudge = new SubjectJudge();
|
||||
SubjectAnswerBO subjectAnswerBO = subjectInfoBO.getOptionList().get(0);
|
||||
subjectJudge.setSubjectId(subjectInfoBO.getId());
|
||||
subjectJudge.setIsCorrect(subjectAnswerBO.getIsCorrect());
|
||||
subjectJudge.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
subjectJudgeService.insert(subjectJudge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubjectOptionBO query(int subjectId) {
|
||||
SubjectJudge subjectJudge = new SubjectJudge();
|
||||
subjectJudge.setSubjectId((long) subjectId);
|
||||
List<SubjectJudge> result = subjectJudgeService.queryByCondition(subjectJudge);
|
||||
List<SubjectAnswerBO> subjectAnswerBOList = JudgeSubjectConverter.INSTANCE.convertEntityToBoList(result);
|
||||
SubjectOptionBO subjectOptionBO = new SubjectOptionBO();
|
||||
subjectOptionBO.setOptionList(subjectAnswerBOList);
|
||||
return subjectOptionBO;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package com.landaiqing.subject.domain.handler.subject;
|
||||
|
||||
import com.landaiqing.subject.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.subject.common.enums.SubjectInfoTypeEnum;
|
||||
import com.landaiqing.subject.domain.convert.MultipleSubjectConverter;
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectOptionBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectMultiple;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectMultipleService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Classname RadioTypeHandler
|
||||
* @BelongsProject: qing-yu-club
|
||||
* @BelongsPackage: com.landaiqing.subject.domain.handler.subject
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-15 15:59
|
||||
* @Description: 多选题目的策略类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class MultipleTypeHandler implements SubjectTypeHandler {
|
||||
|
||||
@Resource
|
||||
private SubjectMultipleService subjectMultipleService;
|
||||
@Override
|
||||
public SubjectInfoTypeEnum getHandlerType() {
|
||||
return SubjectInfoTypeEnum.MULTIPLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(SubjectInfoBO subjectInfoBO) {
|
||||
//多选题目的插入
|
||||
List<SubjectMultiple> subjectMultipleList = new LinkedList<>();
|
||||
subjectInfoBO.getOptionList().forEach(option -> {
|
||||
SubjectMultiple subjectMultiple = MultipleSubjectConverter.INSTANCE.convertBoToEntity(option);
|
||||
subjectMultiple.setSubjectId(subjectInfoBO.getId());
|
||||
subjectMultiple.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
subjectMultipleList.add(subjectMultiple);
|
||||
});
|
||||
subjectMultipleService.batchInsert(subjectMultipleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubjectOptionBO query(int subjectId) {
|
||||
SubjectMultiple subjectMultiple = new SubjectMultiple();
|
||||
subjectMultiple.setSubjectId(Long.valueOf(subjectId));
|
||||
List<SubjectMultiple> result = subjectMultipleService.queryByCondition(subjectMultiple);
|
||||
List<SubjectAnswerBO> subjectAnswerBOList = MultipleSubjectConverter.INSTANCE.convertEntityToBoList(result);
|
||||
SubjectOptionBO subjectOptionBO = new SubjectOptionBO();
|
||||
subjectOptionBO.setOptionList(subjectAnswerBOList);
|
||||
return subjectOptionBO;
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
package com.landaiqing.subject.domain.handler.subject;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.landaiqing.subject.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.subject.common.enums.SubjectInfoTypeEnum;
|
||||
import com.landaiqing.subject.domain.convert.RadioSubjectConverter;
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectOptionBO;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectRadio;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectRadioService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Classname RadioTypeHandler
|
||||
* @BelongsProject: qing-yu-club
|
||||
* @BelongsPackage: com.landaiqing.subject.domain.handler.subject
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-15 15:59
|
||||
* @Description: 单选题目的策略类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class RadioTypeHandler implements SubjectTypeHandler {
|
||||
@Resource
|
||||
private SubjectRadioService subjectRadioService;
|
||||
@Override
|
||||
public SubjectInfoTypeEnum getHandlerType() {
|
||||
return SubjectInfoTypeEnum.RADIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(SubjectInfoBO subjectInfoBO) {
|
||||
//单选题目的插入
|
||||
List<SubjectRadio> subjectRadioList = new LinkedList<>();
|
||||
if (subjectInfoBO.getOptionList() == null && subjectInfoBO.getOptionList().size() < 0) {
|
||||
return;
|
||||
}
|
||||
subjectInfoBO.getOptionList().forEach(option -> {
|
||||
SubjectRadio subjectRadio = RadioSubjectConverter.INSTANCE.convertBoToEntity(option);
|
||||
subjectRadio.setId(subjectInfoBO.getId());
|
||||
subjectRadio.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
subjectRadioList.add(subjectRadio);
|
||||
});
|
||||
subjectRadioService.batchInsert(subjectRadioList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubjectOptionBO query(int subjectId) {
|
||||
SubjectRadio subjectRadio = new SubjectRadio();
|
||||
subjectRadio.setSubjectId(Long.valueOf(subjectId));
|
||||
List<SubjectRadio> result = subjectRadioService.queryByCondition(subjectRadio);
|
||||
List<SubjectAnswerBO> subjectAnswerBOList = RadioSubjectConverter.INSTANCE.convertEntityToBoList(result);
|
||||
SubjectOptionBO subjectOptionBO = new SubjectOptionBO();
|
||||
subjectOptionBO.setOptionList(subjectAnswerBOList);
|
||||
return subjectOptionBO;
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.landaiqing.subject.domain.handler.subject;
|
||||
|
||||
import com.landaiqing.subject.common.enums.SubjectInfoTypeEnum;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectOptionBO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public interface SubjectTypeHandler {
|
||||
/**
|
||||
* @description: 枚举身份的识别
|
||||
* @param: []
|
||||
* @return: com.landaiqing.subject.common.enums.SubjectInfoTypeEnum
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/15 16:26
|
||||
*/
|
||||
SubjectInfoTypeEnum getHandlerType();
|
||||
/**
|
||||
* @description: 实际题目的插入
|
||||
* @param: [subjectInfoBO]
|
||||
* @return: void
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/15 15:58
|
||||
*/
|
||||
void add (SubjectInfoBO subjectInfoBO);
|
||||
|
||||
SubjectOptionBO query(int subjectId);
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.landaiqing.subject.domain.handler.subject;
|
||||
|
||||
import com.landaiqing.subject.common.enums.SubjectInfoTypeEnum;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Classname SubjectTypeFactory
|
||||
* @BelongsProject: qing-yu-club
|
||||
* @BelongsPackage: com.landaiqing.subject.domain.handler.subject
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-15 16:05
|
||||
* @Description: 题目类型工厂
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class SubjectTypeHandlerFactory implements InitializingBean {
|
||||
@Resource
|
||||
private List<SubjectTypeHandler> subjectTypeHandlerList;
|
||||
|
||||
private Map<SubjectInfoTypeEnum,SubjectTypeHandler> handlerMap =new HashMap<>();
|
||||
|
||||
public SubjectTypeHandler getHandler(int subjectType){
|
||||
SubjectInfoTypeEnum subjectInfoTypeEnum = SubjectInfoTypeEnum.getByCode(subjectType);
|
||||
return handlerMap.get(subjectInfoTypeEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
for(SubjectTypeHandler subjectTypeHandler : subjectTypeHandlerList){
|
||||
handlerMap.put(subjectTypeHandler.getHandlerType(),subjectTypeHandler);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing.subject.domain.service;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SubjectCategoryDomainService {
|
||||
/**
|
||||
* 新增分类
|
||||
*/
|
||||
void add(SubjectCategoryBO subjectCategoryBO);
|
||||
|
||||
/**
|
||||
* 查询岗位大类
|
||||
*
|
||||
* @param subjectCategoryBO
|
||||
* @return
|
||||
*/
|
||||
List<SubjectCategoryBO> queryCategory(SubjectCategoryBO subjectCategoryBO);
|
||||
|
||||
/**
|
||||
* @description: 更新分类
|
||||
* @param: [subjectCategoryBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 14:47
|
||||
*/
|
||||
Boolean update(SubjectCategoryBO subjectCategoryBO);
|
||||
|
||||
/**
|
||||
* @description: 删除分类
|
||||
* @param: [subjectCategoryBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 14:58
|
||||
*/
|
||||
Boolean delete(SubjectCategoryBO subjectCategoryBO);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package com.landaiqing.subject.domain.service;
|
||||
|
||||
import com.landaiqing.subject.common.entity.PageResult;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectLabelBO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 题目领域服务
|
||||
*
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 17:22
|
||||
*/
|
||||
public interface SubjectInfoDomainService {
|
||||
/**
|
||||
* 新增题目
|
||||
*/
|
||||
void add(SubjectInfoBO subjectInfoBO);
|
||||
/**
|
||||
* @description: 分页查询
|
||||
* @param: [subjectInfoBO]
|
||||
* @return: com.landaiqing.subject.common.entity.PageResult<com.landaiqing.subject.domain.entity.SubjectInfoBO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/16 12:22
|
||||
*/
|
||||
PageResult<SubjectInfoBO> getSubjectPage(SubjectInfoBO subjectInfoBO);
|
||||
/**
|
||||
* @description: 查询题目信息
|
||||
* @param: [subjectInfoBO]
|
||||
* @return: com.landaiqing.subject.domain.entity.SubjectInfoBO
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/16 13:54
|
||||
*/
|
||||
SubjectInfoBO querySubjectInfo(SubjectInfoBO subjectInfoBO);
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.subject.domain.service;
|
||||
|
||||
import com.landaiqing.subject.domain.entity.SubjectLabelBO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 题目标签领域服务
|
||||
*
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 17:22
|
||||
*/
|
||||
public interface SubjectLabelDomainService {
|
||||
/**
|
||||
* 新增标签
|
||||
*/
|
||||
Boolean add(SubjectLabelBO subjectLabelBO);
|
||||
|
||||
/**
|
||||
* 更新标签
|
||||
*/
|
||||
Boolean update(SubjectLabelBO subjectLabelBO);
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
*/
|
||||
Boolean delete(SubjectLabelBO subjectLabelBO);
|
||||
|
||||
/**
|
||||
* 查询分类下标签
|
||||
*/
|
||||
List<SubjectLabelBO> queryLabelByCategoryId(SubjectLabelBO subjectLabelBO);
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
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.SubjectCategoryConverter;
|
||||
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
|
||||
import com.landaiqing.subject.domain.service.SubjectCategoryDomainService;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectCategoryService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SubjectCategoryDomainServiceImpl implements SubjectCategoryDomainService {
|
||||
@Resource
|
||||
private SubjectCategoryService subjectCategoryService;
|
||||
|
||||
/**
|
||||
* @description: 新增分类
|
||||
* @param: [subjectCategoryBO]
|
||||
* @return: void
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 15:14
|
||||
*/
|
||||
@Override
|
||||
public void add(SubjectCategoryBO subjectCategoryBO) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectCategoryController.add.bo:{}", JSON.toJSONString(subjectCategoryBO));
|
||||
}
|
||||
SubjectCategory subjectCategory = SubjectCategoryConverter.INSTANCE
|
||||
.convertBoToCategory(subjectCategoryBO);
|
||||
subjectCategory.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
subjectCategoryService.insert(subjectCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询岗位大类
|
||||
* @param: [subjectCategoryBO]
|
||||
* @return: java.util.List<com.landaiqing.subject.domain.entity.SubjectCategoryBO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 15:14
|
||||
*/
|
||||
@Override
|
||||
public List<SubjectCategoryBO> queryCategory(SubjectCategoryBO subjectCategoryBO) {
|
||||
SubjectCategory subjectCategory = SubjectCategoryConverter.INSTANCE.convertBoToCategory(subjectCategoryBO);
|
||||
subjectCategory.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
subjectCategory.setCategoryType(CategoryTypeEnum.PRIMARY.getCode());
|
||||
List<SubjectCategory> subjectCategoryList = subjectCategoryService.queryCategory(subjectCategory);
|
||||
List<SubjectCategoryBO> boList = SubjectCategoryConverter.INSTANCE
|
||||
.convertBoToCategory(subjectCategoryList);
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectCategoryController.queryPrimaryCategory.boList:{}", JSON.toJSONString(boList));
|
||||
}
|
||||
return boList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 更新分类
|
||||
* @param: [subjectCategoryBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 14:46
|
||||
*/
|
||||
@Override
|
||||
public Boolean update(SubjectCategoryBO subjectCategoryBO) {
|
||||
SubjectCategory subjectCategory = SubjectCategoryConverter.INSTANCE.convertBoToCategory(subjectCategoryBO);
|
||||
int count = subjectCategoryService.update(subjectCategory);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 删除分类
|
||||
* @param: [subjectCategoryBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 15:04
|
||||
*/
|
||||
@Override
|
||||
public Boolean delete(SubjectCategoryBO subjectCategoryBO) {
|
||||
SubjectCategory subjectCategory = SubjectCategoryConverter.INSTANCE.convertBoToCategory(subjectCategoryBO);
|
||||
subjectCategory.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
int count = subjectCategoryService.update(subjectCategory);
|
||||
return count > 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,123 @@
|
||||
package com.landaiqing.subject.domain.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.landaiqing.subject.common.entity.PageResult;
|
||||
import com.landaiqing.subject.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.subject.domain.convert.SubjectInfoConverter;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectOptionBO;
|
||||
import com.landaiqing.subject.domain.handler.subject.SubjectTypeHandler;
|
||||
import com.landaiqing.subject.domain.handler.subject.SubjectTypeHandlerFactory;
|
||||
import com.landaiqing.subject.domain.service.SubjectInfoDomainService;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectInfo;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectLabel;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectMapping;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectInfoService;
|
||||
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.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SubjectInfoDomainServiceImpl implements SubjectInfoDomainService {
|
||||
@Resource
|
||||
private SubjectInfoService subjectInfoService;
|
||||
@Resource
|
||||
private SubjectMappingService subjectMappingService;
|
||||
@Resource
|
||||
private SubjectTypeHandlerFactory subjectTypeHandlerFactory;
|
||||
|
||||
@Resource
|
||||
private SubjectLabelService subjectLabelService;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 新增标签
|
||||
* @param: [subjectLabelBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 17:27
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(SubjectInfoBO subjectInfoBO) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectInfoDomainServiceImpl.add.bo:{}", JSON.toJSONString(subjectInfoBO));
|
||||
}
|
||||
SubjectInfo subjectInfo = SubjectInfoConverter.INSTANCE.convertBoToInfo(subjectInfoBO);
|
||||
subjectInfo.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
subjectInfoService.insert(subjectInfo);
|
||||
SubjectTypeHandler handler = subjectTypeHandlerFactory.getHandler(subjectInfo.getSubjectType());
|
||||
subjectInfoBO.setId(subjectInfo.getId());
|
||||
handler.add(subjectInfoBO);
|
||||
List<Integer> categoryIds = subjectInfoBO.getCategoryIds();
|
||||
List<Integer> labelIds = subjectInfoBO.getLabelIds();
|
||||
List<SubjectMapping> mappingList = new LinkedList<>();
|
||||
categoryIds.forEach(categoryId -> {
|
||||
labelIds.forEach(labelId -> {
|
||||
SubjectMapping subjectMapping = new SubjectMapping();
|
||||
subjectMapping.setSubjectId(subjectInfo.getId());
|
||||
subjectMapping.setCategoryId(Long.valueOf(categoryId));
|
||||
subjectMapping.setLabelId(Long.valueOf(labelId));
|
||||
subjectMapping.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
mappingList.add(subjectMapping);
|
||||
});
|
||||
});
|
||||
subjectMappingService.batchInsert(mappingList);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 分页查询
|
||||
* @param: [subjectInfoBO]
|
||||
* @return: com.landaiqing.subject.common.entity.PageResult<com.landaiqing.subject.domain.entity.SubjectInfoBO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/16 12:21
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SubjectInfoBO> getSubjectPage(SubjectInfoBO subjectInfoBO) {
|
||||
PageResult<SubjectInfoBO> pageResult = new PageResult<>();
|
||||
pageResult.setPageNo(subjectInfoBO.getPageNo());
|
||||
pageResult.setPageSize(subjectInfoBO.getPageSize());
|
||||
int start = (subjectInfoBO.getPageNo() - 1) * subjectInfoBO.getPageSize();
|
||||
SubjectInfo subjectInfo = SubjectInfoConverter.INSTANCE.convertBoToInfo(subjectInfoBO);
|
||||
|
||||
int count = subjectInfoService.countByCondition(subjectInfo, subjectInfoBO.getLabelId(), subjectInfoBO.getCategoryId());
|
||||
if (count == 0) {
|
||||
return pageResult;
|
||||
}
|
||||
List<SubjectInfo> subjectInfoList = subjectInfoService.queryPage(subjectInfo, subjectInfoBO.getCategoryId(), subjectInfoBO.getLabelId(),
|
||||
start, subjectInfoBO.getPageSize());
|
||||
List<SubjectInfoBO> subjectInfoBOS = SubjectInfoConverter.INSTANCE.convertListInfoBoToBO(subjectInfoList);
|
||||
pageResult.setRecords(subjectInfoBOS);
|
||||
pageResult.setTotal(count);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubjectInfoBO querySubjectInfo(SubjectInfoBO subjectInfoBO) {
|
||||
SubjectInfo subjectInfo = subjectInfoService.queryById(subjectInfoBO.getId());
|
||||
Integer subjectType = subjectInfo.getSubjectType();
|
||||
SubjectTypeHandler handler = subjectTypeHandlerFactory.getHandler(subjectInfo.getSubjectType());
|
||||
SubjectOptionBO optionBO = handler.query(subjectInfo.getId().intValue());
|
||||
SubjectInfoBO bo = SubjectInfoConverter.INSTANCE.convertOptionAndInfoToBO(optionBO, subjectInfo);
|
||||
SubjectMapping subjectMapping = new SubjectMapping();
|
||||
subjectMapping.setSubjectId(subjectInfo.getId());
|
||||
subjectMapping.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
List<SubjectMapping> mappingList = subjectMappingService.queryLabelId(subjectMapping);
|
||||
List<Long> labelIdList = mappingList.stream().map(SubjectMapping::getLabelId).collect(Collectors.toList());
|
||||
List<SubjectLabel> labelList = subjectLabelService.batchQueryById(labelIdList);
|
||||
List<String> labelNameList = labelList.stream().map(SubjectLabel::getLabelName).collect(Collectors.toList());
|
||||
bo.setLabelName(labelNameList);
|
||||
return bo;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,131 @@
|
||||
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;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SubjectLabelDomainServiceImpl implements SubjectLabelDomainService {
|
||||
@Resource
|
||||
private SubjectLabelService subjectLabelService;
|
||||
@Resource
|
||||
private SubjectMappingService subjectMappingService;
|
||||
|
||||
@Resource
|
||||
private SubjectCategoryService subjectCategoryService;
|
||||
|
||||
/**
|
||||
* @description: 新增标签
|
||||
* @param: [subjectLabelBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 17:27
|
||||
*/
|
||||
@Override
|
||||
public Boolean add(SubjectLabelBO subjectLabelBO) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectLabelDomainServiceImpl.add.bo:{}", JSON.toJSONString(subjectLabelBO));
|
||||
}
|
||||
SubjectLabel subjectLabel = SubjectLabelConverter.INSTANCE
|
||||
.convertBoToLabel(subjectLabelBO);
|
||||
subjectLabel.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
int count = subjectLabelService.insert(subjectLabel);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 更新标签
|
||||
* @param: [subjectLabelBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 18:33
|
||||
*/
|
||||
@Override
|
||||
public Boolean update(SubjectLabelBO subjectLabelBO) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectLabelDomainServiceImpl.update.bo:{}", JSON.toJSONString(subjectLabelBO));
|
||||
}
|
||||
SubjectLabel subjectLabel = SubjectLabelConverter.INSTANCE
|
||||
.convertBoToLabel(subjectLabelBO);
|
||||
int count = subjectLabelService.update(subjectLabel);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 删除标签
|
||||
* @param: [subjectLabelBO]
|
||||
* @return: java.lang.Boolean
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 18:58
|
||||
*/
|
||||
@Override
|
||||
public Boolean delete(SubjectLabelBO subjectLabelBO) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectLabelDomainServiceImpl.update.bo:{}", JSON.toJSONString(subjectLabelBO));
|
||||
}
|
||||
SubjectLabel subjectLabel = SubjectLabelConverter.INSTANCE
|
||||
.convertBoToLabel(subjectLabelBO);
|
||||
subjectLabel.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
int count = subjectLabelService.update(subjectLabel);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.setCategoryId(categoryId);
|
||||
subjectMapping.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
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();
|
||||
bo.setId(label.getId());
|
||||
bo.setLabelName(label.getLabelName());
|
||||
bo.setCategoryId(categoryId);
|
||||
bo.setSortNum(label.getSortNum());
|
||||
boList.add(bo);
|
||||
});
|
||||
return boList;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user