Browse Source

问题修改

master
luogw 1 month ago
parent
commit
f0c6cd7939
  1. 4
      src/main/java/com/project/appeal/controller/AppealAdminController.java
  2. 2
      src/main/java/com/project/appeal/domain/enums/AppealStatusEnum.java
  3. 22
      src/main/java/com/project/appeal/domain/service/Impl/CheckAppealDomainServiceImpl.java
  4. 20
      src/main/java/com/project/appeal/domain/service/Impl/SaveAppealDomainServiceImpl.java
  5. 6
      src/main/java/com/project/operation/domain/service/impl/description/AppealDescriptionStrategy.java

4
src/main/java/com/project/appeal/controller/AppealAdmainController.java → src/main/java/com/project/appeal/controller/AppealAdminController.java

@ -15,13 +15,13 @@ import org.springframework.web.bind.annotation.*;
*/
@RequestMapping("/api/admin/appeal")
@RestController
public class AppealAdmainController {
public class AppealAdminController {
@Autowired
private AppealApplication appealApplication;
@PostMapping("saveOrUpdate")
@OperationLog(module = "申诉审批")
public Result<AppealDTO> saveOrUpdate(@RequestBody AppealDTO appealDTO) throws DtErrorException {
public Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO) throws DtErrorException {
return appealApplication.saveOrUpdate(appealDTO);
}

2
src/main/java/com/project/appeal/domain/enums/StatusEnum.java → src/main/java/com/project/appeal/domain/enums/AppealStatusEnum.java

@ -6,7 +6,7 @@ import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
public enum StatusEnum implements HasValueEnum<Integer> {
public enum AppealStatusEnum implements HasValueEnum<Integer> {
PENDING_REVIEW(1,"待审核"),
PASS_REVIEW(2,"审核通过"),
REFUSE_REVIEW(3,"审核拒绝");

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

@ -2,12 +2,11 @@ package com.project.appeal.domain.service.Impl;
import cn.hutool.core.util.ObjectUtil;
import com.project.appeal.domain.dto.AppealDTO;
import com.project.appeal.domain.enums.StatusEnum;
import com.project.appeal.domain.enums.AppealStatusEnum;
import com.project.appeal.domain.service.CheckAppealDomainService;
import com.project.base.domain.exception.BusinessErrorException;
import com.project.base.domain.exception.MissingParameterException;
import com.project.base.domain.exception.PermissionErrorException;
import com.project.base.domain.result.ResultCodeEnum;
import com.project.ding.domain.enums.UserRoleEnum;
import com.project.ding.utils.SecurityUtils;
import org.apache.commons.lang3.StringUtils;
@ -22,37 +21,26 @@ public class CheckAppealDomainServiceImpl implements CheckAppealDomainService {
if (ObjectUtil.isEmpty(appealDTO.getExamId())){
throw new MissingParameterException("缺少考试ID");
}
if (ObjectUtil.isEmpty(appealDTO.getUserId())){
throw new MissingParameterException("缺少用户ID");
}
if (StringUtils.isBlank(appealDTO.getUserName())){
throw new MissingParameterException("缺少用户名称");
}
if (ObjectUtil.isEmpty(appealDTO.getQuestionContent())){
throw new MissingParameterException("缺少题目ID");
}
if (StringUtils.isBlank(appealDTO.getUserAnswer())){
throw new MissingParameterException("缺少用户答案");
}
if (StringUtils.isBlank(appealDTO.getRemark())){
throw new MissingParameterException("缺少申诉理由");
}
if (ObjectUtil.isEmpty(appealDTO.getId()) && appealDTO.getStatus() != StatusEnum.PENDING_REVIEW.getValue()){
if (ObjectUtil.isEmpty(appealDTO.getId()) && !appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){
throw new BusinessErrorException("申诉状态错误");
}
if (ObjectUtil.isNotEmpty(appealDTO.getId()) && appealDTO.getStatus() == StatusEnum.PENDING_REVIEW.getValue()){
if (ObjectUtil.isNotEmpty(appealDTO.getId()) && appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){
throw new BusinessErrorException("申诉状态错误");
}
if (appealDTO.getStatus() != StatusEnum.PENDING_REVIEW.getValue() && StringUtils.isBlank(appealDTO.getReason())){
if (!appealDTO.getStatus().equals(AppealStatusEnum.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().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){
//校验权限
List<String> userRoles = SecurityUtils.getUserRoles();
if(! userRoles.stream().anyMatch(UserRoleEnum.ROLE_ADMIN::equals)){

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

@ -1,34 +1,29 @@
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.entity.AppealEntity;
import com.project.appeal.domain.enums.StatusEnum;
import com.project.appeal.domain.enums.AppealStatusEnum;
import com.project.appeal.domain.service.AppealBaseService;
import com.project.appeal.domain.service.SaveAppealDomainService;
import com.project.base.domain.exception.BusinessErrorException;
import com.project.base.domain.result.Result;
import com.project.ding.domain.dto.UserDTO;
import com.project.ding.utils.DingUtil;
import com.project.ding.utils.SecurityUtils;
import com.project.exam.domain.dto.ExamRecordDTO;
import com.project.exam.domain.entity.ExamRecordEntity;
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.enums.QuestionTypeEnum;
import com.project.task.mapper.TaskMapper;
import org.redisson.mapreduce.Collector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
public class SaveAppealDomainServiceImpl implements SaveAppealDomainService {
@ -48,16 +43,21 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService {
AppealEntity entity = appealDTO.toEntity(AppealEntity::new);
//设置审批人
if (appealDTO.getStatus() != StatusEnum.PENDING_REVIEW.getValue()){
if (!appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){
appealDTO.setAppealUserId(SecurityUtils.getUserId());
}else{
//设置申诉人
appealDTO.setAppealUserId(SecurityUtils.getUserId());
UserDTO user = dingUtil.getUserById(SecurityUtils.getUserId());
appealDTO.setUserName(user.getName());
}
appealBaseService.saveOrUpdate(entity);
//如果审核通过,需要为用户加分
if (appealDTO.getStatus() != StatusEnum.PASS_REVIEW.getValue()) {
if (!appealDTO.getStatus().equals(AppealStatusEnum.PASS_REVIEW.getValue())) {
//审核拒绝,发送工作通知消息,告知用户
if (appealDTO.getStatus() == StatusEnum.REFUSE_REVIEW.getValue()) {
if (appealDTO.getStatus().equals(AppealStatusEnum.REFUSE_REVIEW.getValue())) {
dingUtil.sendWorkNotice(appealDTO);
}
return Result.success(appealDTO);

6
src/main/java/com/project/operation/domain/service/impl/description/AppealDescriptionStrategy.java

@ -1,7 +1,7 @@
package com.project.operation.domain.service.impl.description;
import com.project.appeal.domain.dto.AppealDTO;
import com.project.appeal.domain.enums.StatusEnum;
import com.project.appeal.domain.enums.AppealStatusEnum;
import com.project.operation.domain.dto.OperationLogDTO;
import com.project.operation.domain.enums.ModuleEnum;
import com.project.operation.domain.service.DescriptionStrategy;
@ -19,8 +19,8 @@ public class AppealDescriptionStrategy implements DescriptionStrategy {
private static final Map<Integer, String> STATUS_ACTION_MAP = new HashMap<>();
static {
// 枚举值与操作文案映射,后续新增状态只需加这行
STATUS_ACTION_MAP.put(StatusEnum.PASS_REVIEW.getValue(), "通过");
STATUS_ACTION_MAP.put(StatusEnum.REFUSE_REVIEW.getValue(), "拒绝");
STATUS_ACTION_MAP.put(AppealStatusEnum.PASS_REVIEW.getValue(), "通过");
STATUS_ACTION_MAP.put(AppealStatusEnum.REFUSE_REVIEW.getValue(), "拒绝");
}
@Override

Loading…
Cancel
Save