From f0e8ed5125514299546729b254318b1776543e61 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Fri, 19 Jul 2024 17:54:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/api/CaseApi.java | 23 ++++++++++++++----- .../new_module/admin/AdminCaseController.java | 11 ++++++--- .../new_module/stu/StuCaseController.java | 12 ++++++++-- .../mapper/admin/AdminCaseMapper.java | 4 ++-- .../mapper/SysCaseQuestionMapper.xml | 6 +++-- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/CaseApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/CaseApi.java index 7ffda6d..0fc50e1 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/CaseApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/CaseApi.java @@ -71,8 +71,7 @@ public class CaseApi { sysTopicAndCourse.setId(IdUtil.randomUUID()); sysTopicAndCourse.setTopicType("1"); sysTopicAndCourse.setTopicId(uuid); - SysOneCatalog sysOneCatalogs = getSysOneCatalogs(sysCaseQuestion.getOneName()); - String oneId = sysOneCatalogs.getOneId(); + String oneId = sysOneCatalogs1.getOneId(); sysTopicAndCourse.setOneId(oneId); sysTopicAndCourse.setOneName(sysCaseQuestion.getOneName()); if (StringUtils.isNotBlank(sysCaseQuestion.getTwoId())) { @@ -98,7 +97,7 @@ public class CaseApi { @AnonymousAccess @ApiOperation("案例题页面查询") @PostMapping("selectCaseList") - public PageInfo selectCaseByConditions(@RequestParam Integer index, + public PageInfo selectCaseList(@RequestParam Integer index, @RequestParam Integer size, @RequestParam(required = false) String keyword, @RequestParam(required = false) String systemOwner, @@ -114,9 +113,21 @@ public class CaseApi { @AnonymousAccess @ApiOperation("案例题详细内容展示") @PostMapping("selectCaseDetails") - public SysCaseQuestion selectCaseByConditionsByID(@RequestParam String caseId) { - return caseQuestionMapper.selectByPrimaryKey(caseId); - + public SysCaseQuestion selectCaseByConditionsByID(@RequestParam String caseId, + @RequestParam String oneId) { + SysTopicAndCourseExample example = new SysTopicAndCourseExample(); + example.createCriteria().andOneIdEqualTo(oneId).andTopicIdEqualTo(caseId); + List sysTopicAndCourses = topicAndCourseMapper.selectByExample(example); + if (sysTopicAndCourses != null && !sysTopicAndCourses.isEmpty()) { + SysTopicAndCourse sysTopicAndCourse = sysTopicAndCourses.get(0); + SysCaseQuestion sysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(caseId); + sysCaseQuestion.setTwoId(sysTopicAndCourse.getTwoId()); + sysCaseQuestion.setTwoName(sysTopicAndCourse.getTwoName()); + sysCaseQuestion.setThreeId(sysTopicAndCourse.getThreeId()); + sysCaseQuestion.setThreeName(sysTopicAndCourse.getThreeName()); + return sysCaseQuestion; + } + return null; } diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java index 9711638..56a9590 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java @@ -1,7 +1,6 @@ package com.sztzjy.resource_center.controller.new_module.admin; import cn.hutool.core.util.IdUtil; -import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.reflect.TypeToken; import com.nimbusds.jose.shaded.gson.Gson; @@ -29,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -231,8 +231,13 @@ public class AdminCaseController { @RequestParam Integer size, @RequestParam(required = false) String keyWord, @ApiParam("精品案例不传,院校案例传'院校案例'") @RequestParam(required = false) String source, - @RequestParam(required = false) List labelName) { - List adminCaseReturnDtos = adminCaseMapper.selectByConditions(keyWord, source, labelName); + @RequestParam(required = false) String labelName) { + List list = new ArrayList<>(); + if (StringUtils.isNotBlank(labelName)) { + String[] split = labelName.split(","); + list = Arrays.asList(split); + } + List adminCaseReturnDtos = adminCaseMapper.selectByConditions(keyWord, source, list); PageInfo pageInfo = PageUtil.pageHelper(adminCaseReturnDtos, index, size); return new ResultEntity<>(pageInfo); } diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuCaseController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuCaseController.java index c6b8b04..11d43c8 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuCaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuCaseController.java @@ -16,6 +16,7 @@ import com.sztzjy.resource_center.util.file.IFileUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -24,6 +25,8 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -74,8 +77,13 @@ public class StuCaseController { @RequestParam(required = false) String keyWord, @ApiParam("精品案例传管理员,院校案例传学校ID") @RequestParam(required = false) String source, @ApiParam("收藏案例页面传") @RequestParam(required = false) String userId, - @RequestParam(required = false) List labelName) { - List adminCaseReturnDtos = adminCaseMapper.selectByConditionsByStu(keyWord, source, userId, labelName); + @RequestParam(required = false) String labelName) { + List list = new ArrayList<>(); + if (StringUtils.isNotBlank(labelName)) { + String[] split = labelName.split(","); + list = Arrays.asList(split); + } + List adminCaseReturnDtos = adminCaseMapper.selectByConditionsByStu(keyWord, source, userId, list); PageInfo pageInfo = PageUtil.pageHelper(adminCaseReturnDtos, index, size); return new ResultEntity<>(pageInfo); } diff --git a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminCaseMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminCaseMapper.java index 28db229..c6ad48d 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminCaseMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminCaseMapper.java @@ -42,10 +42,10 @@ public interface AdminCaseMapper { List selectByConditionsByStu(@Param("keyWord") String keyWord, @Param("source") String source, @Param("userId") String userId, - @Param("labelName") List labelName); + @Param("labelName") List list); List selectByConditions(@Param("keyWord") String keyWord, @Param("source") String source, - @Param("labelName") List labelName); + @Param("labelName") List list); } \ No newline at end of file diff --git a/src/main/resources/mapper/SysCaseQuestionMapper.xml b/src/main/resources/mapper/SysCaseQuestionMapper.xml index 2d3a50c..9d45f04 100644 --- a/src/main/resources/mapper/SysCaseQuestionMapper.xml +++ b/src/main/resources/mapper/SysCaseQuestionMapper.xml @@ -435,7 +435,9 @@