From 16bac95deeb771698c40f8aefc76b5fad164620a Mon Sep 17 00:00:00 2001 From: Lqc Date: Tue, 16 Sep 2025 00:31:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E7=9B=AE=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AiolQuestionController.java | 30 ++++++++++++++++--- .../aiol/service/IAiolQuestionService.java | 3 ++ .../service/impl/AiolQuestionServiceImpl.java | 16 ++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolQuestionController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolQuestionController.java index e3fd502d..70712a23 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolQuestionController.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolQuestionController.java @@ -80,7 +80,7 @@ public class AiolQuestionController extends JeecgController pageList = aiolQuestionService.page(page, queryWrapper); return Result.OK(pageList); } - + /** * 添加 * @@ -93,16 +93,38 @@ public class AiolQuestionController extends JeecgController add(@RequestBody AiolQuestion aiolQuestion,@RequestParam String repoId) { + aiolQuestion.setStatus(1); aiolQuestionService.save(aiolQuestion); //题库题目添加 if(repoId!=null&& !repoId.isEmpty()){ AiolQuestionRepo aiolQuestionRepo = new AiolQuestionRepo(); aiolQuestionRepo.setRepoId(repoId); aiolQuestionRepo.setQuestionId(aiolQuestion.getId()); + aiolQuestionRepoController.add(aiolQuestionRepo); } return Result.OK(aiolQuestion.getId()); } + + @AutoLog(value = "题目-是否入库") + @Operation(summary="题目-是否入库") + @PostMapping(value = "/whetherPutStorage") + public Result whetherPutStorage(@RequestBody List ids){ + try { + // 参数校验 + if (ids == null || ids.isEmpty()) { + return Result.error("参数不能为空"); + } + + // 调用服务层更新状态 + aiolQuestionService.updateStatusByIds(ids); + + return Result.OK("操作成功"); + } catch (Exception e) { + log.error("更新题目状态失败", e); + return Result.error("操作失败:" + e.getMessage()); + } + } /** * 编辑 @@ -118,7 +140,7 @@ public class AiolQuestionController extends JeecgController { + void updateStatusByIds(List ids); } diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/service/impl/AiolQuestionServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/service/impl/AiolQuestionServiceImpl.java index 782e18d8..2c63850e 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/service/impl/AiolQuestionServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/service/impl/AiolQuestionServiceImpl.java @@ -1,5 +1,7 @@ package org.jeecg.modules.aiol.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import org.jeecg.modules.aiol.entity.AiolQuestion; import org.jeecg.modules.aiol.mapper.AiolQuestionMapper; import org.jeecg.modules.aiol.service.IAiolQuestionService; @@ -7,6 +9,8 @@ import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.List; + /** * @Description: 题目 * @Author: jeecg-boot @@ -16,4 +20,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @Service public class AiolQuestionServiceImpl extends ServiceImpl implements IAiolQuestionService { + @Override + public void updateStatusByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new IllegalArgumentException("题目ID列表不能为空"); + } + + // 批量更新 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.in(AiolQuestion::getId, ids) + .setSql("status = CASE WHEN status IS NULL OR status = 1 THEN 0 ELSE 1 END"); + this.update(updateWrapper); + } }