改为模糊查询

master
xiaoCJ 8 months ago
parent b8c45e0bb1
commit 8403d560ea

@ -161,7 +161,7 @@ public class TopicResourceController {
@ApiOperation("客观题导入模板下载")
@AnonymousAccess
public void downloadResource(HttpServletResponse response) {
fileUtil.download(response, "客观题导入模板.xlsx", filePath);
fileUtil.download(response, "客观题导入模板.xlsx", null);
}
@ -218,7 +218,7 @@ public class TopicResourceController {
example.createCriteria().andTopicIdEqualTo(dto.getObjectiveId());
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
if (!sysTopicAndCourses.isEmpty()) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除,题目正在使用!");
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法编辑,题目正在使用!");
}
}
//ID不为空修改绑定信息

@ -1,11 +1,9 @@
package com.sztzjy.resource_center.controller.admin;
package com.sztzjy.resource_center.controller.new_module.admin;
import cn.hutool.core.util.IdUtil;
import com.sztzjy.resource_center.entity.admin.AdminCaseDto;
import com.sztzjy.resource_center.entity.admin.AdminCaseWithBLOBs;
import com.sztzjy.resource_center.entity.admin.AdminFile;
import com.sztzjy.resource_center.entity.admin.AdminLabel;
import com.sztzjy.resource_center.entity.admin.*;
import com.sztzjy.resource_center.mapper.admin.AdminCaseMapper;
import com.sztzjy.resource_center.mapper.admin.AdminDataLabelMapper;
import com.sztzjy.resource_center.mapper.admin.AdminFileMapper;
import com.sztzjy.resource_center.mapper.admin.AdminLabelMapper;
import com.sztzjy.resource_center.util.ResultEntity;
@ -13,7 +11,6 @@ import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@ -33,7 +30,7 @@ public class AdminCaseController {
@Autowired
private AdminCaseMapper adminCaseMapper;
@Autowired
private AdminLabelMapper adminLabelMapper;
private AdminDataLabelMapper adminDataLabelMapper;
@Autowired
private AdminFileMapper adminFileMapper;
@Autowired
@ -106,8 +103,17 @@ public class AdminCaseController {
adminFileMapper.insertBatch(list);
}
List<AdminDataLabel>list =new ArrayList<>();
for (AdminLabel adminLabel : adminLabelList) {
AdminDataLabel label =new AdminDataLabel();
label.setId(IdUtil.randomUUID());
label.setLabelId(adminLabel.getLabelId());
label.setName(adminLabel.getName());
label.setDataCaseId(adminCaseDto.getCaseId());
list.add(label);
}
//批量新增标签
adminLabelMapper.insertBatch(adminLabelList);
adminDataLabelMapper.insertBatch(list);
//新增案例
adminCaseMapper.insert(adminCase);
return new ResultEntity<>(HttpStatus.OK, "新增成功!");

@ -1,7 +1,8 @@
package com.sztzjy.resource_center.controller.admin;
package com.sztzjy.resource_center.controller.new_module.admin;
import cn.hutool.core.util.IdUtil;
import com.sztzjy.resource_center.entity.admin.*;
import com.sztzjy.resource_center.mapper.admin.AdminDataLabelMapper;
import com.sztzjy.resource_center.mapper.admin.AdminDataMapper;
import com.sztzjy.resource_center.mapper.admin.AdminFileMapper;
import com.sztzjy.resource_center.mapper.admin.AdminLabelMapper;
@ -29,7 +30,7 @@ public class AdminDataController {
@Autowired
private IFileUtil fileUtil;
@Autowired
private AdminLabelMapper adminLabelMapper;
private AdminDataLabelMapper adminDataLabelMapper;
@Autowired
private AdminFileMapper adminFileMapper;
@Autowired
@ -91,7 +92,16 @@ public class AdminDataController {
}
//批量新增标签
adminLabelMapper.insertBatch(adminLabelList);
List<AdminDataLabel>list =new ArrayList<>();
for (AdminLabel adminLabel : adminLabelList) {
AdminDataLabel label =new AdminDataLabel();
label.setId(IdUtil.randomUUID());
label.setLabelId(adminLabel.getLabelId());
label.setName(adminLabel.getName());
label.setDataCaseId(adminDataDto.getDataId());
list.add(label);
}
adminDataLabelMapper.insertBatch(list);
//新增案例
adminDataMapper.insert(adminDataWithBLOBs);
return new ResultEntity<>(HttpStatus.OK,"新增成功!");

@ -1,4 +1,4 @@
package com.sztzjy.resource_center.controller.admin;
package com.sztzjy.resource_center.controller.new_module.admin;
import cn.hutool.core.util.IdUtil;
import com.sztzjy.resource_center.entity.admin.AdminLabel;

@ -0,0 +1,40 @@
package com.sztzjy.resource_center.controller.new_module.stu;
import com.sztzjy.resource_center.entity.admin.AdminCaseExample;
import com.sztzjy.resource_center.entity.admin.AdminCaseWithBLOBs;
import com.sztzjy.resource_center.mapper.admin.AdminCaseMapper;
import com.sztzjy.resource_center.util.ResultEntity;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;
/**
* @Author xcj
* @Date 2024/7/16
*/
@RestController
@Api(tags = "学生端案例相关")
@RequestMapping("api/stu/case")
public class StuCaseController {
@Autowired
private AdminCaseMapper adminCaseMapper;
@PostMapping("展示")
private ResultEntity<String> add(@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam(required = false) String keyWord,
@Param("1精品案例2收藏案例3院校案例") @RequestParam int type,
@RequestParam(required = false) String label) {
if (type == 1) {
adminCaseMapper.selectByConditions(keyWord,label);
}
return null;
}
}

@ -12,7 +12,10 @@ import java.util.List;
*/
@Data
public class AdminCaseDto {
@ApiModelProperty("数据名称")
@ApiModelProperty("案例Id")
private String caseId;
@ApiModelProperty("案例名称")
private String name;
@ApiModelProperty("标签集合")

@ -19,6 +19,9 @@ public class AdminDataLabel {
@ApiModelProperty("标签名称")
private String name;
@ApiModelProperty("类型 行业标签/专业标签/技术标签")
private String type;
public String getId() {
return id;
}
@ -50,4 +53,12 @@ public class AdminDataLabel {
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
}

@ -383,6 +383,76 @@ public class AdminDataLabelExample {
addCriterion("name not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("type like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("type not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

@ -36,4 +36,6 @@ public interface AdminCaseMapper {
int updateByPrimaryKeyWithBLOBs(AdminCaseWithBLOBs record);
int updateByPrimaryKey(AdminCase record);
void selectByConditions(@Param("keyWord") String keyWord, @Param("label") String label);
}

@ -3,8 +3,10 @@ package com.sztzjy.resource_center.mapper.admin;
import com.sztzjy.resource_center.entity.admin.AdminDataLabel;
import com.sztzjy.resource_center.entity.admin.AdminDataLabelExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface AdminDataLabelMapper {
long countByExample(AdminDataLabelExample example);
@ -27,4 +29,6 @@ public interface AdminDataLabelMapper {
int updateByPrimaryKeySelective(AdminDataLabel record);
int updateByPrimaryKey(AdminDataLabel record);
void insertBatch(@Param("list") List<AdminDataLabel> adminLabelList);
}

@ -23,7 +23,7 @@
<property name="useInformationSchema" value="true"/> <!--useInformationSchema 实体类上添加数据表的注释 -->
</jdbcConnection>
<!-- 配置实体类的位置 -->
<javaModelGenerator targetPackage="com.sztzjy.resource_center.entity" targetProject="src/main/java">
<javaModelGenerator targetPackage="com.sztzjy.resource_center.entity.admin" targetProject="src/main/java">
<!-- 生成的Java模型是否支持序列化 -->
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
@ -35,13 +35,13 @@
</sqlMapGenerator>
<!-- 配置Mapper接口的位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.sztzjy.resource_center.mapper"
<javaClientGenerator type="XMLMAPPER" targetPackage="com.sztzjy.resource_center.mapper.admin"
targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 需要生成的表 -->
<!-- <table tableName="sys_case_questions" domainObjectName="SysCaseQuestion" />-->
<table tableName="sys_case_question_steps" domainObjectName="SysCaseQuestionStep" />
<!-- <table tableName="sys_case_question_steps" domainObjectName="SysCaseQuestionStep" />-->
<!-- <table tableName="sys_model" domainObjectName="SysModel" />-->
<!-- <table tableName="sys_model_question" domainObjectName="SysModelQuestion" />-->
<!-- <table tableName="sys_objective_questions" domainObjectName="SysObjectiveQuestions" />-->
@ -54,7 +54,7 @@
<!-- <table tableName="sys_topic_and_course" domainObjectName="SysTopicAndCourse" />-->
<!-- <table tableName="admin_case" domainObjectName="AdminCase" />-->
<!-- <table tableName="admin_data" domainObjectName="AdminData" />-->
<!-- <table tableName="admin_data_label" domainObjectName="AdminDataLabel" />-->
<table tableName="admin_data_label" domainObjectName="AdminDataLabel" />
<!-- <table tableName="admin_file" domainObjectName="AdminFile" />-->
<!-- <table tableName="sys_knowledge_and_course" domainObjectName="SysKnowledgeAndCourse" />-->
<!-- <table tableName="sys_knowledge_summary" domainObjectName="SysKnowledgeSummary" />-->

@ -6,6 +6,7 @@
<result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId" />
<result column="label_id" jdbcType="VARCHAR" property="labelId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="type" jdbcType="VARCHAR" property="type" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -66,7 +67,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, data_case_id, label_id, name
id, data_case_id, label_id, name, type
</sql>
<select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataLabelExample" resultMap="BaseResultMap">
select
@ -100,9 +101,9 @@
</delete>
<insert id="insert" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataLabel">
insert into admin_data_label (id, data_case_id, label_id,
name)
name, type)
values (#{id,jdbcType=VARCHAR}, #{dataCaseId,jdbcType=VARCHAR}, #{labelId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR})
#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataLabel">
insert into admin_data_label
@ -119,6 +120,9 @@
<if test="name != null">
name,
</if>
<if test="type != null">
type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -133,6 +137,9 @@
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataLabelExample" resultType="java.lang.Long">
@ -156,6 +163,9 @@
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
type = #{record.type,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -166,7 +176,8 @@
set id = #{record.id,jdbcType=VARCHAR},
data_case_id = #{record.dataCaseId,jdbcType=VARCHAR},
label_id = #{record.labelId,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR}
name = #{record.name,jdbcType=VARCHAR},
type = #{record.type,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -183,6 +194,9 @@
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -190,7 +204,23 @@
update admin_data_label
set data_case_id = #{dataCaseId,jdbcType=VARCHAR},
label_id = #{labelId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR}
name = #{name,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO admin_data_label (id,data_case_id, label_id,name,type)
VALUES
<foreach collection="list" index="index" item="item" separator=",">
(
#{item.id},
#{item.data_case_id},
#{item.label_id},
#{item.name},
#{item.type}
)
</foreach>
</insert>
</mapper>

@ -454,7 +454,7 @@
<!--条件查询加绑定关系,有重复数据-->
<select id="selectCaseByConditionsByBind" parameterType="java.lang.String" resultMap="BaseResultMap">
select st.*,s.title,s.content,s.resource_data,s.source,s.type,s.unmount_status,s.create_time
select st.*,s.case_id,s.title,s.content,s.resource_data,s.source,s.type,s.unmount_status,s.create_time,s.update_time
from sys_case_questions s
left join sys_topic_and_course st
on s.case_id = st.topic_id

@ -7,7 +7,7 @@
<result column="resource_name" jdbcType="VARCHAR" property="resourceName" />
<result column="size" jdbcType="DOUBLE" property="size" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="school_id" jdbcType="VARCHAR" property="schoolId" />
<result column="source" jdbcType="VARCHAR" property="source" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -68,7 +68,7 @@
</where>
</sql>
<sql id="Base_Column_List">
resource_data_id, case_id, resource_name, size, url, school_id
resource_data_id, case_id, resource_name, size, url, source
</sql>
<select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.SysResourceDataExample" resultMap="BaseResultMap">
select
@ -102,9 +102,9 @@
</delete>
<insert id="insert" parameterType="com.sztzjy.resource_center.entity.SysResourceData">
insert into sys_resource_data (resource_data_id, case_id, resource_name,
size, url, school_id)
size, url, source)
values (#{resourceDataId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR}, #{resourceName,jdbcType=VARCHAR},
#{size,jdbcType=DOUBLE}, #{url,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR})
#{size,jdbcType=DOUBLE}, #{url,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.SysResourceData">
insert into sys_resource_data
@ -124,8 +124,8 @@
<if test="url != null">
url,
</if>
<if test="schoolId != null">
school_id,
<if test="source != null">
source,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -144,8 +144,8 @@
<if test="url != null">
#{url,jdbcType=VARCHAR},
</if>
<if test="schoolId != null">
#{schoolId,jdbcType=VARCHAR},
<if test="source != null">
#{source,jdbcType=VARCHAR},
</if>
</trim>
</insert>
@ -173,8 +173,8 @@
<if test="record.url != null">
url = #{record.url,jdbcType=VARCHAR},
</if>
<if test="record.schoolId != null">
school_id = #{record.schoolId,jdbcType=VARCHAR},
<if test="record.source != null">
source = #{record.source,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
@ -188,7 +188,7 @@
resource_name = #{record.resourceName,jdbcType=VARCHAR},
size = #{record.size,jdbcType=DOUBLE},
url = #{record.url,jdbcType=VARCHAR},
school_id = #{record.schoolId,jdbcType=VARCHAR}
source = #{record.source,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -208,8 +208,8 @@
<if test="url != null">
url = #{url,jdbcType=VARCHAR},
</if>
<if test="schoolId != null">
school_id = #{schoolId,jdbcType=VARCHAR},
<if test="source != null">
source = #{source,jdbcType=VARCHAR},
</if>
</set>
where resource_data_id = #{resourceDataId,jdbcType=VARCHAR}
@ -220,7 +220,7 @@
resource_name = #{resourceName,jdbcType=VARCHAR},
size = #{size,jdbcType=DOUBLE},
url = #{url,jdbcType=VARCHAR},
school_id = #{schoolId,jdbcType=VARCHAR}
source = #{source,jdbcType=VARCHAR}
where resource_data_id = #{resourceDataId,jdbcType=VARCHAR}
</update>
</mapper>
Loading…
Cancel
Save