|
|
@ -1,8 +1,6 @@ |
|
|
package com.project.appeal.domain.service.Impl; |
|
|
package com.project.appeal.domain.service.Impl; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
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.AppealStatusEnum; |
|
|
import com.project.appeal.domain.enums.AppealStatusEnum; |
|
|
@ -10,6 +8,7 @@ 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.application.UserApplicationService; |
|
|
import com.project.ding.domain.dto.UserDTO; |
|
|
import com.project.ding.domain.dto.UserDTO; |
|
|
import com.project.ding.utils.DingUtil; |
|
|
import com.project.ding.utils.DingUtil; |
|
|
import com.project.ding.utils.SecurityUtils; |
|
|
import com.project.ding.utils.SecurityUtils; |
|
|
@ -28,12 +27,15 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.RoundingMode; |
|
|
import java.math.RoundingMode; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
|
public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private AppealBaseService appealBaseService; |
|
|
private AppealBaseService appealBaseService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
|
|
|
private UserApplicationService userApplicationService; |
|
|
|
|
|
@Autowired |
|
|
private ExamRecordMapper examRecordMapper; |
|
|
private ExamRecordMapper examRecordMapper; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private TaskUserMapper taskUserMapper; |
|
|
private TaskUserMapper taskUserMapper; |
|
|
@ -45,17 +47,19 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = BusinessErrorException.class) |
|
|
@Transactional(rollbackFor = BusinessErrorException.class) |
|
|
public Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO) throws DtErrorException { |
|
|
public Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO) throws Exception { |
|
|
AppealEntity entity = appealDTO.toEntity(AppealEntity::new); |
|
|
AppealEntity entity = appealDTO.toEntity(AppealEntity::new); |
|
|
|
|
|
|
|
|
//设置审批人
|
|
|
//设置审批人
|
|
|
if (!appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){ |
|
|
if (!appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){ |
|
|
appealDTO.setAppealUserId(SecurityUtils.getUserId()); |
|
|
entity.setAppealUserId(SecurityUtils.getUserId()); |
|
|
|
|
|
UserDTO user = userApplicationService.getDetail(SecurityUtils.getUserId()).getData(); |
|
|
|
|
|
entity.setAppealUsername(user.getName()); |
|
|
}else{ |
|
|
}else{ |
|
|
//设置申诉人
|
|
|
//设置申诉人
|
|
|
appealDTO.setAppealUserId(SecurityUtils.getUserId()); |
|
|
entity.setUserId(SecurityUtils.getUserId()); |
|
|
UserDTO user = dingUtil.getUserById(SecurityUtils.getUserId()); |
|
|
UserDTO user = userApplicationService.getDetail(SecurityUtils.getUserId()).getData(); |
|
|
appealDTO.setUserName(user.getName()); |
|
|
entity.setUsername(user.getName()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
appealBaseService.saveOrUpdate(entity); |
|
|
appealBaseService.saveOrUpdate(entity); |
|
|
@ -69,6 +73,7 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
return Result.success(appealDTO); |
|
|
return Result.success(appealDTO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
appealDTO = appealBaseService.getById(appealDTO.getId()).toDTO(AppealDTO::new); |
|
|
ExamRecordEntity examRecord = examRecordMapper.selectById(appealDTO.getExamId()); |
|
|
ExamRecordEntity examRecord = examRecordMapper.selectById(appealDTO.getExamId()); |
|
|
if (examRecord == null){ |
|
|
if (examRecord == null){ |
|
|
throw new BusinessErrorException("用户未该场考试"); |
|
|
throw new BusinessErrorException("用户未该场考试"); |
|
|
@ -81,8 +86,7 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
int index = -1; |
|
|
int index = -1; |
|
|
for (int i = 0; i < answerSnapshotDTOList.size(); i++) { |
|
|
for (int i = 0; i < answerSnapshotDTOList.size(); i++) { |
|
|
ExamRecordDTO.QuestionSnapshotDTO dto = answerSnapshotDTOList.get(i); |
|
|
ExamRecordDTO.QuestionSnapshotDTO dto = answerSnapshotDTOList.get(i); |
|
|
if (appealDTO.getQuestionId() != null |
|
|
if (Objects.equals(appealDTO.getQuestionId(), dto.getQuestionId())) { |
|
|
&& appealDTO.getQuestionId().equals(dto.getQuestionId())) { |
|
|
|
|
|
index = i; |
|
|
index = i; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
@ -94,11 +98,6 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
throw new BusinessErrorException("题目不存在"); |
|
|
throw new BusinessErrorException("题目不存在"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//已申诉题目无法再申诉
|
|
|
|
|
|
if(questionSnapshotDTO.getHasAppealed()){ |
|
|
|
|
|
throw new BusinessErrorException("题目已申诉"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecord.getTaskUserId()); |
|
|
TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecord.getTaskUserId()); |
|
|
|
|
|
|
|
|
QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(questionSnapshotDTO.getType()); |
|
|
QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(questionSnapshotDTO.getType()); |
|
|
|