diff --git a/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/controller/SubjectLabelController.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/controller/SubjectLabelController.java new file mode 100644 index 0000000..bd0a592 --- /dev/null +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/controller/SubjectLabelController.java @@ -0,0 +1,130 @@ +package com.landaiqing.subject.application.controller; + +import com.alibaba.fastjson.JSON; +import com.google.common.base.Preconditions; +import com.landaiqing.subject.application.convert.SubjectLabelDTOConverter; +import com.landaiqing.subject.application.dto.SubjectLabelDTO; +import com.landaiqing.subject.common.entity.Result; +import com.landaiqing.subject.domain.entity.SubjectLabelBO; +import com.landaiqing.subject.domain.service.SubjectLabelDomainService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Classname SubjectLabelController + * @BelongsProject: jc-club + * @BelongsPackage: com.landaiqing.subject.application.controller + * @Author: landaiqing + * @CreateTime: 2024-02-14 17:03 + * @Description: 标签controller + * @Version: 1.0 + */ +@RestController +@RequestMapping("/subject/label") +@Slf4j +public class SubjectLabelController { + @Resource + private SubjectLabelDomainService subjectLabelDomainService; + + /** + * @description: 新增标签 + * @param: [subjectLabelDTO] + * @return: com.landaiqing.subject.common.entity.Result + * @author landaiqing + * @date: 2024/2/14 17:46 + */ + @PostMapping("/add") + public Result add(@RequestBody SubjectLabelDTO subjectLabelDTO) { + + try { + if (log.isInfoEnabled()) { + log.info("SubjectLabelController.add.dto:{}", JSON.toJSONString(subjectLabelDTO)); + } + Preconditions.checkArgument(!StringUtils.isBlank(subjectLabelDTO.getLabelName()), "标签的名称不能为空!"); + SubjectLabelBO subjectLabelBO = SubjectLabelDTOConverter.INSTANCE.convertDtoToLabelBO(subjectLabelDTO); + Boolean result = subjectLabelDomainService.add(subjectLabelBO); + return Result.ok(result); + } catch (Exception e) { + log.error("SubjectLabelController.add.error:{}", e.getMessage(), e); + return Result.fail("新增标签失败!"); + } + } + + /** + * @description: 更新标签 + * @param: [subjectLabelDTO] + * @return: com.landaiqing.subject.common.entity.Result + * @author landaiqing + * @date: 2024/2/14 17:53 + */ + @PostMapping("/update") + public Result update(@RequestBody SubjectLabelDTO subjectLabelDTO) { + try { + if (log.isInfoEnabled()) { + log.info("SubjectLabelController.update.dto:{}", JSON.toJSONString(subjectLabelDTO)); + } + Preconditions.checkNotNull(subjectLabelDTO.getId(), "标签id不能为空"); + SubjectLabelBO subjectLabelBO = SubjectLabelDTOConverter.INSTANCE.convertDtoToLabelBO(subjectLabelDTO); + Boolean result = subjectLabelDomainService.update(subjectLabelBO); + return Result.ok(result); + } catch (Exception e) { + log.error("SubjectLabelController.update.error:{}", e.getMessage(), e); + return Result.fail("更新标签失败"); + } + } + + /** + * @description: 删除标签 + * @param: [subjectLabelDTO] + * @return: com.landaiqing.subject.common.entity.Result + * @author landaiqing + * @date: 2024/2/14 17:53 + */ + @PostMapping("/delete") + public Result delete(@RequestBody SubjectLabelDTO subjectLabelDTO) { + try { + if (log.isInfoEnabled()) { + log.info("SubjectLabelController.delete.dto:{}", JSON.toJSONString(subjectLabelDTO)); + } + Preconditions.checkNotNull(subjectLabelDTO.getId(), "标签id不能为空"); + SubjectLabelBO subjectLabelBO = SubjectLabelDTOConverter.INSTANCE.convertDtoToLabelBO(subjectLabelDTO); + Boolean result = subjectLabelDomainService.delete(subjectLabelBO); + return Result.ok(result); + } catch (Exception e) { + log.error("SubjectLabelController.delete.error:{}", e.getMessage(), e); + return Result.fail("删除标签失败"); + } + } + /** + * @description: 查询分类下的标签 + * @param: [subjectLabelDTO] + * @return: com.landaiqing.subject.common.entity.Result> + * @author landaiqing + * @date: 2024/2/14 18:57 + */ + @PostMapping("/queryLabelByCategoryId") + public Result> queryLabelByCategoryId(@RequestBody SubjectLabelDTO subjectLabelDTO) { + try { + if (log.isInfoEnabled()) { + log.info("SubjectLabelController.queryLabelByCategoryId.dto:{}", + JSON.toJSONString(subjectLabelDTO)); + } + Preconditions.checkNotNull(subjectLabelDTO.getCategoryId(), "分类id不能为空"); + SubjectLabelBO subjectLabelBO = SubjectLabelDTOConverter.INSTANCE.convertDtoToLabelBO(subjectLabelDTO); + List resultList = subjectLabelDomainService.queryLabelByCategoryId(subjectLabelBO); + List subjectLabelDTOS = SubjectLabelDTOConverter.INSTANCE.convertBOToLabelDTOList(resultList); + return Result.ok(subjectLabelDTOS); + } catch (Exception e) { + log.error("SubjectLabelController.queryLabelByCategoryId.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/SubjectLabelDTOConverter.java b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/convert/SubjectLabelDTOConverter.java new file mode 100644 index 0000000..39d45c3 --- /dev/null +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/convert/SubjectLabelDTOConverter.java @@ -0,0 +1,26 @@ +package com.landaiqing.subject.application.convert; + +import com.landaiqing.subject.application.dto.SubjectLabelDTO; +import com.landaiqing.subject.domain.entity.SubjectLabelBO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 标签dto转换器 + * + * @author: landaiqing + * @date: 2024/2/14 + */ +@Mapper +public interface SubjectLabelDTOConverter { + SubjectLabelDTOConverter INSTANCE = Mappers.getMapper(SubjectLabelDTOConverter.class); + + SubjectLabelBO convertDtoToLabelBO(SubjectLabelDTO subjectLabelDTO); + + List convertBOToLabelDTOList(List boList); + + + +} 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 new file mode 100644 index 0000000..ec57c27 --- /dev/null +++ b/jc-club-subject/jc-club-application/jc-club-application-controller/src/main/java/com/landaiqing/subject/application/dto/SubjectLabelDTO.java @@ -0,0 +1,36 @@ +package com.landaiqing.subject.application.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 题目标签DTO + * + * @author makejava + * @since 2024-02-14 17:08:06 + */ +@Data +public class SubjectLabelDTO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 分类id + */ + private Long categoryId; + /** + * 标签分类 + */ + private String labelName; + /** + * 排序 + */ + private Integer sortNum; + + + +} + diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/SubjectLabelConverter.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/SubjectLabelConverter.java new file mode 100644 index 0000000..70a9983 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/convert/SubjectLabelConverter.java @@ -0,0 +1,19 @@ +package com.landaiqing.subject.domain.convert; + +import com.landaiqing.subject.domain.entity.SubjectCategoryBO; +import com.landaiqing.subject.domain.entity.SubjectLabelBO; +import com.landaiqing.subject.infra.basic.entity.SubjectCategory; +import com.landaiqing.subject.infra.basic.entity.SubjectLabel; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface SubjectLabelConverter { + SubjectLabelConverter INSTANCE = Mappers.getMapper(SubjectLabelConverter.class); + + SubjectLabel convertBoToLabel(SubjectLabelBO subjectLabelBO); + List convertLabelToBoList(List subjectLabelList); + +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectLabelBO.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectLabelBO.java new file mode 100644 index 0000000..dd29e21 --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/entity/SubjectLabelBO.java @@ -0,0 +1,35 @@ +package com.landaiqing.subject.domain.entity; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 题目标签Bo + * + * @author makejava + * @since 2024-02-14 17:08:06 + */ +@Data +public class SubjectLabelBO implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 分类id + */ + private Long categoryId; + /** + * 标签分类 + */ + private String labelName; + /** + * 排序 + */ + private Integer sortNum; + + + +} + diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/SubjectLabelDomainService.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/SubjectLabelDomainService.java new file mode 100644 index 0000000..9eece3e --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/SubjectLabelDomainService.java @@ -0,0 +1,34 @@ +package com.landaiqing.subject.domain.service; + +import com.landaiqing.subject.domain.entity.SubjectLabelBO; + +import java.util.List; + + +/** + * @description: 题目标签领域服务 + * + * @author landaiqing + * @date: 2024/2/14 17:22 + */ +public interface SubjectLabelDomainService { + /** + * 新增标签 + */ + Boolean add(SubjectLabelBO subjectLabelBO); + + /** + * 更新标签 + */ + Boolean update(SubjectLabelBO subjectLabelBO); + + /** + * 删除标签 + */ + Boolean delete(SubjectLabelBO subjectLabelBO); + + /** + * 查询分类下标签 + */ + List queryLabelByCategoryId(SubjectLabelBO subjectLabelBO); +} diff --git a/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectLabelDomainServiceImpl.java b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectLabelDomainServiceImpl.java new file mode 100644 index 0000000..ddbdb7d --- /dev/null +++ b/jc-club-subject/jc-club-domain/src/main/java/com/landaiqing/subject/domain/service/impl/SubjectLabelDomainServiceImpl.java @@ -0,0 +1,114 @@ +package com.landaiqing.subject.domain.service.impl; + +import com.alibaba.fastjson.JSON; +import com.landaiqing.subject.common.enums.IsDeletedFlagEnum; +import com.landaiqing.subject.domain.convert.SubjectLabelConverter; +import com.landaiqing.subject.domain.entity.SubjectLabelBO; +import com.landaiqing.subject.domain.service.SubjectLabelDomainService; +import com.landaiqing.subject.infra.basic.entity.SubjectLabel; +import com.landaiqing.subject.infra.basic.entity.SubjectMapping; +import com.landaiqing.subject.infra.basic.service.SubjectLabelService; +import com.landaiqing.subject.infra.basic.service.SubjectMappingService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class SubjectLabelDomainServiceImpl implements SubjectLabelDomainService { + @Resource + private SubjectLabelService subjectLabelService; + @Resource + private SubjectMappingService subjectMappingService; + + /** + * @description: 新增标签 + * @param: [subjectLabelBO] + * @return: java.lang.Boolean + * @author landaiqing + * @date: 2024/2/14 17:27 + */ + @Override + public Boolean add(SubjectLabelBO subjectLabelBO) { + if (log.isInfoEnabled()) { + log.info("SubjectLabelDomainServiceImpl.add.bo:{}", JSON.toJSONString(subjectLabelBO)); + } + SubjectLabel subjectLabel = SubjectLabelConverter.INSTANCE + .convertBoToLabel(subjectLabelBO); + subjectLabel.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode()); + int count = subjectLabelService.insert(subjectLabel); + return count > 0; + } + + /** + * @description: 更新标签 + * @param: [subjectLabelBO] + * @return: java.lang.Boolean + * @author landaiqing + * @date: 2024/2/14 18:33 + */ + @Override + public Boolean update(SubjectLabelBO subjectLabelBO) { + if (log.isInfoEnabled()) { + log.info("SubjectLabelDomainServiceImpl.update.bo:{}", JSON.toJSONString(subjectLabelBO)); + } + SubjectLabel subjectLabel = SubjectLabelConverter.INSTANCE + .convertBoToLabel(subjectLabelBO); + int count = subjectLabelService.update(subjectLabel); + return count > 0; + } + /** + * @description: 删除标签 + * @param: [subjectLabelBO] + * @return: java.lang.Boolean + * @author landaiqing + * @date: 2024/2/14 18:58 + */ + @Override + public Boolean delete(SubjectLabelBO subjectLabelBO) { + if (log.isInfoEnabled()) { + log.info("SubjectLabelDomainServiceImpl.update.bo:{}", JSON.toJSONString(subjectLabelBO)); + } + SubjectLabel subjectLabel = SubjectLabelConverter.INSTANCE + .convertBoToLabel(subjectLabelBO); + subjectLabel.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode()); + int count = subjectLabelService.update(subjectLabel); + return count > 0; + } + /** + * @description: 查询分类下的标签 + * @param: [subjectLabelBO] + * @return: java.util.List + * @author landaiqing + * @date: 2024/2/14 19:08 + */ + @Override + public List queryLabelByCategoryId(SubjectLabelBO subjectLabelBO) { + Long categoryId = subjectLabelBO.getCategoryId(); + SubjectMapping subjectMapping=new SubjectMapping(); + subjectMapping.setCategoryId(categoryId); + subjectMapping.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode()); + List mappingList= subjectMappingService.queryLabelId(subjectMapping); + if(CollectionUtils.isEmpty(mappingList)){ + return Collections.emptyList(); + } + List labelIdList = mappingList.stream().map(SubjectMapping::getLabelId).collect(Collectors.toList()); + List labelList= subjectLabelService.batchQueryById(labelIdList); + List boList=new LinkedList<>(); + labelList.forEach(label->{ + SubjectLabelBO bo=new SubjectLabelBO(); + bo.setId(label.getId()); + bo.setLabelName(label.getLabelName()); + bo.setCategoryId(categoryId); + bo.setSortNum(label.getSortNum()); + boList.add(bo); + }); + return boList; + } +} 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 new file mode 100644 index 0000000..43bad78 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectInfo.java @@ -0,0 +1,68 @@ +package com.landaiqing.subject.infra.basic.entity; + +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * 题目信息表(SubjectInfo)实体类 + * + * @author makejava + * @since 2024-02-14 16:59:04 + */ +@Data +public class SubjectInfo implements Serializable { + private static final long serialVersionUID = 969950536946065645L; + /** + * 主键 + */ + 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 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/SubjectLabel.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectLabel.java new file mode 100644 index 0000000..eac9ef6 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectLabel.java @@ -0,0 +1,51 @@ +package com.landaiqing.subject.infra.basic.entity; + +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * 题目标签表(SubjectLabel)实体类 + * + * @author makejava + * @since 2024-02-14 17:08:06 + */ +@Data +public class SubjectLabel implements Serializable { + /** + * 主键 + */ + private Long id; + /** + * 标签分类 + */ + private String labelName; + /** + * 排序 + */ + private Integer sortNum; + + private Long categoryId; + /** + * 创建人 + */ + 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/SubjectMapping.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectMapping.java new file mode 100644 index 0000000..5255a14 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/entity/SubjectMapping.java @@ -0,0 +1,123 @@ +package com.landaiqing.subject.infra.basic.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 题目分类关系表(SubjectMapping)实体类 + * + * @author makejava + * @since 2024-02-14 18:44:42 + */ +public class SubjectMapping implements Serializable { + private static final long serialVersionUID = -84040462903129597L; + /** + * 主键 + */ + private Long id; + /** + * 题目id + */ + private Long subjectId; + /** + * 分类id + */ + private Long categoryId; + /** + * 标签id + */ + private Long labelId; + /** + * 创建人 + */ + private String createdBy; + /** + * 创建时间 + */ + private Date createdTime; + /** + * 修改人 + */ + private String updateBy; + /** + * 修改时间 + */ + private Date updateTime; + + private Integer isDeleted; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getSubjectId() { + return subjectId; + } + + public void setSubjectId(Long subjectId) { + this.subjectId = subjectId; + } + + public Long getCategoryId() { + return categoryId; + } + + public void setCategoryId(Long categoryId) { + this.categoryId = categoryId; + } + + public Long getLabelId() { + return labelId; + } + + public void setLabelId(Long labelId) { + this.labelId = labelId; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Date getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Date createdTime) { + this.createdTime = createdTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Integer getIsDeleted() { + return isDeleted; + } + + public void setIsDeleted(Integer isDeleted) { + this.isDeleted = isDeleted; + } + +} + 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 new file mode 100644 index 0000000..f86f4e2 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectInfoDao.java @@ -0,0 +1,82 @@ +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; + +/** + * 题目信息表(SubjectInfo)表数据库访问层 + * + * @author makejava + * @since 2024-02-14 16:59:02 + */ +public interface SubjectInfoDao { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SubjectInfo queryById(Long id); + + /** + * 查询指定行数据 + * + * @param subjectInfo 查询条件 + * @param subjectInfo 分页对象 + * @return 对象列表 + */ + List queryAllByLimit(SubjectInfo subjectInfo); + + /** + * 统计总行数 + * + * @param subjectInfo 查询条件 + * @return 总行数 + */ + long count(SubjectInfo subjectInfo); + + /** + * 新增数据 + * + * @param subjectInfo 实例对象 + * @return 影响行数 + */ + int insert(SubjectInfo subjectInfo); + + /** + * 批量新增数据(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 subjectInfo 实例对象 + * @return 影响行数 + */ + int update(SubjectInfo subjectInfo); + + /** + * 通过主键删除数据 + * + * @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/SubjectLabelDao.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectLabelDao.java new file mode 100644 index 0000000..b04411a --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectLabelDao.java @@ -0,0 +1,84 @@ +package com.landaiqing.subject.infra.basic.mapper; + +import com.landaiqing.subject.infra.basic.entity.SubjectLabel; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 题目标签表(SubjectLabel)表数据库访问层 + * + * @author makejava + * @since 2024-02-14 17:08:06 + */ +public interface SubjectLabelDao { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SubjectLabel queryById(Long id); + + /** + * 查询指定行数据 + * + * @param subjectLabel 查询条件 + * @param subjectLabel 分页对象 + * @return 对象列表 + */ + List queryAllByLimit(SubjectLabel subjectLabel); + + /** + * 统计总行数 + * + * @param subjectLabel 查询条件 + * @return 总行数 + */ + long count(SubjectLabel subjectLabel); + + /** + * 新增数据 + * + * @param subjectLabel 实例对象 + * @return 影响行数 + */ + int insert(SubjectLabel subjectLabel); + + /** + * 批量新增数据(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 subjectLabel 实例对象 + * @return 影响行数 + */ + int update(SubjectLabel subjectLabel); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Long id); + + List batchQueryById(List labelIdList); +} + diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectMappingDao.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectMappingDao.java new file mode 100644 index 0000000..254f215 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/mapper/SubjectMappingDao.java @@ -0,0 +1,85 @@ +package com.landaiqing.subject.infra.basic.mapper; + +import com.landaiqing.subject.infra.basic.entity.SubjectMapping; +import org.apache.ibatis.annotations.Param; + + +import java.util.List; + +/** + * 题目分类关系表(SubjectMapping)表数据库访问层 + * + * @author makejava + * @since 2024-02-14 18:44:41 + */ +public interface SubjectMappingDao { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SubjectMapping queryById(Long id); + + /** + * 查询指定行数据 + * + * @param subjectMapping 查询条件 + * @param subjectMapping 分页对象 + * @return 对象列表 + */ + List queryAllByLimit(SubjectMapping subjectMapping); + + /** + * 统计总行数 + * + * @param subjectMapping 查询条件 + * @return 总行数 + */ + long count(SubjectMapping subjectMapping); + + /** + * 新增数据 + * + * @param subjectMapping 实例对象 + * @return 影响行数 + */ + int insert(SubjectMapping subjectMapping); + + /** + * 批量新增数据(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 subjectMapping 实例对象 + * @return 影响行数 + */ + int update(SubjectMapping subjectMapping); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Long id); + + List queryDistinctLabelId(SubjectMapping subjectMapping); +} + 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 new file mode 100644 index 0000000..5e87907 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectInfoService.java @@ -0,0 +1,46 @@ +package com.landaiqing.subject.infra.basic.service; + +import com.landaiqing.subject.infra.basic.entity.SubjectInfo; + +/** + * 题目信息表(SubjectInfo)表服务接口 + * + * @author makejava + * @since 2024-02-14 16:59:04 + */ +public interface SubjectInfoService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SubjectInfo queryById(Long id); + + + /** + * 新增数据 + * + * @param subjectInfo 实例对象 + * @return 实例对象 + */ + SubjectInfo insert(SubjectInfo subjectInfo); + + /** + * 修改数据 + * + * @param subjectInfo 实例对象 + * @return 实例对象 + */ + SubjectInfo update(SubjectInfo subjectInfo); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Long id); + +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectLabelService.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectLabelService.java new file mode 100644 index 0000000..ed07a30 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectLabelService.java @@ -0,0 +1,52 @@ +package com.landaiqing.subject.infra.basic.service; + +import com.landaiqing.subject.infra.basic.entity.SubjectLabel; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +/** + * 题目标签表(SubjectLabel)表服务接口 + * + * @author makejava + * @since 2024-02-14 17:08:07 + */ +public interface SubjectLabelService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SubjectLabel queryById(Long id); + + + + /** + * 新增数据 + * + * @param subjectLabel 实例对象 + * @return 实例对象 + */ + int insert(SubjectLabel subjectLabel); + + /** + * 修改数据 + * + * @param subjectLabel 实例对象 + * @return 实例对象 + */ + int update(SubjectLabel subjectLabel); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Long id); + + List batchQueryById(@Param("list") List labelIdList); +} 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 new file mode 100644 index 0000000..5eedf3a --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/SubjectMappingService.java @@ -0,0 +1,57 @@ +package com.landaiqing.subject.infra.basic.service; + +import com.landaiqing.subject.infra.basic.entity.SubjectMapping; + +import java.util.List; + + +/** + * 题目分类关系表(SubjectMapping)表服务接口 + * + * @author makejava + * @since 2024-02-14 18:44:42 + */ +public interface SubjectMappingService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SubjectMapping queryById(Long id); + + + + /** + * 新增数据 + * + * @param subjectMapping 实例对象 + * @return 实例对象 + */ + SubjectMapping insert(SubjectMapping subjectMapping); + + /** + * 修改数据 + * + * @param subjectMapping 实例对象 + * @return 实例对象 + */ + int update(SubjectMapping subjectMapping); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Long id); + /** + * @description: 查询分类下的标签 + * @param: [subjectMapping] + * @return: java.util.List + * @author landaiqing + * @date: 2024/2/14 19:13 + */ + List queryLabelId(SubjectMapping subjectMapping); +} 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 new file mode 100644 index 0000000..a3b57a8 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectInfoServiceImpl.java @@ -0,0 +1,68 @@ +package com.landaiqing.subject.infra.basic.service.impl; + +import com.landaiqing.subject.infra.basic.entity.SubjectInfo; +import com.landaiqing.subject.infra.basic.mapper.SubjectInfoDao; +import com.landaiqing.subject.infra.basic.service.SubjectInfoService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 题目信息表(SubjectInfo)表服务实现类 + * + * @author makejava + * @since 2024-02-14 16:59:04 + */ +@Service("subjectInfoService") +public class SubjectInfoServiceImpl implements SubjectInfoService { + @Resource + private SubjectInfoDao subjectInfoDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public SubjectInfo queryById(Long id) { + return this.subjectInfoDao.queryById(id); + } + + + + /** + * 新增数据 + * + * @param subjectInfo 实例对象 + * @return 实例对象 + */ + @Override + public SubjectInfo insert(SubjectInfo subjectInfo) { + this.subjectInfoDao.insert(subjectInfo); + return subjectInfo; + } + + /** + * 修改数据 + * + * @param subjectInfo 实例对象 + * @return 实例对象 + */ + @Override + public SubjectInfo update(SubjectInfo subjectInfo) { + this.subjectInfoDao.update(subjectInfo); + return this.queryById(subjectInfo.getId()); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Long id) { + return this.subjectInfoDao.deleteById(id) > 0; + } +} diff --git a/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectLabelServiceImpl.java b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectLabelServiceImpl.java new file mode 100644 index 0000000..c43e5a6 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectLabelServiceImpl.java @@ -0,0 +1,74 @@ +package com.landaiqing.subject.infra.basic.service.impl; + +import com.landaiqing.subject.infra.basic.entity.SubjectLabel; +import com.landaiqing.subject.infra.basic.mapper.SubjectLabelDao; +import com.landaiqing.subject.infra.basic.service.SubjectLabelService; +import org.springframework.stereotype.Service; + + +import javax.annotation.Resource; +import java.util.List; + +/** + * 题目标签表(SubjectLabel)表服务实现类 + * + * @author makejava + * @since 2024-02-14 17:08:07 + */ +@Service("subjectLabelService") +public class SubjectLabelServiceImpl implements SubjectLabelService { + @Resource + private SubjectLabelDao subjectLabelDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public SubjectLabel queryById(Long id) { + return this.subjectLabelDao.queryById(id); + } + + + /** + * 新增数据 + * + * @param subjectLabel 实例对象 + * @return 实例对象 + */ + @Override + public int insert(SubjectLabel subjectLabel) { + return this.subjectLabelDao.insert(subjectLabel); + + } + + /** + * 修改数据 + * + * @param subjectLabel 实例对象 + * @return 实例对象 + */ + @Override + public int update(SubjectLabel subjectLabel) { + return this.subjectLabelDao.update(subjectLabel); + + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Long id) { + return this.subjectLabelDao.deleteById(id) > 0; + } + + @Override + public List batchQueryById(List labelIdList) { + return this.subjectLabelDao.batchQueryById(labelIdList); + } +} 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 new file mode 100644 index 0000000..7c8eca3 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/java/com/landaiqing/subject/infra/basic/service/impl/SubjectMappingServiceImpl.java @@ -0,0 +1,79 @@ +package com.landaiqing.subject.infra.basic.service.impl; + +import com.landaiqing.subject.infra.basic.entity.SubjectMapping; +import com.landaiqing.subject.infra.basic.mapper.SubjectMappingDao; +import com.landaiqing.subject.infra.basic.service.SubjectMappingService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 题目分类关系表(SubjectMapping)表服务实现类 + * + * @author makejava + * @since 2024-02-14 18:44:42 + */ +@Service("subjectMappingService") +public class SubjectMappingServiceImpl implements SubjectMappingService { + @Resource + private SubjectMappingDao subjectMappingDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public SubjectMapping queryById(Long id) { + return this.subjectMappingDao.queryById(id); + } + + + /** + * 新增数据 + * + * @param subjectMapping 实例对象 + * @return 实例对象 + */ + @Override + public SubjectMapping insert(SubjectMapping subjectMapping) { + this.subjectMappingDao.insert(subjectMapping); + return subjectMapping; + } + + /** + * 修改数据 + * + * @param subjectMapping 实例对象 + * @return 实例对象 + */ + @Override + public int update(SubjectMapping subjectMapping) { + return this.subjectMappingDao.update(subjectMapping); + + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Long id) { + return this.subjectMappingDao.deleteById(id) > 0; + } + /** + * @description: 查询分类下的标签 + * @param: [subjectMapping] + * @return: java.util.List + * @author landaiqing + * @date: 2024/2/14 19:13 + */ + @Override + public List queryLabelId(SubjectMapping subjectMapping) { + return this.subjectMappingDao.queryDistinctLabelId(subjectMapping); + } +} 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 new file mode 100644 index 0000000..a10a980 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectInfoDao.xml @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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) + values + + (#{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) + 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) + + + + + update subject_info + + + subject_name = #{subjectName}, + + + subject_difficult = #{subjectDifficult}, + + + settle_name = #{settleName}, + + + subject_type = #{subjectType}, + + + subject_score = #{subjectScore}, + + + subject_parse = #{subjectParse}, + + + created_by = #{createdBy}, + + + created_time = #{createdTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + is_deleted = #{isDeleted}, + + + where id = #{id} + + + + + delete from subject_info where id = #{id} + + + + diff --git a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectLabelDao.xml b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectLabelDao.xml new file mode 100644 index 0000000..0a66877 --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectLabelDao.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into subject_label(label_name,sort_num,category_id,created_by,created_time,update_by,update_time,is_deleted) + values (#{labelName},#{sortNum},#{categoryId},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted}) + + + + insert into subject_label(label_name,sort_num,category_id,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.labelName},#{entity.sortNum},#{entity.categoryId},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + + + + insert into subject_label(label_name,sort_num,category_id,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.labelName},#{entity.sortNum},#{entity.categoryId},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + on duplicate key update + label_name = values(label_name)sort_num = values(sort_num)category_id = values(category_id)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_label + + + label_name = #{labelName}, + + + sort_num = #{sortNum}, + + + category_id = #{categoryId}, + + + created_by = #{createdBy}, + + + created_time = #{createdTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + is_deleted = #{isDeleted}, + + + where id = #{id} + + + + + delete + from subject_label + where id = #{id} + + + + diff --git a/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectMappingDao.xml b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectMappingDao.xml new file mode 100644 index 0000000..0bcce1e --- /dev/null +++ b/jc-club-subject/jc-club-infra/src/main/resources/mapper/SubjectMappingDao.xml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into subject_mapping(subject_id,category_id,label_id,created_by,created_time,update_by,update_time,is_deleted) + values (#{subjectId},#{categoryId},#{labelId},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted}) + + + + insert into subject_mapping(subject_id,category_id,label_id,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.categoryId},#{entity.labelId},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + + + + insert into subject_mapping(subject_id,category_id,label_id,created_by,created_time,update_by,update_time,is_deleted) + values + + (#{entity.subjectId},#{entity.categoryId},#{entity.labelId},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted}) + + on duplicate key update + subject_id = values(subject_id)category_id = values(category_id)label_id = values(label_id)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_mapping + + + subject_id = #{subjectId}, + + + category_id = #{categoryId}, + + + label_id = #{labelId}, + + + created_by = #{createdBy}, + + + created_time = #{createdTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + is_deleted = #{isDeleted}, + + + where id = #{id} + + + + + delete + from subject_mapping + where id = #{id} + + + +