Browse Source

知识点模块开发

master
luogw 1 month ago
parent
commit
4ab20b31a1
  1. 1
      src/main/java/com/project/appeal/domain/dto/AppealDTO.java
  2. 4
      src/main/java/com/project/appeal/domain/entity/AppealEntity.java
  3. 11
      src/main/java/com/project/appeal/domain/service/Impl/CheckAppealDomainServiceImpl.java
  4. 77
      src/main/java/com/project/appeal/domain/service/Impl/SaveAppealDomainServiceImpl.java
  5. 3
      src/main/java/com/project/appeal/domain/service/SaveAppealDomainService.java
  6. 2
      src/main/java/com/project/base/domain/dto/BaseDTO.java
  7. 4
      src/main/java/com/project/base/domain/entity/BaseEntity.java
  8. 53
      src/main/java/com/project/ding/utils/DingUtil.java
  9. 11
      src/main/java/com/project/exam/mapper/ExamRecordMapper.java
  10. 8
      src/main/java/com/project/information/application/KnowledgePointApplicationService.java
  11. 18
      src/main/java/com/project/information/application/KnowledgePointApplicationServiceImpl.java
  12. 21
      src/main/java/com/project/information/controller/KnowledgePointController.java
  13. 1
      src/main/java/com/project/information/domain/dto/KnowledgePointDTO.java
  14. 16
      src/main/java/com/project/information/domain/dto/KnowledgePointStatisticsDTO.java
  15. 5
      src/main/java/com/project/information/domain/entity/KnowledgePointEntity.java
  16. 7
      src/main/java/com/project/information/domain/service/SearchKnowledgePointDomainService.java
  17. 33
      src/main/java/com/project/information/domain/service/SearchKnowledgePointDomainServiceImpl.java
  18. 12
      src/main/java/com/project/information/mapper/KnowledgePointMapper.java
  19. 7
      src/main/java/com/project/operation/aop/OperationLogAspect.java
  20. 25
      src/main/java/com/project/operation/config/AsyncConfig.java
  21. 9
      src/main/java/com/project/task/domain/enums/QuestionTypeEnum.java

1
src/main/java/com/project/appeal/domain/dto/AppealDTO.java

@ -20,6 +20,7 @@ import java.util.List;
public class AppealDTO extends BaseDTO { public class AppealDTO extends BaseDTO {
private Long id; private Long id;
private String userId; private String userId;
private String appealUserId;
private String userName; private String userName;
private Long examId; private Long examId;
private Long taskId; private Long taskId;

4
src/main/java/com/project/appeal/domain/entity/AppealEntity.java

@ -29,6 +29,10 @@ public class AppealEntity extends BaseEntity {
@Column(name = "username" , columnDefinition="varchar(50) comment '用户名称'") @Column(name = "username" , columnDefinition="varchar(50) comment '用户名称'")
private String username; private String username;
@TableField("appeal_user_id")
@Column(name = "appeal_user_id" , columnDefinition="varchar(50) comment '审批用户id'")
private String appealUserId;
@TableField("exam_id") @TableField("exam_id")
@Column(name = "exam_id" , columnDefinition="bigint(20) comment '考试id'") @Column(name = "exam_id" , columnDefinition="bigint(20) comment '考试id'")
private Long examId; private Long examId;

11
src/main/java/com/project/appeal/domain/service/Impl/CheckAppealDomainServiceImpl.java

@ -2,11 +2,13 @@ package com.project.appeal.domain.service.Impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.project.appeal.domain.dto.AppealDTO; import com.project.appeal.domain.dto.AppealDTO;
import com.project.appeal.domain.enums.StatusEnum;
import com.project.appeal.domain.service.CheckAppealDomainService; import com.project.appeal.domain.service.CheckAppealDomainService;
import com.project.base.domain.exception.BusinessErrorException; import com.project.base.domain.exception.BusinessErrorException;
import com.project.base.domain.exception.MissingParameterException; import com.project.base.domain.exception.MissingParameterException;
import com.project.base.domain.exception.PermissionErrorException; import com.project.base.domain.exception.PermissionErrorException;
import com.project.base.domain.result.ResultCodeEnum; import com.project.base.domain.result.ResultCodeEnum;
import com.project.ding.domain.enums.UserRoleEnum;
import com.project.ding.utils.SecurityUtils; import com.project.ding.utils.SecurityUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -40,17 +42,20 @@ public class CheckAppealDomainServiceImpl implements CheckAppealDomainService {
if (StringUtils.isBlank(appealDTO.getRemark())){ if (StringUtils.isBlank(appealDTO.getRemark())){
throw new MissingParameterException("缺少申诉理由"); throw new MissingParameterException("缺少申诉理由");
} }
if (ObjectUtil.isEmpty(appealDTO.getId()) && appealDTO.getStatus() != 1){ if (ObjectUtil.isEmpty(appealDTO.getId()) && appealDTO.getStatus() != StatusEnum.PENDING_REVIEW.getValue()){
throw new BusinessErrorException("申诉状态错误"); throw new BusinessErrorException("申诉状态错误");
} }
if (ObjectUtil.isNotEmpty(appealDTO.getId()) && appealDTO.getStatus() == 1){ if (ObjectUtil.isNotEmpty(appealDTO.getId()) && appealDTO.getStatus() == StatusEnum.PENDING_REVIEW.getValue()){
throw new BusinessErrorException("申诉状态错误"); throw new BusinessErrorException("申诉状态错误");
} }
if (appealDTO.getStatus() != StatusEnum.PENDING_REVIEW.getValue() && StringUtils.isBlank(appealDTO.getReason())){
throw new BusinessErrorException("缺少审批意见");
}
//权限校验 //权限校验
if (ObjectUtil.isNotEmpty(appealDTO.getId()) && appealDTO.getStatus() != 1){ if (ObjectUtil.isNotEmpty(appealDTO.getId()) && appealDTO.getStatus() != 1){
//校验权限 //校验权限
List<String> userRoles = SecurityUtils.getUserRoles(); List<String> userRoles = SecurityUtils.getUserRoles();
if(! userRoles.stream().anyMatch("ROLE_ADMIN"::equals)){ if(! userRoles.stream().anyMatch(UserRoleEnum.ROLE_ADMIN::equals)){
throw new PermissionErrorException(); throw new PermissionErrorException();
} }
} }

77
src/main/java/com/project/appeal/domain/service/Impl/SaveAppealDomainServiceImpl.java

@ -1,19 +1,27 @@
package com.project.appeal.domain.service.Impl; package com.project.appeal.domain.service.Impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.tingyugetc520.ali.dingtalk.error.DtErrorException;
import com.project.appeal.domain.dto.AppealDTO; import com.project.appeal.domain.dto.AppealDTO;
import com.project.appeal.domain.entity.AppealEntity; import com.project.appeal.domain.entity.AppealEntity;
import com.project.appeal.domain.enums.StatusEnum;
import com.project.appeal.domain.service.AppealBaseService; import com.project.appeal.domain.service.AppealBaseService;
import com.project.appeal.domain.service.SaveAppealDomainService; import com.project.appeal.domain.service.SaveAppealDomainService;
import com.project.base.domain.exception.BusinessErrorException; import com.project.base.domain.exception.BusinessErrorException;
import com.project.base.domain.result.Result; import com.project.base.domain.result.Result;
import com.project.ding.utils.DingUtil;
import com.project.ding.utils.SecurityUtils;
import com.project.exam.domain.dto.ExamRecordDTO; import com.project.exam.domain.dto.ExamRecordDTO;
import com.project.exam.domain.entity.ExamRecordEntity; import com.project.exam.domain.entity.ExamRecordEntity;
import com.project.exam.domain.service.ExamRecordBaseService; import com.project.exam.domain.service.ExamRecordBaseService;
import com.project.exam.mapper.ExamRecordMapper;
import com.project.task.domain.entity.TaskEntity; import com.project.task.domain.entity.TaskEntity;
import com.project.task.domain.enums.QuestionTypeEnum;
import com.project.task.mapper.TaskMapper; import com.project.task.mapper.TaskMapper;
import org.redisson.mapreduce.Collector; import org.redisson.mapreduce.Collector;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
@ -27,35 +35,55 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService {
@Autowired @Autowired
private AppealBaseService appealBaseService; private AppealBaseService appealBaseService;
@Autowired @Autowired
private ExamRecordBaseService examRecordBaseService; private ExamRecordMapper examRecordMapper;
@Autowired @Autowired
private TaskMapper taskMapper; private TaskMapper taskMapper;
@Autowired
private DingUtil dingUtil;
@Override @Override
public Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO) { @Transactional(rollbackFor = BusinessErrorException.class)
public Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO) throws DtErrorException {
AppealEntity entity = appealDTO.toEntity(AppealEntity::new); AppealEntity entity = appealDTO.toEntity(AppealEntity::new);
//设置审批人
if (appealDTO.getStatus() != StatusEnum.PENDING_REVIEW.getValue()){
appealDTO.setAppealUserId(SecurityUtils.getUserId());
}
appealBaseService.saveOrUpdate(entity); appealBaseService.saveOrUpdate(entity);
//如果审核通过,需要为用户加分 //如果审核通过,需要为用户加分
if (appealDTO.getStatus() != 2){ if (appealDTO.getStatus() != StatusEnum.PASS_REVIEW.getValue()) {
//审核拒绝,发送工作通知消息,告知用户
if (appealDTO.getStatus() == StatusEnum.REFUSE_REVIEW.getValue()) {
dingUtil.sendWorkNotice(appealDTO);
}
return Result.success(appealDTO); return Result.success(appealDTO);
} }
ExamRecordEntity examRecord = examRecordBaseService.getById(appealDTO.getExamId()); ExamRecordEntity examRecord = examRecordMapper.selectById(appealDTO.getExamId());
if (examRecord == null){ if (examRecord == null){
throw new BusinessErrorException("用户未该场考试"); throw new BusinessErrorException("用户未该场考试");
} }
//找到题目相关信息,获取该类型题目分数 //找到题目相关信息,获取该类型题目分数
ExamRecordDTO examRecordDTO = examRecord.toDTO(ExamRecordDTO::new); ExamRecordDTO examRecordDTO = examRecord.toDTO(ExamRecordDTO::new);
List<ExamRecordDTO.QuestionSnapshotDTO> answerSnapshotDTOList = examRecordDTO.getAnswerSnapshotDTOList();
ExamRecordDTO.QuestionSnapshotDTO questionSnapshotDTO = null; ExamRecordDTO.QuestionSnapshotDTO questionSnapshotDTO = null;
Optional<? extends ExamRecordDTO.QuestionSnapshotDTO> optionalDTO = examRecordDTO.getAnswerSnapshotDTOList().stream()
.filter(answerSnapshotDTO -> appealDTO.getQuestionId() != null int index = -1;
&& appealDTO.getQuestionId().equals(answerSnapshotDTO.getQuestionId())) for (int i = 0; i < answerSnapshotDTOList.size(); i++) {
.findFirst(); ExamRecordDTO.QuestionSnapshotDTO dto = answerSnapshotDTOList.get(i);
if (optionalDTO.isPresent()) { if (appealDTO.getQuestionId() != null
questionSnapshotDTO = optionalDTO.get(); && appealDTO.getQuestionId().equals(dto.getQuestionId())) {
index = i;
break;
}
}
if (index != -1) {
questionSnapshotDTO = answerSnapshotDTOList.get(index);
}else { }else {
throw new BusinessErrorException("题目不存在"); throw new BusinessErrorException("题目不存在");
} }
@ -67,28 +95,23 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService {
TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecord.getTaskUserId()); TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecord.getTaskUserId());
Double questionScore = switch (questionSnapshotDTO.getType()) { QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(questionSnapshotDTO.getType());
case 1 -> taskEntity.getSingleChoiceScore(); if (questionType == null) {
case 2 -> taskEntity.getMultipleChoiceScore(); throw new BusinessErrorException("不支持的题目类型:" + questionSnapshotDTO.getType());
case 3 -> taskEntity.getTrueFalseScore(); }
default -> throw new IllegalArgumentException( Double questionScore = switch (questionType) {
"不支持的题目类型:" + questionSnapshotDTO.getType() case SINGLE_CHOICE-> taskEntity.getSingleChoiceScore();
); case MULTIPLE_CHOICE -> taskEntity.getMultipleChoiceScore();
case TRUE_FALSE -> taskEntity.getTrueFalseScore();
}; };
//总分+单题分数 //总分+单题分数
BigDecimal score = BigDecimal.valueOf(questionScore).add(BigDecimal.valueOf(examRecordDTO.getScore())).setScale(2, RoundingMode.HALF_UP); BigDecimal score = BigDecimal.valueOf(questionScore).add(BigDecimal.valueOf(examRecordDTO.getScore())).setScale(2, RoundingMode.HALF_UP);
examRecord.setScore(score.doubleValue());
questionSnapshotDTO.setHasAppealed(true);
List<ExamRecordDTO.QuestionSnapshotDTO> questionSnapshotDTOList = examRecordDTO.getAnswerSnapshotDTOList().stream()
.filter(answerSnapshotDTO -> !appealDTO.getQuestionId().equals(answerSnapshotDTO.getQuestionId()))
.collect(Collectors.toCollection(ArrayList::new));
questionSnapshotDTOList.add(questionSnapshotDTO);
examRecordDTO.setAnswerSnapshotDTOList(questionSnapshotDTOList);
//保存 //保存
examRecordBaseService.save(examRecordDTO.toEntity(ExamRecordEntity::new)); examRecordMapper.updateScore(index,score.doubleValue(),examRecord.getId());
//通知用户
dingUtil.sendWorkNotice(appealDTO);
return Result.success(appealDTO); return Result.success(appealDTO);
} }

3
src/main/java/com/project/appeal/domain/service/SaveAppealDomainService.java

@ -1,8 +1,9 @@
package com.project.appeal.domain.service; package com.project.appeal.domain.service;
import com.github.tingyugetc520.ali.dingtalk.error.DtErrorException;
import com.project.appeal.domain.dto.AppealDTO; import com.project.appeal.domain.dto.AppealDTO;
import com.project.base.domain.result.Result; import com.project.base.domain.result.Result;
public interface SaveAppealDomainService { public interface SaveAppealDomainService {
Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO); Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO) throws DtErrorException;
} }

