From b64d3ed42b02cee727a99ea5045be0b3a3a58dbf Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Thu, 19 Dec 2024 13:56:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A1=88=E4=BE=8B=E9=A2=98?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=92=8C=E6=A1=88=E4=BE=8B=E9=A2=98=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CaseController.java | 19 +++++++++---------- .../controller/CaseStepController.java | 8 ++++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/sztzjy/resource_center/controller/CaseController.java b/src/main/java/com/sztzjy/resource_center/controller/CaseController.java index 59afb25..999b34a 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CaseController.java @@ -202,18 +202,17 @@ public class CaseController { public ResultEntity deleteCase(@RequestBody SysCaseQuestion sysCaseQuestion, @ApiParam("哪个用的掉的请求,传管理员/学校ID") @RequestParam String source) { List sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId(), sysCaseQuestion.getOneId()); -// if (!sysTopicAndCourses.isEmpty()) { -// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!"); -// } else { - //todo 管理员任意删除 老师只能删除自己上传的 - if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) { - topicAndCourseMapper.deleteByPrimaryKey(sysTopicAndCourses.get(0).getId()); - caseQuestionMapper.deleteByPrimaryKey(sysCaseQuestion.getCaseId()); - return new ResultEntity<>(HttpStatus.OK, "删除成功!"); + if (!sysTopicAndCourses.isEmpty()) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!"); } else { - return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!"); + if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) { + topicAndCourseMapper.deleteByPrimaryKey(sysTopicAndCourses.get(0).getId()); + caseQuestionMapper.deleteByPrimaryKey(sysCaseQuestion.getCaseId()); + return new ResultEntity<>(HttpStatus.OK, "删除成功!"); + } else { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!"); + } } -// } } private List getSysTopicAndCourses(String caseId, String oneId) { diff --git a/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java b/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java index 225c595..9c883a6 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java @@ -77,10 +77,10 @@ public class CaseStepController { @PostMapping("deleteCase") public ResultEntity deleteCase(@RequestBody SysCaseQuestionStepWithBLOBs sysCaseQuestionStep, @ApiParam("哪个用的掉的请求,传管理员/学校ID") @RequestParam String source) { -// List sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestionStep.getCaseId()); -// if (!sysTopicAndCourses.isEmpty()) { -// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!"); todo 暂时把判断去掉 -// } + List sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestionStep.getCaseId()); + if (!sysTopicAndCourses.isEmpty()) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!"); + } //todo 管理员任意删除 老师只能删除自己上传的 SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(sysCaseQuestionStep.getCaseId()); if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {