From 29badb21bc2d30b6289a67e163d6c730a2d3bb91 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Tue, 16 Jul 2024 16:23:42 +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/CaseController.java | 6 +- .../controller/CourseManageController.java | 3 + .../controller/CourseTagManageController.java | 1 - .../new_module/admin/AdminCaseController.java | 103 +++++++++++++- .../new_module/admin/AdminDataController.java | 46 ++++++- .../admin/AdminLabelController.java | 17 ++- .../new_module/stu/StuCaseController.java | 16 +-- .../entity/admin/AdminCase.java | 13 +- .../entity/admin/AdminCaseDto.java | 3 + .../entity/admin/AdminCaseExample.java | 70 ++++++++++ .../entity/admin/AdminCaseReturnDto.java | 39 ++++++ .../entity/admin/AdminData.java | 22 +++ .../entity/admin/AdminDataExample.java | 130 ++++++++++++++++++ .../entity/admin/AdminDataReturnDto.java | 41 ++++++ .../mapper/admin/AdminCaseMapper.java | 5 +- .../mapper/admin/AdminDataMapper.java | 10 +- .../mapper/admin/AdminFileMapper.java | 3 + .../resource_center/util/CompressUtil.java | 98 +++++++++++++ src/main/resources/generatorConfig.xml | 6 +- src/main/resources/mapper/AdminCaseMapper.xml | 79 ++++++++++- src/main/resources/mapper/AdminDataMapper.xml | 94 ++++++++++++- src/main/resources/mapper/AdminFileMapper.xml | 8 ++ .../mapper/SysThreeCatalogMapper.xml | 120 +++++++++++----- 23 files changed, 848 insertions(+), 85 deletions(-) create mode 100644 src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseReturnDto.java create mode 100644 src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataReturnDto.java create mode 100644 src/main/java/com/sztzjy/resource_center/util/CompressUtil.java 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 63216b6..dda8739 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CaseController.java @@ -18,8 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -97,7 +99,7 @@ public class CaseController { @RequestParam(required = false) String title, @RequestParam(required = false) String oneId) { PageHelper.startPage(index, size); - List list = caseQuestionMapper.selectCaseByConditions(title, oneId,null); + List list = caseQuestionMapper.selectCaseByConditions(title, oneId, null); PageInfo pageInfo = new PageInfo(list); return new ResultEntity>(pageInfo); } @@ -202,4 +204,4 @@ public class CaseController { } } } -} +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/controller/CourseManageController.java b/src/main/java/com/sztzjy/resource_center/controller/CourseManageController.java index 9d9c66a..18a3aa3 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CourseManageController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CourseManageController.java @@ -78,6 +78,7 @@ public class CourseManageController { @PostMapping("getAllOneCatalogListByDropDown") public ResultEntity> getAllOneCatalogListByDropDown() { SysOneCatalogExample example = new SysOneCatalogExample(); + example.setOrderByClause("sort"); List sysOneCatalogs = sysOneCatalogMapper.selectByExample(example); return new ResultEntity<>(sysOneCatalogs); } @@ -101,6 +102,7 @@ public class CourseManageController { public ResultEntity> getAllTwoCatalogList(@RequestParam String oneId) { SysTwoCatalogExample example = new SysTwoCatalogExample(); example.createCriteria().andOneIdEqualTo(oneId); + example.setOrderByClause("sort"); List sysTwoCatalogs = sysTwoCatalogMapper.selectByExample(example); return new ResultEntity<>(sysTwoCatalogs); } @@ -112,6 +114,7 @@ public class CourseManageController { public ResultEntity> getAllThreeCatalogList(@RequestParam String oneId, @RequestParam String twoId) { SysThreeCatalogExample example = new SysThreeCatalogExample(); example.createCriteria().andOntIdEqualTo(oneId).andTwoIdEqualTo(twoId); + example.setOrderByClause("sort"); List sysThreeCatalogs = sysThreeCatalogMapper.selectByExample(example); return new ResultEntity<>(sysThreeCatalogs); } diff --git a/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java b/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java index 75f1fc5..0700e15 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java @@ -182,7 +182,6 @@ public class CourseTagManageController { @PostMapping("/login") @ApiOperation("登录接口") @AnonymousAccess - public ResultEntity login(@RequestParam String password, @RequestParam String userName) { if (StringUtils.isBlank(password) diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java index 80bb071..9e5c3eb 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java @@ -1,23 +1,32 @@ package com.sztzjy.resource_center.controller.new_module.admin; 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.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.CompressUtil; import com.sztzjy.resource_center.util.ResultEntity; import com.sztzjy.resource_center.util.file.IFileUtil; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.annotations.Param; 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.*; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @Author xcj @@ -35,8 +44,12 @@ public class AdminCaseController { private AdminFileMapper adminFileMapper; @Autowired private IFileUtil fileUtil; + @Value("${file.path}") + private String filePath; - @PostMapping("新增") + + @PostMapping("add") + @ApiOperation("新增") //todo 案例目录和案例正文通过前端传路径过来 ,这里只存url @Transactional ResultEntity add(@ModelAttribute AdminCaseDto adminCaseDto) { if (StringUtils.isBlank(adminCaseDto.getName())) { @@ -61,6 +74,7 @@ public class AdminCaseController { adminCase.setId(caseId); adminCase.setName(adminCaseDto.getName()); adminCase.setStatus(0); //新增默认下架,发布后上架 + adminCase.setSource(adminCaseDto.getSource()); if (adminCaseDto.getPictureFile() != null) { String pictureUrl = fileUtil.upload(adminCaseDto.getPictureFile()); adminCase.setPictureUrl(pictureUrl); @@ -103,9 +117,9 @@ public class AdminCaseController { adminFileMapper.insertBatch(list); } - Listlist =new ArrayList<>(); + List list = new ArrayList<>(); for (AdminLabel adminLabel : adminLabelList) { - AdminDataLabel label =new AdminDataLabel(); + AdminDataLabel label = new AdminDataLabel(); label.setId(IdUtil.randomUUID()); label.setLabelId(adminLabel.getLabelId()); label.setName(adminLabel.getName()); @@ -120,4 +134,85 @@ public class AdminCaseController { } + @PostMapping("get") + @ApiOperation("展示") + @AnonymousAccess + private ResultEntity> add(@RequestParam Integer index, + @RequestParam Integer size, + @RequestParam(required = false) String keyWord, + @Param("精品案例不传,院校案例传学校ID") @RequestParam(required = false) String source, + @RequestParam(required = false) String labelName) { + PageHelper.startPage(index, size); + List adminCaseReturnDtos = adminCaseMapper.selectByConditions(keyWord, source, labelName); + PageInfo pageInfo = new PageInfo(adminCaseReturnDtos); + return new ResultEntity<>(pageInfo); + } + + + @PostMapping("updateAdminCase") + @ApiOperation("案例编辑") + private ResultEntity updateAdminCase(@ModelAttribute AdminCaseDto adminCaseDto) { + List adminLabelList = adminCaseDto.getAdminLabelList(); + List dataFile = adminCaseDto.getDataFile(); + AdminCaseWithBLOBs adminCaseWithBLOBs = adminCaseMapper.selectByPrimaryKey(adminCaseDto.getCaseId()); + + if (adminCaseDto.getPictureFile() != null) { + MultipartFile pictureFile = adminCaseDto.getPictureFile(); + String pictureUrl = fileUtil.upload(pictureFile); + adminCaseWithBLOBs.setPictureUrl(pictureUrl); + } + if (adminCaseDto.getCaseCatalogFile() != null) { + MultipartFile pictureFile = adminCaseDto.getPictureFile(); + String pictureUrl = fileUtil.upload(pictureFile); + adminCaseWithBLOBs.setPictureUrl(pictureUrl); + } + return null; + } + + + @PostMapping("updateStatus") + @ApiOperation("发布或禁用") + private ResultEntity add(@RequestParam String id, + @Param("传0禁用,传1发布上架") @RequestParam int status) { + try { + AdminCaseWithBLOBs adminCaseWithBLOBs = adminCaseMapper.selectByPrimaryKey(id); + adminCaseWithBLOBs.setStatus(status); + adminCaseMapper.updateByPrimaryKeyWithBLOBs(adminCaseWithBLOBs); + } catch (Exception e) { + e.printStackTrace(); + return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR, "发生错误,请联系管理员!"); + } + if (status == 0) { + return new ResultEntity<>(HttpStatus.OK, "成功禁用!"); + } + if (status == 1) { + return new ResultEntity<>(HttpStatus.OK, "成功发布!"); + } + return null; + } + + /** + * 下载文件 支持多个下载 + * 格式 zip包 + * + * @param ids + */ + @GetMapping("/downloadZIP") + @ApiOperation("数据文件打包下载") + @AnonymousAccess + public void download(@RequestBody List ids, HttpServletResponse response) { + this.downloadFile(ids, response); + } + + + public void downloadFile(List ids, HttpServletResponse response) { + if (ids != null && !ids.isEmpty()) { + List> filePaths = adminFileMapper.getByIds(ids); + String zipName = "TZ_" + ((int) (Math.random() * 10000)) + ".zip"; + String zipPath = filePath + "/" + zipName; + CompressUtil.compress(filePaths, zipPath, false); + File pocZipFile = new File(zipPath); + CompressUtil.downloadZip(response, zipName, pocZipFile); + } + } } diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java index 8a30af9..65eb2ff 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java @@ -1,6 +1,9 @@ package com.sztzjy.resource_center.controller.new_module.admin; 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.admin.*; import com.sztzjy.resource_center.mapper.admin.AdminDataLabelMapper; import com.sztzjy.resource_center.mapper.admin.AdminDataMapper; @@ -9,7 +12,9 @@ import com.sztzjy.resource_center.mapper.admin.AdminLabelMapper; import com.sztzjy.resource_center.util.ResultEntity; import com.sztzjy.resource_center.util.file.IFileUtil; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.transaction.annotation.Transactional; @@ -36,7 +41,8 @@ public class AdminDataController { @Autowired private AdminDataMapper adminDataMapper; - @PostMapping("新增") + @PostMapping("add") + @ApiOperation("新增") @Transactional ResultEntity add(@ModelAttribute AdminDataDto adminDataDto) { if (StringUtils.isBlank(adminDataDto.getName())) { @@ -67,6 +73,7 @@ public class AdminDataController { adminDataWithBLOBs.setName(adminDataDto.getName()); adminDataWithBLOBs.setDataScenarios(adminDataDto.getDataScenarios()); adminDataWithBLOBs.setFieldDescription(adminDataDto.getFieldDescription()); + adminDataWithBLOBs.setStatus(0); //默认下架,发布后上架 if (adminDataDto.getPictureUrl() != null) { String pictureUrl = fileUtil.upload(adminDataDto.getPictureFile()); adminDataWithBLOBs.setPictureUrl(pictureUrl); @@ -106,4 +113,41 @@ public class AdminDataController { adminDataMapper.insert(adminDataWithBLOBs); return new ResultEntity<>(HttpStatus.OK,"新增成功!"); } + + @PostMapping("updateStatus") + @ApiOperation("发布或禁用") + private ResultEntity updateStatus(@RequestParam String id, + @Param("传0禁用,传1发布上架") @RequestParam int status) { + try { + AdminDataWithBLOBs adminDataWithBLOBs = adminDataMapper.selectByPrimaryKey(id); + adminDataWithBLOBs.setStatus(status); + adminDataMapper.updateByPrimaryKeyWithBLOBs(adminDataWithBLOBs); + } catch (Exception e) { + e.printStackTrace(); + return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR,"发生错误,请联系管理员!"); + } + if (status == 0) { + return new ResultEntity<>(HttpStatus.OK, "成功禁用!"); + } + if (status == 1) { + return new ResultEntity<>(HttpStatus.OK, "成功发布!"); + } + return null; + } + + + @PostMapping("get") + @ApiOperation("展示") + @AnonymousAccess + private ResultEntity> add(@RequestParam Integer index, + @RequestParam Integer size, + @RequestParam(required = false) String keyWord, + @Param("精品案例不传,院校案例传学校ID") @RequestParam(required = false) String source, + @RequestParam(required = false) String labelName) { + PageHelper.startPage(index, size); + List adminDataReturnDtos = adminDataMapper.selectByConditions(keyWord, source, labelName); + PageInfo pageInfo = new PageInfo(adminDataReturnDtos); + return new ResultEntity<>(pageInfo); + } + } diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminLabelController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminLabelController.java index 8a123c3..a5020e1 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminLabelController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminLabelController.java @@ -6,6 +6,8 @@ import com.sztzjy.resource_center.entity.admin.AdminLabelExample; import com.sztzjy.resource_center.mapper.admin.AdminLabelMapper; import com.sztzjy.resource_center.util.ResultEntity; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -25,7 +27,8 @@ public class AdminLabelController { private AdminLabelMapper adminLabelMapper; - @PostMapping("新增") + @PostMapping("add") + @ApiOperation("新增") private ResultEntity addLabel(@RequestBody AdminLabel adminLabel) { if (StringUtils.isBlank(adminLabel.getName())) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "标签名称不能为空!"); @@ -38,7 +41,8 @@ public class AdminLabelController { return new ResultEntity<>(HttpStatus.OK, "新增成功!"); } - @PostMapping("修改") + @PostMapping("update") + @ApiOperation("修改") private ResultEntity updateLabel(@RequestBody AdminLabel adminLabel) { if (StringUtils.isBlank(adminLabel.getLabelId())) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "缺少必要的ID!"); @@ -60,20 +64,23 @@ public class AdminLabelController { } } - @PostMapping("删除") + @PostMapping("delete") + @ApiOperation("删除") private ResultEntity deleteLabel(@RequestParam String id) { adminLabelMapper.deleteByPrimaryKey(id); return new ResultEntity<>(HttpStatus.OK, "删除成功!"); } - @PostMapping("展示") + @PostMapping("getAdminLabel") + @ApiOperation("展示") private ResultEntity> getLabel() { AdminLabelExample example = new AdminLabelExample(); List adminLabels = adminLabelMapper.selectByExample(example); return new ResultEntity<>(adminLabels); } - @PostMapping("下拉框") + @PostMapping("getDropDown") + @ApiOperation("下拉框") private ResultEntity> getLabelByType(@RequestParam String type) { AdminLabelExample example = new AdminLabelExample(); example.createCriteria().andTypeEqualTo(type); 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 index 4a603bc..3cc104c 100644 --- 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 @@ -1,10 +1,11 @@ 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.annotation.AnonymousAccess; +import com.sztzjy.resource_center.entity.admin.AdminCaseReturnDto; import com.sztzjy.resource_center.mapper.admin.AdminCaseMapper; import com.sztzjy.resource_center.util.ResultEntity; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -26,15 +27,4 @@ public class StuCaseController { 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/AdminCase.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCase.java index 55b6865..d0b33ff 100644 --- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCase.java +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCase.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; public class AdminCase { private String id; - @ApiModelProperty("数据名称") + @ApiModelProperty("案例名称") private String name; @ApiModelProperty("标签表ID") @@ -21,6 +21,9 @@ public class AdminCase { @ApiModelProperty("0下架 1上架") private Integer status; + @ApiModelProperty("管理员/学校ID") + private String source; + public String getId() { return id; } @@ -60,4 +63,12 @@ public class AdminCase { public void setStatus(Integer status) { this.status = status; } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source == null ? null : source.trim(); + } } \ No newline at end of file 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 f4e7269..1f1f245 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 @@ -18,6 +18,9 @@ public class AdminCaseDto { @ApiModelProperty("案例名称") private String name; + @ApiModelProperty("来源/管理员或学校ID") + private String source; + @ApiModelProperty("标签集合") private List adminLabelList; diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseExample.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseExample.java index f6840ae..8724a11 100644 --- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseExample.java +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseExample.java @@ -443,6 +443,76 @@ public class AdminCaseExample { addCriterion("status not between", value1, value2, "status"); return (Criteria) this; } + + public Criteria andSourceIsNull() { + addCriterion("source is null"); + return (Criteria) this; + } + + public Criteria andSourceIsNotNull() { + addCriterion("source is not null"); + return (Criteria) this; + } + + public Criteria andSourceEqualTo(String value) { + addCriterion("source =", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotEqualTo(String value) { + addCriterion("source <>", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceGreaterThan(String value) { + addCriterion("source >", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceGreaterThanOrEqualTo(String value) { + addCriterion("source >=", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLessThan(String value) { + addCriterion("source <", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLessThanOrEqualTo(String value) { + addCriterion("source <=", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLike(String value) { + addCriterion("source like", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotLike(String value) { + addCriterion("source not like", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceIn(List values) { + addCriterion("source in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotIn(List values) { + addCriterion("source not in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceBetween(String value1, String value2) { + addCriterion("source between", value1, value2, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotBetween(String value1, String value2) { + addCriterion("source not between", value1, value2, "source"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseReturnDto.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseReturnDto.java new file mode 100644 index 0000000..4d719fe --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminCaseReturnDto.java @@ -0,0 +1,39 @@ +package com.sztzjy.resource_center.entity.admin; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author xcj + * @Date 2024/7/16 + */ +@Data +public class AdminCaseReturnDto { + private String id; + + @ApiModelProperty("数据名称") + private String name; + + @ApiModelProperty("标签表ID") + private String labelId; + + @ApiModelProperty("图片地址") + private String pictureUrl; + + @ApiModelProperty("0下架 1上架") + private Integer status; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("目录") + private String catalog; + + @ApiModelProperty("标签集") + private List adminDataLabels; + + @ApiModelProperty("文件集") + private List adminFiles; +} diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminData.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminData.java index f573b20..6896137 100644 --- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminData.java +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminData.java @@ -16,6 +16,12 @@ public class AdminData { @ApiModelProperty("图片名称") private String pictureUrl; + @ApiModelProperty("0下架,1上架") + private Integer status; + + @ApiModelProperty("管理员/学校ID") + private String source; + public String getDataId() { return dataId; } @@ -39,4 +45,20 @@ public class AdminData { public void setPictureUrl(String pictureUrl) { this.pictureUrl = pictureUrl == null ? null : pictureUrl.trim(); } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source == null ? null : source.trim(); + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataExample.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataExample.java index 9009d6a..b44d9ff 100644 --- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataExample.java +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataExample.java @@ -313,6 +313,136 @@ public class AdminDataExample { addCriterion("picture_url not between", value1, value2, "pictureUrl"); return (Criteria) this; } + + public Criteria andStatusIsNull() { + addCriterion("status is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("status is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("status =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("status <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("status >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("status >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("status <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("status <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("status in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("status not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("status between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("status not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andSourceIsNull() { + addCriterion("source is null"); + return (Criteria) this; + } + + public Criteria andSourceIsNotNull() { + addCriterion("source is not null"); + return (Criteria) this; + } + + public Criteria andSourceEqualTo(String value) { + addCriterion("source =", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotEqualTo(String value) { + addCriterion("source <>", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceGreaterThan(String value) { + addCriterion("source >", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceGreaterThanOrEqualTo(String value) { + addCriterion("source >=", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLessThan(String value) { + addCriterion("source <", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLessThanOrEqualTo(String value) { + addCriterion("source <=", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLike(String value) { + addCriterion("source like", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotLike(String value) { + addCriterion("source not like", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceIn(List values) { + addCriterion("source in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotIn(List values) { + addCriterion("source not in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceBetween(String value1, String value2) { + addCriterion("source between", value1, value2, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotBetween(String value1, String value2) { + addCriterion("source not between", value1, value2, "source"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataReturnDto.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataReturnDto.java new file mode 100644 index 0000000..706701d --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataReturnDto.java @@ -0,0 +1,41 @@ +package com.sztzjy.resource_center.entity.admin; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author xcj + * @Date 2024/7/16 + */ +@Data +public class AdminDataReturnDto { + @ApiModelProperty("数据表ID") + private String dataId; + + @ApiModelProperty("数据名称") + private String name; + + @ApiModelProperty("图片名称") + private String pictureUrl; + + @ApiModelProperty("0下架,1上架") + private Integer status; + + @ApiModelProperty("管理员/学校ID") + private String source; + + @ApiModelProperty("数据应用场景") + private String dataScenarios; + + @ApiModelProperty("字段描述") + private String fieldDescription; + + @ApiModelProperty("标签集") + private List adminDataLabels; + + @ApiModelProperty("文件集") + private List adminFiles; + +} 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 1423965..039f2d1 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 @@ -2,6 +2,7 @@ package com.sztzjy.resource_center.mapper.admin; import com.sztzjy.resource_center.entity.admin.AdminCase; import com.sztzjy.resource_center.entity.admin.AdminCaseExample; +import com.sztzjy.resource_center.entity.admin.AdminCaseReturnDto; import com.sztzjy.resource_center.entity.admin.AdminCaseWithBLOBs; import java.util.List; @@ -37,5 +38,7 @@ public interface AdminCaseMapper { int updateByPrimaryKey(AdminCase record); - void selectByConditions(@Param("keyWord") String keyWord, @Param("label") String label); + List selectByConditions(@Param("keyWord") String keyWord, + @Param("source") String source, + @Param("labelName") String labelName); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataMapper.java index 5f406a2..90a86a2 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataMapper.java @@ -2,12 +2,12 @@ package com.sztzjy.resource_center.mapper.admin; import com.sztzjy.resource_center.entity.admin.AdminData; import com.sztzjy.resource_center.entity.admin.AdminDataExample; +import com.sztzjy.resource_center.entity.admin.AdminDataReturnDto; import com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface AdminDataMapper { long countByExample(AdminDataExample example); @@ -37,4 +37,8 @@ public interface AdminDataMapper { int updateByPrimaryKeyWithBLOBs(AdminDataWithBLOBs record); int updateByPrimaryKey(AdminData record); + + List selectByConditions(@Param("keyWord") String keyWord, + @Param("source") String source, + @Param("labelName") String labelName); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminFileMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminFileMapper.java index 7dce12a..369c5ec 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminFileMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminFileMapper.java @@ -3,6 +3,7 @@ package com.sztzjy.resource_center.mapper.admin; import com.sztzjy.resource_center.entity.admin.AdminFile; import com.sztzjy.resource_center.entity.admin.AdminFileExample; import java.util.List; +import java.util.Map; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -33,4 +34,6 @@ public interface AdminFileMapper { int updateByPrimaryKey(AdminFile record); void insertBatch(@Param("list") List dataFileList); + + List> getByIds(@Param("ids") List ids); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/util/CompressUtil.java b/src/main/java/com/sztzjy/resource_center/util/CompressUtil.java new file mode 100644 index 0000000..6623f34 --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/util/CompressUtil.java @@ -0,0 +1,98 @@ +package com.sztzjy.resource_center.util; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +@Component +public class CompressUtil { + private static String filePath; + + @Value("${file.path}") + public void setKey(String filePath) { //注意这里的set方法不能是静态的 + CompressUtil.filePath = filePath; + } + /** + * 生成zip压缩文件 + * @param filePaths + * @param zipFilePath + * @param keepDirStructure + */ + public static void compress(List> filePaths, String zipFilePath, Boolean keepDirStructure) { + byte[] buf = new byte[1024]; + File zipFile = new File(zipFilePath); + try { + ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)); + for (int i = 0; i < filePaths.size(); i++) { + String relativeName = filePaths.get(i).get("name"); + String relativePath = filePath+filePaths.get(i).get("file_url")+"/"+relativeName; + if (StringUtils.isEmpty(relativePath)) { + continue; + } + File sourceFile = new File(relativePath); + if (sourceFile == null || !sourceFile.exists()) { + continue; + } + FileInputStream fis = new FileInputStream(sourceFile); + if (keepDirStructure != null && keepDirStructure) { + zos.putNextEntry(new ZipEntry(relativePath)); + } else { + zos.putNextEntry(new ZipEntry(i + "_" + relativeName)); + } + int len; + while ((len = fis.read(buf)) > 0) { + zos.write(buf, 0, len); + } + zos.closeEntry(); + // zos.close(); + } + zos.close(); + if (!zipFile.exists()) { + zipFile.createNewFile(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 下载zip + * + * @param response + * @param zipName 浏览器header中zip名称 + * @param zipFile zipFile文件 + */ + public static void downloadZip(HttpServletResponse response, String zipName, File zipFile) { + //下载文件 + try { + response.setCharacterEncoding("utf-8"); + response.setContentType("application/zip"); + response.setHeader("Content-Disposition", "attachment;FileName=" + zipName); + ServletOutputStream out = response.getOutputStream(); + int len = 0; + byte[] buffer = new byte[1024]; + FileInputStream fis = new FileInputStream(zipFile); + while ((len = fis.read(buffer)) > 0) { + out.write(buffer, 0, len); + out.flush(); + } + out.close(); + fis.close(); + response.flushBuffer(); + } catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index 0e4ea99..9912658 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -52,9 +52,9 @@ - - - +
+
+ diff --git a/src/main/resources/mapper/AdminCaseMapper.xml b/src/main/resources/mapper/AdminCaseMapper.xml index 0fc3b66..b85c633 100644 --- a/src/main/resources/mapper/AdminCaseMapper.xml +++ b/src/main/resources/mapper/AdminCaseMapper.xml @@ -7,6 +7,7 @@ + @@ -71,7 +72,7 @@ - id, name, label_id, picture_url, status + id, name, label_id, picture_url, status, source content, catalog @@ -126,11 +127,11 @@ insert into admin_case (id, name, label_id, - picture_url, status, content, - catalog) + picture_url, status, source, + content, catalog) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{labelId,jdbcType=VARCHAR}, - #{pictureUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{content,jdbcType=LONGVARCHAR}, - #{catalog,jdbcType=LONGVARCHAR}) + #{pictureUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR}, + #{content,jdbcType=LONGVARCHAR}, #{catalog,jdbcType=LONGVARCHAR}) insert into admin_case @@ -150,6 +151,9 @@ status, + + source, + content, @@ -173,6 +177,9 @@ #{status,jdbcType=INTEGER}, + + #{source,jdbcType=VARCHAR}, + #{content,jdbcType=LONGVARCHAR}, @@ -205,6 +212,9 @@ status = #{record.status,jdbcType=INTEGER}, + + source = #{record.source,jdbcType=VARCHAR}, + content = #{record.content,jdbcType=LONGVARCHAR}, @@ -223,6 +233,7 @@ label_id = #{record.labelId,jdbcType=VARCHAR}, picture_url = #{record.pictureUrl,jdbcType=VARCHAR}, status = #{record.status,jdbcType=INTEGER}, + source = #{record.source,jdbcType=VARCHAR}, content = #{record.content,jdbcType=LONGVARCHAR}, catalog = #{record.catalog,jdbcType=LONGVARCHAR} @@ -235,7 +246,8 @@ name = #{record.name,jdbcType=VARCHAR}, label_id = #{record.labelId,jdbcType=VARCHAR}, picture_url = #{record.pictureUrl,jdbcType=VARCHAR}, - status = #{record.status,jdbcType=INTEGER} + status = #{record.status,jdbcType=INTEGER}, + source = #{record.source,jdbcType=VARCHAR} @@ -255,6 +267,9 @@ status = #{status,jdbcType=INTEGER}, + + source = #{source,jdbcType=VARCHAR}, + content = #{content,jdbcType=LONGVARCHAR}, @@ -270,6 +285,7 @@ label_id = #{labelId,jdbcType=VARCHAR}, picture_url = #{pictureUrl,jdbcType=VARCHAR}, status = #{status,jdbcType=INTEGER}, + source = #{source,jdbcType=VARCHAR}, content = #{content,jdbcType=LONGVARCHAR}, catalog = #{catalog,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -279,7 +295,56 @@ set name = #{name,jdbcType=VARCHAR}, label_id = #{labelId,jdbcType=VARCHAR}, picture_url = #{pictureUrl,jdbcType=VARCHAR}, - status = #{status,jdbcType=INTEGER} + status = #{status,jdbcType=INTEGER}, + source = #{source,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/AdminDataMapper.xml b/src/main/resources/mapper/AdminDataMapper.xml index e44964a..d13bdb8 100644 --- a/src/main/resources/mapper/AdminDataMapper.xml +++ b/src/main/resources/mapper/AdminDataMapper.xml @@ -5,6 +5,8 @@ + + @@ -69,7 +71,7 @@ - data_id, name, picture_url + data_id, name, picture_url, status, source data_scenarios, field_description @@ -124,11 +126,11 @@ insert into admin_data (data_id, name, picture_url, - data_scenarios, field_description - ) + status, source, data_scenarios, + field_description) values (#{dataId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pictureUrl,jdbcType=VARCHAR}, - #{dataScenarios,jdbcType=LONGVARCHAR}, #{fieldDescription,jdbcType=LONGVARCHAR} - ) + #{status,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR}, #{dataScenarios,jdbcType=LONGVARCHAR}, + #{fieldDescription,jdbcType=LONGVARCHAR}) insert into admin_data @@ -142,6 +144,12 @@ picture_url, + + status, + + + source, + data_scenarios, @@ -159,6 +167,12 @@ #{pictureUrl,jdbcType=VARCHAR}, + + #{status,jdbcType=INTEGER}, + + + #{source,jdbcType=VARCHAR}, + #{dataScenarios,jdbcType=LONGVARCHAR}, @@ -185,6 +199,12 @@ picture_url = #{record.pictureUrl,jdbcType=VARCHAR}, + + status = #{record.status,jdbcType=INTEGER}, + + + source = #{record.source,jdbcType=VARCHAR}, + data_scenarios = #{record.dataScenarios,jdbcType=LONGVARCHAR}, @@ -201,6 +221,8 @@ set data_id = #{record.dataId,jdbcType=VARCHAR}, name = #{record.name,jdbcType=VARCHAR}, picture_url = #{record.pictureUrl,jdbcType=VARCHAR}, + status = #{record.status,jdbcType=INTEGER}, + source = #{record.source,jdbcType=VARCHAR}, data_scenarios = #{record.dataScenarios,jdbcType=LONGVARCHAR}, field_description = #{record.fieldDescription,jdbcType=LONGVARCHAR} @@ -211,7 +233,9 @@ update admin_data set data_id = #{record.dataId,jdbcType=VARCHAR}, name = #{record.name,jdbcType=VARCHAR}, - picture_url = #{record.pictureUrl,jdbcType=VARCHAR} + picture_url = #{record.pictureUrl,jdbcType=VARCHAR}, + status = #{record.status,jdbcType=INTEGER}, + source = #{record.source,jdbcType=VARCHAR} @@ -225,6 +249,12 @@ picture_url = #{pictureUrl,jdbcType=VARCHAR}, + + status = #{status,jdbcType=INTEGER}, + + + source = #{source,jdbcType=VARCHAR}, + data_scenarios = #{dataScenarios,jdbcType=LONGVARCHAR}, @@ -238,6 +268,8 @@ update admin_data set name = #{name,jdbcType=VARCHAR}, picture_url = #{pictureUrl,jdbcType=VARCHAR}, + status = #{status,jdbcType=INTEGER}, + source = #{source,jdbcType=VARCHAR}, data_scenarios = #{dataScenarios,jdbcType=LONGVARCHAR}, field_description = #{fieldDescription,jdbcType=LONGVARCHAR} where data_id = #{dataId,jdbcType=VARCHAR} @@ -245,7 +277,55 @@ update admin_data set name = #{name,jdbcType=VARCHAR}, - picture_url = #{pictureUrl,jdbcType=VARCHAR} + picture_url = #{pictureUrl,jdbcType=VARCHAR}, + status = #{status,jdbcType=INTEGER}, + source = #{source,jdbcType=VARCHAR} where data_id = #{dataId,jdbcType=VARCHAR} + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/AdminFileMapper.xml b/src/main/resources/mapper/AdminFileMapper.xml index e2c94d2..77e3827 100644 --- a/src/main/resources/mapper/AdminFileMapper.xml +++ b/src/main/resources/mapper/AdminFileMapper.xml @@ -222,5 +222,13 @@ ) + \ No newline at end of file diff --git a/src/main/resources/mapper/SysThreeCatalogMapper.xml b/src/main/resources/mapper/SysThreeCatalogMapper.xml index 8e2ec1a..64cfd36 100644 --- a/src/main/resources/mapper/SysThreeCatalogMapper.xml +++ b/src/main/resources/mapper/SysThreeCatalogMapper.xml @@ -242,55 +242,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UPDATE sys_three_catalog - - - ont_id = CASE - - - WHEN three_id = #{innerItem.threeId} THEN #{innerItem.ontId} - - - ELSE ont_id - END, - - + + ont_id = CASE + + + WHEN three_id = #{item.threeId} THEN #{item.ontId} + + + ELSE ont_id + END, + - - - two_id = CASE - - - WHEN three_id = #{innerItem.threeId} THEN #{innerItem.twoId} - - - ELSE two_id - END, - - + + two_id = CASE + + + WHEN three_id = #{item.threeId} THEN #{item.twoId} + + + ELSE two_id + END, + - - - sort = CASE - - - WHEN three_id = #{innerItem.threeId} THEN #{innerItem.sort} - - - ELSE sort - END - - + + sort = CASE + + + WHEN three_id = #{item.threeId} THEN #{item.sort} + + + ELSE sort + END + WHERE three_id IN - + #{item.threeId} + \ No newline at end of file