diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/config/GlobalConfig.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/config/GlobalConfig.java new file mode 100644 index 0000000..92a1844 --- /dev/null +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/config/GlobalConfig.java @@ -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> 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; + } +} diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/controller/SubjectController.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/controller/SubjectController.java index 99e836f..88d786e 100644 --- a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/controller/SubjectController.java +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/controller/SubjectController.java @@ -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 + * @author landaiqing + * @date: 2024/2/15 15:06 + */ + @PostMapping("/add") + public Result 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 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> + * @author landaiqing + * @date: 2024/2/16 12:16 + */ + @PostMapping("/getSubjectPage") + public Result> 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 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 + * @author landaiqing + * @date: 2024/2/16 15:44 + */ + @PostMapping("/querySubjectInfo") + public Result 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("查询题目详情失败!"); + } } } diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/convert/SubjectAnswerDTOConverter.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/convert/SubjectAnswerDTOConverter.java new file mode 100644 index 0000000..53522d6 --- /dev/null +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/convert/SubjectAnswerDTOConverter.java @@ -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 convertListDtoToBO(List dtoList); + + +} diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/convert/SubjectInfoDTOConverter.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/convert/SubjectInfoDTOConverter.java new file mode 100644 index 0000000..833dc13 --- /dev/null +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/convert/SubjectInfoDTOConverter.java @@ -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); + + +} diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectAnswerDTO.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectAnswerDTO.java new file mode 100644 index 0000000..4e76ca5 --- /dev/null +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectAnswerDTO.java @@ -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; + + + + + +} + diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectCategoryDTO.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectCategoryDTO.java index dac5c94..be79c2c 100644 --- a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectCategoryDTO.java +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectCategoryDTO.java @@ -8,7 +8,7 @@ import java.util.List; /** * 题目分类(SubjectCategory)实体类 * - * @author makejava + * @author landaiqing * @since 2024-02-07 16:17:17 */ @Data diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectInfoDTO.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectInfoDTO.java new file mode 100644 index 0000000..78a7710 --- /dev/null +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectInfoDTO.java @@ -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 categoryIds; + + /** + * 标签id + */ + private List labelIds; + /** + * 答案选项 + */ + private List optionList; + + private Long categoryId; + private Long labelId; + + /** + * 标签名称 + */ + private List labelName; + + +} + diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java index ec57c27..f6abf76 100644 --- a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java @@ -8,7 +8,7 @@ import java.util.Date; /** * 题目标签DTO * - * @author makejava + * @author landaiqing * @since 2024-02-14 17:08:06 */ @Data diff --git a/jc-club-subject/jc-club-common/src/main/java/com/landaiqing/subject/common/entity/PageInfo.java b/jc-club-subject/jc-club-common/src/main/java/com/landaiqing/subject/common/entity/PageInfo.java new file mode 100644 index 0000000..02223e0 --- /dev/null +++ b/jc-club-subject/jc-club-common/src/main/java/com/landaiqing/subject/common/entity/PageInfo.java @@ -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; + + } + + +} diff --git a/jc-club-subject/jc-club-common/src/main/java/com/landaiqing/subject/common/entity/PageResult.java b/jc-club-subject/jc-club-common/src/main/java/com/landaiqing/subject/common/entity/PageResult.java new file mode 100644 index 0000000..82d3ff4 --- /dev/null +++ b/jc-club-subject/jc-club-common/src/main/java/com/landaiqing/subject/common/entity/PageResult.java @@ -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 implements Serializable { + private Integer pageNo = 1; + private Integer pageSize = 20; + private Integer total = 0; + + private Integer totalPages = 0; + + private List result = Collections.emptyList(); + + private Integer start = 1; + + private Integer end = 0; + + public void setRecords(List 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; + } +} diff --git a/jc-club-subject/jc-club-domain/pom.xml b/jc-club-subject/jc-club-domain/pom.xml index c9b1b12..477ef05 100644 --- a/jc-club-subject/jc-club-domain/pom.xml +++ b/jc-club-subject/jc-club-domain/pom.xml @@ -8,6 +8,18 @@ jc-club-domain + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + jar jc-club-domain diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/BriefSubjectConverter.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/BriefSubjectConverter.java new file mode 100644 index 0000000..1429b0c --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/BriefSubjectConverter.java @@ -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); + +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/JudgeSubjectConverter.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/JudgeSubjectConverter.java new file mode 100644 index 0000000..d70e486 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/JudgeSubjectConverter.java @@ -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 convertEntityToBoList(List subjectJudgeList); + +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/MultipleSubjectConverter.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/MultipleSubjectConverter.java new file mode 100644 index 0000000..d3aed2e --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/MultipleSubjectConverter.java @@ -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 convertEntityToBoList(List subjectMultipleList); + + +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/RadioSubjectConverter.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/RadioSubjectConverter.java new file mode 100644 index 0000000..87c0964 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/RadioSubjectConverter.java @@ -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 convertEntityToBoList(List subjectRadioList); + +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/SubjectInfoConverter.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/SubjectInfoConverter.java new file mode 100644 index 0000000..947fa08 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/SubjectInfoConverter.java @@ -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 convertListInfoBoToBO(List subjectInfoList); + + +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectAnswerBO.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectAnswerBO.java new file mode 100644 index 0000000..81104cd --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectAnswerBO.java @@ -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; + + + + + +} + diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectInfoBO.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectInfoBO.java new file mode 100644 index 0000000..b8c7f30 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectInfoBO.java @@ -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 categoryIds; + + /** + * 标签名称 + */ + private List labelName; + + /** + * 标签id + */ + private List labelIds; + /** + * 答案选项 + */ + private List optionList; + + + private Long categoryId; + private Long labelId; + + + + +} + diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectOptionBO.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectOptionBO.java new file mode 100644 index 0000000..7745ed1 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectOptionBO.java @@ -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 optionList; + +} + diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/BriefTypeHandler.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/BriefTypeHandler.java new file mode 100644 index 0000000..cbe6aa9 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/BriefTypeHandler.java @@ -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; + } +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/JudgeTypeHandler.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/JudgeTypeHandler.java new file mode 100644 index 0000000..6926b0a --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/JudgeTypeHandler.java @@ -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 result = subjectJudgeService.queryByCondition(subjectJudge); + List subjectAnswerBOList = JudgeSubjectConverter.INSTANCE.convertEntityToBoList(result); + SubjectOptionBO subjectOptionBO = new SubjectOptionBO(); + subjectOptionBO.setOptionList(subjectAnswerBOList); + return subjectOptionBO; + } +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/MultipleTypeHandler.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/MultipleTypeHandler.java new file mode 100644 index 0000000..568e9ff --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/MultipleTypeHandler.java @@ -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 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 result = subjectMultipleService.queryByCondition(subjectMultiple); + List subjectAnswerBOList = MultipleSubjectConverter.INSTANCE.convertEntityToBoList(result); + SubjectOptionBO subjectOptionBO = new SubjectOptionBO(); + subjectOptionBO.setOptionList(subjectAnswerBOList); + return subjectOptionBO; + } +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/RadioTypeHandler.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/RadioTypeHandler.java new file mode 100644 index 0000000..0eb2850 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/RadioTypeHandler.java @@ -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 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 result = subjectRadioService.queryByCondition(subjectRadio); + List subjectAnswerBOList = RadioSubjectConverter.INSTANCE.convertEntityToBoList(result); + SubjectOptionBO subjectOptionBO = new SubjectOptionBO(); + subjectOptionBO.setOptionList(subjectAnswerBOList); + return subjectOptionBO; + } +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/SubjectTypeHandler.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/SubjectTypeHandler.java new file mode 100644 index 0000000..774ac98 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/SubjectTypeHandler.java @@ -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); +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/SubjectTypeHandlerFactory.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/SubjectTypeHandlerFactory.java new file mode 100644 index 0000000..969ba42 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/handler/subject/SubjectTypeHandlerFactory.java @@ -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 subjectTypeHandlerList; + + private Map 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); + } + } +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/SubjectInfoDomainService.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/SubjectInfoDomainService.java new file mode 100644 index 0000000..77bd0f7 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/SubjectInfoDomainService.java @@ -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 + * @author landaiqing + * @date: 2024/2/16 12:22 + */ + PageResult 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); +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectInfoDomainServiceImpl.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectInfoDomainServiceImpl.java new file mode 100644 index 0000000..17eae54 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectInfoDomainServiceImpl.java @@ -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 categoryIds = subjectInfoBO.getCategoryIds(); + List labelIds = subjectInfoBO.getLabelIds(); + List 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 + * @author landaiqing + * @date: 2024/2/16 12:21 + */ + @Override + public PageResult getSubjectPage(SubjectInfoBO subjectInfoBO) { + PageResult 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 subjectInfoList = subjectInfoService.queryPage(subjectInfo, subjectInfoBO.getCategoryId(), subjectInfoBO.getLabelId(), + start, subjectInfoBO.getPageSize()); + List 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 mappingList = subjectMappingService.queryLabelId(subjectMapping); + List labelIdList = mappingList.stream().map(SubjectMapping::getLabelId).collect(Collectors.toList()); + List labelList = subjectLabelService.batchQueryById(labelIdList); + List labelNameList = labelList.stream().map(SubjectLabel::getLabelName).collect(Collectors.toList()); + bo.setLabelName(labelNameList); + return bo; + } + + +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/MybatisConfiguration.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/MybatisConfiguration.java new file mode 100644 index 0000000..506686a --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/MybatisConfiguration.java @@ -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; + } + +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/MybatisPlusAllSqlLog.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/MybatisPlusAllSqlLog.java new file mode 100644 index 0000000..f92cea0 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/MybatisPlusAllSqlLog.java @@ -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 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; + } + +} \ No newline at end of file diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/SqlStatementInterceptor.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/SqlStatementInterceptor.java new file mode 100644 index 0000000..f87b7e5 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/config/SqlStatementInterceptor.java @@ -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) { + + } +} \ No newline at end of file diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectBrief.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectBrief.java new file mode 100644 index 0000000..86e3c82 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectBrief.java @@ -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; + + +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectInfo.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectInfo.java index 43bad78..fb6be15 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectInfo.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectInfo.java @@ -13,7 +13,6 @@ import java.io.Serializable; */ @Data public class SubjectInfo implements Serializable { - private static final long serialVersionUID = 969950536946065645L; /** * 主键 */ diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectJudge.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectJudge.java new file mode 100644 index 0000000..fa6cb20 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectJudge.java @@ -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; + + +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectMultiple.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectMultiple.java new file mode 100644 index 0000000..de037c3 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectMultiple.java @@ -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; + + +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectRadio.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectRadio.java new file mode 100644 index 0000000..a76543b --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectRadio.java @@ -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; + +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectBriefDao.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectBriefDao.java new file mode 100644 index 0000000..0143f9c --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectBriefDao.java @@ -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 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param subjectBrief 实例对象 + * @return 影响行数 + */ + int update(SubjectBrief subjectBrief); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Long id); + +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectInfoDao.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectInfoDao.java index f86f4e2..12b5d21 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectInfoDao.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectInfoDao.java @@ -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 queryPage(@Param("subjectInfo") SubjectInfo subjectInfo, + @Param("categoryId") Long categoryId, + @Param("labelId") Long labelId, + @Param("start") int start, + @Param("pageSize") Integer pageSize); } diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectJudgeDao.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectJudgeDao.java new file mode 100644 index 0000000..bc99e3d --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectJudgeDao.java @@ -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 queryAllByLimit(SubjectJudge subjectJudge); + + /** + * 统计总行数 + * + * @param subjectJudge 查询条件 + * @return 总行数 + */ + long count(SubjectJudge subjectJudge); + + /** + * 新增数据 + * + * @param subjectJudge 实例对象 + * @return 影响行数 + */ + int insert(SubjectJudge subjectJudge); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param subjectJudge 实例对象 + * @return 影响行数 + */ + int update(SubjectJudge subjectJudge); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Long id); + +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectMultipleDao.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectMultipleDao.java new file mode 100644 index 0000000..3eda507 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectMultipleDao.java @@ -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 queryAllByLimit(SubjectMultiple subjectMultiple); + + /** + * 统计总行数 + * + * @param subjectMultiple 查询条件 + * @return 总行数 + */ + long count(SubjectMultiple subjectMultiple); + + /** + * 新增数据 + * + * @param subjectMultiple 实例对象 + * @return 影响行数 + */ + int insert(SubjectMultiple subjectMultiple); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param subjectMultiple 实例对象 + * @return 影响行数 + */ + int update(SubjectMultiple subjectMultiple); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Long id); + +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectRadioDao.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectRadioDao.java new file mode 100644 index 0000000..40225bd --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectRadioDao.java @@ -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 queryAllByLimit(SubjectRadio subjectRadio); + + /** + * 统计总行数 + * + * @param subjectRadio 查询条件 + * @return 总行数 + */ + long count(SubjectRadio subjectRadio); + + /** + * 新增数据 + * + * @param subjectRadio 实例对象 + * @return 影响行数 + */ + int insert(SubjectRadio subjectRadio); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param subjectRadio 实例对象 + * @return 影响行数 + */ + int update(SubjectRadio subjectRadio); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Long id); + +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectBriefService.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectBriefService.java new file mode 100644 index 0000000..b367c0e --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectBriefService.java @@ -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); +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectInfoService.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectInfoService.java index 5e87907..42a1097 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectInfoService.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectInfoService.java @@ -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 queryPage(SubjectInfo subjectInfo, Long categoryId, Long labelId, int start, Integer pageSize); } diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectJudgeService.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectJudgeService.java new file mode 100644 index 0000000..21e119d --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectJudgeService.java @@ -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 queryByCondition(SubjectJudge subjectJudge); +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectMappingService.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectMappingService.java index 5eedf3a..d11dfba 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectMappingService.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectMappingService.java @@ -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 + + /** + * @description: 查询分类下的标签 + * @param: [subjectMapping] + * @return: java.util.List * @author landaiqing * @date: 2024/2/14 19:13 - */ + */ List queryLabelId(SubjectMapping subjectMapping); + + /** + * @description: 批量插入 + * @param: [mappingList] + * @return: void + * @author landaiqing + * @date: 2024/2/15 17:33 + */ + void batchInsert(List mappingList); } diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectMultipleService.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectMultipleService.java new file mode 100644 index 0000000..9bf322e --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectMultipleService.java @@ -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 subjectMultipleList); + + List queryByCondition(SubjectMultiple subjectMultiple); +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectRadioService.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectRadioService.java new file mode 100644 index 0000000..37cabb5 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectRadioService.java @@ -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 subjectRadioList); + + /** + * 修改数据 + * + * @param subjectRadio 实例对象 + * @return 实例对象 + */ + SubjectRadio update(SubjectRadio subjectRadio); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Long id); + + List queryByCondition(SubjectRadio subjectRadio); +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectBriefServiceImpl.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectBriefServiceImpl.java new file mode 100644 index 0000000..b3cde7f --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectBriefServiceImpl.java @@ -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); + } +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectInfoServiceImpl.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectInfoServiceImpl.java index a3b57a8..78cd55a 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectInfoServiceImpl.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectInfoServiceImpl.java @@ -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 queryPage(SubjectInfo subjectInfo, Long categoryId, Long labelId, int start, Integer pageSize) { + return this.subjectInfoDao.queryPage(subjectInfo,categoryId,labelId,start,pageSize); + } } diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectJudgeServiceImpl.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectJudgeServiceImpl.java new file mode 100644 index 0000000..068fe9c --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectJudgeServiceImpl.java @@ -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 queryByCondition(SubjectJudge subjectJudge) { + return this.subjectJudgeDao.queryAllByLimit(subjectJudge); + } +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectMappingServiceImpl.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectMappingServiceImpl.java index 7c8eca3..5b2bde5 100644 --- a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectMappingServiceImpl.java +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectMappingServiceImpl.java @@ -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 queryLabelId(SubjectMapping subjectMapping) { return this.subjectMappingDao.queryDistinctLabelId(subjectMapping); } + + @Override + public void batchInsert(List mappingList) { + this.subjectMappingDao.insertBatch(mappingList); + } } diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectMultipleServiceImpl.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectMultipleServiceImpl.java new file mode 100644 index 0000000..0c0318f --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectMultipleServiceImpl.java @@ -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 subjectMultipleList) { + this.subjectMultipleDao.insertBatch(subjectMultipleList); + } + + @Override + public List queryByCondition(SubjectMultiple subjectMultiple) { + return this.subjectMultipleDao.queryAllByLimit(subjectMultiple); + } +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectRadioServiceImpl.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectRadioServiceImpl.java new file mode 100644 index 0000000..9581ca3 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectRadioServiceImpl.java @@ -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 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 queryByCondition(SubjectRadio subjectRadio) { + return this.subjectRadioDao.queryAllByLimit(subjectRadio); + } +} diff --git a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectBriefDao.xml b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectBriefDao.xml new file mode 100644 index 0000000..2e7995d --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectBriefDao.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 into subject_brief(subject_id,subject_answer,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.subjectAnswer},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + + + + insert into subject_brief(subject_id,subject_answer,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.subjectAnswer},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + 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) + + + + + update subject_brief + + + subject_id = #{subjectId}, + + + subject_answer = #{subjectAnswer}, + + + created_by = #{createdBy}, + + + created_time = #{createdTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + is_deleted = #{isDeleted}, + + + where id = #{id} + + + + + delete + from subject_brief + where id = #{id} + + + + diff --git a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectInfoDao.xml b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectInfoDao.xml index a10a980..650eca5 100644 --- a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectInfoDao.xml +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectInfoDao.xml @@ -19,8 +19,18 @@ @@ -114,29 +124,83 @@ id,subject_name,subject_difficult,settle_name,subject_type,subject_score,subject + + - 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}) + + SELECT LAST_INSERT_ID() + + 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 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 - (#{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}) - 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 (#{entity.subjectName},#{entity.subjectDifficult},#{entity.settleName},#{entity.subjectType},#{entity.subjectScore},#{entity.subjectParse},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) 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) @@ -182,7 +246,9 @@ subject_name = values(subject_name)subject_difficult = values(subject_difficult) - delete from subject_info where id = #{id} + delete + from subject_info + where id = #{id} diff --git a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectJudgeDao.xml b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectJudgeDao.xml new file mode 100644 index 0000000..cbc84a2 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectJudgeDao.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 into subject_judge(subject_id,is_correct,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + + + + insert into subject_judge(subject_id,is_correct,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + 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) + + + + + update subject_judge + + + subject_id = #{subjectId}, + + + is_correct = #{isCorrect}, + + + created_by = #{createdBy}, + + + created_time = #{createdTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + is_deleted = #{isDeleted}, + + + where id = #{id} + + + + + delete + from subject_judge + where id = #{id} + + + + diff --git a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectMultipleDao.xml b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectMultipleDao.xml new file mode 100644 index 0000000..c5476f1 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectMultipleDao.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 into + subject_multiple(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.optionType},#{entity.optionContent},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + + + + insert into + subject_multiple(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.optionType},#{entity.optionContent},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + 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) + + + + + update subject_multiple + + + subject_id = #{subjectId}, + + + option_type = #{optionType}, + + + option_content = #{optionContent}, + + + is_correct = #{isCorrect}, + + + created_by = #{createdBy}, + + + created_time = #{createdTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + is_deleted = #{isDeleted}, + + + where id = #{id} + + + + + delete + from subject_multiple + where id = #{id} + + + + diff --git a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectRadioDao.xml b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectRadioDao.xml new file mode 100644 index 0000000..d070cb9 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectRadioDao.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 into + subject_radio(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.optionType},#{entity.optionContent},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + + + + insert into + subject_radio(subject_id,option_type,option_content,is_correct,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.optionType},#{entity.optionContent},#{entity.isCorrect},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + 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) + + + + + update subject_radio + + + subject_id = #{subjectId}, + + + option_type = #{optionType}, + + + option_content = #{optionContent}, + + + is_correct = #{isCorrect}, + + + created_by = #{createdBy}, + + + created_time = #{createdTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + is_deleted = #{isDeleted}, + + + where id = #{id} + + + + + delete + from subject_radio + where id = #{id} + + + + diff --git a/jc-club-subject/jc-club-starter/pom.xml b/jc-club-subject/jc-club-starter/pom.xml index 67cefce..cf39634 100644 --- a/jc-club-subject/jc-club-starter/pom.xml +++ b/jc-club-subject/jc-club-starter/pom.xml @@ -40,4 +40,23 @@ 1.0-SNAPSHOT + + + ${project.artifactId} + + + + org.springframework.boot + spring-boot-maven-plugin + 2.3.0.RELEASE + + + + repackage + + + + + + diff --git a/jc-club-subject/jc-club-starter/src/main/resources/application.yml b/jc-club-subject/jc-club-starter/src/main/resources/application.yml index 98de145..8b356df 100644 --- a/jc-club-subject/jc-club-starter/src/main/resources/application.yml +++ b/jc-club-subject/jc-club-starter/src/main/resources/application.yml @@ -31,4 +31,8 @@ publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANTIIARobM6yJvDThAMZo6W185Kr4MMNqJosK logging: config: classpath:log4j2-spring.xml +#mybatis-plus: +# configuration: +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl +