改为模糊查询

master
xiaoCJ 8 months ago
parent 8403d560ea
commit 29badb21bc

@ -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<SysCaseQuestion> list = caseQuestionMapper.selectCaseByConditions(title, oneId,null);
List<SysCaseQuestion> list = caseQuestionMapper.selectCaseByConditions(title, oneId, null);
PageInfo pageInfo = new PageInfo<SysCaseQuestion>(list);
return new ResultEntity<PageInfo<SysCaseQuestion>>(pageInfo);
}

@ -78,6 +78,7 @@ public class CourseManageController {
@PostMapping("getAllOneCatalogListByDropDown")
public ResultEntity<List<SysOneCatalog>> getAllOneCatalogListByDropDown() {
SysOneCatalogExample example = new SysOneCatalogExample();
example.setOrderByClause("sort");
List<SysOneCatalog> sysOneCatalogs = sysOneCatalogMapper.selectByExample(example);
return new ResultEntity<>(sysOneCatalogs);
}
@ -101,6 +102,7 @@ public class CourseManageController {
public ResultEntity<List<SysTwoCatalog>> getAllTwoCatalogList(@RequestParam String oneId) {
SysTwoCatalogExample example = new SysTwoCatalogExample();
example.createCriteria().andOneIdEqualTo(oneId);
example.setOrderByClause("sort");
List<SysTwoCatalog> sysTwoCatalogs = sysTwoCatalogMapper.selectByExample(example);
return new ResultEntity<>(sysTwoCatalogs);
}
@ -112,6 +114,7 @@ public class CourseManageController {
public ResultEntity<List<SysThreeCatalog>> getAllThreeCatalogList(@RequestParam String oneId, @RequestParam String twoId) {
SysThreeCatalogExample example = new SysThreeCatalogExample();
example.createCriteria().andOntIdEqualTo(oneId).andTwoIdEqualTo(twoId);
example.setOrderByClause("sort");
List<SysThreeCatalog> sysThreeCatalogs = sysThreeCatalogMapper.selectByExample(example);
return new ResultEntity<>(sysThreeCatalogs);
}

@ -182,7 +182,6 @@ public class CourseTagManageController {
@PostMapping("/login")
@ApiOperation("登录接口")
@AnonymousAccess
public ResultEntity login(@RequestParam String password,
@RequestParam String userName) {
if (StringUtils.isBlank(password)

@ -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<String> 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);
}
List<AdminDataLabel>list =new ArrayList<>();
List<AdminDataLabel> 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<PageInfo<AdminCaseReturnDto>> 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<AdminCaseReturnDto> adminCaseReturnDtos = adminCaseMapper.selectByConditions(keyWord, source, labelName);
PageInfo pageInfo = new PageInfo(adminCaseReturnDtos);
return new ResultEntity<>(pageInfo);
}
@PostMapping("updateAdminCase")
@ApiOperation("案例编辑")
private ResultEntity<String> updateAdminCase(@ModelAttribute AdminCaseDto adminCaseDto) {
List<AdminLabel> adminLabelList = adminCaseDto.getAdminLabelList();
List<MultipartFile> 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<String> 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<String> ids, HttpServletResponse response) {
this.downloadFile(ids, response);
}
public void downloadFile(List<String> ids, HttpServletResponse response) {
if (ids != null && !ids.isEmpty()) {
List<Map<String, String>> 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);
}
}
}

@ -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<String> 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<String> 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<PageInfo<AdminDataReturnDto>> 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<AdminDataReturnDto> adminDataReturnDtos = adminDataMapper.selectByConditions(keyWord, source, labelName);
PageInfo pageInfo = new PageInfo(adminDataReturnDtos);
return new ResultEntity<>(pageInfo);
}
}

@ -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<String> 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<String> 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<String> deleteLabel(@RequestParam String id) {
adminLabelMapper.deleteByPrimaryKey(id);
return new ResultEntity<>(HttpStatus.OK, "删除成功!");
}
@PostMapping("展示")
@PostMapping("getAdminLabel")
@ApiOperation("展示")
private ResultEntity<List<AdminLabel>> getLabel() {
AdminLabelExample example = new AdminLabelExample();
List<AdminLabel> adminLabels = adminLabelMapper.selectByExample(example);
return new ResultEntity<>(adminLabels);
}
@PostMapping("下拉框")
@PostMapping("getDropDown")
@ApiOperation("下拉框")
private ResultEntity<List<AdminLabel>> getLabelByType(@RequestParam String type) {
AdminLabelExample example = new AdminLabelExample();
example.createCriteria().andTypeEqualTo(type);

@ -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<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;
}
}

@ -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();
}
}

@ -18,6 +18,9 @@ public class AdminCaseDto {
@ApiModelProperty("案例名称")
private String name;
@ApiModelProperty("来源/管理员或学校ID")
private String source;
@ApiModelProperty("标签集合")
private List<AdminLabel> adminLabelList;

@ -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<String> values) {
addCriterion("source in", values, "source");
return (Criteria) this;
}
public Criteria andSourceNotIn(List<String> 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 {

@ -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<AdminDataLabel> adminDataLabels;
@ApiModelProperty("文件集")
private List<AdminFile> adminFiles;
}

@ -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();
}
}

@ -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<Integer> values) {
addCriterion("status in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<Integer> 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<String> values) {
addCriterion("source in", values, "source");
return (Criteria) this;
}
public Criteria andSourceNotIn(List<String> 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 {

@ -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<AdminDataLabel> adminDataLabels;
@ApiModelProperty("文件集")
private List<AdminFile> adminFiles;
}

@ -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<AdminCaseReturnDto> selectByConditions(@Param("keyWord") String keyWord,
@Param("source") String source,
@Param("labelName") String labelName);
}

@ -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<AdminDataReturnDto> selectByConditions(@Param("keyWord") String keyWord,
@Param("source") String source,
@Param("labelName") String labelName);
}

@ -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<AdminFile> dataFileList);
List<Map<String, String>> getByIds(@Param("ids") List<String> ids);
}

@ -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<Map<String, String>> 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 headerzip
* @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();
}
}
}

@ -52,9 +52,9 @@
<!-- <table tableName="sys_school" domainObjectName="SysSchool" />-->
<!-- <table tableName="sys_three_catalog" domainObjectName="SysThreeCatalog" />-->
<!-- <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_case" domainObjectName="AdminCase" />
<table tableName="admin_data" domainObjectName="AdminData" />
<!-- <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" />-->

