feat: vpps model 添加树结构

This commit is contained in:
super_liu
2021-07-15 18:37:49 +08:00
parent 23e90a822c
commit 5efce6f2d1
16 changed files with 434 additions and 12 deletions
@@ -0,0 +1,41 @@
package com.adc.da.slrs.sarVppsTree.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarVppsTree.service.ISarVppsTreeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.adc.da.slrs.sarVppsTree.entity.SarVppsTree;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.adc.da.base.web.BaseController;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author super_liu
* @since 2021-07-15
*/
@RestController
@Api(tags = "福田标准法规--标准法规库-Vpps树结构")
@RequestMapping("/${restPath}/sarVppsTree")
public class SarVppsTreeController extends BaseController<SarVppsTree> {
@Autowired
private ISarVppsTreeService iSarVppsTreeService;
@ApiOperation("查询所有资源")
@GetMapping("/list")
public ResponseMessage<List<SarVppsTree>> getAll(SarVppsTree sarVppsTree){
List<SarVppsTree> tsResources = iSarVppsTreeService.getAll(sarVppsTree);
return Result.success(tsResources);
}
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarVppsTree.dao;
import com.adc.da.slrs.sarVppsTree.entity.SarVppsTree;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author super_liu
* @since 2021-07-15
*/
public interface SarVppsTreeDao extends BaseMapper<SarVppsTree> {
}
@@ -0,0 +1,76 @@
package com.adc.da.slrs.sarVppsTree.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author super_liu
* @since 2021-07-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarVppsTree对象", description="")
public class SarVppsTree extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId("ID")
private String id;
@ApiModelProperty(value = "VPPS编码")
@TableField("VPPS_CODE")
private String vppsCode;
@ApiModelProperty(value = "父级id")
@TableField("PID")
private String pid;
@ApiModelProperty(value = "编码")
@TableField("CODE")
private String code;
@ApiModelProperty(value = "中文名称")
@TableField("CHINESE_NAME")
private String chineseName;
@ApiModelProperty(value = "中文名称")
@TableField("ENGLISH_NAME")
private String englishName;
@ApiModelProperty(value = "删除标识 1:未删除 2:已删除")
@TableField("DEL_FLAG")
private String delFlag;
@ApiModelProperty(value = "排序序号")
@TableField("SORT")
private Integer sort;
@ApiModelProperty(value = "子菜单")
@TableField(exist = false)
private List<SarVppsTree> children;
@ApiModelProperty(value = "上级菜单名称")
@TableField(exist = false)
private String parentIdsName;
@TableField(exist=false)
private List<String> roleIds;
@TableField(exist=false)
private List<String> childMenuIds;
}
@@ -0,0 +1,19 @@
package com.adc.da.slrs.sarVppsTree.service;
import com.adc.da.slrs.sarVppsTree.entity.SarVppsTree;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author super_liu
* @since 2021-07-15
*/
public interface ISarVppsTreeService extends IService<SarVppsTree> {
List<SarVppsTree> getAll(SarVppsTree sarVppsTree);
}
@@ -0,0 +1,53 @@
package com.adc.da.slrs.sarVppsTree.service.impl;
import com.adc.da.slrs.sarVppsTree.entity.SarVppsTree;
import com.adc.da.slrs.sarVppsTree.dao.SarVppsTreeDao;
import com.adc.da.slrs.sarVppsTree.service.ISarVppsTreeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author super_liu
* @since 2021-07-15
*/
@Service
public class SarVppsTreeServiceImpl extends ServiceImpl<SarVppsTreeDao, SarVppsTree> implements ISarVppsTreeService {
/**
* 查询所有菜单
* @param sarVppsTree
*/
@Override
public List<SarVppsTree> getAll(SarVppsTree sarVppsTree) {
QueryWrapper<SarVppsTree> tsResourceQueryWrapper=new QueryWrapper<>();
tsResourceQueryWrapper.isNull("PID");
List<SarVppsTree> list = this.baseMapper.selectList(tsResourceQueryWrapper);
for(SarVppsTree tree:list){
tree.setChildren(recursionGetChildren((tree)));
}
return list;
}
/**
* 递归调用获取子节点
* @param parent:父节点
* @return List<SarMenu>
*/
private List<SarVppsTree> recursionGetChildren(SarVppsTree parent){
QueryWrapper<SarVppsTree> sarMenuQueryWrapper=new QueryWrapper<>();
sarMenuQueryWrapper.orderByAsc("SORT");
sarMenuQueryWrapper.eq("PID",parent.getId());
List<SarVppsTree> children=this.baseMapper.selectList(sarMenuQueryWrapper);
for(SarVppsTree sarMenu:children){
sarMenu.setChildren(recursionGetChildren((sarMenu)));
}
return children;
}
}