| | |
| | | private ThCertService certService; |
| | | |
| | | @Override |
| | | public boolean receiveQuestionBank(JSONObject jsonObject) throws Exception { |
| | | public AjaxResult receiveQuestionBank(JSONObject jsonObject) throws Exception { |
| | | InstitutionUser institutionUser = ThreeInContextHolder.getContext(); |
| | | ThQuestionBankReqDTO questionBankReqDTO = decryptData(jsonObject, new TypeReference<ThQuestionBankReqDTO>() {},"题库数据"); |
| | | if(questionBankReqDTO==null){ |
| | | List<ThQuestionBankReqDTO> questionBankReqDTO = decryptData(jsonObject, new TypeReference<List<ThQuestionBankReqDTO>>() {},"题库数据"); |
| | | if(CollectionUtils.isEmpty(questionBankReqDTO)){ |
| | | throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"题库数据不可为空"); |
| | | } |
| | | String valdateMessage=ValidatorUtils.validateFast(questionBankReqDTO); |
| | | if(!StringUtils.isEmpty(valdateMessage)){ |
| | | throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,valdateMessage); |
| | | List<ThErrorDataRespDTO> errorDataRespDTOS = new ArrayList<>(); |
| | | List<ThQuestionBankReqDTO> thQuestionBankReqDTOS = new ArrayList<>(); |
| | | for (ThQuestionBankReqDTO thQuestionBankReqDTO : questionBankReqDTO) { |
| | | String valdateMessage=ValidatorUtils.validateFast(thQuestionBankReqDTO); |
| | | if(!StringUtils.isEmpty(valdateMessage)){ |
| | | // throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,valdateMessage); |
| | | errorDataRespDTOS.add(new ThErrorDataRespDTO(thQuestionBankReqDTO.getUuid(),valdateMessage)); |
| | | continue; |
| | | } |
| | | thQuestionBankReqDTOS.add(thQuestionBankReqDTO); |
| | | } |
| | | //根据uuid查询数据 |
| | | ThQuestionBank qb = questionBankService.getQuestionInfoByUuid(questionBankReqDTO.getUuid()); |
| | | boolean i = true; |
| | | if(qb == null){ |
| | | //新增 |
| | | qb = new ThQuestionBank(); |
| | | BeanUtils.copyProperties(questionBankReqDTO, qb); |
| | | qb.setUuid(questionBankReqDTO.getUuid()); |
| | | qb.setInstitutionId(institutionUser.getId()); |
| | | qb.setInstitutionName(institutionUser.getInstitutionalName()); |
| | | qb.setCreateBy(institutionUser.getInstitutionalName()); |
| | | qb.setUpdateBy(institutionUser.getInstitutionalName()); |
| | | i = questionBankService.save(qb); |
| | | }else { |
| | | //修改 |
| | | BeanUtils.copyProperties(questionBankReqDTO, qb); |
| | | qb.setUpdateBy(institutionUser.getInstitutionalName()); |
| | | i = questionBankService.updateById(qb); |
| | | List<ThQuestionBank> savethQuestionBanks = new ArrayList<>(); |
| | | List<ThQuestionBank> updatethQuestionBanks = new ArrayList<>(); |
| | | for (ThQuestionBankReqDTO thQuestionBankReqDTO : thQuestionBankReqDTOS) { |
| | | //根据uuid查询数据 |
| | | ThQuestionBank qb = questionBankService.getQuestionInfoByUuid(thQuestionBankReqDTO.getUuid()); |
| | | if(qb == null){ |
| | | //新增 |
| | | qb = new ThQuestionBank(); |
| | | BeanUtils.copyProperties(thQuestionBankReqDTO, qb); |
| | | qb.setUuid(thQuestionBankReqDTO.getUuid()); |
| | | qb.setInstitutionId(institutionUser.getId()); |
| | | qb.setInstitutionName(institutionUser.getInstitutionalName()); |
| | | qb.setCreateBy(institutionUser.getInstitutionalName()); |
| | | qb.setUpdateBy(institutionUser.getInstitutionalName()); |
| | | savethQuestionBanks.add(qb); |
| | | }else { |
| | | //修改 |
| | | BeanUtils.copyProperties(thQuestionBankReqDTO, qb); |
| | | qb.setUpdateBy(institutionUser.getInstitutionalName()); |
| | | updatethQuestionBanks.add(qb); |
| | | } |
| | | } |
| | | return i; |
| | | questionBankService.saveBatch(savethQuestionBanks); |
| | | questionBankService.updateBatchById(updatethQuestionBanks); |
| | | return AjaxResult.success(errorDataRespDTOS); |
| | | } |
| | | |
| | | @Transactional |