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,40 @@
package com.adc.da.slrs.sarModelTree.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarModelTree.service.ISarModelTreeService;
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.sarModelTree.entity.SarModelTree;
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 = "福田标准法规--标准法规库-模块树结构")
@RequestMapping("/${restPath}/sarModelTree")
public class SarModelTreeController extends BaseController<SarModelTree> {
@Autowired
private ISarModelTreeService iSarModelTreeService;
@ApiOperation("查询所有资源")
@GetMapping("/list")
public ResponseMessage<List<SarModelTree>> getAll(SarModelTree sarVppsTree){
List<SarModelTree> tsResources = iSarModelTreeService.getAll(sarVppsTree);
return Result.success(tsResources);
}
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarModelTree.dao;
import com.adc.da.slrs.sarModelTree.entity.SarModelTree;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author super_liu
* @since 2021-07-15
*/
public interface SarModelTreeDao extends BaseMapper<SarModelTree> {
}
@@ -0,0 +1,68 @@
package com.adc.da.slrs.sarModelTree.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="SarModelTree对象", description="")
public class SarModelTree extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId("ID")
private String id;
@TableField("NAME")
private String name;
@TableField("PID")
private String pid;
@TableField("MODEL")
private String model;
@ApiModelProperty(value = "模块结构特性")
@TableField("FEATURES")
private String features;
@ApiModelProperty(value = "删除标识 1:未删除 2:已删除")
@TableField("DEL_FLAG")
private String delFlag;
@ApiModelProperty(value = "排序序号")
@TableField("SORT")
private Integer sort;
@ApiModelProperty(value = "子菜单")
@TableField(exist = false)
private List<SarModelTree> 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,20 @@
package com.adc.da.slrs.sarModelTree.service;
import com.adc.da.slrs.sarModelTree.entity.SarModelTree;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author super_liu
* @since 2021-07-15
*/
public interface ISarModelTreeService extends IService<SarModelTree> {
List<SarModelTree> getAll(SarModelTree sarModelTree);
}
@@ -0,0 +1,53 @@
package com.adc.da.slrs.sarModelTree.service.impl;
import com.adc.da.slrs.sarModelTree.entity.SarModelTree;
import com.adc.da.slrs.sarModelTree.dao.SarModelTreeDao;
import com.adc.da.slrs.sarModelTree.service.ISarModelTreeService;
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 SarModelTreeServiceImpl extends ServiceImpl<SarModelTreeDao, SarModelTree> implements ISarModelTreeService {
/**
* 查询所有菜单
* @param sarModelTree
*/
@Override
public List<SarModelTree> getAll(SarModelTree sarModelTree) {
QueryWrapper<SarModelTree> tsResourceQueryWrapper=new QueryWrapper<>();
tsResourceQueryWrapper.isNull("PID");
List<SarModelTree> list = this.baseMapper.selectList(tsResourceQueryWrapper);
for(SarModelTree tree:list){
tree.setChildren(recursionGetChildren((tree)));
}
return list;
}
/**
* 递归调用获取子节点
* @param parent:父节点
* @return List<SarMenu>
*/
private List<SarModelTree> recursionGetChildren(SarModelTree parent){
QueryWrapper<SarModelTree> sarMenuQueryWrapper=new QueryWrapper<>();
sarMenuQueryWrapper.orderByAsc("SORT");
sarMenuQueryWrapper.eq("PID",parent.getId());
List<SarModelTree> children=this.baseMapper.selectList(sarMenuQueryWrapper);
for(SarModelTree sarMenu:children){
sarMenu.setChildren(recursionGetChildren((sarMenu)));
}
return children;
}
}