2
src/main/java/com/project/base/domain/dto/BaseDTO.java

@ -12,7 +12,7 @@ import java.util.function.Supplier;
public class BaseDTO { public class BaseDTO {
private Long creatorId; private String creatorId;
private Date createTime; private Date createTime;

4
src/main/java/com/project/base/domain/entity/BaseEntity.java

@ -20,8 +20,8 @@ public class BaseEntity implements Serializable {
@TableField(value = "creator_id" , fill = FieldFill.INSERT) @TableField(value = "creator_id" , fill = FieldFill.INSERT)
@Column(name = "creator_id" , columnDefinition="bigint(20) comment '创建用户id'") @Column(name = "creator_id" , columnDefinition="varchar(20) comment '创建用户id'")
private Long creatorId; private String creatorId;
@TableField(value = "create_time" , fill = FieldFill.INSERT) @TableField(value = "create_time" , fill = FieldFill.INSERT)
@Comment("创建时间") @Comment("创建时间")

53
src/main/java/com/project/ding/utils/DingUtil.java

@ -12,14 +12,19 @@ import com.github.tingyugetc520.ali.dingtalk.error.DtErrorException;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import com.project.appeal.domain.dto.AppealDTO;
import com.project.ding.domain.dto.DepartmentDTO; import com.project.ding.domain.dto.DepartmentDTO;
import com.project.ding.domain.dto.DingUserDTO; import com.project.ding.domain.dto.DingUserDTO;
import com.project.ding.domain.dto.UserDTO; import com.project.ding.domain.dto.UserDTO;
import io.vavr.control.Try; import io.vavr.control.Try;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -29,7 +34,6 @@ public class DingUtil {
private DtService dtService; private DtService dtService;
public List<DepartmentDTO> getAllDepartment() throws Exception { public List<DepartmentDTO> getAllDepartment() throws Exception {
List<DtDepart> list = dtService.getDepartmentService().list(null, true); List<DtDepart> list = dtService.getDepartmentService().list(null, true);
List<DepartmentDTO> res = new ArrayList<>(); List<DepartmentDTO> res = new ArrayList<>();
@ -137,25 +141,42 @@ public class DingUtil {
/** /**
* 发送工作通知 * 发送工作通知
*/ */
public void sendWorkNotice(String userId,String message) throws DtErrorException { @Async("dingNoticeExecutor")
public void sendWorkNotice(AppealDTO appealDTO) throws DtErrorException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String nowTime = LocalDateTime.now().format(formatter);
boolean approved = appealDTO.getStatus() != null && appealDTO.getStatus() == 2;
UserDTO userDTO = getUserById(appealDTO.getAppealUserId());
String resultLine = approved
? "- ✅ **审核通过**"
: "- ❌ **审核不通过**";
String markdownText = String.format(
"### AI考核-申诉审批完成\n\n" +
"#### 任务信息\n" +
"- 题目名称:%s\n" +
"- 申诉理由:%s\n\n" +
"#### 审批结果\n" +
"%s\n\n" +
"---\n" +
"- 📅 审批时间:%s\n" +
"- 👤 审批人:%s\n" +
"- 💬 审批意见:%s",
appealDTO.getQuestionContent(),
appealDTO.getRemark(),
resultLine,
nowTime,
userDTO.getName(),
appealDTO.getReason()
);
//发送工作通知
DtCorpConversationMessage corpConversationMessage = DtCorpConversationMessage.builder() DtCorpConversationMessage corpConversationMessage = DtCorpConversationMessage.builder()
.agentId(dtService.getDtConfigStorage().getAgentId()) .agentId(dtService.getDtConfigStorage().getAgentId())
.userIds(Lists.newArrayList(userId)) .userIds(Lists.newArrayList(appealDTO.getUserId()))
.msg(DtMessage.MARKDOWN() .msg(DtMessage.MARKDOWN()
.content("AI考核-审批申诉结果") .content("AI考核-审批申诉结果")
.text(String.format("### AI考核-申诉审批完成\n" + .text(markdownText)
"\n" +
"#### 任务信息\n" +
"- 考试任务:%d\n" +
"- 题目名称:%d\n" +
"\n" +
"#### 审批结果\n" +
"- ✅ 审核通过\n" +
"\n" +
"---\n" +
"- \uD83D\uDCC5 审批时间:%d\n" +
"- \uD83D\uDC64 审批人:%d\n" +
"- \uD83D\uDCAC 审批意见:%d","任务1","题目1","时间","人","意见"))
.build()) .build())
.build(); .build();

11
src/main/java/com/project/exam/mapper/ExamRecordMapper.java

@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import java.math.BigDecimal;
@Mapper @Mapper
public interface ExamRecordMapper extends BaseMapper<ExamRecordEntity> { public interface ExamRecordMapper extends BaseMapper<ExamRecordEntity> {
/** /**
@ -19,4 +21,13 @@ public interface ExamRecordMapper extends BaseMapper<ExamRecordEntity> {
int updateAnswerIncremental(@Param("recordId") Long recordId, int updateAnswerIncremental(@Param("recordId") Long recordId,
@Param("idx") int idx, @Param("idx") int idx,
@Param("answer") String answer); @Param("answer") String answer);
@Update("UPDATE evaluator_exam_record SET " +
"answer_snapshot = JSON_SET(answer_snapshot, '$[${index}].hasAppealed', true), " +
"score = #{score}" +
"update_time = NOW() " +
"WHERE id = #{id}")
void updateScore(@Param("index") int index,
@Param("score") double score,
@Param("id") Long id);
} }

8
src/main/java/com/project/information/application/KnowledgePointApplicationService.java

@ -0,0 +1,8 @@
package com.project.information.application;
import com.project.base.domain.result.Result;
import com.project.information.domain.dto.KnowledgePointStatisticsDTO;
public interface KnowledgePointApplicationService {
Result<KnowledgePointStatisticsDTO> getSum(Long subLineId);
}

18
src/main/java/com/project/information/application/KnowledgePointApplicationServiceImpl.java

@ -0,0 +1,18 @@
package com.project.information.application;
import com.project.base.domain.result.Result;
import com.project.information.domain.dto.KnowledgePointStatisticsDTO;
import com.project.information.domain.service.SearchKnowledgePointDomainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class KnowledgePointApplicationServiceImpl implements KnowledgePointApplicationService {
@Autowired
private SearchKnowledgePointDomainService searchKnowledgePointDomainService;
@Override
public Result<KnowledgePointStatisticsDTO> getSum(Long subLineId) {
return Result.success(searchKnowledgePointDomainService.getSum(subLineId));
}
}

21
src/main/java/com/project/information/controller/KnowledgePointController.java

@ -0,0 +1,21 @@
package com.project.information.controller;
import com.project.base.domain.result.Result;
import com.project.information.application.KnowledgePointApplicationService;
import com.project.information.domain.dto.KnowledgePointStatisticsDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api/admin/knowledgePoint")
@RestController
public class KnowledgePointController {
@Autowired
private KnowledgePointApplicationService knowledgePointApplicationService;
@GetMapping("/getSum")
public Result<KnowledgePointStatisticsDTO> getSum(Long subLineId){
return knowledgePointApplicationService.getSum(subLineId);
}
}

1
src/main/java/com/project/information/domain/dto/KnowledgePointDTO.java

@ -9,4 +9,5 @@ public class KnowledgePointDTO extends BaseDTO {
private String content; private String content;
private Integer backgroundColor;
} }

16
src/main/java/com/project/information/domain/dto/KnowledgePointStatisticsDTO.java

@ -0,0 +1,16 @@
package com.project.information.domain.dto;
import lombok.Data;
@Data
public class KnowledgePointStatisticsDTO {
/**
* 精准掌握知识点数黄色
*/
private Integer preciseSum;
/**
* 模糊掌握知识点数黄色
*/
private Integer blurSum;
}

5
src/main/java/com/project/information/domain/entity/KnowledgePointEntity.java

@ -25,6 +25,11 @@ public class KnowledgePointEntity extends BaseEntity {
@Column(name = "content", columnDefinition="TEXT comment '原始知识点文本内容'") @Column(name = "content", columnDefinition="TEXT comment '原始知识点文本内容'")
private String content; private String content;
@Comment("知识点底色,0-黄,1-红,2-绿")
@Column(name = "background_color")
@TableField("background_color")
private Integer backgroundColor;
@Column(name = "information_id") @Column(name = "information_id")
@Comment("来源资料id") @Comment("来源资料id")
@TableField("information_id") @TableField("information_id")

7
src/main/java/com/project/information/domain/service/SearchKnowledgePointDomainService.java

@ -0,0 +1,7 @@
package com.project.information.domain.service;
import com.project.information.domain.dto.KnowledgePointStatisticsDTO;
public interface SearchKnowledgePointDomainService {
KnowledgePointStatisticsDTO getSum(Long subLineId);
}

33
src/main/java/com/project/information/domain/service/SearchKnowledgePointDomainServiceImpl.java

@ -0,0 +1,33 @@
package com.project.information.domain.service;
import com.project.information.domain.dto.KnowledgePointDTO;
import com.project.information.domain.dto.KnowledgePointStatisticsDTO;
import com.project.information.mapper.KnowledgePointMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SearchKnowledgePointDomainServiceImpl implements SearchKnowledgePointDomainService {
@Autowired
private KnowledgePointMapper knowledgePointMapper;
@Override
public KnowledgePointStatisticsDTO getSum(Long subLineId) {
List<KnowledgePointDTO> knowledgePointDTOList = knowledgePointMapper.selectBySubLineId(subLineId);
Integer preciseSum = 0;
Integer blurSum = 0;
for (KnowledgePointDTO knowledgePointDTO : knowledgePointDTOList) {
if (knowledgePointDTO.getBackgroundColor() == 0){
preciseSum += knowledgePointDTO.getBackgroundColor();
}else if(knowledgePointDTO.getBackgroundColor() == 1){
blurSum += knowledgePointDTO.getBackgroundColor();
}
}
KnowledgePointStatisticsDTO knowledgePointStatisticsDTO = new KnowledgePointStatisticsDTO();
knowledgePointStatisticsDTO.setPreciseSum(preciseSum);
knowledgePointStatisticsDTO.setBlurSum(blurSum);
return knowledgePointStatisticsDTO;
}
}

12
src/main/java/com/project/information/mapper/KnowledgePointMapper.java

@ -2,9 +2,21 @@ package com.project.information.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.information.domain.dto.KnowledgePointDTO;
import com.project.information.domain.entity.KnowledgePointEntity; import com.project.information.domain.entity.KnowledgePointEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;
import java.util.List;
@Mapper @Mapper
public interface KnowledgePointMapper extends BaseMapper<KnowledgePointEntity> { public interface KnowledgePointMapper extends BaseMapper<KnowledgePointEntity> {
@Select({
"SELECT e.*" +
"FROM evaluator_information e" +
"INNER JOIN evaluator_knowledge_point p ON p.information_id = e.id" +
"WHERE e.sub_line_id = #{subLineId};"
})
List<KnowledgePointDTO> selectBySubLineId(@Param("subLineId") Long subLineId);
} }

7
src/main/java/com/project/operation/aop/OperationLogAspect.java

@ -12,6 +12,7 @@ import com.project.operation.domain.service.impl.description.DescriptionManager;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
@ -89,8 +90,8 @@ public class OperationLogAspect {
// 收集登录用户ID // 收集登录用户ID
String userId = SecurityUtils.getUserId(); String userId = SecurityUtils.getUserId();
if (userId != null) { if (StringUtils.isNotBlank(userId)) {
operationLogDTO.setCreatorId(Long.parseLong(userId.toString())); operationLogDTO.setCreatorId(userId);
} }
} }
@ -130,7 +131,7 @@ public class OperationLogAspect {
LoginDTO data = ((Result<LoginDTO>) businessResult).getData(); LoginDTO data = ((Result<LoginDTO>) businessResult).getData();
if (data != null && data.getToken() != null) { if (data != null && data.getToken() != null) {
String userId = jwtUtils.parseToken(data.getToken()).getSubject(); String userId = jwtUtils.parseToken(data.getToken()).getSubject();
operationLogDTO.setCreatorId(Long.parseLong(userId)); operationLogDTO.setCreatorId(userId);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("解析登录Token获取用户ID失败", e); log.error("解析登录Token获取用户ID失败", e);

25
src/main/java/com/project/operation/config/AsyncConfig.java

@ -9,7 +9,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
/** /**
* 异步配置类开启异步支持 + 自定义日志异步线程池 * 异步配置类开启异步支持
*/ */
@Configuration @Configuration
@EnableAsync @EnableAsync
@ -37,4 +37,27 @@ public class AsyncConfig {
executor.initialize(); executor.initialize();
return executor; return executor;
} }
/**
* 自定义日志异步线程池
*/
@Bean(name = "dingNoticeExecutor")
public Executor dingNoticeExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// 核心线程数(根据业务量调整)
executor.setCorePoolSize(5);
// 最大线程数
executor.setMaxPoolSize(20);
// 队列容量
executor.setQueueCapacity(100);
// 线程前缀名(便于日志排查)
executor.setThreadNamePrefix("ding-notice-");
// 线程空闲超时时间
executor.setKeepAliveSeconds(60);
// 拒绝策略:队列满时由调用线程执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// 初始化线程池
executor.initialize();
return executor;
}
} }

9
src/main/java/com/project/task/domain/enums/QuestionTypeEnum.java

@ -15,4 +15,13 @@ public enum QuestionTypeEnum implements HasValueEnum<Integer> {
private final Integer value; private final Integer value;
private final String description; private final String description;
private final String type; private final String type;
public static QuestionTypeEnum findByValue(Integer value) {
for (QuestionTypeEnum type : values()) {
if (type.value.equals(value)) {
return type;
}
}
return null;
}
} }

Loading…
Cancel
Save