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 a836357..2c21a85 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CaseController.java @@ -1,8 +1,11 @@ package com.sztzjy.resource_center.controller; 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.SysCaseQuestion; +import com.sztzjy.resource_center.entity.SysCaseQuestionExample; import com.sztzjy.resource_center.entity.SysTopicAndCourse; import com.sztzjy.resource_center.mapper.SysCaseQuestionMapper; import com.sztzjy.resource_center.mapper.SysCaseQuestionStepMapper; @@ -14,12 +17,10 @@ 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.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.Date; +import java.util.List; /** * @Author xcj @@ -43,33 +44,78 @@ public class CaseController { @PostMapping("insertCase") public ResultEntity insertCase(@ApiParam("目前二级三级ID可以为空,来源和题型要传,上架状态传true") @RequestBody SysCaseQuestion sysCaseQuestion) { if (!("1").equals(sysCaseQuestion.getType())) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST,"题型错误!"); + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "题型错误!"); } if (StringUtils.isBlank(sysCaseQuestion.getOneId())) { //todo 目前二级三级ID可以为空 - return new ResultEntity<>(HttpStatus.BAD_REQUEST,"课程不能为空!"); + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "课程不能为空!"); } - if (StringUtils.isBlank(sysCaseQuestion.getContent())||StringUtils.isBlank(sysCaseQuestion.getTitle())) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST,"题目内容不能为空!"); + if (StringUtils.isBlank(sysCaseQuestion.getContent()) || StringUtils.isBlank(sysCaseQuestion.getTitle())) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "题目内容不能为空!"); } if (StringUtils.isBlank(sysCaseQuestion.getSource())) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST,"题目来源不能为空!"); + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "题目来源不能为空!"); } + String title = sysCaseQuestion.getTitle(); + SysCaseQuestionExample example = new SysCaseQuestionExample(); + example.createCriteria().andTitleEqualTo(title); + List sysCaseQuestions = caseQuestionMapper.selectByExample(example); + if (!sysCaseQuestions.isEmpty()) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "案例名称不能重复!"); + } + String uuid = IdUtil.randomUUID(); sysCaseQuestion.setCaseId(uuid); sysCaseQuestion.setCreateTime(new Date()); caseQuestionMapper.insert(sysCaseQuestion); //新增绑定关系 - SysTopicAndCourse sysTopicAndCourse =new SysTopicAndCourse(); + SysTopicAndCourse sysTopicAndCourse = new SysTopicAndCourse(); sysTopicAndCourse.setTopicType("1"); sysTopicAndCourse.setTopicId(uuid); sysTopicAndCourse.setOneId(sysCaseQuestion.getOneId()); - if (StringUtils.isNotBlank(sysCaseQuestion.getTwoId())){ + if (StringUtils.isNotBlank(sysCaseQuestion.getTwoId())) { sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId()); } - if (StringUtils.isNotBlank(sysCaseQuestion.getThree())){ + if (StringUtils.isNotBlank(sysCaseQuestion.getThree())) { sysTopicAndCourse.setThreeId(sysCaseQuestion.getThree()); } topicAndCourseMapper.insert(sysTopicAndCourse); - return new ResultEntity<>(HttpStatus.OK,"新增成功!"); + return new ResultEntity<>(HttpStatus.OK, "新增成功!"); + } + + + @AnonymousAccess + @ApiOperation("案例题查询") + @PostMapping("selectCaseByConditions") + public ResultEntity> selectCaseByConditions(@RequestParam Integer index, + @RequestParam Integer size, + @RequestParam String title, + @RequestParam String oneId) { + PageHelper.startPage(index, size); + List list = caseQuestionMapper.selectCaseByConditions(title, oneId); + PageInfo pageInfo = new PageInfo(list); + return new ResultEntity>(pageInfo); + } + + //案例库自动同步课程配置新增的和老师新增的案例,老师新增的案例正在使用时只能查看,如果老师删除了这个案例,这个案例可以编辑删除。 + @AnonymousAccess + @ApiOperation("案例题编辑") + @PostMapping("updateCase") + public ResultEntity updateCase() { + return null; + } + + //删除案例时如果案例正在被使用则不能删除,提示该案例正在被xx课程xx章节使用,不能删除。 + @AnonymousAccess + @ApiOperation("案例题删除") + @PostMapping("deleteCase") + public ResultEntity deleteCase() { + return null; + } + + @AnonymousAccess + @ApiOperation("案例题添加步骤") + @PostMapping("insertCaseStepByCaseId") + public ResultEntity insertCaseStepByCaseId() { + return null; } } diff --git a/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionMapper.java index 56a01e3..8dbacb1 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionMapper.java @@ -35,4 +35,6 @@ public interface SysCaseQuestionMapper { int updateByPrimaryKeyWithBLOBs(SysCaseQuestion record); int updateByPrimaryKey(SysCaseQuestion record); + + List selectCaseByConditions(@Param("title")String title, @Param("oneId")String oneId); } \ No newline at end of file diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index e2e2c5f..5d0c2f4 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -40,11 +40,11 @@ - - + +
-
+ diff --git a/src/main/resources/mapper/SysCaseQuestionMapper.xml b/src/main/resources/mapper/SysCaseQuestionMapper.xml index 30e4a60..cc792c0 100644 --- a/src/main/resources/mapper/SysCaseQuestionMapper.xml +++ b/src/main/resources/mapper/SysCaseQuestionMapper.xml @@ -1,377 +1,396 @@ - - - - - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + - - - - - - - case_id, title, resource_data, source, type, one_id, two_id, three, unmount_status, + + + + case_id + , title, resource_data, source, type, one_id, two_id, three, unmount_status, create_time, update_time - - - content - - - - - - delete from sys_case_questions - where case_id = #{caseId,jdbcType=VARCHAR} - - - delete from sys_case_questions - - - - - - insert into sys_case_questions (case_id, title, resource_data, - source, type, one_id, - two_id, three, 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}, - #{twoId,jdbcType=VARCHAR}, #{three,jdbcType=VARCHAR}, #{unmountStatus,jdbcType=BIT}, - #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR} - ) - - - insert into sys_case_questions - - - case_id, - - - title, - - - resource_data, - - - source, - - - type, - - - one_id, - - - two_id, - - - three, - - - unmount_status, - - - create_time, - - - update_time, - - - content, - - - - - #{caseId,jdbcType=VARCHAR}, - - - #{title,jdbcType=VARCHAR}, - - - #{resourceData,jdbcType=VARCHAR}, - - - #{source,jdbcType=VARCHAR}, - - - #{type,jdbcType=VARCHAR}, - - - #{oneId,jdbcType=VARCHAR}, - - - #{twoId,jdbcType=VARCHAR}, - - - #{three,jdbcType=VARCHAR}, - - - #{unmountStatus,jdbcType=BIT}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{updateTime,jdbcType=TIMESTAMP}, - - - #{content,jdbcType=LONGVARCHAR}, - - - - - - update sys_case_questions - - - case_id = #{record.caseId,jdbcType=VARCHAR}, - - + + + content + + + + + + delete + from sys_case_questions + where case_id = #{caseId,jdbcType=VARCHAR} + + + delete from sys_case_questions + + + + + + insert into sys_case_questions (case_id, title, resource_data, + source, type, one_id, + two_id, three, 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}, + #{twoId,jdbcType=VARCHAR}, #{three,jdbcType=VARCHAR}, #{unmountStatus,jdbcType=BIT}, + #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR}) + + + insert into sys_case_questions + + + case_id, + + + title, + + + resource_data, + + + source, + + + type, + + + one_id, + + + two_id, + + + three, + + + unmount_status, + + + create_time, + + + update_time, + + + content, + + + + + #{caseId,jdbcType=VARCHAR}, + + + #{title,jdbcType=VARCHAR}, + + + #{resourceData,jdbcType=VARCHAR}, + + + #{source,jdbcType=VARCHAR}, + + + #{type,jdbcType=VARCHAR}, + + + #{oneId,jdbcType=VARCHAR}, + + + #{twoId,jdbcType=VARCHAR}, + + + #{three,jdbcType=VARCHAR}, + + + #{unmountStatus,jdbcType=BIT}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{content,jdbcType=LONGVARCHAR}, + + + + + + update sys_case_questions + + + case_id = #{record.caseId,jdbcType=VARCHAR}, + + + title = #{record.title,jdbcType=VARCHAR}, + + + resource_data = #{record.resourceData,jdbcType=VARCHAR}, + + + source = #{record.source,jdbcType=VARCHAR}, + + + type = #{record.type,jdbcType=VARCHAR}, + + + one_id = #{record.oneId,jdbcType=VARCHAR}, + + + two_id = #{record.twoId,jdbcType=VARCHAR}, + + + three = #{record.three,jdbcType=VARCHAR}, + + + unmount_status = #{record.unmountStatus,jdbcType=BIT}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + + content = #{record.content,jdbcType=LONGVARCHAR}, + + + + + + + + update sys_case_questions + set case_id = #{record.caseId,jdbcType=VARCHAR}, title = #{record.title,jdbcType=VARCHAR}, - - resource_data = #{record.resourceData,jdbcType=VARCHAR}, - - source = #{record.source,jdbcType=VARCHAR}, - - type = #{record.type,jdbcType=VARCHAR}, - - one_id = #{record.oneId,jdbcType=VARCHAR}, - - two_id = #{record.twoId,jdbcType=VARCHAR}, - - three = #{record.three,jdbcType=VARCHAR}, - - unmount_status = #{record.unmountStatus,jdbcType=BIT}, - - create_time = #{record.createTime,jdbcType=TIMESTAMP}, - - update_time = #{record.updateTime,jdbcType=TIMESTAMP}, - - - content = #{record.content,jdbcType=LONGVARCHAR}, - - - - - - - - update sys_case_questions - set case_id = #{record.caseId,jdbcType=VARCHAR}, - title = #{record.title,jdbcType=VARCHAR}, - resource_data = #{record.resourceData,jdbcType=VARCHAR}, - source = #{record.source,jdbcType=VARCHAR}, - type = #{record.type,jdbcType=VARCHAR}, - one_id = #{record.oneId,jdbcType=VARCHAR}, - two_id = #{record.twoId,jdbcType=VARCHAR}, - three = #{record.three,jdbcType=VARCHAR}, - unmount_status = #{record.unmountStatus,jdbcType=BIT}, - create_time = #{record.createTime,jdbcType=TIMESTAMP}, - update_time = #{record.updateTime,jdbcType=TIMESTAMP}, - content = #{record.content,jdbcType=LONGVARCHAR} - - - - - - update sys_case_questions - set case_id = #{record.caseId,jdbcType=VARCHAR}, - title = #{record.title,jdbcType=VARCHAR}, - resource_data = #{record.resourceData,jdbcType=VARCHAR}, - source = #{record.source,jdbcType=VARCHAR}, - type = #{record.type,jdbcType=VARCHAR}, - one_id = #{record.oneId,jdbcType=VARCHAR}, - two_id = #{record.twoId,jdbcType=VARCHAR}, - three = #{record.three,jdbcType=VARCHAR}, - unmount_status = #{record.unmountStatus,jdbcType=BIT}, - create_time = #{record.createTime,jdbcType=TIMESTAMP}, - update_time = #{record.updateTime,jdbcType=TIMESTAMP} - - - - - - update sys_case_questions - - - title = #{title,jdbcType=VARCHAR}, - - - resource_data = #{resourceData,jdbcType=VARCHAR}, - - - source = #{source,jdbcType=VARCHAR}, - - - type = #{type,jdbcType=VARCHAR}, - - - one_id = #{oneId,jdbcType=VARCHAR}, - - - two_id = #{twoId,jdbcType=VARCHAR}, - - - three = #{three,jdbcType=VARCHAR}, - - - unmount_status = #{unmountStatus,jdbcType=BIT}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - - - content = #{content,jdbcType=LONGVARCHAR}, - - - where case_id = #{caseId,jdbcType=VARCHAR} - - - update sys_case_questions - set title = #{title,jdbcType=VARCHAR}, - resource_data = #{resourceData,jdbcType=VARCHAR}, - source = #{source,jdbcType=VARCHAR}, - type = #{type,jdbcType=VARCHAR}, - one_id = #{oneId,jdbcType=VARCHAR}, - two_id = #{twoId,jdbcType=VARCHAR}, - three = #{three,jdbcType=VARCHAR}, - unmount_status = #{unmountStatus,jdbcType=BIT}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - update_time = #{updateTime,jdbcType=TIMESTAMP}, - content = #{content,jdbcType=LONGVARCHAR} - where case_id = #{caseId,jdbcType=VARCHAR} - - - update sys_case_questions - set title = #{title,jdbcType=VARCHAR}, - resource_data = #{resourceData,jdbcType=VARCHAR}, - source = #{source,jdbcType=VARCHAR}, - type = #{type,jdbcType=VARCHAR}, - one_id = #{oneId,jdbcType=VARCHAR}, - two_id = #{twoId,jdbcType=VARCHAR}, - three = #{three,jdbcType=VARCHAR}, - unmount_status = #{unmountStatus,jdbcType=BIT}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - update_time = #{updateTime,jdbcType=TIMESTAMP} - where case_id = #{caseId,jdbcType=VARCHAR} - + content = #{record.content,jdbcType=LONGVARCHAR} + + + + + + update sys_case_questions + set case_id = #{record.caseId,jdbcType=VARCHAR}, + title = #{record.title,jdbcType=VARCHAR}, + resource_data = #{record.resourceData,jdbcType=VARCHAR}, + source = #{record.source,jdbcType=VARCHAR}, + type = #{record.type,jdbcType=VARCHAR}, + one_id = #{record.oneId,jdbcType=VARCHAR}, + two_id = #{record.twoId,jdbcType=VARCHAR}, + three = #{record.three,jdbcType=VARCHAR}, + unmount_status = #{record.unmountStatus,jdbcType=BIT}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP} + + + + + + update sys_case_questions + + + title = #{title,jdbcType=VARCHAR}, + + + resource_data = #{resourceData,jdbcType=VARCHAR}, + + + source = #{source,jdbcType=VARCHAR}, + + + type = #{type,jdbcType=VARCHAR}, + + + one_id = #{oneId,jdbcType=VARCHAR}, + + + two_id = #{twoId,jdbcType=VARCHAR}, + + + three = #{three,jdbcType=VARCHAR}, + + + unmount_status = #{unmountStatus,jdbcType=BIT}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + content = #{content,jdbcType=LONGVARCHAR}, + + + where case_id = #{caseId,jdbcType=VARCHAR} + + + update sys_case_questions + set title = #{title,jdbcType=VARCHAR}, + resource_data = #{resourceData,jdbcType=VARCHAR}, + source = #{source,jdbcType=VARCHAR}, + type = #{type,jdbcType=VARCHAR}, + one_id = #{oneId,jdbcType=VARCHAR}, + two_id = #{twoId,jdbcType=VARCHAR}, + three = #{three,jdbcType=VARCHAR}, + unmount_status = #{unmountStatus,jdbcType=BIT}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + content = #{content,jdbcType=LONGVARCHAR} + where case_id = #{caseId,jdbcType=VARCHAR} + + + update sys_case_questions + set title = #{title,jdbcType=VARCHAR}, + resource_data = #{resourceData,jdbcType=VARCHAR}, + source = #{source,jdbcType=VARCHAR}, + type = #{type,jdbcType=VARCHAR}, + one_id = #{oneId,jdbcType=VARCHAR}, + two_id = #{twoId,jdbcType=VARCHAR}, + three = #{three,jdbcType=VARCHAR}, + unmount_status = #{unmountStatus,jdbcType=BIT}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP} + where case_id = #{caseId,jdbcType=VARCHAR} + + + + + \ No newline at end of file