资料中心 接口 以及sql

This commit is contained in:
yuezhihang
2022-07-06 17:53:01 +08:00
parent 667b3efff4
commit 9cd2536e71
17 changed files with 521 additions and 25 deletions
@@ -1,7 +1,10 @@
package com.adc.da.slrs.fileMaterialCenter.dao;
import com.adc.da.slrs.fileMaterialCenter.entity.FileMaterial;
import com.adc.da.slrs.fileMaterialCenter.entity.FileMaterialPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
/**
@@ -16,4 +19,7 @@ public interface FileMaterialDao extends BaseMapper<FileMaterial> {
int topping(@Param("id") String id);
IPage<FileMaterial> getFileMaterialPage(IPage<FileMaterial> page, @Param("flieM") FileMaterialPage fileMaterialPage);
}
@@ -67,4 +67,8 @@ public class FileMaterial extends BaseEntity {
@ApiModelProperty(value = "删除标志")
@TableLogic(value = "0",delval = "1")
private String delFlag;
@ApiModelProperty(value = "删除标志")
@TableField("is_show")
private String isShow;
}
@@ -18,6 +18,8 @@ public class FileMaterialPage {
private String endDataUploadTime;
private String treeId;
private Integer page;
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -32,37 +33,13 @@ public class FileMaterialServiceImpl extends ServiceImpl<FileMaterialDao, FileMa
@Override
public IPage<FileMaterial> getFileMaterial(FileMaterialPage queryPage) {
QueryWrapper<FileMaterial> queryWrapper = new QueryWrapper<>();
if (queryPage.getDataType()!=null){
queryWrapper.eq("data_type",queryPage.getDataType());
}
if (queryPage.getDataTitle()!=null){
queryWrapper.like("data_title",queryPage.getDataTitle());
}
if (queryPage.getStartDataUploadTime()!=null && queryPage.getEndDataUploadTime()!=null){
String strDateFormat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
queryWrapper.between("data_upload_time", queryPage.getStartDataUploadTime(),
queryPage.getEndDataUploadTime());
}
if (queryPage.getId()!=null && !"".equals(queryPage.getId()) ){
queryWrapper.eq("id",queryPage.getId());
}
IPage<FileMaterial> page=null;
if (queryPage.getPage()==null || queryPage .getPageSize()==null){
page=new Page<>(1,1);
}else {
page=new Page<>(queryPage.getPage(),queryPage.getPageSize());
}
return this.page(page,queryWrapper);
return fileMaterialDao.getFileMaterialPage(page,queryPage);
}
@Override
@@ -0,0 +1,72 @@
package com.adc.da.slrs.zlTree.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.zlTree.entity.TreeData;
import com.adc.da.slrs.zlTree.entity.ZlTree;
import com.adc.da.slrs.zlTree.service.IZlTreeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
@RestController
@Api(description = "资料中心")
@RequestMapping("/${restPath}/fileMaterialCenter/zlTree")
public class ZlTreeController extends BaseController<ZlTree> {
@Autowired
IZlTreeService iZlTreeService;
@PostMapping
@ApiOperation("新增资料中心左侧树节点")
public ResponseMessage addFileMaterial(@RequestBody ZlTree material){
boolean save = iZlTreeService.save(material);
return Result.success(save);
}
@DeleteMapping
@ApiOperation("删除树节点")
public ResponseMessage deleteMaterial(String id){
List<String> idList = Arrays.asList(id.split(","));
boolean b = iZlTreeService.removeByIds(idList);
return Result.success(b);
}
@GetMapping
@ApiOperation("查询树结构")
public ResponseMessage<TreeData> getFileMaterial(){
TreeData fileMaterial = iZlTreeService.getLeftTree();
return Result.success(fileMaterial);
}
@PutMapping
@ApiOperation("修改树节点")
public ResponseMessage updateFileMaterial(@RequestBody ZlTree zlTree){
boolean b = iZlTreeService.updateById(zlTree);
return Result.success(b);
}
}
@@ -0,0 +1,54 @@
package com.adc.da.slrs.zlTree.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.zlTree.entity.ZlTree;
import com.adc.da.slrs.zlTree.entity.ZlTreeData;
import com.adc.da.slrs.zlTree.service.IZlTreeDataService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 前端控制器
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
@RestController
@Api(description = "资料中心")
@RequestMapping("/${restPath}/fileMaterialCenter/zlTreeData")
public class ZlTreeDataController extends BaseController<ZlTree> {
@Autowired
IZlTreeDataService iZlTreeService;
@PostMapping(value = "/add")
@ApiOperation("树与数据关联")
public ResponseMessage addFileMaterial(@RequestBody ZlTreeData zlTreeData){
boolean save = iZlTreeService.save(zlTreeData);
return Result.success(save);
}
@PostMapping(value = "/remove")
@ApiOperation("树与数据关联移除")
public ResponseMessage deleteMaterial(@RequestBody ZlTreeData zlTreeData){
QueryWrapper<ZlTreeData> wrapper=new QueryWrapper<>();
wrapper.eq("id",zlTreeData.getId());
wrapper.eq("data_id",zlTreeData.getDataId());
boolean b = iZlTreeService.remove(wrapper);
return Result.success(b);
}
}
@@ -0,0 +1,19 @@
package com.adc.da.slrs.zlTree.dao;
import com.adc.da.slrs.zlTree.entity.ZlTree;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
public interface ZlTreeDao extends BaseMapper<ZlTree> {
int topping(@Param("id") String id);
}
@@ -0,0 +1,17 @@
package com.adc.da.slrs.zlTree.dao;
import com.adc.da.slrs.zlTree.entity.ZlTreeData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
public interface ZlTreeDataDao extends BaseMapper<ZlTreeData> {
}
@@ -0,0 +1,40 @@
package com.adc.da.slrs.zlTree.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class TreeData extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId
private String id;
@ApiModelProperty(value = "父节点")
private String pId;
@ApiModelProperty(value = "名称")
private String name;
List<TreeData> children;
}
@@ -0,0 +1,44 @@
package com.adc.da.slrs.zlTree.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("zl_tree")
public class ZlTree extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "父节点")
@TableField("p_id")
private String pId;
@ApiModelProperty(value = "名称")
@TableField("name")
private String name;
}
@@ -0,0 +1,38 @@
package com.adc.da.slrs.zlTree.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("zl_data")
public class ZlTreeData extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "父节点")
@TableField("data_id")
private String dataId;
}
@@ -0,0 +1,19 @@
package com.adc.da.slrs.zlTree.service;
import com.adc.da.slrs.zlTree.entity.ZlTreeData;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
public interface IZlTreeDataService extends IService<ZlTreeData> {
}
@@ -0,0 +1,43 @@
package com.adc.da.slrs.zlTree.service;
import com.adc.da.slrs.zlTree.entity.TreeData;
import com.adc.da.slrs.zlTree.entity.ZlTree;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
public interface IZlTreeService extends IService<ZlTree> {
/**
* 查询树结构
* @param
* @return
*/
TreeData getLeftTree();
/**
* 获取类型
* @return
*/
List<String> getFileMaterialType();
/**
* 置顶
* @param id
* @return
*/
int topping(String id);
}
@@ -0,0 +1,23 @@
package com.adc.da.slrs.zlTree.service.impl;
import com.adc.da.slrs.zlTree.dao.ZlTreeDataDao;
import com.adc.da.slrs.zlTree.entity.ZlTreeData;
import com.adc.da.slrs.zlTree.service.IZlTreeDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
@Service
public class ZlTreeDataServiceImpl extends ServiceImpl<ZlTreeDataDao, ZlTreeData> implements IZlTreeDataService {
}
@@ -0,0 +1,90 @@
package com.adc.da.slrs.zlTree.service.impl;
import com.adc.da.slrs.zlTree.dao.ZlTreeDao;
import com.adc.da.slrs.zlTree.entity.TreeData;
import com.adc.da.slrs.zlTree.entity.ZlTree;
import com.adc.da.slrs.zlTree.entity.ZlTreeData;
import com.adc.da.slrs.zlTree.service.IZlTreeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author zhaokaiyao
* @since 2021-12-14
*/
@Service
public class ZlTreeServiceImpl extends ServiceImpl<ZlTreeDao, ZlTree> implements IZlTreeService {
@Autowired
ZlTreeDao zlTreeDao;
@Override
public TreeData getLeftTree() {
TreeData res=new TreeData();
List<ZlTree> list=this.list();
List<TreeData> treeData=new ArrayList<>();
//代码遍历生成树
for (ZlTree zlTree:list) {
if (StringUtils.isNotBlank(zlTree.getPId())){
TreeData zlTreeData=new TreeData();
BeanUtils.copyProperties(zlTree,zlTreeData);
treeData.add(zlTreeData);
}else {
BeanUtils.copyProperties(zlTree,res);
}
}
//递归生成树
digui(res,treeData);
return res;
}
private void digui(TreeData res,List<TreeData> treeData){
for (TreeData data:treeData) {
if (res.getId().equals(data.getPId())){
if (null!=res.getChildren()){
res.getChildren().add(data);
}else {
List<TreeData> data1=new ArrayList<>();
data1.add(data);
res.setChildren(data1);
}
}
}
if (null!=res.getChildren()){
for (TreeData treeData1:res.getChildren()) {
digui(treeData1,treeData);
}
}
}
@Override
public List<String> getFileMaterialType() {
QueryWrapper<ZlTree> queryWrapper = new QueryWrapper<>();
queryWrapper.select("DISTINCT data_type");
return this.listObjs(queryWrapper, item -> item.toString());
}
@Override
public int topping(String id) {
return zlTreeDao.topping(id);
}
}