From 84569abda51ecf6c5549dec4cadee8d043422379 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 30 九月 2025 09:33:28 +0800 Subject: [PATCH] 2025.9.30 --- src/main/kotlin/com/flightfeather/grid/service/impl/ClueQuestionServiceImpl.kt | 32 ++++++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/grid/service/impl/ClueQuestionServiceImpl.kt b/src/main/kotlin/com/flightfeather/grid/service/impl/ClueQuestionServiceImpl.kt index e224ef5..4da2338 100644 --- a/src/main/kotlin/com/flightfeather/grid/service/impl/ClueQuestionServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/grid/service/impl/ClueQuestionServiceImpl.kt @@ -35,16 +35,18 @@ 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) @@ -55,6 +57,20 @@ 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 } @@ -147,7 +163,7 @@ ) } } - orderBy("cqId") + orderBy("cqUid") }) return res } -- Gitblit v1.9.3