feat: 题目模块开发
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.landaiqing.subject.application.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Classname GlobalConfig
|
||||
* @BelongsProject: jc-club
|
||||
* @BelongsPackage: com.landaiqing.subject.application.config
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-16 15:57
|
||||
* @Description: MVC全局处理
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class GlobalConfig extends WebMvcConfigurationSupport {
|
||||
@Override
|
||||
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
super.configureMessageConverters(converters);
|
||||
converters.add(mappingJackson2HttpMessageConverter());
|
||||
}
|
||||
private MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(){
|
||||
ObjectMapper objectMapper=new ObjectMapper();
|
||||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false);
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
MappingJackson2HttpMessageConverter converter=new MappingJackson2HttpMessageConverter(objectMapper);
|
||||
return converter;
|
||||
}
|
||||
}
|
@@ -1,11 +1,22 @@
|
||||
package com.landaiqing.subject.application.controller;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectCategory;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectCategoryService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.landaiqing.subject.application.convert.SubjectAnswerDTOConverter;
|
||||
import com.landaiqing.subject.application.convert.SubjectInfoDTOConverter;
|
||||
import com.landaiqing.subject.application.dto.SubjectInfoDTO;
|
||||
import com.landaiqing.subject.common.entity.PageResult;
|
||||
import com.landaiqing.subject.common.entity.Result;
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import com.landaiqing.subject.domain.service.SubjectInfoDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 刷题controller
|
||||
@@ -14,13 +25,95 @@ import javax.annotation.Resource;
|
||||
* @date: 2024/2/7
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/subject/")
|
||||
@Slf4j
|
||||
public class SubjectController {
|
||||
|
||||
@Resource
|
||||
private SubjectCategoryService subjectCategoryService;
|
||||
@GetMapping("/test")
|
||||
public String test(){
|
||||
SubjectCategory subjectCategory = subjectCategoryService.queryById(1L);
|
||||
return subjectCategory.getCategoryName();
|
||||
private SubjectInfoDomainService subjectInfoDomainService;
|
||||
|
||||
/**
|
||||
* @description: 新增题目
|
||||
* @param: [subjectInfoDTO]
|
||||
* @return: com.landaiqing.subject.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/15 15:06
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result<Boolean> add(@RequestBody SubjectInfoDTO subjectInfoDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectController.add.dto:{}", JSON.toJSONString(subjectInfoDTO));
|
||||
}
|
||||
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(subjectInfoDTO.getSubjectName()), "题目的名称不能为空!");
|
||||
Preconditions.checkNotNull(subjectInfoDTO.getSubjectDifficult(), "题目难度不能为空!");
|
||||
Preconditions.checkNotNull(subjectInfoDTO.getSubjectType(), "题目类型不能为空!");
|
||||
Preconditions.checkNotNull(subjectInfoDTO.getSubjectScore(), "分数不能为空!");
|
||||
Preconditions.checkArgument(!CollectionUtils.isEmpty(subjectInfoDTO.getCategoryIds()), "分类id不能为空!");
|
||||
Preconditions.checkArgument(!CollectionUtils.isEmpty(subjectInfoDTO.getLabelIds()), "标签id不能为空!");
|
||||
SubjectInfoBO subjectInfoBO = SubjectInfoDTOConverter.INSTANCE.convertDtoToBO(subjectInfoDTO);
|
||||
List<SubjectAnswerBO> subjectAnswerBOS = SubjectAnswerDTOConverter.INSTANCE.convertListDtoToBO(subjectInfoDTO.getOptionList());
|
||||
subjectInfoBO.setOptionList(subjectAnswerBOS);
|
||||
subjectInfoDomainService.add(subjectInfoBO);
|
||||
return Result.ok(true);
|
||||
} catch (Exception e) {
|
||||
log.error("SubjectController.add.error:{}", e.getMessage(), e);
|
||||
return Result.fail("新增题目失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询题目列表
|
||||
* @param: [subjectInfoDTO]
|
||||
* @return: com.landaiqing.subject.common.entity.Result<com.landaiqing.subject.common.entity.PageResult < com.landaiqing.subject.application.dto.SubjectInfoDTO>>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/16 12:16
|
||||
*/
|
||||
@PostMapping("/getSubjectPage")
|
||||
public Result<PageResult<SubjectInfoDTO>> getSubjectPage(@RequestBody SubjectInfoDTO subjectInfoDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectController.getSubjectPage.dto:{}", JSON.toJSONString(subjectInfoDTO));
|
||||
}
|
||||
|
||||
Preconditions.checkNotNull(subjectInfoDTO.getCategoryId(), "分类id不能为空!");
|
||||
Preconditions.checkNotNull(subjectInfoDTO.getLabelId(), "标签id不能为空!");
|
||||
|
||||
SubjectInfoBO subjectInfoBO = SubjectInfoDTOConverter.INSTANCE.convertDtoToBO(subjectInfoDTO);
|
||||
PageResult<SubjectInfoBO> boPageResult = subjectInfoDomainService.getSubjectPage(subjectInfoBO);
|
||||
return Result.ok(boPageResult);
|
||||
} catch (Exception e) {
|
||||
log.error("SubjectController.getSubjectPage.error:{}", e.getMessage(), e);
|
||||
return Result.fail("查询题目列表失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询题目详情
|
||||
* @param: [subjectInfoDTO]
|
||||
* @return: com.landaiqing.subject.common.entity.Result<com.landaiqing.subject.application.dto.SubjectInfoDTO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/16 15:44
|
||||
*/
|
||||
@PostMapping("/querySubjectInfo")
|
||||
public Result<SubjectInfoDTO> querySubjectInfo(@RequestBody SubjectInfoDTO subjectInfoDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SubjectController.querySubjectInfo.dto:{}", JSON.toJSONString(subjectInfoDTO));
|
||||
}
|
||||
|
||||
Preconditions.checkNotNull(subjectInfoDTO.getId(), "题目id不能为空!");
|
||||
SubjectInfoBO subjectInfoBO = SubjectInfoDTOConverter.INSTANCE.convertDtoToBO(subjectInfoDTO);
|
||||
SubjectInfoBO boResult = subjectInfoDomainService.querySubjectInfo(subjectInfoBO);
|
||||
SubjectInfoDTO dtoResult = SubjectInfoDTOConverter.INSTANCE.convertBOToDTO(boResult);
|
||||
return Result.ok(dtoResult);
|
||||
} catch (Exception e) {
|
||||
log.error("SubjectController.querySubjectInfo.error:{}", e.getMessage(), e);
|
||||
return Result.fail("查询题目详情失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package com.landaiqing.subject.application.convert;
|
||||
|
||||
import com.landaiqing.subject.application.dto.SubjectAnswerDTO;
|
||||
import com.landaiqing.subject.application.dto.SubjectInfoDTO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectAnswerBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目答案dto转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/13
|
||||
*/
|
||||
@Mapper
|
||||
public interface SubjectAnswerDTOConverter {
|
||||
SubjectAnswerDTOConverter INSTANCE = Mappers.getMapper(SubjectAnswerDTOConverter.class);
|
||||
|
||||
SubjectAnswerBO convertDtoToBO(SubjectAnswerDTO subjectAnswerDTO);
|
||||
List<SubjectAnswerBO> convertListDtoToBO(List<SubjectAnswerDTO> dtoList);
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.landaiqing.subject.application.convert;
|
||||
|
||||
import com.landaiqing.subject.application.dto.SubjectCategoryDTO;
|
||||
import com.landaiqing.subject.application.dto.SubjectInfoDTO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectCategoryBO;
|
||||
import com.landaiqing.subject.domain.entity.SubjectInfoBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目分类dto转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/13
|
||||
*/
|
||||
@Mapper
|
||||
public interface SubjectInfoDTOConverter {
|
||||
SubjectInfoDTOConverter INSTANCE = Mappers.getMapper(SubjectInfoDTOConverter.class);
|
||||
|
||||
SubjectInfoBO convertDtoToBO(SubjectInfoDTO subjectInfoDTO);
|
||||
SubjectInfoDTO convertBOToDTO(SubjectInfoBO subjectInfoBO);
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.subject.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目答案DTO
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-02-14 16:59:04
|
||||
*/
|
||||
@Data
|
||||
public class SubjectAnswerDTO implements Serializable {
|
||||
/**
|
||||
* 答案选项标识
|
||||
*/
|
||||
private Integer optionType;
|
||||
/**
|
||||
* 答案
|
||||
*/
|
||||
private String optionContent;
|
||||
/**
|
||||
* 是否正确
|
||||
*/
|
||||
private Integer isCorrect;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
/**
|
||||
* 题目分类(SubjectCategory)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @author landaiqing
|
||||
* @since 2024-02-07 16:17:17
|
||||
*/
|
||||
@Data
|
||||
|
@@ -0,0 +1,78 @@
|
||||
package com.landaiqing.subject.application.dto;
|
||||
|
||||
import com.landaiqing.subject.common.entity.PageInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目DTO
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-02-14 16:59:04
|
||||
*/
|
||||
@Data
|
||||
public class SubjectInfoDTO 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;
|
||||
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
private List<Integer> labelIds;
|
||||
/**
|
||||
* 答案选项
|
||||
*/
|
||||
private List<SubjectAnswerDTO> optionList;
|
||||
|
||||
private Long categoryId;
|
||||
private Long labelId;
|
||||
|
||||
/**
|
||||
* 标签名称
|
||||
*/
|
||||
private List<String> labelName;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import java.util.Date;
|
||||
/**
|
||||
* 题目标签DTO
|
||||
*
|
||||
* @author makejava
|
||||
* @author landaiqing
|
||||
* @since 2024-02-14 17:08:06
|
||||
*/
|
||||
@Data
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package com.landaiqing.subject.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Classname PageInfo
|
||||
* @BelongsProject: jc-club
|
||||
* @BelongsPackage: com.landaiqing.subject.common.entity
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-16 11:52
|
||||
* @Description: 分页请求实体
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class PageInfo implements Serializable {
|
||||
private Integer pageNo = 1;
|
||||
private Integer pageSize = 20;
|
||||
|
||||
public Integer getPageNo() {
|
||||
if (pageNo == null || pageNo <= 1) {
|
||||
return 1;
|
||||
}
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
if (pageSize == null || pageSize < 1 || pageSize > Integer.MAX_VALUE) {
|
||||
return 20;
|
||||
}
|
||||
return pageSize;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package com.landaiqing.subject.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Classname PageResult
|
||||
* @BelongsProject: jc-club
|
||||
* @BelongsPackage: com.landaiqing.subject.common.entity
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-16 11:56
|
||||
* @Description: 分页返回的实体
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class PageResult<T> implements Serializable {
|
||||
private Integer pageNo = 1;
|
||||
private Integer pageSize = 20;
|
||||
private Integer total = 0;
|
||||
|
||||
private Integer totalPages = 0;
|
||||
|
||||
private List<T> result = Collections.emptyList();
|
||||
|
||||
private Integer start = 1;
|
||||
|
||||
private Integer end = 0;
|
||||
|
||||
public void setRecords(List<T> result) {
|
||||
this.result = result;
|
||||
if (result != null && result.size() > 0) {
|
||||
setTotal(result.size());
|
||||
}
|
||||
}
|
||||
|
||||
public void setTotal(Integer total) {
|
||||
this.total = total;
|
||||
if (pageSize > 0) {
|
||||
this.totalPages = (total / this.pageSize) + (total % this.pageSize == 0 ? 0 : 1);
|
||||
} else {
|
||||
this.totalPages = 0;
|
||||
}
|
||||
this.start = (this.pageSize > 0 ? (this.pageNo - 1) * this.pageSize : 0) + 1;
|
||||
this.end = (this.start - 1 + this.pageSize * (this.pageNo > 0 ? 1 : 0));
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public void setPageNo(Integer pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
}
|
@@ -8,6 +8,18 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>jc-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>jc-club-domain</name>
|
||||
|
@@ -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,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,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,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,28 @@
|
||||
package com.landaiqing.subject.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目dto
|
||||
*
|
||||
* @author: ChickenWing
|
||||
* @date: 2023/10/5
|
||||
*/
|
||||
@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: jc-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: jc-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: jc-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: jc-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: jc-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,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,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,17 @@
|
||||
package com.landaiqing.subject.infra.basic.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MybatisConfiguration {
|
||||
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor(){
|
||||
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
|
||||
mybatisPlusInterceptor.addInnerInterceptor(new MybatisPlusAllSqlLog());
|
||||
return mybatisPlusInterceptor;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
package com.landaiqing.subject.infra.basic.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.mapping.ParameterMapping;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
public class MybatisPlusAllSqlLog implements InnerInterceptor {
|
||||
public static final Logger log = LoggerFactory.getLogger("sys-sql");
|
||||
|
||||
@Override
|
||||
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
|
||||
logInfo(boundSql, ms, parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeUpdate(Executor executor, MappedStatement ms, Object parameter) throws SQLException {
|
||||
BoundSql boundSql = ms.getBoundSql(parameter);
|
||||
logInfo(boundSql, ms, parameter);
|
||||
}
|
||||
|
||||
private static void logInfo(BoundSql boundSql, MappedStatement ms, Object parameter) {
|
||||
try {
|
||||
log.info("parameter = " + parameter);
|
||||
// 获取到节点的id,即sql语句的id
|
||||
String sqlId = ms.getId();
|
||||
log.info("sqlId = " + sqlId);
|
||||
// 获取节点的配置
|
||||
Configuration configuration = ms.getConfiguration();
|
||||
// 获取到最终的sql语句
|
||||
String sql = getSql(configuration, boundSql, sqlId);
|
||||
log.info("完整的sql:{}", sql);
|
||||
} catch (Exception e) {
|
||||
log.error("异常:{}", e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// 封装了一下sql语句,使得结果返回完整xml路径下的sql语句节点id + sql语句
|
||||
public static String getSql(Configuration configuration, BoundSql boundSql, String sqlId) {
|
||||
return sqlId + ":" + showSql(configuration, boundSql);
|
||||
}
|
||||
|
||||
// 进行?的替换
|
||||
public static String showSql(Configuration configuration, BoundSql boundSql) {
|
||||
// 获取参数
|
||||
Object parameterObject = boundSql.getParameterObject();
|
||||
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
|
||||
// sql语句中多个空格都用一个空格代替
|
||||
String sql = boundSql.getSql().replaceAll("[\\s]+", " ");
|
||||
if (!CollectionUtils.isEmpty(parameterMappings) && parameterObject != null) {
|
||||
// 获取类型处理器注册器,类型处理器的功能是进行java类型和数据库类型的转换
|
||||
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
|
||||
// 如果根据parameterObject.getClass()可以找到对应的类型,则替换
|
||||
if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
|
||||
sql = sql.replaceFirst("\\?",
|
||||
Matcher.quoteReplacement(getParameterValue(parameterObject)));
|
||||
} else {
|
||||
// MetaObject主要是封装了originalObject对象,提供了get和set的方法用于获取和设置originalObject的属性值,主要支持对JavaBean、Collection、Map三种类型对象的操作
|
||||
MetaObject metaObject = configuration.newMetaObject(parameterObject);
|
||||
for (ParameterMapping parameterMapping : parameterMappings) {
|
||||
String propertyName = parameterMapping.getProperty();
|
||||
if (metaObject.hasGetter(propertyName)) {
|
||||
Object obj = metaObject.getValue(propertyName);
|
||||
sql = sql.replaceFirst("\\?",
|
||||
Matcher.quoteReplacement(getParameterValue(obj)));
|
||||
} else if (boundSql.hasAdditionalParameter(propertyName)) {
|
||||
// 该分支是动态sql
|
||||
Object obj = boundSql.getAdditionalParameter(propertyName);
|
||||
sql = sql.replaceFirst("\\?",
|
||||
Matcher.quoteReplacement(getParameterValue(obj)));
|
||||
} else {
|
||||
// 打印出缺失,提醒该参数缺失并防止错位
|
||||
sql = sql.replaceFirst("\\?", "缺失");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
// 如果参数是String,则添加单引号, 如果是日期,则转换为时间格式器并加单引号; 对参数是null和不是null的情况作了处理
|
||||
private static String getParameterValue(Object obj) {
|
||||
String value;
|
||||
if (obj instanceof String) {
|
||||
value = "'" + obj.toString() + "'";
|
||||
} else if (obj instanceof Date) {
|
||||
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
|
||||
DateFormat.DEFAULT, Locale.CHINA);
|
||||
value = "'" + formatter.format(new Date()) + "'";
|
||||
} else {
|
||||
if (obj != null) {
|
||||
value = obj.toString();
|
||||
} else {
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package com.landaiqing.subject.infra.basic.config;
|
||||
|
||||
import org.apache.ibatis.cache.CacheKey;
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
@Intercepts({
|
||||
@Signature(type = Executor.class, method = "update", args = {MappedStatement.class,
|
||||
Object.class}),
|
||||
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class,
|
||||
Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class})})
|
||||
public class SqlStatementInterceptor implements Interceptor {
|
||||
|
||||
public static final Logger log = LoggerFactory.getLogger("sys-sql");
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
return invocation.proceed();
|
||||
} finally {
|
||||
long timeConsuming = System.currentTimeMillis() - startTime;
|
||||
log.info("执行SQL:{}ms", timeConsuming);
|
||||
if (timeConsuming > 999 && timeConsuming < 5000) {
|
||||
log.info("执行SQL大于1s:{}ms", timeConsuming);
|
||||
} else if (timeConsuming >= 5000 && timeConsuming < 10000) {
|
||||
log.info("执行SQL大于5s:{}ms", timeConsuming);
|
||||
} else if (timeConsuming >= 10000) {
|
||||
log.info("执行SQL大于10s:{}ms", timeConsuming);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.landaiqing.subject.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 简答题(SubjectBrief)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:29:44
|
||||
*/
|
||||
@Data
|
||||
public class SubjectBrief implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 题目id
|
||||
*/
|
||||
private Integer subjectId;
|
||||
/**
|
||||
* 题目答案
|
||||
*/
|
||||
private String subjectAnswer;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ import java.io.Serializable;
|
||||
*/
|
||||
@Data
|
||||
public class SubjectInfo implements Serializable {
|
||||
private static final long serialVersionUID = 969950536946065645L;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
|
@@ -0,0 +1,49 @@
|
||||
package com.landaiqing.subject.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 判断题(SubjectJudge)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:32:25
|
||||
*/
|
||||
@Data
|
||||
public class SubjectJudge implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 题目id
|
||||
*/
|
||||
private Long subjectId;
|
||||
/**
|
||||
* 是否正确
|
||||
*/
|
||||
private Integer isCorrect;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,57 @@
|
||||
package com.landaiqing.subject.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 多选题信息表(SubjectMultiple)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:32:48
|
||||
*/
|
||||
@Data
|
||||
public class SubjectMultiple implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 题目id
|
||||
*/
|
||||
private Long subjectId;
|
||||
/**
|
||||
* 选项类型
|
||||
*/
|
||||
private Long optionType;
|
||||
/**
|
||||
* 选项内容
|
||||
*/
|
||||
private String optionContent;
|
||||
/**
|
||||
* 是否正确
|
||||
*/
|
||||
private Integer isCorrect;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,56 @@
|
||||
package com.landaiqing.subject.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 单选题信息表(SubjectRadio)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:33:07
|
||||
*/
|
||||
@Data
|
||||
public class SubjectRadio implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 题目id
|
||||
*/
|
||||
private Long subjectId;
|
||||
/**
|
||||
* a,b,c,d
|
||||
*/
|
||||
private Integer optionType;
|
||||
/**
|
||||
* 选项内容
|
||||
*/
|
||||
private String optionContent;
|
||||
/**
|
||||
* 是否正确
|
||||
*/
|
||||
private Integer isCorrect;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,84 @@
|
||||
package com.landaiqing.subject.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectBrief;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 简答题(SubjectBrief)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:29:42
|
||||
*/
|
||||
public interface SubjectBriefDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectBrief queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param subjectBrief 查询条件
|
||||
* @param subjectBrief 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
SubjectBrief queryAllByLimit(SubjectBrief subjectBrief);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param subjectBrief 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(SubjectBrief subjectBrief);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectBrief 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(SubjectBrief subjectBrief);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectBrief> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<SubjectBrief> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectBrief> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<SubjectBrief> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectBrief 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(SubjectBrief subjectBrief);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.landaiqing.subject.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -78,5 +79,14 @@ public interface SubjectInfoDao {
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
int countByCondition(@Param("subjectInfo") SubjectInfo subjectInfo,
|
||||
@Param("labelId") Long labelId,
|
||||
@Param("categoryId") Long categoryId);
|
||||
|
||||
List<SubjectInfo> queryPage(@Param("subjectInfo") SubjectInfo subjectInfo,
|
||||
@Param("categoryId") Long categoryId,
|
||||
@Param("labelId") Long labelId,
|
||||
@Param("start") int start,
|
||||
@Param("pageSize") Integer pageSize);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,84 @@
|
||||
package com.landaiqing.subject.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectJudge;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 判断题(SubjectJudge)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:32:25
|
||||
*/
|
||||
public interface SubjectJudgeDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectJudge queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param subjectJudge 查询条件
|
||||
* @param subjectJudge 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<SubjectJudge> queryAllByLimit(SubjectJudge subjectJudge);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param subjectJudge 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(SubjectJudge subjectJudge);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectJudge 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(SubjectJudge subjectJudge);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectJudge> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<SubjectJudge> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectJudge> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<SubjectJudge> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectJudge 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(SubjectJudge subjectJudge);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,83 @@
|
||||
package com.landaiqing.subject.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectMultiple;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 多选题信息表(SubjectMultiple)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:32:48
|
||||
*/
|
||||
public interface SubjectMultipleDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectMultiple queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param subjectMultiple 查询条件
|
||||
* @param subjectMultiple 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<SubjectMultiple> queryAllByLimit(SubjectMultiple subjectMultiple);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param subjectMultiple 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(SubjectMultiple subjectMultiple);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectMultiple 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(SubjectMultiple subjectMultiple);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectMultiple> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<SubjectMultiple> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectMultiple> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<SubjectMultiple> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectMultiple 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(SubjectMultiple subjectMultiple);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,83 @@
|
||||
package com.landaiqing.subject.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectRadio;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单选题信息表(SubjectRadio)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:33:07
|
||||
*/
|
||||
public interface SubjectRadioDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectRadio queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param subjectRadio 查询条件
|
||||
* @param subjectRadio 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<SubjectRadio> queryAllByLimit(SubjectRadio subjectRadio);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param subjectRadio 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(SubjectRadio subjectRadio);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectRadio 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(SubjectRadio subjectRadio);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectRadio> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<SubjectRadio> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<SubjectRadio> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<SubjectRadio> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectRadio 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(SubjectRadio subjectRadio);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,50 @@
|
||||
package com.landaiqing.subject.infra.basic.service;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectBrief;
|
||||
|
||||
|
||||
/**
|
||||
* 简答题(SubjectBrief)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:29:45
|
||||
*/
|
||||
public interface SubjectBriefService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectBrief queryById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectBrief 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectBrief insert(SubjectBrief subjectBrief);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectBrief 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectBrief update(SubjectBrief subjectBrief);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
/**
|
||||
* 条件查询
|
||||
*/
|
||||
SubjectBrief queryByCondition(SubjectBrief subjectBrief);
|
||||
}
|
@@ -2,6 +2,8 @@ package com.landaiqing.subject.infra.basic.service;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目信息表(SubjectInfo)表服务接口
|
||||
*
|
||||
@@ -43,4 +45,7 @@ public interface SubjectInfoService {
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
int countByCondition(SubjectInfo subjectInfo, Long labelId, Long categoryId);
|
||||
|
||||
List<SubjectInfo> queryPage(SubjectInfo subjectInfo, Long categoryId, Long labelId, int start, Integer pageSize);
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
package com.landaiqing.subject.infra.basic.service;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectJudge;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 判断题(SubjectJudge)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:32:25
|
||||
*/
|
||||
public interface SubjectJudgeService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectJudge queryById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectJudge 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectJudge insert(SubjectJudge subjectJudge);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectJudge 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectJudge update(SubjectJudge subjectJudge);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
List<SubjectJudge> queryByCondition(SubjectJudge subjectJudge);
|
||||
}
|
@@ -22,7 +22,6 @@ public interface SubjectMappingService {
|
||||
SubjectMapping queryById(Long id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
@@ -46,12 +45,22 @@ public interface SubjectMappingService {
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
/**
|
||||
* @description: 查询分类下的标签
|
||||
* @param: [subjectMapping]
|
||||
* @return: java.util.List<com.landaiqing.subject.infra.basic.entity.SubjectMapping>
|
||||
|
||||
/**
|
||||
* @description: 查询分类下的标签
|
||||
* @param: [subjectMapping]
|
||||
* @return: java.util.List<com.landaiqing.subject.infra.basic.entity.SubjectMapping>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/14 19:13
|
||||
*/
|
||||
*/
|
||||
List<SubjectMapping> queryLabelId(SubjectMapping subjectMapping);
|
||||
|
||||
/**
|
||||
* @description: 批量插入
|
||||
* @param: [mappingList]
|
||||
* @return: void
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/15 17:33
|
||||
*/
|
||||
void batchInsert(List<SubjectMapping> mappingList);
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
package com.landaiqing.subject.infra.basic.service;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectMultiple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 多选题信息表(SubjectMultiple)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:32:48
|
||||
*/
|
||||
public interface SubjectMultipleService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectMultiple queryById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectMultiple 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectMultiple insert(SubjectMultiple subjectMultiple);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectMultiple 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectMultiple update(SubjectMultiple subjectMultiple);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
void batchInsert(List<SubjectMultiple> subjectMultipleList);
|
||||
|
||||
List<SubjectMultiple> queryByCondition(SubjectMultiple subjectMultiple);
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package com.landaiqing.subject.infra.basic.service;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectRadio;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单选题信息表(SubjectRadio)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:33:07
|
||||
*/
|
||||
public interface SubjectRadioService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectRadio queryById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectRadio 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectRadio insert(SubjectRadio subjectRadio);
|
||||
/**
|
||||
* 批量插入
|
||||
*
|
||||
* @param subjectRadioList 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
void batchInsert(List<SubjectRadio> subjectRadioList);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectRadio 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
SubjectRadio update(SubjectRadio subjectRadio);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
List<SubjectRadio> queryByCondition(SubjectRadio subjectRadio);
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
package com.landaiqing.subject.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectBrief;
|
||||
import com.landaiqing.subject.infra.basic.mapper.SubjectBriefDao;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectBriefService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 简答题(SubjectBrief)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:29:45
|
||||
*/
|
||||
@Service("subjectBriefService")
|
||||
public class SubjectBriefServiceImpl implements SubjectBriefService {
|
||||
@Resource
|
||||
private SubjectBriefDao subjectBriefDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectBrief queryById(Long id) {
|
||||
return this.subjectBriefDao.queryById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectBrief 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectBrief insert(SubjectBrief subjectBrief) {
|
||||
this.subjectBriefDao.insert(subjectBrief);
|
||||
return subjectBrief;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectBrief 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectBrief update(SubjectBrief subjectBrief) {
|
||||
this.subjectBriefDao.update(subjectBrief);
|
||||
return this.queryById(subjectBrief.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.subjectBriefDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubjectBrief queryByCondition(SubjectBrief subjectBrief) {
|
||||
return this.subjectBriefDao.queryAllByLimit(subjectBrief);
|
||||
}
|
||||
}
|
@@ -6,6 +6,7 @@ import com.landaiqing.subject.infra.basic.service.SubjectInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目信息表(SubjectInfo)表服务实现类
|
||||
@@ -65,4 +66,14 @@ public class SubjectInfoServiceImpl implements SubjectInfoService {
|
||||
public boolean deleteById(Long id) {
|
||||
return this.subjectInfoDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countByCondition(SubjectInfo subjectInfo, Long labelId, Long categoryId) {
|
||||
return this.subjectInfoDao.countByCondition(subjectInfo,labelId,categoryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubjectInfo> queryPage(SubjectInfo subjectInfo, Long categoryId, Long labelId, int start, Integer pageSize) {
|
||||
return this.subjectInfoDao.queryPage(subjectInfo,categoryId,labelId,start,pageSize);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,74 @@
|
||||
package com.landaiqing.subject.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectJudge;
|
||||
import com.landaiqing.subject.infra.basic.mapper.SubjectJudgeDao;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectJudgeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 判断题(SubjectJudge)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:32:25
|
||||
*/
|
||||
@Service("subjectJudgeService")
|
||||
public class SubjectJudgeServiceImpl implements SubjectJudgeService {
|
||||
@Resource
|
||||
private SubjectJudgeDao subjectJudgeDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectJudge queryById(Long id) {
|
||||
return this.subjectJudgeDao.queryById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectJudge 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectJudge insert(SubjectJudge subjectJudge) {
|
||||
this.subjectJudgeDao.insert(subjectJudge);
|
||||
return subjectJudge;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectJudge 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectJudge update(SubjectJudge subjectJudge) {
|
||||
this.subjectJudgeDao.update(subjectJudge);
|
||||
return this.queryById(subjectJudge.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.subjectJudgeDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubjectJudge> queryByCondition(SubjectJudge subjectJudge) {
|
||||
return this.subjectJudgeDao.queryAllByLimit(subjectJudge);
|
||||
}
|
||||
}
|
@@ -65,6 +65,7 @@ public class SubjectMappingServiceImpl implements SubjectMappingService {
|
||||
public boolean deleteById(Long id) {
|
||||
return this.subjectMappingDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询分类下的标签
|
||||
* @param: [subjectMapping]
|
||||
@@ -76,4 +77,9 @@ public class SubjectMappingServiceImpl implements SubjectMappingService {
|
||||
public List<SubjectMapping> queryLabelId(SubjectMapping subjectMapping) {
|
||||
return this.subjectMappingDao.queryDistinctLabelId(subjectMapping);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchInsert(List<SubjectMapping> mappingList) {
|
||||
this.subjectMappingDao.insertBatch(mappingList);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,78 @@
|
||||
package com.landaiqing.subject.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectMultiple;
|
||||
import com.landaiqing.subject.infra.basic.mapper.SubjectMultipleDao;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectMultipleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 多选题信息表(SubjectMultiple)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:32:49
|
||||
*/
|
||||
@Service("subjectMultipleService")
|
||||
public class SubjectMultipleServiceImpl implements SubjectMultipleService {
|
||||
@Resource
|
||||
private SubjectMultipleDao subjectMultipleDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectMultiple queryById(Long id) {
|
||||
return this.subjectMultipleDao.queryById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectMultiple 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectMultiple insert(SubjectMultiple subjectMultiple) {
|
||||
this.subjectMultipleDao.insert(subjectMultiple);
|
||||
return subjectMultiple;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectMultiple 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectMultiple update(SubjectMultiple subjectMultiple) {
|
||||
this.subjectMultipleDao.update(subjectMultiple);
|
||||
return this.queryById(subjectMultiple.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.subjectMultipleDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchInsert(List<SubjectMultiple> subjectMultipleList) {
|
||||
this.subjectMultipleDao.insertBatch(subjectMultipleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubjectMultiple> queryByCondition(SubjectMultiple subjectMultiple) {
|
||||
return this.subjectMultipleDao.queryAllByLimit(subjectMultiple);
|
||||
}
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
package com.landaiqing.subject.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectRadio;
|
||||
import com.landaiqing.subject.infra.basic.mapper.SubjectRadioDao;
|
||||
import com.landaiqing.subject.infra.basic.service.SubjectRadioService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单选题信息表(SubjectRadio)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-02-15 14:33:07
|
||||
*/
|
||||
@Service("subjectRadioService")
|
||||
public class SubjectRadioServiceImpl implements SubjectRadioService {
|
||||
@Resource
|
||||
private SubjectRadioDao subjectRadioDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectRadio queryById(Long id) {
|
||||
return this.subjectRadioDao.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param subjectRadio 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectRadio insert(SubjectRadio subjectRadio) {
|
||||
this.subjectRadioDao.insert(subjectRadio);
|
||||
return subjectRadio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchInsert(List<SubjectRadio> subjectRadioList) {
|
||||
this.subjectRadioDao.insertBatch(subjectRadioList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param subjectRadio 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SubjectRadio update(SubjectRadio subjectRadio) {
|
||||
this.subjectRadioDao.update(subjectRadio);
|
||||
return this.queryById(subjectRadio.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.subjectRadioDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubjectRadio> queryByCondition(SubjectRadio subjectRadio) {
|
||||
return this.subjectRadioDao.queryAllByLimit(subjectRadio);
|
||||
}
|
||||
}
|
@@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.landaiqing.subject.infra.basic.mapper.SubjectBriefDao">
|
||||
|
||||
<resultMap type="com.landaiqing.subject.infra.basic.entity.SubjectBrief" id="SubjectBriefMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="subjectId" column="subject_id" jdbcType="INTEGER"/>
|
||||
<result property="subjectAnswer" column="subject_answer" jdbcType="VARCHAR"/>
|
||||
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="SubjectBriefMap">
|
||||
select id,subject_id,subject_answer,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_brief
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="SubjectBriefMap">
|
||||
select
|
||||
id,subject_id,subject_answer,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_brief
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="subjectId != null">
|
||||
and subject_id = #{subjectId}
|
||||
</if>
|
||||
<if test="subjectAnswer != null and subjectAnswer != ''">
|
||||
and subject_answer = #{subjectAnswer}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from subject_brief
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="subjectId != null">
|
||||
and subject_id = #{subjectId}
|
||||
</if>
|
||||
<if test="subjectAnswer != null and subjectAnswer != ''">
|
||||
and subject_answer = #{subjectAnswer}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_brief(subject_id,subject_answer,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values (#{subjectId},#{subjectAnswer},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_brief(subject_id,subject_answer,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectId},#{entity.subjectAnswer},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_brief(subject_id,subject_answer,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectId},#{entity.subjectAnswer},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
subject_id = values(subject_id)subject_answer = values(subject_answer)created_by =
|
||||
values(created_by)created_time = values(created_time)update_by = values(update_by)update_time =
|
||||
values(update_time)is_deleted = values(is_deleted)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update subject_brief
|
||||
<set>
|
||||
<if test="subjectId != null">
|
||||
subject_id = #{subjectId},
|
||||
</if>
|
||||
<if test="subjectAnswer != null and subjectAnswer != ''">
|
||||
subject_answer = #{subjectAnswer},
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
created_by = #{createdBy},
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
created_time = #{createdTime},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
is_deleted = #{isDeleted},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete
|
||||
from subject_brief
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
@@ -19,8 +19,18 @@
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="SubjectInfoMap">
|
||||
select
|
||||
id,subject_name,subject_difficult,settle_name,subject_type,subject_score,subject_parse,created_by,created_time,update_by,update_time,is_deleted
|
||||
select id,
|
||||
subject_name,
|
||||
subject_difficult,
|
||||
settle_name,
|
||||
subject_type,
|
||||
subject_score,
|
||||
subject_parse,
|
||||
created_by,
|
||||
created_time,
|
||||
update_by,
|
||||
update_time,
|
||||
is_deleted
|
||||
from subject_info
|
||||
where id = #{id}
|
||||
</select>
|
||||
@@ -114,29 +124,83 @@ id,subject_name,subject_difficult,settle_name,subject_type,subject_score,subject
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="countByCondition" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from subject_info a,
|
||||
subject_mapping b
|
||||
where a.id = b.subject_id
|
||||
and b.label_id = #{labelId}
|
||||
and b.category_id = #{categoryId}
|
||||
and a.is_deleted = 0
|
||||
and b.is_deleted = 0
|
||||
<if test="subjectInfo.subjectDifficult != null">
|
||||
and a.subject_difficult = #{subjectInfo.subjectDifficult}
|
||||
</if>
|
||||
<if test="subjectInfo.subjectType != null">
|
||||
and a.subject_type = #{subjectInfo.subjectType}
|
||||
</if>
|
||||
</select>
|
||||
<select id="queryPage" resultMap="SubjectInfoMap">
|
||||
select a.id,
|
||||
a.subject_name,
|
||||
a.subject_difficult,
|
||||
a.settle_name,
|
||||
a.subject_type,
|
||||
a.subject_score,
|
||||
a.subject_parse,
|
||||
a.created_by,
|
||||
a.created_time,
|
||||
a. update_by,
|
||||
a.update_time,
|
||||
a.is_deleted
|
||||
from subject_info a,
|
||||
subject_mapping b
|
||||
where a.id = b.subject_id
|
||||
and b.label_id = #{labelId}
|
||||
and b.category_id = #{categoryId}
|
||||
and a.is_deleted = 0
|
||||
and b.is_deleted = 0
|
||||
<if test="subjectInfo.subjectDifficult != null">
|
||||
and a.subject_difficult = #{subjectInfo.subjectDifficult}
|
||||
</if>
|
||||
<if test="subjectInfo.subjectType != null">
|
||||
and a.subject_type = #{subjectInfo.subjectType}
|
||||
</if>
|
||||
limit #{start},#{pageSize}
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_info(subject_name,subject_difficult,settle_name,subject_type,subject_score,subject_parse,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values (#{subjectName},#{subjectDifficult},#{settleName},#{subjectType},#{subjectScore},#{subjectParse},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
insert into
|
||||
subject_info(subject_name,subject_difficult,settle_name,subject_type,subject_score,subject_parse,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
(#{subjectName},#{subjectDifficult},#{settleName},#{subjectType},#{subjectScore},#{subjectParse},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_info(subject_name,subject_difficult,settle_name,subject_type,subject_score,subject_parse,created_by,created_time,update_by,update_time,is_deleted)
|
||||
insert into
|
||||
subject_info(subject_name,subject_difficult,settle_name,subject_type,subject_score,subject_parse,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectName}#{entity.subjectDifficult}#{entity.settleName}#{entity.subjectType}#{entity.subjectScore}#{entity.subjectParse}#{entity.createdBy}#{entity.createdTime}#{entity.updateBy}#{entity.updateTime}#{entity.isDeleted})
|
||||
(#{entity.subjectName},#{entity.subjectDifficult},#{entity.settleName},#{entity.subjectType},#{entity.subjectScore},#{entity.subjectParse},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_info(subject_name,subject_difficult,settle_name,subject_type,subject_score,subject_parse,created_by,created_time,update_by,update_time,is_deleted)
|
||||
insert into
|
||||
subject_info(subject_name,subject_difficult,settle_name,subject_type,subject_score,subject_parse,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectName},#{entity.subjectDifficult},#{entity.settleName},#{entity.subjectType},#{entity.subjectScore},#{entity.subjectParse},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
subject_name = values(subject_name)subject_difficult = values(subject_difficult)settle_name = values(settle_name)subject_type = values(subject_type)subject_score = values(subject_score)subject_parse = values(subject_parse)created_by = values(created_by)created_time = values(created_time)update_by = values(update_by)update_time = values(update_time)is_deleted = values(is_deleted)
|
||||
subject_name = values(subject_name)subject_difficult = values(subject_difficult)settle_name =
|
||||
values(settle_name)subject_type = values(subject_type)subject_score = values(subject_score)subject_parse =
|
||||
values(subject_parse)created_by = values(created_by)created_time = values(created_time)update_by =
|
||||
values(update_by)update_time = values(update_time)is_deleted = values(is_deleted)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
@@ -182,7 +246,9 @@ subject_name = values(subject_name)subject_difficult = values(subject_difficult)
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from subject_info where id = #{id}
|
||||
delete
|
||||
from subject_info
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
@@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.landaiqing.subject.infra.basic.mapper.SubjectJudgeDao">
|
||||
|
||||
<resultMap type="com.landaiqing.subject.infra.basic.entity.SubjectJudge" id="SubjectJudgeMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="subjectId" column="subject_id" jdbcType="INTEGER"/>
|
||||
<result property="isCorrect" column="is_correct" jdbcType="INTEGER"/>
|
||||
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="SubjectJudgeMap">
|
||||
select id,subject_id,is_correct,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_judge
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="SubjectJudgeMap">
|
||||
select
|
||||
id,subject_id,is_correct,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_judge
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="subjectId != null">
|
||||
and subject_id = #{subjectId}
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
and is_correct = #{isCorrect}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from subject_judge
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="subjectId != null">
|
||||
and subject_id = #{subjectId}
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
and is_correct = #{isCorrect}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_judge(subject_id,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values (#{subjectId},#{isCorrect},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_judge(subject_id,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectId},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_judge(subject_id,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectId},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
subject_id = values(subject_id)is_correct = values(is_correct)created_by = values(created_by)created_time =
|
||||
values(created_time)update_by = values(update_by)update_time = values(update_time)is_deleted =
|
||||
values(is_deleted)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update subject_judge
|
||||
<set>
|
||||
<if test="subjectId != null">
|
||||
subject_id = #{subjectId},
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
is_correct = #{isCorrect},
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
created_by = #{createdBy},
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
created_time = #{createdTime},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
is_deleted = #{isDeleted},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete
|
||||
from subject_judge
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
@@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.landaiqing.subject.infra.basic.mapper.SubjectMultipleDao">
|
||||
|
||||
<resultMap type="com.landaiqing.subject.infra.basic.entity.SubjectMultiple" id="SubjectMultipleMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="subjectId" column="subject_id" jdbcType="INTEGER"/>
|
||||
<result property="optionType" column="option_type" jdbcType="INTEGER"/>
|
||||
<result property="optionContent" column="option_content" jdbcType="VARCHAR"/>
|
||||
<result property="isCorrect" column="is_correct" jdbcType="INTEGER"/>
|
||||
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="SubjectMultipleMap">
|
||||
select id,subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_multiple
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="SubjectMultipleMap">
|
||||
select
|
||||
id,subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_multiple
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="subjectId != null">
|
||||
and subject_id = #{subjectId}
|
||||
</if>
|
||||
<if test="optionType != null">
|
||||
and option_type = #{optionType}
|
||||
</if>
|
||||
<if test="optionContent != null and optionContent != ''">
|
||||
and option_content = #{optionContent}
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
and is_correct = #{isCorrect}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from subject_multiple
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="subjectId != null">
|
||||
and subject_id = #{subjectId}
|
||||
</if>
|
||||
<if test="optionType != null">
|
||||
and option_type = #{optionType}
|
||||
</if>
|
||||
<if test="optionContent != null and optionContent != ''">
|
||||
and option_content = #{optionContent}
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
and is_correct = #{isCorrect}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_multiple(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values (#{subjectId},#{optionType},#{optionContent},#{isCorrect},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into
|
||||
subject_multiple(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectId},#{entity.optionType},#{entity.optionContent},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into
|
||||
subject_multiple(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectId},#{entity.optionType},#{entity.optionContent},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
subject_id = values(subject_id)option_type = values(option_type)option_content =
|
||||
values(option_content)is_correct = values(is_correct)created_by = values(created_by)created_time =
|
||||
values(created_time)update_by = values(update_by)update_time = values(update_time)is_deleted =
|
||||
values(is_deleted)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update subject_multiple
|
||||
<set>
|
||||
<if test="subjectId != null">
|
||||
subject_id = #{subjectId},
|
||||
</if>
|
||||
<if test="optionType != null">
|
||||
option_type = #{optionType},
|
||||
</if>
|
||||
<if test="optionContent != null and optionContent != ''">
|
||||
option_content = #{optionContent},
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
is_correct = #{isCorrect},
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
created_by = #{createdBy},
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
created_time = #{createdTime},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
is_deleted = #{isDeleted},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete
|
||||
from subject_multiple
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
@@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.landaiqing.subject.infra.basic.mapper.SubjectRadioDao">
|
||||
|
||||
<resultMap type="com.landaiqing.subject.infra.basic.entity.SubjectRadio" id="SubjectRadioMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="subjectId" column="subject_id" jdbcType="INTEGER"/>
|
||||
<result property="optionType" column="option_type" jdbcType="INTEGER"/>
|
||||
<result property="optionContent" column="option_content" jdbcType="VARCHAR"/>
|
||||
<result property="isCorrect" column="is_correct" jdbcType="INTEGER"/>
|
||||
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="SubjectRadioMap">
|
||||
select id,subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_radio
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="SubjectRadioMap">
|
||||
select
|
||||
id,subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted
|
||||
from subject_radio
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="subjectId != null">
|
||||
and subject_id = #{subjectId}
|
||||
</if>
|
||||
<if test="optionType != null">
|
||||
and option_type = #{optionType}
|
||||
</if>
|
||||
<if test="optionContent != null and optionContent != ''">
|
||||
and option_content = #{optionContent}
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
and is_correct = #{isCorrect}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from subject_radio
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="subjectId != null">
|
||||
and subject_id = #{subjectId}
|
||||
</if>
|
||||
<if test="optionType != null">
|
||||
and option_type = #{optionType}
|
||||
</if>
|
||||
<if test="optionContent != null and optionContent != ''">
|
||||
and option_content = #{optionContent}
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
and is_correct = #{isCorrect}
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
and created_by = #{createdBy}
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
and created_time = #{createdTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
and is_deleted = #{isDeleted}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into subject_radio(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values (#{subjectId},#{optionType},#{optionContent},#{isCorrect},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into
|
||||
subject_radio(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectId},#{entity.optionType},#{entity.optionContent},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into
|
||||
subject_radio(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.subjectId},#{entity.optionType},#{entity.optionContent},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
subject_id = values(subject_id)option_type = values(option_type)option_content =
|
||||
values(option_content)is_correct = values(is_correct)created_by = values(created_by)created_time =
|
||||
values(created_time)update_by = values(update_by)update_time = values(update_time)is_deleted =
|
||||
values(is_deleted)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update subject_radio
|
||||
<set>
|
||||
<if test="subjectId != null">
|
||||
subject_id = #{subjectId},
|
||||
</if>
|
||||
<if test="optionType != null">
|
||||
option_type = #{optionType},
|
||||
</if>
|
||||
<if test="optionContent != null and optionContent != ''">
|
||||
option_content = #{optionContent},
|
||||
</if>
|
||||
<if test="isCorrect != null">
|
||||
is_correct = #{isCorrect},
|
||||
</if>
|
||||
<if test="createdBy != null and createdBy != ''">
|
||||
created_by = #{createdBy},
|
||||
</if>
|
||||
<if test="createdTime != null">
|
||||
created_time = #{createdTime},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="isDeleted != null">
|
||||
is_deleted = #{isDeleted},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete
|
||||
from subject_radio
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
@@ -40,4 +40,23 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<!--打包成jar包时的名字-->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.3.0.RELEASE</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@@ -31,4 +31,8 @@ publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANTIIARobM6yJvDThAMZo6W185Kr4MMNqJosK
|
||||
logging:
|
||||
config: classpath:log4j2-spring.xml
|
||||
|
||||
#mybatis-plus:
|
||||
# configuration:
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user