大屏配置
This commit is contained in:
parent
e3c376f4ee
commit
242d0b4c7d
@ -0,0 +1,233 @@
|
|||||||
|
package com.zhgd.xmgl.modules.basicdata.controller;
|
||||||
|
|
||||||
|
import com.zhgd.annotation.OperLog;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.dto.ScreenAuthDto;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.vo.ScreenAuthVo;
|
||||||
|
import com.zhgd.xmgl.util.PageUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
|
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import com.zhgd.jeecg.common.util.oConvertUtils;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.ScreenAuth;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.service.IScreenAuthService;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections.MapUtils;
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Title: Controller
|
||||||
|
* @Description: 大屏权限配置
|
||||||
|
* @author: pengj
|
||||||
|
* @date: 2024-12-18
|
||||||
|
* @version: V1.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/xmgl/screenAuth")
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "大屏权限配置管理")
|
||||||
|
public class ScreenAuthController {
|
||||||
|
@Autowired
|
||||||
|
private IScreenAuthService screenAuthService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "分页查询", operDesc = "分页列表查询大屏权限配置信息")
|
||||||
|
@ApiOperation(value = " 分页列表查询大屏权限配置信息", notes = "分页列表查询大屏权限配置信息", httpMethod = "POST")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "current", value = "页数", paramType = "body", required = true, defaultValue = "1", dataType = "Integer"),
|
||||||
|
@ApiImplicitParam(name = "size", value = "每页条数", paramType = "body", required = true, defaultValue = "10", dataType = "Integer")
|
||||||
|
})
|
||||||
|
@PostMapping(value = "/page")
|
||||||
|
public Result<IPage<ScreenAuth>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||||
|
QueryWrapper<ScreenAuth> queryWrapper = QueryGenerator.initPageQueryWrapper(ScreenAuth.class, map);
|
||||||
|
Page<ScreenAuth> page = PageUtil.getPage(map);
|
||||||
|
IPage<ScreenAuth> pageList = screenAuthService.page(page, queryWrapper);
|
||||||
|
return Result.success(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
*
|
||||||
|
* @param screenAuth
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "列表查询", operDesc = "列表查询大屏权限配置信息")
|
||||||
|
@ApiOperation(value = " 列表查询大屏权限配置信息", notes = "列表查询大屏权限配置信息", httpMethod = "POST")
|
||||||
|
@PostMapping(value = "/list")
|
||||||
|
public Result<List<ScreenAuth>> queryList(@RequestBody ScreenAuth screenAuth) {
|
||||||
|
QueryWrapper<ScreenAuth> queryWrapper = QueryGenerator.initQueryWrapper(screenAuth);
|
||||||
|
List<ScreenAuth> list = screenAuthService.list(queryWrapper);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "列表查询", operDesc = "管理员查询模块菜单树")
|
||||||
|
@ApiOperation(value = " 管理员查询模块菜单树", notes = "管理员查询模块菜单树", httpMethod = "GET")
|
||||||
|
@GetMapping(value = "/moduleAndMenuTree")
|
||||||
|
public Result<List<ScreenAuthDto>> moduleAndMenuTree() {
|
||||||
|
List<ScreenAuthDto> list = screenAuthService.moduleAndMenuTree();
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
*
|
||||||
|
* @param screenAuth
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "列表查询", operDesc = "树形查询大屏权限配置信息")
|
||||||
|
@ApiOperation(value = " 树形查询大屏权限配置信息", notes = "树形查询大屏权限配置信息", httpMethod = "POST")
|
||||||
|
@PostMapping(value = "/tree")
|
||||||
|
public Result<List<ScreenAuthDto>> treeList(@RequestBody ScreenAuth screenAuth) {
|
||||||
|
QueryWrapper<ScreenAuth> queryWrapper = QueryGenerator.initQueryWrapper(screenAuth);
|
||||||
|
queryWrapper.lambda().orderByAsc(ScreenAuth::getSortIndex);
|
||||||
|
List<ScreenAuthDto> list = screenAuthService.treeList(queryWrapper);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 添加
|
||||||
|
// *
|
||||||
|
// * @param screenAuthVo
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// @OperLog(operModul = "大屏权限配置管理", operType = "新增", operDesc = "模版添加大屏权限配置信息")
|
||||||
|
// @ApiOperation(value = "模版添加大屏权限配置信息", notes = "模版添加大屏权限配置信息", httpMethod = "POST")
|
||||||
|
// @PostMapping(value = "/templateAdd")
|
||||||
|
// public Result<Object> templateAdd(@RequestBody ScreenAuthVo screenAuthVo) {
|
||||||
|
// screenAuthService.saveInfo(screenAuthVo, 0L);
|
||||||
|
// return Result.success("添加成功!");
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param screenAuthVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "新增", operDesc = "添加大屏权限配置信息")
|
||||||
|
@ApiOperation(value = " 添加大屏权限配置信息", notes = "添加大屏权限配置信息", httpMethod = "POST")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<Object> add(@RequestBody ScreenAuthVo screenAuthVo) {
|
||||||
|
screenAuthService.saveInfo(screenAuthVo);
|
||||||
|
return Result.success("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param screenAuth
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "修改", operDesc = "编辑大屏权限配置信息")
|
||||||
|
@ApiOperation(value = "编辑大屏权限配置信息", notes = "编辑大屏权限配置信息", httpMethod = "POST")
|
||||||
|
@PostMapping(value = "/edit")
|
||||||
|
public Result<ScreenAuth> edit(@RequestBody ScreenAuth screenAuth) {
|
||||||
|
Result<ScreenAuth> result = new Result<ScreenAuth>();
|
||||||
|
ScreenAuth screenAuthEntity = screenAuthService.getById(screenAuth.getId());
|
||||||
|
if (screenAuthEntity == null) {
|
||||||
|
result.error500("未找到对应实体");
|
||||||
|
} else {
|
||||||
|
boolean ok = screenAuthService.updateById(screenAuth);
|
||||||
|
if (ok) {
|
||||||
|
result.success("修改成功!");
|
||||||
|
} else {
|
||||||
|
result.success("操作失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "删除", operDesc = "删除大屏权限配置信息")
|
||||||
|
@ApiOperation(value = "删除大屏权限配置信息", notes = "删除大屏权限配置信息", httpMethod = "POST")
|
||||||
|
@ApiImplicitParam(name = "id", value = "大屏权限配置ID", paramType = "body", required = true, dataType = "Integer")
|
||||||
|
@PostMapping(value = "/delete")
|
||||||
|
public Result<ScreenAuth> delete(@ApiIgnore @RequestBody ScreenAuth screenAuth) {
|
||||||
|
Result<ScreenAuth> result = new Result<ScreenAuth>();
|
||||||
|
ScreenAuth screenAuthEntity = screenAuthService.getById(screenAuth.getId());
|
||||||
|
if (screenAuthEntity == null) {
|
||||||
|
result.error500("未找到对应实体");
|
||||||
|
} else {
|
||||||
|
boolean ok = screenAuthService.delInfo(screenAuth.getId().toString());
|
||||||
|
if (ok) {
|
||||||
|
result.success("删除成功!");
|
||||||
|
} else {
|
||||||
|
result.success("操作失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "查询", operDesc = "通过id查询大屏权限配置信息")
|
||||||
|
@ApiOperation(value = "通过id查询大屏权限配置信息", notes = "通过id查询大屏权限配置信息", httpMethod = "POST")
|
||||||
|
@ApiImplicitParam(name = "id", value = "大屏权限配置ID", paramType = "body", required = true, dataType = "Integer")
|
||||||
|
@PostMapping(value = "/queryById")
|
||||||
|
public Result<ScreenAuth> queryById(@ApiIgnore @RequestBody ScreenAuth screenAuthVo) {
|
||||||
|
Result<ScreenAuth> result = new Result<ScreenAuth>();
|
||||||
|
ScreenAuth screenAuth = screenAuthService.getById(screenAuthVo.getId());
|
||||||
|
if (screenAuth == null) {
|
||||||
|
result.error500("未找到对应实体");
|
||||||
|
} else {
|
||||||
|
result.setResult(screenAuth);
|
||||||
|
result.setSuccess(true);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@OperLog(operModul = "大屏权限配置管理", operType = "新增", operDesc = "获取当前账号大屏权限配置信息")
|
||||||
|
@ApiOperation(value = "获取当前账号大屏权限配置信息", notes = "获取当前账号大屏权限配置信息", httpMethod = "GET")
|
||||||
|
@GetMapping(value = "/getModuleAndMenu")
|
||||||
|
public Result<Object> getModuleAndMenu() {
|
||||||
|
return Result.success(screenAuthService.getModuleAndMenu());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,89 @@
|
|||||||
|
package com.zhgd.xmgl.modules.basicdata.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 大屏权限配置
|
||||||
|
* @author: pengj
|
||||||
|
* @date: 2024-12-18
|
||||||
|
* @version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("screen_auth")
|
||||||
|
@ApiModel(value = "ScreenAuth实体类", description = "ScreenAuth")
|
||||||
|
public class ScreenAuth implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大屏权限ID
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ApiModelProperty(value = "大屏权限ID")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 祖级列表
|
||||||
|
*/
|
||||||
|
@Excel(name = "祖级列表", width = 15)
|
||||||
|
@ApiModelProperty(value = "祖级列表")
|
||||||
|
private String ancestors;
|
||||||
|
/**
|
||||||
|
* 权限ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "权限ID", width = 15)
|
||||||
|
@ApiModelProperty(value = "权限ID")
|
||||||
|
private Long authId;
|
||||||
|
/**
|
||||||
|
* 模块名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "模块名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "模块名称")
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 路由路径
|
||||||
|
*/
|
||||||
|
@Excel(name = "路由路径", width = 15)
|
||||||
|
@ApiModelProperty(value = "路由路径")
|
||||||
|
private String routePath;
|
||||||
|
/**
|
||||||
|
* 下标排序
|
||||||
|
*/
|
||||||
|
@Excel(name = "下标排序", width = 15)
|
||||||
|
@ApiModelProperty(value = "下标排序")
|
||||||
|
private Integer sortIndex;
|
||||||
|
/**
|
||||||
|
* 父级ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "父级ID", width = 15)
|
||||||
|
@ApiModelProperty(value = "父级ID")
|
||||||
|
private Long parentId;
|
||||||
|
/**
|
||||||
|
* 权限归属类型(1:企业;2:项目;3:企业子账号;4:项目角色)
|
||||||
|
*/
|
||||||
|
@Excel(name = "权限归属类型(1:企业;2:项目;3:企业子账号;4:项目角色)", width = 15)
|
||||||
|
@ApiModelProperty(value = "权限归属类型(1:企业;2:项目;3:企业子账号;4:项目角色)")
|
||||||
|
private Integer authType;
|
||||||
|
/**
|
||||||
|
* 对应唯一标识
|
||||||
|
*/
|
||||||
|
@Excel(name = "对应唯一标识", width = 15)
|
||||||
|
@ApiModelProperty(value = "对应唯一标识")
|
||||||
|
private String uniqueFlag;
|
||||||
|
/**
|
||||||
|
* 权限类型(1:模版菜单;2:自定义菜单)
|
||||||
|
*/
|
||||||
|
@Excel(name = "权限类型(1:模版菜单;2:自定义菜单)", width = 15)
|
||||||
|
@ApiModelProperty(value = "权限类型(1:模版菜单;2:自定义菜单)")
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.zhgd.xmgl.modules.basicdata.entity.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.ScreenAuth;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ScreenAuthDto {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "大屏权限ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "权限ID")
|
||||||
|
private Long authId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "祖级列表")
|
||||||
|
private String ancestors;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "路由路径")
|
||||||
|
private String routePath;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "下标排序")
|
||||||
|
private String sortIndex;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "父级ID")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "权限归属类型(1:企业;2:项目;3:企业子账号;4:项目角色)")
|
||||||
|
private Integer authType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "对应唯一标识")
|
||||||
|
private String uniqueFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "权限类型(1:模版菜单;2:自定义菜单)")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "子级菜单")
|
||||||
|
private List<ScreenAuthDto> children;
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.zhgd.xmgl.modules.basicdata.entity.vo;
|
||||||
|
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.dto.ScreenAuthDto;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ScreenAuthVo {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "权限归属类型(1:企业;2:项目;3:企业子账号;4:项目角色)")
|
||||||
|
private Integer authType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "对应唯一标识")
|
||||||
|
private String uniqueFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜单信息")
|
||||||
|
List<ScreenAuthDto> screenAuth;
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package com.zhgd.xmgl.modules.basicdata.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.dto.ScreenAuthDto;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.ScreenAuth;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 大屏权限配置
|
||||||
|
* @author: pengj
|
||||||
|
* @date: 2024-12-18
|
||||||
|
* @version: V1.0
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ScreenAuthMapper extends BaseMapper<ScreenAuth> {
|
||||||
|
|
||||||
|
List<ScreenAuthDto> list(@Param(Constants.WRAPPER)Wrapper<ScreenAuth> wrapper);
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.zhgd.xmgl.modules.basicdata.mapper.ScreenAuthMapper">
|
||||||
|
|
||||||
|
<select id="list" resultType="com.zhgd.xmgl.modules.basicdata.entity.dto.ScreenAuthDto">
|
||||||
|
select * from screen_auth
|
||||||
|
${ew.customSqlSegment}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.zhgd.xmgl.modules.basicdata.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.ScreenAuth;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.dto.ScreenAuthDto;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.vo.ScreenAuthVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 大屏权限配置
|
||||||
|
* @author: pengj
|
||||||
|
* @date: 2024-12-18
|
||||||
|
* @version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IScreenAuthService extends IService<ScreenAuth> {
|
||||||
|
|
||||||
|
List<ScreenAuthDto> moduleAndMenuTree();
|
||||||
|
|
||||||
|
List<ScreenAuthDto> treeList(Wrapper<ScreenAuth> wrapper);
|
||||||
|
|
||||||
|
boolean saveInfo(ScreenAuthVo screenAuthVo);
|
||||||
|
|
||||||
|
boolean delInfo(String id);
|
||||||
|
|
||||||
|
List<ScreenAuthDto> getModuleAndMenu();
|
||||||
|
}
|
||||||
@ -0,0 +1,270 @@
|
|||||||
|
package com.zhgd.xmgl.modules.basicdata.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.sun.glass.ui.Screen;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.*;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.dto.ScreenAuthDto;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.entity.vo.ScreenAuthVo;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.mapper.ScreenAuthMapper;
|
||||||
|
import com.zhgd.xmgl.modules.basicdata.service.*;
|
||||||
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||||
|
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||||
|
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||||
|
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||||
|
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 大屏权限配置
|
||||||
|
* @author: pengj
|
||||||
|
* @date: 2024-12-18
|
||||||
|
* @version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class ScreenAuthServiceImpl extends ServiceImpl<ScreenAuthMapper, ScreenAuth> implements IScreenAuthService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBaseModuleService baseModuleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBaseMenuService baseMenuService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IProjectService projectService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICompanyService companyService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBaseRoleService baseRoleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISystemUserService systemUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBaseRoleUserService baseRoleUserService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ScreenAuthDto> moduleAndMenuTree() {
|
||||||
|
List<BaseModule> baseModuleList = baseModuleService.list(Wrappers.<BaseModule>lambdaQuery().eq(BaseModule::getModuleType, 8));
|
||||||
|
List<ScreenAuthDto> resultList = moduleToScreen(baseModuleList);
|
||||||
|
if (baseModuleList.size() > 0) {
|
||||||
|
List<BaseMenu> baseMenuList = baseMenuService.list(Wrappers.<BaseMenu>lambdaQuery().eq(BaseMenu::getStatus, 1)
|
||||||
|
.in(BaseMenu::getModuleId, baseModuleList.stream().map(b -> b.getModuleId()).collect(Collectors.toList())));
|
||||||
|
for (ScreenAuthDto screenAuthDto : resultList) {
|
||||||
|
List<BaseMenu> menuList = baseMenuList.stream().filter(b -> b.getModuleId().toString().equals(screenAuthDto.getId().toString())).collect(Collectors.toList());
|
||||||
|
screenAuthDto.setChildren(menuToScreen(menuList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ScreenAuthDto> treeList(Wrapper<ScreenAuth> wrapper) {
|
||||||
|
List<ScreenAuthDto> allList = baseMapper.list(wrapper);
|
||||||
|
List<ScreenAuthDto> delList = new ArrayList<>();
|
||||||
|
Set<Long> authIds = new HashSet<>();
|
||||||
|
for (ScreenAuthDto screenAuthDto : allList) {
|
||||||
|
boolean add = authIds.add(screenAuthDto.getAuthId());
|
||||||
|
if (!add) {
|
||||||
|
delList.add(screenAuthDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
allList.removeAll(delList);
|
||||||
|
List<ScreenAuthDto> treeList = new ArrayList<>();
|
||||||
|
if (allList.size() > 0) {
|
||||||
|
treeList.addAll(allList.stream().filter(a -> a.getParentId().toString().equals("0")).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
getChildren(allList, treeList);
|
||||||
|
return treeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveInfo(ScreenAuthVo screenAuthVo) {
|
||||||
|
return saveOrUpdate(screenAuthVo.getScreenAuth(), screenAuthVo.getAuthType(), screenAuthVo.getUniqueFlag());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delInfo(String id) {
|
||||||
|
this.remove(Wrappers.<ScreenAuth>lambdaQuery().eq(ScreenAuth::getParentId, id));
|
||||||
|
return this.removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ScreenAuthDto> getModuleAndMenu() {
|
||||||
|
UserInfo user = SecurityUtils.getUser();
|
||||||
|
SystemUser systemUser = systemUserService.getById(user.getUserId());
|
||||||
|
List<String> roleIds = baseRoleUserService.list(Wrappers.<BaseRoleUser>lambdaQuery().eq(BaseRoleUser::getUserId, systemUser.getUserId()))
|
||||||
|
.stream().map(u -> u.getRoleId().toString()).collect(Collectors.toList());
|
||||||
|
Project project = projectService.getOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectSn, systemUser.getSn()));
|
||||||
|
Company company = new Company();
|
||||||
|
if (project != null) {
|
||||||
|
company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, project.getCompanySn()));
|
||||||
|
} else {
|
||||||
|
company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, systemUser.getSn()));
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<ScreenAuth> wrapper = Wrappers.<ScreenAuth>lambdaQuery();
|
||||||
|
if (systemUser.getAccountType() == 2) {
|
||||||
|
wrapper.eq(ScreenAuth::getUniqueFlag, company.getHeadquartersSn()).eq(ScreenAuth::getAuthType, 1);
|
||||||
|
} else if (systemUser.getAccountType() == 7 || systemUser.getAccountType() == 4 || systemUser.getAccountType() == 3) {
|
||||||
|
wrapper.eq(ScreenAuth::getUniqueFlag, systemUser.getUserId()).eq(ScreenAuth::getAuthType, 3);
|
||||||
|
} else if (systemUser.getAccountType() == 5 || systemUser.getAccountType() == 10) {
|
||||||
|
wrapper.eq(ScreenAuth::getUniqueFlag, project.getProjectSn()).eq(ScreenAuth::getAuthType, 2);
|
||||||
|
} else if (systemUser.getAccountType() == 6) {
|
||||||
|
wrapper.in(ScreenAuth::getUniqueFlag, roleIds).eq(ScreenAuth::getAuthType, 4);
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(ScreenAuth::getSortIndex);
|
||||||
|
return treeList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean saveOrUpdate(List<ScreenAuthDto> screenAuthDtoList, Integer authType, String uniqueFlag) {
|
||||||
|
String ancestors = getAncestors(authType, uniqueFlag);
|
||||||
|
List<ScreenAuth> uniqueList = this.list(Wrappers.<ScreenAuth>lambdaQuery().eq(ScreenAuth::getAuthType, authType)
|
||||||
|
.eq(ScreenAuth::getUniqueFlag, uniqueFlag));
|
||||||
|
List<ScreenAuth> updateId = new ArrayList<>();
|
||||||
|
List<ScreenAuth> delId = new ArrayList<>();
|
||||||
|
List<ScreenAuth> allId = new ArrayList<>();
|
||||||
|
getList(screenAuthDtoList, 0L, ancestors, updateId, allId, uniqueList);
|
||||||
|
for (ScreenAuth screenAuth : uniqueList) {
|
||||||
|
List<String> stringList = allId.stream().map(s -> s.getId().toString()).collect(Collectors.toList());
|
||||||
|
if (!stringList.contains(screenAuth.getId().toString())) {
|
||||||
|
delId.add(screenAuth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (delId.size() > 0) {
|
||||||
|
this.removeByIds(delId.stream().map(d -> d.getId()).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
List<ScreenAuth> childrenList = new ArrayList<>();
|
||||||
|
if (authType == 1) {
|
||||||
|
// 调整企业角色、项目、项目人员的权限
|
||||||
|
childrenList = this.list(Wrappers.<ScreenAuth>lambdaQuery().gt(ScreenAuth::getAuthType, 1).apply("find_in_set({0}, ancestors)", ancestors));
|
||||||
|
}
|
||||||
|
if (authType == 2) {
|
||||||
|
// 调整项目的权限
|
||||||
|
childrenList = this.list(Wrappers.<ScreenAuth>lambdaQuery().eq(ScreenAuth::getAuthType, 4).apply("find_in_set({0}, ancestors)", ancestors));
|
||||||
|
}
|
||||||
|
List<Long> childrenIdList = childrenList.stream().map(c -> c.getId()).collect(Collectors.toList());
|
||||||
|
// 删除
|
||||||
|
if (delId.size() > 0 && childrenIdList.size() > 0) {
|
||||||
|
this.remove(Wrappers.<ScreenAuth>lambdaQuery().in(ScreenAuth::getAuthId, delId.stream().map(d -> d.getAuthId()).collect(Collectors.toList()))
|
||||||
|
.in(ScreenAuth::getId, childrenIdList));
|
||||||
|
}
|
||||||
|
// 修改
|
||||||
|
if (childrenList.size() > 0) {
|
||||||
|
long count = childrenList.stream().filter(c -> c.getAuthType() == 2 && c.getType() == 2).count();
|
||||||
|
if (count > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
List<ScreenAuth> updateList = new ArrayList<>();
|
||||||
|
for (ScreenAuth screenAuth : updateId) {
|
||||||
|
List<ScreenAuth> childrenList1 = childrenList.stream().filter(c -> c.getType() == 1 && c.getAuthId().toString().equals(screenAuth.getAuthId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
for (ScreenAuth auth : childrenList1) {
|
||||||
|
auth.setAuthId(screenAuth.getAuthId());
|
||||||
|
auth.setName(screenAuth.getName());
|
||||||
|
auth.setRoutePath(screenAuth.getRoutePath());
|
||||||
|
auth.setSortIndex(screenAuth.getSortIndex());
|
||||||
|
updateList.add(auth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.updateBatchById(updateList);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getList(List<ScreenAuthDto> screenAuthDtoList, Long parentId, String ancestors, List<ScreenAuth> updateId, List<ScreenAuth> allId, List<ScreenAuth> uniqueList) {
|
||||||
|
for (ScreenAuthDto screenAuthDto : screenAuthDtoList) {
|
||||||
|
List<ScreenAuth> collect = uniqueList.stream().filter(u -> u.getUniqueFlag().equals(screenAuthDto.getUniqueFlag()) &&
|
||||||
|
u.getAuthId().toString().equals(screenAuthDto.getAuthId().toString()) && u.getAuthType() == screenAuthDto.getAuthType()
|
||||||
|
&& u.getType() == screenAuthDto.getType()).collect(Collectors.toList());
|
||||||
|
if (collect.size() > 0) {
|
||||||
|
screenAuthDto.setId(collect.get(0).getId());
|
||||||
|
} else {
|
||||||
|
screenAuthDto.setId(null);
|
||||||
|
}
|
||||||
|
ScreenAuth screenAuth = new ScreenAuth();
|
||||||
|
BeanUtils.copyProperties(screenAuthDto, screenAuth);
|
||||||
|
screenAuth.setParentId(parentId);
|
||||||
|
screenAuth.setAncestors(ancestors);
|
||||||
|
if (screenAuth.getId() != null) {
|
||||||
|
updateId.add(screenAuth);
|
||||||
|
allId.add(screenAuth);
|
||||||
|
}
|
||||||
|
this.saveOrUpdate(screenAuth);
|
||||||
|
if (screenAuthDto.getChildren() != null && screenAuthDto.getChildren().size() > 0) {
|
||||||
|
getList(screenAuthDto.getChildren(), screenAuth.getId(), ancestors, updateId, allId, uniqueList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getAncestors(Integer authType, String uniqueFlag) {
|
||||||
|
if (authType == 1 || authType == 3) {
|
||||||
|
return uniqueFlag;
|
||||||
|
} else if (authType == 2) {
|
||||||
|
Project project = projectService.getOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectSn, uniqueFlag));
|
||||||
|
Company company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, project.getCompanySn()));
|
||||||
|
return company.getHeadquartersSn() + "," + uniqueFlag;
|
||||||
|
} else {
|
||||||
|
BaseRole baseRole = baseRoleService.getById(uniqueFlag);
|
||||||
|
Project project = projectService.getOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectSn, baseRole.getProjectSn()));
|
||||||
|
Company company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, project.getCompanySn()));
|
||||||
|
return company.getHeadquartersSn() + "," + project.getProjectSn() + "," + uniqueFlag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getChildren(List<ScreenAuthDto> allList, List<ScreenAuthDto> treeList) {
|
||||||
|
for (ScreenAuthDto screenAuthDto : treeList) {
|
||||||
|
List<ScreenAuthDto> childrenList = allList.stream().filter(a -> a.getParentId().toString().equals(screenAuthDto.getId().toString()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (childrenList.size() > 0) {
|
||||||
|
getChildren(allList, childrenList);
|
||||||
|
}
|
||||||
|
screenAuthDto.setChildren(childrenList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ScreenAuthDto> moduleToScreen(List<BaseModule> moduleList) {
|
||||||
|
List<ScreenAuthDto> screenAuthList = new ArrayList<>();
|
||||||
|
for (BaseModule baseModule : moduleList) {
|
||||||
|
ScreenAuthDto screenAuthDto = new ScreenAuthDto();
|
||||||
|
screenAuthDto.setId(baseModule.getModuleId());
|
||||||
|
screenAuthDto.setAuthId(baseModule.getModuleId());
|
||||||
|
screenAuthDto.setName(baseModule.getModuleName());
|
||||||
|
screenAuthDto.setRoutePath(baseModule.getModulePath());
|
||||||
|
screenAuthDto.setSortIndex(baseModule.getSortIndex());
|
||||||
|
screenAuthDto.setParentId(0L);
|
||||||
|
screenAuthList.add(screenAuthDto);
|
||||||
|
}
|
||||||
|
return screenAuthList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ScreenAuthDto> menuToScreen(List<BaseMenu> menuList) {
|
||||||
|
List<ScreenAuthDto> screenAuthList = new ArrayList<>();
|
||||||
|
for (BaseMenu baseMenu : menuList) {
|
||||||
|
ScreenAuthDto screenAuthDto = new ScreenAuthDto();
|
||||||
|
screenAuthDto.setId(baseMenu.getMenuId());
|
||||||
|
screenAuthDto.setAuthId(baseMenu.getMenuId());
|
||||||
|
screenAuthDto.setName(baseMenu.getMenuName());
|
||||||
|
screenAuthDto.setRoutePath(baseMenu.getPath());
|
||||||
|
screenAuthDto.setSortIndex(baseMenu.getPriority().toString());
|
||||||
|
screenAuthDto.setParentId(baseMenu.getModuleId());
|
||||||
|
screenAuthList.add(screenAuthDto);
|
||||||
|
}
|
||||||
|
return screenAuthList;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user