| | |
| | | return res == 1 |
| | | } |
| | | |
| | | override fun updateQuestionAndImage(question: String, deleteImg: String, files: Array<MultipartFile>): Boolean { |
| | | override fun updateQuestionAndImage(question: String, deleteImg: String?, files: Array<MultipartFile>?): Boolean { |
| | | val questionVo = Gson().fromJson(question, ClueQuestion::class.java) |
| | | val oldOne = clueQuestionMapper.selectByPrimaryKey(questionVo.cqId) ?: throw BizException("问题不存在") |
| | | if (oldOne.cqUploaded) throw BizException("问题已上传,无法修改") |
| | | deleteImageFile(questionVo, deleteImg) |
| | | val picPath = saveImageFile(questionVo, files) |
| | | if (questionVo.cqFilePath.isEmpty()) { |
| | | questionVo.cqFilePath = picPath |
| | | } else { |
| | | questionVo.cqFilePath += ";${picPath}" |
| | | if (deleteImg != null) deleteImageFile(questionVo, deleteImg) |
| | | if (files != null) { |
| | | val picPath = saveImageFile(questionVo, files) |
| | | if (questionVo.cqFilePath.isEmpty()) { |
| | | questionVo.cqFilePath = picPath |
| | | } else { |
| | | questionVo.cqFilePath += ";${picPath}" |
| | | } |
| | | } |
| | | questionVo.cqCreateTime = Date() |
| | | val res = clueQuestionMapper.updateByPrimaryKeySelective(questionVo) |
| | |
| | | val oldOne = clueQuestionMapper.selectByPrimaryKey(questionId) ?: throw BizException("问题不存在") |
| | | if (oldOne.cqUploaded) throw BizException("问题已上传,无法删除") |
| | | deleteImageDirectory(oldOne) |
| | | |
| | | PageHelper.startPage<ClueQuestion>(1, 1) |
| | | clueQuestionMapper.selectByExample(Example(ClueQuestion::class.java).apply { |
| | | createCriteria().andEqualTo("cId", oldOne.cId) |
| | | orderBy("cqUid").desc() |
| | | })?.takeIf { it.isNotEmpty() }?.let { |
| | | val q = it[0] |
| | | if (q?.cqUid != oldOne.cqUid) { |
| | | q?.cqUid = oldOne.cqUid |
| | | clueQuestionMapper.updateByPrimaryKeySelective(q) |
| | | } |
| | | } |
| | | |
| | | // clueQuestionMapper.select |
| | | val res = clueQuestionMapper.deleteByPrimaryKey(questionId) |
| | | return res == 1 |
| | | } |
| | |
| | | ) |
| | | } |
| | | } |
| | | orderBy("cqId") |
| | | orderBy("cqUid") |
| | | }) |
| | | return res |
| | | } |