@ -7,6 +7,7 @@
<result column="label_id" jdbcType="VARCHAR" property="labelId" />
<result column="picture_url" jdbcType="VARCHAR" property="pictureUrl" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="source" jdbcType="VARCHAR" property="source" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.sztzjy.resource_center.entity.admin.AdminCaseWithBLOBs">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
@ -71,7 +72,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, name, label_id, picture_url, status
id, name, label_id, picture_url, status, source
</sql>
<sql id="Blob_Column_List">
content, catalog
@ -126,11 +127,11 @@
</delete>
<insert id="insert" parameterType="com.sztzjy.resource_center.entity.admin.AdminCaseWithBLOBs">
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>
<insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.admin.AdminCaseWithBLOBs">
insert into admin_case
@ -150,6 +151,9 @@
<if test="status != null">
status,
</if>
<if test="source != null">
source,
</if>
<if test="content != null">
content,
</if>
@ -173,6 +177,9 @@
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="source != null">
#{source,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
@ -205,6 +212,9 @@
<if test="record.status != null">
status = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.source != null">
source = #{record.source,jdbcType=VARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
@ -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}
<if test="_parameter != null">
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -255,6 +267,9 @@
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="source != null">
source = #{source,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
@ -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}
</update>
<resultMap id="dtoMap" type="com.sztzjy.resource_center.entity.admin.AdminCaseReturnDto">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="label_id" jdbcType="VARCHAR" property="labelId"/>
<result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="content" jdbcType="LONGVARCHAR" property="content"/>
<result column="catalog" jdbcType="LONGVARCHAR" property="catalog"/>
<result column="source" jdbcType="VARCHAR" property="source"/>
<collection property="adminDataLabels" ofType="com.sztzjy.resource_center.entity.admin.AdminDataLabel">
<id column="label_id" jdbcType="VARCHAR" property="labelId"/>
<result column="label_name" jdbcType="VARCHAR" property="name"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId"/>
</collection>
<collection property="adminFiles" ofType="com.sztzjy.resource_center.entity.admin.AdminFile">
<id column="file_url" jdbcType="VARCHAR" property="fileUrl"/>
<id column="file_id" jdbcType="VARCHAR" property="fileId"/>
<result column="file_name" jdbcType="VARCHAR" property="name"/>
<result column="source" jdbcType="VARCHAR" property="source"/>
<result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId"/>
</collection>
</resultMap>
<select id="selectByConditions" resultMap="dtoMap">
SELECT a.id,a.name,a.content,a.catalog,a.picture_url,a.`status`,a.source,
ad.`name`as label_name,ad.label_id,ad.type,ad.data_case_id,
af.file_url,af.`name` as file_name,af.source,af.file_id,af.data_case_id
FROM admin_case a
left join admin_data_label ad ON a.id = ad.data_case_id
LEFT JOIN admin_file af on a.id = af.data_case_id
<where>
a.status=1
<if test="keyWord !=null and keyWord !=''">
and a.name like CONCAT('%', #{keyWord}, '%')
</if>
<if test="labelName !=null and labelName !=''">
and ad.name = #{labelName}
</if>
<if test="source !=null and source !=''">
and a.source = #{source}
</if>
</where>
</select>
</mapper>

@ -5,6 +5,8 @@
<id column="data_id" jdbcType="VARCHAR" property="dataId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="picture_url" jdbcType="VARCHAR" property="pictureUrl" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="source" jdbcType="VARCHAR" property="source" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
<result column="data_scenarios" jdbcType="LONGVARCHAR" property="dataScenarios" />
@ -69,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List">
data_id, name, picture_url
data_id, name, picture_url, status, source
</sql>
<sql id="Blob_Column_List">
data_scenarios, field_description
@ -124,11 +126,11 @@
</delete>
<insert id="insert" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
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>
<insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
insert into admin_data
@ -142,6 +144,12 @@
<if test="pictureUrl != null">
picture_url,
</if>
<if test="status != null">
status,
</if>
<if test="source != null">
source,
</if>
<if test="dataScenarios != null">
data_scenarios,
</if>
@ -159,6 +167,12 @@
<if test="pictureUrl != null">
#{pictureUrl,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="source != null">
#{source,jdbcType=VARCHAR},
</if>
<if test="dataScenarios != null">
#{dataScenarios,jdbcType=LONGVARCHAR},
</if>
@ -185,6 +199,12 @@
<if test="record.pictureUrl != null">
picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.source != null">
source = #{record.source,jdbcType=VARCHAR},
</if>
<if test="record.dataScenarios != null">
data_scenarios = #{record.dataScenarios,jdbcType=LONGVARCHAR},
</if>
@ -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}
<if test="_parameter != null">
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -225,6 +249,12 @@
<if test="pictureUrl != null">
picture_url = #{pictureUrl,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="source != null">
source = #{source,jdbcType=VARCHAR},
</if>
<if test="dataScenarios != null">
data_scenarios = #{dataScenarios,jdbcType=LONGVARCHAR},
</if>
@ -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 id="updateByPrimaryKey" parameterType="com.sztzjy.resource_center.entity.admin.AdminData">
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}
</update>
<resultMap id="dtoMap" type="com.sztzjy.resource_center.entity.admin.AdminDataReturnDto">
<id column="data_id" jdbcType="VARCHAR" property="dataId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="data_scenarios" jdbcType="LONGVARCHAR" property="dataScenarios"/>
<result column="field_description" jdbcType="LONGVARCHAR" property="fieldDescription"/>
<result column="source" jdbcType="VARCHAR" property="source"/>
<collection property="adminDataLabels" ofType="com.sztzjy.resource_center.entity.admin.AdminDataLabel">
<id column="label_id" jdbcType="VARCHAR" property="labelId"/>
<result column="label_name" jdbcType="VARCHAR" property="name"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId"/>
</collection>
<collection property="adminFiles" ofType="com.sztzjy.resource_center.entity.admin.AdminFile">
<id column="file_url" jdbcType="VARCHAR" property="fileUrl"/>
<id column="file_id" jdbcType="VARCHAR" property="fileId"/>
<result column="file_name" jdbcType="VARCHAR" property="name"/>
<result column="source" jdbcType="VARCHAR" property="source"/>
<result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId"/>
</collection>
</resultMap>
<select id="selectByConditions" resultMap="dtoMap">
SELECT a.data_id,a.name,a.picture_url,a.data_scenarios,a.field_description,a.`status`,a.source,
ad.`name`as label_name,ad.label_id,ad.type,ad.data_case_id,
af.file_url,af.`name` as file_name,af.source,af.file_id,af.data_case_id
FROM admin_data a
left join admin_data_label ad ON a.data_id = ad.data_case_id
LEFT JOIN admin_file af on a.data_id = af.data_case_id
<where>
a.status=1
<if test="keyWord !=null and keyWord !=''">
and a.name like CONCAT('%', #{keyWord}, '%')
</if>
<if test="labelName !=null and labelName !=''">
and ad.name = #{labelName}
</if>
<if test="source !=null and source !=''">
and a.source = #{source}
</if>
</where>
</select>
</mapper>

@ -222,5 +222,13 @@
)
</foreach>
</insert>
<select id="getByIds" parameterType="String" resultType="map">
SELECT af.file_url,af.name FROM admin_file af
WHERE af.file_url IS NOT NULL
AND af.file_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

