新增题库管理页面接口,题库表新增逻辑删除字段

master
xiaoCJ 9 months ago
parent a923682de9
commit f9fd31c7cf

@ -1,8 +1,11 @@
package com.sztzjy.resource_center.controller; package com.sztzjy.resource_center.controller;
import cn.hutool.core.util.IdUtil; 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.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.SysCaseQuestion; 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.entity.SysTopicAndCourse;
import com.sztzjy.resource_center.mapper.SysCaseQuestionMapper; import com.sztzjy.resource_center.mapper.SysCaseQuestionMapper;
import com.sztzjy.resource_center.mapper.SysCaseQuestionStepMapper; import com.sztzjy.resource_center.mapper.SysCaseQuestionStepMapper;
@ -14,12 +17,10 @@ import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @Author xcj * @Author xcj
@ -54,6 +55,14 @@ public class CaseController {
if (StringUtils.isBlank(sysCaseQuestion.getSource())) { 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<SysCaseQuestion> sysCaseQuestions = caseQuestionMapper.selectByExample(example);
if (!sysCaseQuestions.isEmpty()) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "案例名称不能重复!");
}
String uuid = IdUtil.randomUUID(); String uuid = IdUtil.randomUUID();
sysCaseQuestion.setCaseId(uuid); sysCaseQuestion.setCaseId(uuid);
sysCaseQuestion.setCreateTime(new Date()); sysCaseQuestion.setCreateTime(new Date());
@ -72,4 +81,41 @@ public class CaseController {
topicAndCourseMapper.insert(sysTopicAndCourse); topicAndCourseMapper.insert(sysTopicAndCourse);
return new ResultEntity<>(HttpStatus.OK, "新增成功!"); return new ResultEntity<>(HttpStatus.OK, "新增成功!");
} }
@AnonymousAccess
@ApiOperation("案例题查询")
@PostMapping("selectCaseByConditions")
public ResultEntity<PageInfo<SysCaseQuestion>> selectCaseByConditions(@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam String title,
@RequestParam String oneId) {
PageHelper.startPage(index, size);
List<SysCaseQuestion> list = caseQuestionMapper.selectCaseByConditions(title, oneId);
PageInfo pageInfo = new PageInfo<SysCaseQuestion>(list);
return new ResultEntity<PageInfo<SysCaseQuestion>>(pageInfo);
}
//案例库自动同步课程配置新增的和老师新增的案例,老师新增的案例正在使用时只能查看,如果老师删除了这个案例,这个案例可以编辑删除。
@AnonymousAccess
@ApiOperation("案例题编辑")
@PostMapping("updateCase")
public ResultEntity<HttpStatus> updateCase() {
return null;
}
//删除案例时如果案例正在被使用则不能删除提示该案例正在被xx课程xx章节使用不能删除。
@AnonymousAccess
@ApiOperation("案例题删除")
@PostMapping("deleteCase")
public ResultEntity<HttpStatus> deleteCase() {
return null;
}
@AnonymousAccess
@ApiOperation("案例题添加步骤")
@PostMapping("insertCaseStepByCaseId")
public ResultEntity<HttpStatus> insertCaseStepByCaseId() {
return null;
}
} }

@ -35,4 +35,6 @@ public interface SysCaseQuestionMapper {
int updateByPrimaryKeyWithBLOBs(SysCaseQuestion record); int updateByPrimaryKeyWithBLOBs(SysCaseQuestion record);
int updateByPrimaryKey(SysCaseQuestion record); int updateByPrimaryKey(SysCaseQuestion record);
List<SysCaseQuestion> selectCaseByConditions(@Param("title")String title, @Param("oneId")String oneId);
} }

