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 8ab676c..368a554 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CaseController.java @@ -63,12 +63,8 @@ public class CaseController { if (!sysCaseQuestions.isEmpty()) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "案例名称不能重复!"); } - String uuid = IdUtil.randomUUID(); - sysCaseQuestion.setCaseId(uuid); - sysCaseQuestion.setCreateTime(new Date()); - sysCaseQuestion.setUnmountStatus(false); - caseQuestionMapper.insert(sysCaseQuestion); + //新增绑定关系 SysTopicAndCourse sysTopicAndCourse = new SysTopicAndCourse(); sysTopicAndCourse.setId(IdUtil.randomUUID()); @@ -85,6 +81,10 @@ public class CaseController { sysTopicAndCourse.setThreeName(sysCaseQuestion.getThreeName()); } topicAndCourseMapper.insert(sysTopicAndCourse); + sysCaseQuestion.setCaseId(uuid); + sysCaseQuestion.setCreateTime(new Date()); + sysCaseQuestion.setUnmountStatus(false); + caseQuestionMapper.insert(sysCaseQuestion); return new ResultEntity<>(HttpStatus.OK, "新增成功!"); } @@ -122,11 +122,16 @@ public class CaseController { @AnonymousAccess @ApiOperation("案例题详细内容展示") @PostMapping("selectCaseByConditionsByID") - public ResultEntity selectCaseByConditionsByID(@RequestParam String caseId) { + public ResultEntity selectCaseByConditionsByID(@RequestParam String caseId, + @RequestParam(required = false) String oneId) { SysCaseQuestion sysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(caseId); SysTopicAndCourseExample example = new SysTopicAndCourseExample(); - example.createCriteria().andTopicIdEqualTo(caseId); + SysTopicAndCourseExample.Criteria criteria = example.createCriteria(); + criteria.andTopicIdEqualTo(caseId); + if (StringUtils.isNotBlank(oneId)) { + criteria.andOneIdEqualTo(oneId); + } List topicAndCourseList = topicAndCourseMapper.selectByExample(example); if (!topicAndCourseList.isEmpty()) { SysTopicAndCourse sysTopicAndCourse = topicAndCourseList.get(0); @@ -168,6 +173,18 @@ public class CaseController { sysTopicAndCourse.setTwoName(sysCaseQuestion.getTwoName()); sysTopicAndCourse.setThreeName(sysCaseQuestion.getThreeName()); topicAndCourseMapper.updateByPrimaryKeySelective(sysTopicAndCourse); + } else { + SysTopicAndCourse sysTopicAndCourse = new SysTopicAndCourse(); + sysTopicAndCourse.setId(IdUtil.randomUUID()); + sysTopicAndCourse.setTopicId(sysCaseQuestion.getCaseId()); + sysTopicAndCourse.setOneId(sysCaseQuestion.getOneId()); + sysTopicAndCourse.setOneName(sysCaseQuestion.getOneName()); + sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId()); + sysTopicAndCourse.setThreeId(sysCaseQuestion.getThreeId()); + sysTopicAndCourse.setTwoName(sysCaseQuestion.getTwoName()); + sysTopicAndCourse.setThreeName(sysCaseQuestion.getThreeName()); + sysTopicAndCourse.setTopicType("1"); + topicAndCourseMapper.insert(sysTopicAndCourse); } caseQuestionMapper.updateByPrimaryKeySelective(sysCaseQuestion); return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); diff --git a/src/main/java/com/sztzjy/resource_center/controller/CourseConfigController.java b/src/main/java/com/sztzjy/resource_center/controller/CourseConfigController.java index 974f601..d5773e9 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CourseConfigController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CourseConfigController.java @@ -4,7 +4,6 @@ import cn.hutool.core.util.IdUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.sztzjy.resource_center.annotation.AnonymousAccess; -import com.sztzjy.resource_center.entity.SysCaseQuestionExample; import com.sztzjy.resource_center.entity.SysResource; import com.sztzjy.resource_center.entity.SysResourceAndCourse; import com.sztzjy.resource_center.entity.SysResourceAndCourseExample; @@ -128,10 +127,11 @@ public class CourseConfigController { public ResultEntity> selectResource(@ApiParam("课程ID") @RequestParam(required = false) String oneID, @ApiParam("章ID") @RequestParam(required = false) String twoID, @ApiParam("节ID") @RequestParam(required = false) String threeID, + @ApiParam("资源名称") @RequestParam(required = false) String name, @RequestParam Integer index, @RequestParam Integer size) { PageHelper.startPage(index, size); - List sysResourceDtos = sysResourceMapper.selectResource(oneID, twoID, threeID,null); + List sysResourceDtos = sysResourceMapper.selectResource(oneID, twoID, threeID, name,null); PageInfo pageInfo = new PageInfo(sysResourceDtos); return new ResultEntity>(pageInfo); } @@ -162,5 +162,4 @@ public class CourseConfigController { } return new ResultEntity<>(HttpStatus.OK, "删除成功!"); } - } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java b/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java index e186c1a..6dd2dcd 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java @@ -241,14 +241,12 @@ public class TopicResourceController { @ApiOperation("删除题目绑定关系") @PostMapping("deleteTopicBinding") private ResultEntity deleteTopicBinding(@RequestParam String id, - @RequestParam(required = false) String oneId, + @RequestParam String oneId, @RequestParam(required = false) String twoId, @RequestParam(required = false) String threeId) { SysTopicAndCourseExample example = new SysTopicAndCourseExample(); SysTopicAndCourseExample.Criteria criteria = example.createCriteria(); - if (StringUtils.isNotBlank(oneId)) { - criteria.andOneIdEqualTo(oneId); - } + criteria.andOneIdEqualTo(oneId); if (StringUtils.isNotBlank(twoId)) { criteria.andTwoIdEqualTo(twoId); } @@ -388,8 +386,8 @@ public class TopicResourceController { String threeId = threeIdMap.get(threeName); if (threeId == null) { threeId = sysThreeCatalogMapper.getIdByName(twoName, threeName); - if (threeId==null){ - return new ResultEntity(HttpStatus.INTERNAL_SERVER_ERROR,"导入关联的章节不存在,请在添加后重新导入"); + if (threeId == null) { + return new ResultEntity(HttpStatus.INTERNAL_SERVER_ERROR, "导入关联的章节不存在,请在添加后重新导入"); } threeIdMap.put(threeName, threeId); } 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 989b15e..8e31e6e 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 @@ -63,10 +63,7 @@ public class CaseApi { } String uuid = IdUtil.randomUUID(); - sysCaseQuestion.setCaseId(uuid); - sysCaseQuestion.setCreateTime(new Date()); - sysCaseQuestion.setUnmountStatus(false); - caseQuestionMapper.insert(sysCaseQuestion); + //新增绑定关系 SysTopicAndCourse sysTopicAndCourse = new SysTopicAndCourse(); sysTopicAndCourse.setId(IdUtil.randomUUID()); @@ -83,6 +80,18 @@ public class CaseApi { sysTopicAndCourse.setThreeName(sysCaseQuestion.getThreeName()); } topicAndCourseMapper.insert(sysTopicAndCourse); + + sysCaseQuestion.setOneId(null); + sysCaseQuestion.setOneName(null); + sysCaseQuestion.setTwoId(null); + sysCaseQuestion.setTwoName(null); + sysCaseQuestion.setThreeId(null); + sysCaseQuestion.setThreeName(null); //这几个参数只是方便前端传 , 不能直接插入,否则展示会有问题 + sysCaseQuestion.setCaseId(uuid); + sysCaseQuestion.setCreateTime(new Date()); + sysCaseQuestion.setUnmountStatus(false); + caseQuestionMapper.insert(sysCaseQuestion); + return true; } @@ -343,7 +352,8 @@ public class CaseApi { @RequestParam String systemOwner) { SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner); String oneId = sysOneCatalogs.getOneId(); - return caseQuestionStepMapper.getGradeReportCase(caseIdList, schoolId, oneId); + List gradeReportCase = caseQuestionStepMapper.getGradeReportCase(caseIdList, schoolId, oneId); + return gradeReportCase; } diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/ResourceApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/ResourceApi.java index 5fb3a2b..90e3b32 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/ResourceApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/ResourceApi.java @@ -128,7 +128,7 @@ public class ResourceApi { @RequestParam String twoId, @RequestParam String schoolId) { SysOneCatalog sysOneCatalogs = getSysOneCatalogs(oneId); - return sysResourceMapper.selectResource(sysOneCatalogs.getOneId(), twoId, null, schoolId); + return sysResourceMapper.selectResource(sysOneCatalogs.getOneId(), twoId, null, null, schoolId); } @@ -144,7 +144,7 @@ public class ResourceApi { public List selectResourceByChapterId(@RequestParam String oneId, //这里传的是一级的名称 @RequestParam String threeId) { SysOneCatalog sysOneCatalogs = getSysOneCatalogs(oneId); - return sysResourceMapper.selectResource(sysOneCatalogs.getOneId(), null, threeId, null); + return sysResourceMapper.selectResource(sysOneCatalogs.getOneId(), null, null, threeId, null); } diff --git a/src/main/java/com/sztzjy/resource_center/mapper/SysResourceMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/SysResourceMapper.java index ab20183..871454e 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/SysResourceMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/SysResourceMapper.java @@ -2,14 +2,14 @@ package com.sztzjy.resource_center.mapper; import com.sztzjy.resource_center.entity.SysResource; import com.sztzjy.resource_center.entity.SysResourceExample; -import java.util.List; -import java.util.Map; - import com.sztzjy.resource_center.entity.dto.SysResourceDto; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; +import java.util.List; +import java.util.Map; + @Mapper public interface SysResourceMapper { long countByExample(SysResourceExample example); @@ -38,6 +38,7 @@ public interface SysResourceMapper { List selectResource(@Param("oneId") String oneId, @Param("twoId") String twoId, @Param("threeId") String threeId, + @Param("name") String name, @Param("source") String source); List selectResourceByRepeat(@Param("oneId") String oneId, diff --git a/src/main/resources/mapper/SysCaseQuestionMapper.xml b/src/main/resources/mapper/SysCaseQuestionMapper.xml index 8d07e56..18191bb 100644 --- a/src/main/resources/mapper/SysCaseQuestionMapper.xml +++ b/src/main/resources/mapper/SysCaseQuestionMapper.xml @@ -141,14 +141,10 @@ insert into sys_case_questions (case_id, title, resource_data, - source, type, one_id, - one_name, two_id, two_name, - three_id, three_name, unmount_status, + source, type, unmount_status, create_time, update_time, content) values (#{caseId,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{resourceData,jdbcType=VARCHAR}, - #{source,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{oneId,jdbcType=VARCHAR}, - #{oneName,jdbcType=VARCHAR}, #{twoId,jdbcType=VARCHAR}, #{twoName,jdbcType=VARCHAR}, - #{threeId,jdbcType=VARCHAR}, #{threeName,jdbcType=VARCHAR}, #{unmountStatus,jdbcType=BIT}, + #{source,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{unmountStatus,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR}) @@ -364,24 +360,6 @@ type = #{type,jdbcType=VARCHAR}, - - one_id = #{oneId,jdbcType=VARCHAR}, - - - one_name = #{oneName,jdbcType=VARCHAR}, - - - two_id = #{twoId,jdbcType=VARCHAR}, - - - two_name = #{twoName,jdbcType=VARCHAR}, - - - three_id = #{threeId,jdbcType=VARCHAR}, - - - three_name = #{threeName,jdbcType=VARCHAR}, - unmount_status = #{unmountStatus,jdbcType=BIT}, diff --git a/src/main/resources/mapper/SysCaseQuestionStepMapper.xml b/src/main/resources/mapper/SysCaseQuestionStepMapper.xml index 809df3a..71939cc 100644 --- a/src/main/resources/mapper/SysCaseQuestionStepMapper.xml +++ b/src/main/resources/mapper/SysCaseQuestionStepMapper.xml @@ -389,7 +389,7 @@ - + @@ -401,7 +401,7 @@ JOIN sys_case_questions s2 ON s1.case_id = s2.case_id JOIN sys_topic_and_course s3 ON s2.case_id = s3.topic_id WHERE s2.case_id IN - + #{id} and s2.source in ('管理员', #{schoolId}) diff --git a/src/main/resources/mapper/SysResourceMapper.xml b/src/main/resources/mapper/SysResourceMapper.xml index 18c5bf4..1f81437 100644 --- a/src/main/resources/mapper/SysResourceMapper.xml +++ b/src/main/resources/mapper/SysResourceMapper.xml @@ -429,6 +429,9 @@ and sr.source in (#{source},'管理员') + + and sr.resource_name LIKE CONCAT('%', #{name}, '%') + order by sr.create_time