From 8403d560ea4825afc99fbc65503b49f2c27642c1 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Tue, 16 Jul 2024 10:19:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=A8=A1=E7=B3=8A=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TopicResourceController.java | 4 +- .../admin/AdminCaseController.java | 22 +++--- .../admin/AdminDataController.java | 16 ++++- .../admin/AdminLabelController.java | 2 +- .../new_module/stu/StuCaseController.java | 40 +++++++++++ .../entity/admin/AdminCaseDto.java | 5 +- .../entity/admin/AdminDataLabel.java | 11 +++ .../entity/admin/AdminDataLabelExample.java | 70 +++++++++++++++++++ .../mapper/admin/AdminCaseMapper.java | 2 + .../mapper/admin/AdminDataLabelMapper.java | 6 +- src/main/resources/generatorConfig.xml | 8 +-- .../resources/mapper/AdminDataLabelMapper.xml | 40 +++++++++-- .../mapper/SysCaseQuestionMapper.xml | 2 +- .../mapper/SysResourceDataMapper.xml | 28 ++++---- 14 files changed, 216 insertions(+), 40 deletions(-) rename src/main/java/com/sztzjy/resource_center/controller/{ => new_module}/admin/AdminCaseController.java (86%) rename src/main/java/com/sztzjy/resource_center/controller/{ => new_module}/admin/AdminDataController.java (86%) rename src/main/java/com/sztzjy/resource_center/controller/{ => new_module}/admin/AdminLabelController.java (98%) create mode 100644 src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuCaseController.java 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 182a2e5..e8fe7a6 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java @@ -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 sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example); if (!sysTopicAndCourses.isEmpty()) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除,题目正在使用!"); + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法编辑,题目正在使用!"); } } //ID不为空,修改绑定信息 diff --git a/src/main/java/com/sztzjy/resource_center/controller/admin/AdminCaseController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java similarity index 86% rename from src/main/java/com/sztzjy/resource_center/controller/admin/AdminCaseController.java rename to src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java index d16b5fb..80bb071 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/admin/AdminCaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java @@ -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); } + Listlist =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, "新增成功!"); diff --git a/src/main/java/com/sztzjy/resource_center/controller/admin/AdminDataController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java similarity index 86% rename from src/main/java/com/sztzjy/resource_center/controller/admin/AdminDataController.java rename to src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java index b2da48f..8a30af9 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/admin/AdminDataController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java @@ -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); + Listlist =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,"新增成功!"); diff --git a/src/main/java/com/sztzjy/resource_center/controller/admin/AdminLabelController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminLabelController.java similarity index 98% rename from src/main/java/com/sztzjy/resource_center/controller/admin/AdminLabelController.java rename to src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminLabelController.java index 282c035..8a123c3 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/admin/AdminLabelController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminLabelController.java @@ -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; diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuCaseController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuCaseController.java new file mode 100644 index 0000000..4a603bc --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuCaseController.java @@ -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 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; + } +} diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseDto.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseDto.java index 3ff1cc1..f4e7269 100644 --- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseDto.java +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseDto.java @@ -12,7 +12,10 @@ import java.util.List; */ @Data public class AdminCaseDto { - @ApiModelProperty("数据名称") + @ApiModelProperty("案例Id") + private String caseId; + + @ApiModelProperty("案例名称") private String name; @ApiModelProperty("标签集合") diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataLabel.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataLabel.java index 4d92d07..c96ce73 100644 --- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataLabel.java +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataLabel.java @@ -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(); + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataLabelExample.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataLabelExample.java index 2a8020f..65ed9df 100644 --- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataLabelExample.java +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataLabelExample.java @@ -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 values) { + addCriterion("type in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List 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 { diff --git a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminCaseMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminCaseMapper.java index 004c61c..1423965 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminCaseMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminCaseMapper.java @@ -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); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataLabelMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataLabelMapper.java index f9afff2..2d9de44 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataLabelMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataLabelMapper.java @@ -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 adminLabelList); } \ No newline at end of file diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index c03ffed..0e4ea99 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -23,7 +23,7 @@ - + @@ -35,13 +35,13 @@ - - + @@ -54,7 +54,7 @@ - +
diff --git a/src/main/resources/mapper/AdminDataLabelMapper.xml b/src/main/resources/mapper/AdminDataLabelMapper.xml index 2a3107c..32bf488 100644 --- a/src/main/resources/mapper/AdminDataLabelMapper.xml +++ b/src/main/resources/mapper/AdminDataLabelMapper.xml @@ -6,6 +6,7 @@ + @@ -66,7 +67,7 @@ - id, data_case_id, label_id, name + id, data_case_id, label_id, name, type @@ -156,6 +163,9 @@ name = #{record.name,jdbcType=VARCHAR}, + + type = #{record.type,jdbcType=VARCHAR}, + @@ -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} @@ -183,6 +194,9 @@ name = #{name,jdbcType=VARCHAR}, + + type = #{type,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -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} + + + INSERT INTO admin_data_label (id,data_case_id, label_id,name,type) + VALUES + + ( + #{item.id}, + #{item.data_case_id}, + #{item.label_id}, + #{item.name}, + #{item.type} + ) + + + \ No newline at end of file diff --git a/src/main/resources/mapper/SysCaseQuestionMapper.xml b/src/main/resources/mapper/SysCaseQuestionMapper.xml index 6dd4040..f366c86 100644 --- a/src/main/resources/mapper/SysCaseQuestionMapper.xml +++ b/src/main/resources/mapper/SysCaseQuestionMapper.xml @@ -454,7 +454,7 @@ select @@ -102,9 +102,9 @@ 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 into sys_resource_data @@ -124,8 +124,8 @@ url, - - school_id, + + source, @@ -144,8 +144,8 @@ #{url,jdbcType=VARCHAR}, - - #{schoolId,jdbcType=VARCHAR}, + + #{source,jdbcType=VARCHAR}, @@ -173,8 +173,8 @@ url = #{record.url,jdbcType=VARCHAR}, - - school_id = #{record.schoolId,jdbcType=VARCHAR}, + + source = #{record.source,jdbcType=VARCHAR}, @@ -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} @@ -208,8 +208,8 @@ url = #{url,jdbcType=VARCHAR}, - - school_id = #{schoolId,jdbcType=VARCHAR}, + + source = #{source,jdbcType=VARCHAR}, 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} \ No newline at end of file