@ -40,11 +40,11 @@
<property name="enableSubPackages" value="true"/> <property name="enableSubPackages" value="true"/>
</javaClientGenerator> </javaClientGenerator>
<!-- 需要生成的表 --> <!-- 需要生成的表 -->
<!-- <table tableName="sys_case_question" domainObjectName="SysCaseQuestion" />--> <table tableName="sys_case_questions" domainObjectName="SysCaseQuestion" />
<!-- <table tableName="sys_case_question_step" domainObjectName="SysCaseQuestionStep" />--> <table tableName="sys_case_question_steps" domainObjectName="SysCaseQuestionStep" />
<!-- <table tableName="sys_model" domainObjectName="SysModel" />--> <!-- <table tableName="sys_model" domainObjectName="SysModel" />-->
<!-- <table tableName="sys_model_question" domainObjectName="SysModelQuestion" />--> <!-- <table tableName="sys_model_question" domainObjectName="SysModelQuestion" />-->
<table tableName="sys_objective_question" domainObjectName="SysObjectiveQuestions" /> <!-- <table tableName="sys_objective_question" domainObjectName="SysObjectiveQuestions" />-->
<!-- <table tableName="sys_one_catalog" domainObjectName="SysOneCatalog" />--> <!-- <table tableName="sys_one_catalog" domainObjectName="SysOneCatalog" />-->
<!-- <table tableName="sys_resource" domainObjectName="SysResource" />--> <!-- <table tableName="sys_resource" domainObjectName="SysResource" />-->
<!-- <table tableName="sys_resource_and_course" domainObjectName="SysResourceAndCourse" />--> <!-- <table tableName="sys_resource_and_course" domainObjectName="SysResourceAndCourse" />-->

@ -35,7 +35,8 @@
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -64,7 +65,8 @@
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -76,13 +78,15 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
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 create_time, update_time
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
content content
</sql> </sql>
<select id="selectByExampleWithBLOBs" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestionExample" resultMap="ResultMapWithBLOBs"> <select id="selectByExampleWithBLOBs" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestionExample"
resultMap="ResultMapWithBLOBs">
select select
<if test="distinct"> <if test="distinct">
distinct distinct
@ -98,7 +102,8 @@
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestionExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestionExample"
resultMap="BaseResultMap">
select select
<if test="distinct"> <if test="distinct">
distinct distinct
@ -121,7 +126,8 @@
where case_id = #{caseId,jdbcType=VARCHAR} where case_id = #{caseId,jdbcType=VARCHAR}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from sys_case_questions delete
from sys_case_questions
where case_id = #{caseId,jdbcType=VARCHAR} where case_id = #{caseId,jdbcType=VARCHAR}
</delete> </delete>
<delete id="deleteByExample" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestionExample"> <delete id="deleteByExample" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestionExample">
@ -134,13 +140,11 @@
insert into sys_case_questions (case_id, title, resource_data, insert into sys_case_questions (case_id, title, resource_data,
source, type, one_id, source, type, one_id,
two_id, three, unmount_status, two_id, three, unmount_status,
create_time, update_time, content create_time, update_time, content)
)
values (#{caseId,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{resourceData,jdbcType=VARCHAR}, values (#{caseId,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{resourceData,jdbcType=VARCHAR},
#{source,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{oneId,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{oneId,jdbcType=VARCHAR},
#{twoId,jdbcType=VARCHAR}, #{three,jdbcType=VARCHAR}, #{unmountStatus,jdbcType=BIT}, #{twoId,jdbcType=VARCHAR}, #{three,jdbcType=VARCHAR}, #{unmountStatus,jdbcType=BIT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR} #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR})
)
</insert> </insert>
<insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestion"> <insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestion">
insert into sys_case_questions insert into sys_case_questions
@ -221,7 +225,8 @@
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestionExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.sztzjy.resource_center.entity.SysCaseQuestionExample"
resultType="java.lang.Long">
select count(*) from sys_case_questions select count(*) from sys_case_questions
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause"/> <include refid="Example_Where_Clause"/>
@ -374,4 +379,18 @@
update_time = #{updateTime,jdbcType=TIMESTAMP} update_time = #{updateTime,jdbcType=TIMESTAMP}
where case_id = #{caseId,jdbcType=VARCHAR} where case_id = #{caseId,jdbcType=VARCHAR}
</update> </update>
<!--条件查询-->
<select id="selectCaseByConditions" parameterType="java.lang.String" resultMap="BaseResultMap">
select * from sys_case_question s
<where>
<if test="oneId != null and oneId != ''">
s.one_id = #{oneId}
</if>
<if test="title != null and title != ''">
and s.title = #{title}
</if>
</where>
</select>
</mapper> </mapper>
Loading…
Cancel
Save