@ -242,55 +242,101 @@
</update>
<!-- <update id="updateByBatch" parameterType="java.util.List">-->
<!-- UPDATE sys_three_catalog-->
<!-- <set>-->
<!-- &lt;!&ndash; 更新 ont_id 字段 &ndash;&gt;-->
<!-- <foreach collection="sysThreeCatalogs" item="item" separator=",">-->
<!-- <if test="item.ontId != null and item.ontId != ''">-->
<!-- ont_id = CASE-->
<!-- <foreach collection="sysThreeCatalogs" item="innerItem" separator=" ">-->
<!-- <if test="innerItem.twoId != null and innerItem.ontId != null and innerItem.threeId == item.threeId">-->
<!-- WHEN three_id = #{innerItem.threeId} THEN #{innerItem.ontId}-->
<!-- </if>-->
<!-- </foreach>-->
<!-- ELSE ont_id-->
<!-- END,-->
<!-- </if>-->
<!-- </foreach>-->
<!-- &lt;!&ndash; 更新 two_id 字段 &ndash;&gt;-->
<!-- <foreach collection="sysThreeCatalogs" item="item" separator=",">-->
<!-- <if test="item.twoId != null and item.twoId != ''">-->
<!-- two_id = CASE-->
<!-- <foreach collection="sysThreeCatalogs" item="innerItem" separator=" ">-->
<!-- <if test="innerItem.twoId != null and innerItem.ontId != null and innerItem.threeId == item.threeId">-->
<!-- WHEN three_id = #{innerItem.threeId} THEN #{innerItem.twoId}-->
<!-- </if>-->
<!-- </foreach>-->
<!-- ELSE two_id-->
<!-- END,-->
<!-- </if>-->
<!-- </foreach>-->
<!-- &lt;!&ndash; 更新 sort 字段 &ndash;&gt;-->
<!-- <foreach collection="sysThreeCatalogs" item="item" separator=",">-->
<!-- <if test="item.sort != null">-->
<!-- sort = CASE-->
<!-- <foreach collection="sysThreeCatalogs" item="innerItem" separator=" ">-->
<!-- <if test="innerItem.twoId != null and innerItem.sort != null and innerItem.threeId == item.threeId">-->
<!-- WHEN three_id = #{innerItem.threeId} THEN #{innerItem.sort}-->
<!-- </if>-->
<!-- </foreach>-->
<!-- ELSE sort-->
<!-- END-->
<!-- </if>-->
<!-- </foreach>-->
<!-- </set>-->
<!-- WHERE three_id IN-->
<!-- <foreach collection="sysThreeCatalogs" item="item" open="(" close=")" separator=",">-->
<!-- #{item.threeId}-->
<!-- </foreach>-->
<!-- </update>-->
<update id="updateByBatch" parameterType="java.util.List">
UPDATE sys_three_catalog
<set>
<!-- 更新 ont_id 字段 -->
<foreach collection="sysThreeCatalogs" item="item" separator=",">
<if test="item.ontId != null and item.ontId != ''">
<if test="sysThreeCatalogs != null and !sysThreeCatalogs.isEmpty()">
ont_id = CASE
<foreach collection="sysThreeCatalogs" item="innerItem" separator=" ">
<if test="innerItem.twoId != null and innerItem.ontId != null and innerItem.threeId == item.threeId">
WHEN three_id = #{innerItem.threeId} THEN #{innerItem.ontId}
<foreach collection="sysThreeCatalogs" item="item">
<if test="item.ontId != null and item.ontId != ''">
WHEN three_id = #{item.threeId} THEN #{item.ontId}
</if>
</foreach>
ELSE ont_id
END,
</if>
</foreach>
<!-- 更新 two_id 字段 -->
<foreach collection="sysThreeCatalogs" item="item" separator=",">
<if test="item.twoId != null and item.twoId != ''">
<if test="sysThreeCatalogs != null and !sysThreeCatalogs.isEmpty()">
two_id = CASE
<foreach collection="sysThreeCatalogs" item="innerItem" separator=" ">
<if test="innerItem.twoId != null and innerItem.ontId != null and innerItem.threeId == item.threeId">
WHEN three_id = #{innerItem.threeId} THEN #{innerItem.twoId}
<foreach collection="sysThreeCatalogs" item="item">
<if test="item.twoId != null and item.twoId != ''">
WHEN three_id = #{item.threeId} THEN #{item.twoId}
</if>
</foreach>
ELSE two_id
END,
</if>
</foreach>
<!-- 更新 sort 字段 -->
<foreach collection="sysThreeCatalogs" item="item" separator=",">
<if test="item.sort != null">
<if test="sysThreeCatalogs != null and !sysThreeCatalogs.isEmpty()">
sort = CASE
<foreach collection="sysThreeCatalogs" item="innerItem" separator=" ">
<if test="innerItem.twoId != null and innerItem.sort != null and innerItem.threeId == item.threeId">
WHEN three_id = #{innerItem.threeId} THEN #{innerItem.sort}
<foreach collection="sysThreeCatalogs" item="item">
<if test="item.sort != null">
WHEN three_id = #{item.threeId} THEN #{item.sort}
</if>
</foreach>
ELSE sort
END
</if>
</foreach>
</set>
WHERE three_id IN
<foreach collection="sysThreeCatalogs" item="item" open="(" close=")" separator=",">
<foreach collection="sysThreeCatalogs" item="item" open="(" separator="," close=")">
#{item.threeId}
</foreach>
</update>
</mapper>
Loading…
Cancel
Save