权限的树状结构

dev
liuguijing 1 year ago
parent 523ec042c5
commit 054a15a6f0

@ -151,11 +151,11 @@
<!-- <version>3.14.9</version>-->
<!-- </dependency>-->
<dependency>
<groupId>io.github.admin4j</groupId>
<artifactId>http</artifactId>
<version>0.4.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.github.admin4j</groupId>-->
<!-- <artifactId>http</artifactId>-->
<!-- <version>0.4.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->

@ -2,8 +2,12 @@ package com.shxy.xymanager_admin.controller;
import com.shxy.xymanager_common.base.BaseController;
import com.shxy.xymanager_common.base.ResponseReult;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.bean.ServiceStatus;
import com.shxy.xymanager_common.entity.TbPermission;
import com.shxy.xymanager_common.entity.TbRole;
import com.shxy.xymanager_common.model.DyLineTreeListModel;
import com.shxy.xymanager_common.model.PermissionDyLineTreeListModel;
import com.shxy.xymanager_common.model.PermissionModel;
import com.shxy.xymanager_service.service.RoleService;
@ -73,9 +77,13 @@ public class RoleController extends BaseController {
@GetMapping("getPermissionTree")
@ApiOperation("查询权限树状图")
public ResponseReult<List<TbPermission>> getPermissionTree() throws Exception {
List<TbPermission> result = service.getPermissionTree();
return ResponseReult.success(result);
public ResponseReult<PermissionDyLineTreeListModel> getPermissionTree() throws Exception {
ServiceBody<PermissionDyLineTreeListModel> serviceBody = service.getPermissionTree();
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
}

@ -139,10 +139,10 @@
<!-- <artifactId>okhttp</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.github.admin4j</groupId>
<artifactId>http</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.github.admin4j</groupId>-->
<!-- <artifactId>http</artifactId>-->
<!-- </dependency>-->
<!-- &lt;!&ndash;shiro&ndash;&gt;-->
<!-- <dependency>-->

@ -0,0 +1,88 @@
package com.shxy.xymanager_common.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 线
*/
@Data
@ApiModel(value = "权限电压线路树状图列表", description = "权限电压线路树状图列表")
public class PermissionDyLineTreeListModel implements Serializable {
@ApiModelProperty(value = "电压列表", example = "[]")
private List<DyListBean> list;
@Data
public static class DyListBean {
@ApiModelProperty(value = "电压编号", example = "123456")
private Integer id;
@ApiModelProperty(value = "电压名称", example = "AAAA")
private String name;
@ApiModelProperty(value = "电压大小", example = "AAAA")
private Integer dyValue;
@ApiModelProperty(value = "线路列表", example = "[]")
private List<LineBean> list;
}
@Data
public static class LineBean {
@ApiModelProperty(value = "线路编号", example = "123456")
private Integer id;
@ApiModelProperty(value = "线路名称", example = "AAAA")
private String name;
@ApiModelProperty(value = "单位", example = "123456")
private String bsManufacturer;
@ApiModelProperty(value = "装置信息", example = "123456")
private List<TerminalBean> list;
}
@Data
public static class TerminalBean {
@ApiModelProperty(value = "装置编号", example = "123456")
private Integer id;
@ApiModelProperty(value = "杆塔编号", example = "123456")
private Integer towerid;
@ApiModelProperty(value = "图像监测装置 ID17 位编码)", example = "12345678")
private String cmdid;
@ApiModelProperty(value = "装置名称", example = "名称名称")
private String equipname;
@ApiModelProperty(value = "杆塔显示名", example = "名称名称")
private String name;
@ApiModelProperty(value = "杆塔地址", example = "名称名称")
private String address;
@ApiModelProperty(value = "规约", example = "规约")
private Integer protocol;
@ApiModelProperty(value = "装置显示名", example = "名称名称")
private String displayname;
@ApiModelProperty(value = "装置型号", example = "型号型号")
private String model;
}
}

@ -1,70 +1,70 @@
package com.shxy.xymanager_common.util.http;
import com.alibaba.fastjson.JSONObject;
import io.github.admin4j.http.HttpRequest;
import io.github.admin4j.http.core.Pair;
import io.github.admin4j.http.util.HttpUtil;
import okhttp3.Response;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class OkHttpUtils {
public static JSONObject get(String url, Map<String, Object> queryParams) throws IOException {
Response response = HttpUtil.get(url, queryParams);
return JSONObject.parseObject(response.body().string());
}
public static JSONObject get(String url, Map<String, Object> queryParams, Map<String, Object> headers) throws IOException {
HttpRequest httpRequest = HttpRequest.get(url);
setParams(queryParams, httpRequest);
Response response = httpRequest.queryParams().headers(headers).execute();
return JSONObject.parseObject(response.body().string());
}
public static JSONObject post(String url, String json) throws IOException {
Response response = HttpUtil.post(url, json);
assert response.body() != null;
return JSONObject.parseObject(response.body().string());
}
public static JSONObject postForm(String url, Map<String, Object> formParams) throws IOException {
Response response = HttpUtil.postForm(url, formParams);
assert response.body() != null;
return JSONObject.parseObject(response.body().string());
}
public static JSONObject post(String url, String json, Map<String, Object> headers) throws IOException {
HttpRequest httpRequest = HttpRequest.post(url);
httpRequest.setBody(json);
Response response = httpRequest.headers(headers).execute();
return JSONObject.parseObject(response.body().string());
}
private static void setParams(Map<String, Object> queryParams, HttpRequest httpRequest) {
List<Pair> pairs = new ArrayList<>(queryParams.size());
queryParams.forEach((x, y) -> pairs.add(Pair.of(x, y)));
if (pairs.size() > 0) {
pairs.forEach(httpRequest::queryParams);
}
}
private static JSONObject upload() throws IOException {
File file = new File("C:\\Users\\andanyang\\Downloads\\Sql.txt");
Map<String, Object> formParams = new HashMap<>();
formParams.put("key", "test");
formParams.put("file", file);
formParams.put("token", "WXyUseb-D4sCum-EvTIDYL-mEehwDtrSBg-Zca7t:qgOcR2gUoKmxt-VnsNb657Oatzo=:eyJzY29wZSI6InpoYW56aGkiLCJkZWFkbGluZSI6MTY2NTMwNzUxNH0=");
Response response = HttpUtil.upload("https://upload.qiniup.com/", formParams);
return JSONObject.parseObject(response.body().string());
}
private static void download() throws IOException {
HttpUtil.down("https://gitee.com/admin4j/common-http","path/");
}
}
//package com.shxy.xymanager_common.util.http;
//import com.alibaba.fastjson.JSONObject;
//import io.github.admin4j.http.HttpRequest;
//import io.github.admin4j.http.core.Pair;
//import io.github.admin4j.http.util.HttpUtil;
//import okhttp3.Response;
//
//import java.io.File;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//public class OkHttpUtils {
//
// public static JSONObject get(String url, Map<String, Object> queryParams) throws IOException {
// Response response = HttpUtil.get(url, queryParams);
// return JSONObject.parseObject(response.body().string());
// }
//
// public static JSONObject get(String url, Map<String, Object> queryParams, Map<String, Object> headers) throws IOException {
// HttpRequest httpRequest = HttpRequest.get(url);
// setParams(queryParams, httpRequest);
// Response response = httpRequest.queryParams().headers(headers).execute();
// return JSONObject.parseObject(response.body().string());
// }
//
// public static JSONObject post(String url, String json) throws IOException {
// Response response = HttpUtil.post(url, json);
// assert response.body() != null;
// return JSONObject.parseObject(response.body().string());
// }
//
// public static JSONObject postForm(String url, Map<String, Object> formParams) throws IOException {
// Response response = HttpUtil.postForm(url, formParams);
// assert response.body() != null;
// return JSONObject.parseObject(response.body().string());
// }
//
// public static JSONObject post(String url, String json, Map<String, Object> headers) throws IOException {
// HttpRequest httpRequest = HttpRequest.post(url);
// httpRequest.setBody(json);
// Response response = httpRequest.headers(headers).execute();
// return JSONObject.parseObject(response.body().string());
// }
//
// private static void setParams(Map<String, Object> queryParams, HttpRequest httpRequest) {
// List<Pair> pairs = new ArrayList<>(queryParams.size());
// queryParams.forEach((x, y) -> pairs.add(Pair.of(x, y)));
// if (pairs.size() > 0) {
// pairs.forEach(httpRequest::queryParams);
// }
// }
//
// private static JSONObject upload() throws IOException {
// File file = new File("C:\\Users\\andanyang\\Downloads\\Sql.txt");
// Map<String, Object> formParams = new HashMap<>();
// formParams.put("key", "test");
// formParams.put("file", file);
// formParams.put("token", "WXyUseb-D4sCum-EvTIDYL-mEehwDtrSBg-Zca7t:qgOcR2gUoKmxt-VnsNb657Oatzo=:eyJzY29wZSI6InpoYW56aGkiLCJkZWFkbGluZSI6MTY2NTMwNzUxNH0=");
// Response response = HttpUtil.upload("https://upload.qiniup.com/", formParams);
// return JSONObject.parseObject(response.body().string());
// }
//
// private static void download() throws IOException {
// HttpUtil.down("https://gitee.com/admin4j/common-http","path/");
// }
//
//}

@ -40,10 +40,10 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<!-- <exclusion>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId>-->
<!-- </exclusion>-->
</exclusions>
</dependency>
<!-- SpringBoot 拦截器 -->

@ -49,154 +49,6 @@ public class CacheServiceImpl implements CacheService {
@Autowired
ProtocolsDao protocolsDao;
// @Override
// @Cacheable(value = "globalParams", key = "#param")
// public GlobalParams getGlobalParams(String param) {
// System.out.println("测试缓存:" + param);
// return globalParamsDao.selectByParam(param);
// }
//
// @Override
// @CachePut(value = "globalParams", key = "#result.paramName")
// public GlobalParams updateGlobalParams(GlobalParams record) {
// globalParamsDao.updateByParamName(record, new Date());
// return record;
//
// }
//
// @Override
// @Cacheable(value = "linesMap", key = "#id")
// public Lines getLine(Integer id) {
// Lines lines = linesDao.selectByPrimaryKey(id);
// return lines;
// }
//
// @Override
// @CacheEvict(value = "linesMap", allEntries = true)
// public Integer deleteLine(List<Lines> lines) {
// int i = linesDao.deleteById(lines, CommonStatus.DELETE.value(), new Date());
// return i;
// }
//
// @Override
// @CachePut(value = "linesMap", key = "#result.id")
// public Lines updateLine(Lines lines) {
// int i = linesDao.updateByPrimaryKeySelective(lines, new Date());
// if (i == 0) {
// return null;
// } else {
// return lines;
// }
// }
//
// @Override
// @Cacheable(value = "towerMap", key = "#id")
// public TowerDto getTower(Integer id) {
// TowerDto dto = towerDao.getInfoByPrimaryKey(id, CommonStatus.EFFECTIVE.value());
// return dto;
// }
//
// @Override
// @CacheEvict(value = "towerMap", allEntries = true)
// public Integer deleteTower(List<Towers> list) {
// int i = towerDao.deleteById(list, CommonStatus.DELETE.value(), new Date());
// return i;
// }
//
// @Override
// @CachePut(value = "towerMap", key = "#result.id")
// public Towers updateTower(Towers towers) {
// int i = towerDao.updateByPrimaryKeySelective(towers, new Date());
// if (i == 0) {
// return null;
// } else {
// return towers;
// }
// }
//
// @Override
// @Cacheable(value = "terminalMap", key = "#id")
// public Terminals getTerminal(Integer id) {
// Terminals terminals = terminalsDao.selectById(id, CommonStatus.EFFECTIVE.value());
// return terminals;
// }
//
// @Override
// @CacheEvict(value = "terminalMap", allEntries = true)
// public Integer deleteTerminal(List<Terminals> list) {
// int i = terminalsDao.deleteById(list, CommonStatus.DELETE.value(), new Date());
// return i;
// }
//
// @Override
// @CachePut(value = "terminalMap", key = "#result.id")
// public Towers updateTerminal(Towers towers) {
// int i = towerDao.updateByPrimaryKeySelective(towers, new Date());
// if (i == 0) {
// return null;
// } else {
// return towers;
// }
// }
//
//
// @Override
// @Cacheable(value = "termchannelMap", key = "#id")
// public TerminalChannels getTermchannelMap(Integer id) {
// TerminalChannels terminalChannels = terminalChannelsDao.selectByPrimaryKey(id, CommonStatus.EFFECTIVE.value());
// return terminalChannels;
// }
//
// @Override
// @CacheEvict(value = "termchannelMap", allEntries = true)
// public Integer deleteTermchannelMap(List<TerminalChannels> list) {
// int i = terminalChannelsDao.deleteList(list, CommonStatus.DELETE.value(), new Date());
// return i;
// }
//
// @Override
// @CachePut(value = "termchannelMap", key = "#result.id")
// public TerminalChannels updateTermchannelMap(TerminalChannels terminalChannels) {
// int i = terminalChannelsDao.updateByPrimaryKeySelective(terminalChannels, new Date());
// if (i == 0) {
// return null;
// } else {
// return terminalChannels;
// }
// }
//
//
// @Override
// @Cacheable(value = "termchannelMapMap", key = "#id")
// public TerminalChannelMapper getTermchannelMapMap(Integer id, Integer channelid) {
// TerminalChannelMapper terminalChannels = terminalChannelMapperDao.selectByTermidAndChannelid(id, channelid, CommonStatus.EFFECTIVE.value());
// return terminalChannels;
// }
//
// @Override
// @CacheEvict(value = "termchannelMapMap", allEntries = true)
// public Integer deleteTermchannelMapMap(Integer id) {
// int i = terminalChannelMapperDao.deleteByTermId(id);
// return i;
// }
//
// @Override
// @Cacheable(value = "alarmParamMap")
// public List<TerminalImgAlarmParams> getAlarmParsms() {
// List<TerminalImgAlarmParams> terminalImgAlarmParams = terminalImgAlarmParamsDao.selectAll();
// return terminalImgAlarmParams;
// }
//
// @Override
// @CacheEvict(value = "alarmParamMap", allEntries = true)
// public List<TerminalImgAlarmParams> updateAlarmParsms(List<TerminalImgAlarmParams> list) {
// int i = terminalImgAlarmParamsDao.updateList(list, new Date());
// if (i == 0) {
// return null;
// } else {
// return list;
// }
// }
@Override

@ -1,12 +1,19 @@
package com.shxy.xymanager_service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.dto.DyLineAndTerminalWithHeartDto;
import com.shxy.xymanager_common.dto.LineAndTerminalWithHeartDto;
import com.shxy.xymanager_common.dto.TerminalsWithHeart;
import com.shxy.xymanager_common.entity.TbPermission;
import com.shxy.xymanager_common.entity.TbPermissionExample;
import com.shxy.xymanager_common.entity.TbRole;
import com.shxy.xymanager_common.entity.TbRoleExample;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.DyLineTreeListModel;
import com.shxy.xymanager_common.model.PermissionDyLineTreeListModel;
import com.shxy.xymanager_common.util.xinyin.TerminalUtils;
import com.shxy.xymanager_dao.dao.DyLevelDao;
import com.shxy.xymanager_dao.dao.TbPermissionMapper;
import com.shxy.xymanager_dao.dao.TbRoleMapper;
@ -16,6 +23,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -91,11 +100,58 @@ public class RoleServiceImpl implements RoleService {
*
* */
@Override
public List<TbPermission> getPermissionTree() {
DyLineTreeListModel model = new DyLineTreeListModel();
public ServiceBody<PermissionDyLineTreeListModel> getPermissionTree() {
PermissionDyLineTreeListModel model = new PermissionDyLineTreeListModel();
List<DyLineAndTerminalWithHeartDto> list = dyLevelDao.selectPermissionListTreeList();
return null;
boolean empty = CollectionUtil.isEmpty(list);
if (empty) {
model.setList(new ArrayList<>());
} else {
ArrayList<PermissionDyLineTreeListModel.DyListBean> dyListBeans = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
DyLineAndTerminalWithHeartDto dyDto = list.get(i);
List<LineAndTerminalWithHeartDto> linelist = dyDto.getList();
if (CollectionUtil.isEmpty(linelist)) {
continue;
}
PermissionDyLineTreeListModel.DyListBean dyModel = new PermissionDyLineTreeListModel.DyListBean();
dyModel.setId(dyDto.getId());
dyModel.setDyValue(dyDto.getDyValue());
dyModel.setName(dyDto.getName());
ArrayList<PermissionDyLineTreeListModel.LineBean> lineBeans = new ArrayList<>();
for (int j = 0; j < linelist.size(); j++) {
LineAndTerminalWithHeartDto lineDto = linelist.get(j);
List<TerminalsWithHeart> termlist = lineDto.getList();
if (CollectionUtil.isEmpty(termlist)) {
continue;
}
PermissionDyLineTreeListModel.LineBean lineBean = new PermissionDyLineTreeListModel.LineBean();
lineBean.setId(lineDto.getId());
lineBean.setName(lineDto.getName());
lineBean.setBsManufacturer(lineDto.getBsManufacturer());
ArrayList<PermissionDyLineTreeListModel.TerminalBean> beanlist = new ArrayList<>();
for (int k = 0; k < termlist.size(); k++) {
TerminalsWithHeart terminalsWithHeart = termlist.get(k);
PermissionDyLineTreeListModel.TerminalBean bean = new PermissionDyLineTreeListModel.TerminalBean();
bean.setId(terminalsWithHeart.getId());
bean.setAddress(terminalsWithHeart.getAddress());
bean.setCmdid(terminalsWithHeart.getCmdid());
bean.setDisplayname(terminalsWithHeart.getDisplayname());
bean.setEquipname(terminalsWithHeart.getEquipname());
bean.setModel(terminalsWithHeart.getModel());
bean.setName(terminalsWithHeart.getName());
bean.setTowerid(terminalsWithHeart.getTowerid());
}
lineBean.setList(beanlist);
lineBeans.add(lineBean);
}
dyModel.setList(lineBeans);
dyListBeans.add(dyModel);
}
}
return Asserts.success(model);
}
}

@ -1,7 +1,9 @@
package com.shxy.xymanager_service.service;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.entity.TbPermission;
import com.shxy.xymanager_common.entity.TbRole;
import com.shxy.xymanager_common.model.PermissionDyLineTreeListModel;
import java.util.List;
@ -19,6 +21,6 @@ public interface RoleService {
void changePermission(Integer roleId, List<TbPermission> list) throws Exception;
List<TbPermission> getPermissionTree() throws Exception;
ServiceBody<PermissionDyLineTreeListModel> getPermissionTree() throws Exception;
}

Loading…
Cancel
Save