| | |
| | | import com.project.enforce.domain.EnforceEvaluateQuestion; |
| | | import com.project.enforce.domain.bo.editBo.EnforceEvaluateBo; |
| | | import com.project.enforce.domain.vo.EnforceEvaluateVo; |
| | | import com.project.enforce.service.IEnforceEvaluateAnswerService; |
| | | import com.project.enforce.service.IEnforceEvaluateQuestionService; |
| | | import com.project.enforce.service.IEnforceEvaluateService; |
| | | import com.project.enforce.service.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | private final IEnforceEvaluateQuestionService questionService; |
| | | private final IEnforceEvaluateAnswerService answerService; |
| | | private final IEnforceOrderService orderService; |
| | | private final IEnforceEvaluateLogService evaluateLogService; |
| | | |
| | | |
| | | @Override//保存 |
| | | @Transactional |
| | | public Boolean save(EnforceEvaluateBo bo) |
| | | { |
| | | questionService.clearQuestionAndAnswer(); |
| | | List<EnforceEvaluateQuestion> questionList = bo.getQuestionList(); |
| | | if (StringUtils.isEmpty(questionList)){ |
| | | throw new BaseException("题目不可为空!"); |
| | | throw new BaseException("评价项不可为空!"); |
| | | } |
| | | for (EnforceEvaluateQuestion question : bo.getQuestionList()) { |
| | | if (question.getQuestionType()==1 && StringUtils.isEmpty(question.getAnswerList())){ |
| | |
| | | int count = questionService.count(questionService.lq() |
| | | .eq(EnforceEvaluateQuestion::getQuestionName, question.getQuestionId())); |
| | | if (count>0) { |
| | | throw new BaseException(StringUtils.format("{},题目重复,请重试!", question.getQuestionName())); |
| | | throw new BaseException(StringUtils.format("{},重复,请重试!", question.getQuestionName())); |
| | | } |
| | | if (StringUtils.isNotEmpty(question.getAnswerList())){ |
| | | EnforceEvaluateQuestion one = questionService.getOne(questionService.lq().eq(EnforceEvaluateQuestion::getQuestionName, question.getQuestionName())); |
| | | question.getAnswerList().forEach(enforceEvaluateAnswer -> { |
| | | enforceEvaluateAnswer.setQuestionId(one.getQuestionId()); |
| | | enforceEvaluateAnswer.setQuestionName(one.getQuestionName()); |
| | | }); |
| | | } |
| | | |
| | | } else { |
| | | int count = questionService.count(questionService.lq(). |
| | | eq(EnforceEvaluateQuestion::getQuestionName, question.getQuestionId()) |
| | |
| | | } |
| | | questionService.saveOrUpdate(question); |
| | | if (StringUtils.isNotEmpty(question.getAnswerList())){ |
| | | EnforceEvaluateQuestion one = questionService.getOne(questionService.lq().eq(EnforceEvaluateQuestion::getQuestionName, question.getQuestionName())); |
| | | question.getAnswerList().forEach(enforceEvaluateAnswer -> { |
| | | enforceEvaluateAnswer.setQuestionId(one.getQuestionId()); |
| | | enforceEvaluateAnswer.setQuestionName(one.getQuestionName()); |
| | | }); |
| | | answerService.saveOrUpdateBatch(question.getAnswerList()); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | return true; |
| | | } |
| | | |
| | | @Override//评价设置详情 |
| | |
| | | vo.setQuestionList(questionList); |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | } |