diff --git a/src/main/java/com/sztzjy/resource_center/controller/KnowledgeSummaryController.java b/src/main/java/com/sztzjy/resource_center/controller/KnowledgeSummaryController.java index c3bfc69..1a3ca1d 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/KnowledgeSummaryController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/KnowledgeSummaryController.java @@ -15,10 +15,7 @@ import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -39,13 +36,17 @@ public class KnowledgeSummaryController { @AnonymousAccess @ApiOperation("知识概要新增或修改") @PostMapping("addOrUpdate") - public ResultEntity addOrUpdate(@ApiParam("没传ID为新增,传了为修改,新增传source字段") @RequestParam SysKnowledgeSummary sysKnowledgeSummary) { + public ResultEntity addOrUpdate(@ApiParam("没传ID为新增,传了为修改,新增传source字段") @RequestBody SysKnowledgeSummary sysKnowledgeSummary) { if (StringUtils.isBlank(sysKnowledgeSummary.getContent())) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "内容不能为空!"); } //不为空修改 - if (!StringUtils.isBlank(sysKnowledgeSummary.getKnowledgeSummaryId())) { - knowledgeSummaryMapper.updateByPrimaryKey(sysKnowledgeSummary); + SysKnowledgeSummaryExample example = new SysKnowledgeSummaryExample(); + SysKnowledgeSummaryExample.Criteria criteria = example.createCriteria(); + criteria.andOneTagIdEqualTo(sysKnowledgeSummary.getOneTagId()).andThreeTagIdEqualTo(sysKnowledgeSummary.getThreeTagId()).andTwoTagIdEqualTo(sysKnowledgeSummary.getTwoTagId()); + List sysKnowledgeSummaries = knowledgeSummaryMapper.selectByExampleWithBLOBs(example); + if (sysKnowledgeSummaries != null && !sysKnowledgeSummaries.isEmpty()) { + knowledgeSummaryMapper.updateByPrimaryKeyWithBLOBs(sysKnowledgeSummary); return new ResultEntity<>(HttpStatus.OK, "修改成功!"); } @@ -102,7 +103,7 @@ public class KnowledgeSummaryController { @AnonymousAccess - @ApiOperation("知识概要条件查询") + @ApiOperation("知识概要展示") @PostMapping("selectByConditions") public ResultEntity selectByConditions(@RequestParam String oneId, @RequestParam String twoId, @@ -110,8 +111,10 @@ public class KnowledgeSummaryController { SysKnowledgeSummaryExample example = new SysKnowledgeSummaryExample(); SysKnowledgeSummaryExample.Criteria criteria = example.createCriteria(); criteria.andOneTagIdEqualTo(oneId).andThreeTagIdEqualTo(threeId).andTwoTagIdEqualTo(twoId); - List sysKnowledgeSummaries = knowledgeSummaryMapper.selectByExample(example); - return new ResultEntity(sysKnowledgeSummaries.get(0)); + List sysKnowledgeSummaries = knowledgeSummaryMapper.selectByExampleWithBLOBs(example); + if (sysKnowledgeSummaries != null && !sysKnowledgeSummaries.isEmpty()) { + return new ResultEntity(sysKnowledgeSummaries.get(0)); + } else return null; } 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 2ce10af..78c8cb0 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java @@ -96,11 +96,11 @@ public class TopicResourceController { sysTopicAndCourse.setTopicType(objectiveQuestion.getType()); sysTopicAndCourse.setOneId(objectiveQuestion.getOneID()); sysTopicAndCourse.setOneName(objectiveQuestion.getOneName()); - if (StringUtils.isNotBlank(sysTopicAndCourse.getTwoId())) { + if (StringUtils.isNotBlank(objectiveQuestion.getTwoID())) { sysTopicAndCourse.setTwoId(sysTopicAndCourse.getTwoId()); sysTopicAndCourse.setTwoName(objectiveQuestion.getTwoName()); } - if (StringUtils.isNotBlank(sysTopicAndCourse.getThreeId())) { + if (StringUtils.isNotBlank(objectiveQuestion.getThreeID())) { sysTopicAndCourse.setThreeId(sysTopicAndCourse.getThreeId()); sysTopicAndCourse.setThreeName(objectiveQuestion.getThreeName()); } @@ -160,9 +160,10 @@ public class TopicResourceController { @RequestParam(required = false) String oneID, @RequestParam(required = false) String twoID, @RequestParam(required = false) String threeID, + @RequestParam(required = false) String type, @ApiParam("题干") @RequestParam(required = false) String content) { PageHelper.startPage(index, size); - List list = sysObjectiveQuestionMapper.selectTopicByConditions(oneID, twoID, threeID, content); + List list = sysObjectiveQuestionMapper.selectTopicByConditions(oneID, twoID, threeID, type,content); PageInfo pageInfo = new PageInfo(list); return new ResultEntity>(pageInfo); } diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java index f7a4062..ab07704 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java @@ -61,16 +61,15 @@ public class CourseApi { @AnonymousAccess @ApiOperation("添加二级目录") @PostMapping("insertSysTwoCatalog") - public Boolean insertSysTwoCatalog(@RequestBody SysTwoCatalog sysTwoCatalog, @RequestParam String systemOwner) { - SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner); + public Boolean insertSysTwoCatalog(@RequestBody SysTwoCatalog sysTwoCatalog) { + SysOneCatalog sysOneCatalogs = getSysOneCatalogs(sysTwoCatalog.getOneId()); if (sysOneCatalogs == null) { return false; } - String oneName = sysOneCatalogs.getOneName(); + String oneId = sysOneCatalogs.getOneId(); sysTwoCatalog.setTwoId(IdUtil.randomUUID()); - sysTwoCatalog.setOneId(oneName); + sysTwoCatalog.setOneId(oneId); sysTwoCatalog.setCreateTime(new Date()); - sysTwoCatalog.setCreator(sysTwoCatalog.getCreator()); sysTwoCatalog.setSort(null); twoCatalogMapper.insert(sysTwoCatalog); return true; @@ -87,9 +86,9 @@ public class CourseApi { @AnonymousAccess @ApiOperation("添加三级目录") @PostMapping("insertSysThreeCatalog") - public Boolean insertSysThreeCatalog(@RequestBody SysThreeCatalog sysThreeCatalog, @RequestParam String systemOwner) { + public Boolean insertSysThreeCatalog(@RequestBody SysThreeCatalog sysThreeCatalog) { try { - SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner); + SysOneCatalog sysOneCatalogs = getSysOneCatalogs(sysThreeCatalog.getOntId()); sysThreeCatalog.setThreeId(IdUtil.randomUUID()); sysThreeCatalog.setOntId(sysOneCatalogs.getOneId()); sysThreeCatalog.setCreateTime(new Date()); diff --git a/src/main/java/com/sztzjy/resource_center/mapper/SysObjectiveQuestionsMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/SysObjectiveQuestionsMapper.java index e1f8193..41c8f24 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/SysObjectiveQuestionsMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/SysObjectiveQuestionsMapper.java @@ -34,6 +34,7 @@ public interface SysObjectiveQuestionsMapper { List selectTopicByConditions(@Param("oneID")String oneID, @Param("twoID") String twoID, @Param("threeID") String threeID, + @Param("type")String type, @Param("content") String content); int insertBatch(@Param("objectiveQuestionList") List objectiveQuestionList); diff --git a/src/main/resources/mapper/SysObjectiveQuestionsMapper.xml b/src/main/resources/mapper/SysObjectiveQuestionsMapper.xml index a7f06a7..e92d3f2 100644 --- a/src/main/resources/mapper/SysObjectiveQuestionsMapper.xml +++ b/src/main/resources/mapper/SysObjectiveQuestionsMapper.xml @@ -400,13 +400,16 @@ on sb.objective_id = st.topic_id - sb.one_id = #{oneID} + st.one_id = #{oneID} - and sb.two_id = #{twoID} + and st.two_id = #{twoID} - and sb.three_id = #{threeID} + and st.three_id = #{threeID} + + + and sb.type = #{type} and sb.content = #{content}