角色权限优化
This commit is contained in:
parent
513367710d
commit
22f288a860
@ -14,7 +14,7 @@ public class CorsConfig{
|
||||
public FilterRegistrationBean corsFilter() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowCredentials(true);
|
||||
config.addAllowedOrigin("http://10.75.253.12:6090");
|
||||
config.addAllowedOrigin("*");
|
||||
config.addAllowedHeader("*");
|
||||
config.addAllowedMethod("*");
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
|
||||
@ -230,4 +230,15 @@ public class BaseMenuController {
|
||||
public Result<List<MenuHzDto>> getAll(@RequestBody Map<String, Object> map) {
|
||||
return Result.success(baseMenuService.getAllForHz(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询相对应角色的全部菜单列表(项目管理子系统)
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "系统菜单管理", operType = "查询", operDesc = "查询相对应角色的全部菜单列表(项目管理子系统)")
|
||||
@ApiOperation(value = "查询相对应角色的全部菜单列表(项目管理子系统)", notes = "查询相对应角色的全部菜单列表(项目管理子系统)" , httpMethod="POST")
|
||||
@PostMapping(value = "/getMenus")
|
||||
public Result<List<MenuTreeDto>> getMenus(@RequestBody Map<String, Object> map) {
|
||||
return Result.success(baseMenuService.getMenusForHz(map));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.controller.admin;
|
||||
|
||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import cn.xuyanwu.spring.file.storage.FileStorageService;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.file.FileUtil;
|
||||
@ -16,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -37,28 +39,28 @@ public class FileController {
|
||||
@Autowired
|
||||
private IFileDetailService fileDetailService;
|
||||
|
||||
// /**
|
||||
// * 上传文件到指定存储平台,成功返回文件信息
|
||||
// */
|
||||
// @OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "文件上传")
|
||||
// @ApiOperation(value = "文件上传", notes = "文件上传", httpMethod="POST")
|
||||
// @PostMapping("/upload")
|
||||
// public Result<FileInfo> uploadPlatform(MultipartFile file) {
|
||||
// return Result.success(fileStorageService.of(file)
|
||||
// .setPlatform("minio-1") //使用指定的存储平台
|
||||
// .upload());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 上传文件到本地,成功返回文件信息
|
||||
* 上传文件到指定存储平台,成功返回文件信息
|
||||
*/
|
||||
@OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "文件上传")
|
||||
@ApiOperation(value = "文件上传", notes = "文件上传", httpMethod="POST")
|
||||
@PostMapping("/upload")
|
||||
public Result<Map<String, Object>> upload(MultipartFile file) {
|
||||
return Result.success(fileDetailService.upload(file));
|
||||
public Result<FileInfo> uploadPlatform(MultipartFile file) {
|
||||
return Result.success(fileStorageService.of(file)
|
||||
.setPlatform("minio-1") //使用指定的存储平台
|
||||
.upload());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 上传文件到本地,成功返回文件信息
|
||||
// */
|
||||
// @OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "文件上传")
|
||||
// @ApiOperation(value = "文件上传", notes = "文件上传", httpMethod="POST")
|
||||
// @PostMapping("/upload")
|
||||
// public Result<Map<String, Object>> upload(MultipartFile file) {
|
||||
// return Result.success(fileDetailService.upload(file));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 上传BASE64文件
|
||||
*/
|
||||
@ -66,48 +68,33 @@ public class FileController {
|
||||
@ApiOperation(value = "BASE64文件上传", notes = "BASE64文件上传", httpMethod="POST")
|
||||
@ApiImplicitParam(name = "base64", value = "BASE64字符串", required = true, dataType = "String")
|
||||
@PostMapping("/uploadBase64")
|
||||
public Result<Map<String, Object>> uploadBase64(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
public Result<FileInfo> uploadBase64(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
String base64 = MapUtils.getString(map, "base64");
|
||||
MultipartFile multipartFile = FileUtil.base64toMultipart(base64, "text.jpg");
|
||||
return Result.success(fileDetailService.upload(multipartFile));
|
||||
return Result.success(fileStorageService.of(multipartFile)
|
||||
.setPlatform("minio-1") //使用指定的存储平台
|
||||
.upload());
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 下载文件
|
||||
// */
|
||||
// @OperLog(operModul = "文件管理", operType = "文件下载", operDesc = "文件下载")
|
||||
// @ApiOperation(value = "文件下载", notes = "文件下载", httpMethod="POST")
|
||||
// @ApiImplicitParam(name = "fileUrl", value = "文件路径", paramType = "body", dataType = "String")
|
||||
// @PostMapping("/download")
|
||||
// public void download(@ApiIgnore @RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
|
||||
// // 获取文件信息
|
||||
// String fileUrl = MapUtils.getString(map, "fileUrl");
|
||||
// FileInfo fileInfo = fileStorageService.getFileInfoByUrl(fileUrl);
|
||||
// if (null == fileInfo) {
|
||||
// throw new Exception("缩略图文件下载失败,文件不存在!fileInfo:" + fileInfo);
|
||||
// }
|
||||
// response.setHeader("Content-disposition", "attachment; filename=" + fileUrl.substring(fileUrl.lastIndexOf("/") + 1));
|
||||
// response.setContentType("application/octet-stream");// 定义输出类型
|
||||
// fileStorageService.download(fileInfo).outputStream(response.getOutputStream());
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 获取预览文件流
|
||||
// */
|
||||
// @OperLog(operModul = "文件管理", operType = "获取预览文件流", operDesc = "获取预览文件流")
|
||||
// @ApiOperation(value = "获取预览文件流", notes = "获取预览文件流", httpMethod="POST")
|
||||
// @GetMapping("/preview")
|
||||
// public void download(@RequestParam(value = "fileUrl", required = true) String fileUrl, HttpServletResponse response) throws Exception {
|
||||
// // 获取文件信息
|
||||
// FileInfo fileInfo = fileStorageService.getFileInfoByUrl(fileUrl);
|
||||
// if (null == fileInfo) {
|
||||
// throw new Exception("缩略图文件预览失败,文件不存在!fileInfo:" + fileInfo);
|
||||
// }
|
||||
// response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileInfo.getOriginalFilename(), "UTF-8"));
|
||||
// response.setContentType("application/octet-stream");// 定义输出类型
|
||||
// fileStorageService.download(fileInfo).outputStream(response.getOutputStream());
|
||||
// }
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
@OperLog(operModul = "文件管理", operType = "文件下载", operDesc = "文件下载")
|
||||
@ApiOperation(value = "文件下载", notes = "文件下载", httpMethod="POST")
|
||||
@ApiImplicitParam(name = "fileUrl", value = "文件路径", paramType = "body", dataType = "String")
|
||||
@PostMapping("/download")
|
||||
public void download(@ApiIgnore @RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
|
||||
// 获取文件信息
|
||||
String fileUrl = MapUtils.getString(map, "fileUrl");
|
||||
FileInfo fileInfo = fileStorageService.getFileInfoByUrl(fileUrl);
|
||||
if (null == fileInfo) {
|
||||
throw new Exception("缩略图文件下载失败,文件不存在!fileInfo:" + fileInfo);
|
||||
}
|
||||
response.setHeader("Content-disposition", "attachment; filename=" + fileUrl.substring(fileUrl.lastIndexOf("/") + 1));
|
||||
response.setContentType("application/octet-stream");// 定义输出类型
|
||||
fileStorageService.download(fileInfo).outputStream(response.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预览文件流
|
||||
@ -117,6 +104,23 @@ public class FileController {
|
||||
@GetMapping("/preview")
|
||||
public void download(@RequestParam(value = "fileUrl", required = true) String fileUrl, HttpServletResponse response) throws Exception {
|
||||
// 获取文件信息
|
||||
fileDetailService.download(fileUrl, response);
|
||||
FileInfo fileInfo = fileStorageService.getFileInfoByUrl(fileUrl);
|
||||
if (null == fileInfo) {
|
||||
throw new Exception("缩略图文件预览失败,文件不存在!fileInfo:" + fileInfo);
|
||||
}
|
||||
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileInfo.getOriginalFilename(), "UTF-8"));
|
||||
response.setContentType("application/octet-stream");// 定义输出类型
|
||||
fileStorageService.download(fileInfo).outputStream(response.getOutputStream());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 获取预览文件流
|
||||
// */
|
||||
// @OperLog(operModul = "文件管理", operType = "获取预览文件流", operDesc = "获取预览文件流")
|
||||
// @ApiOperation(value = "获取预览文件流", notes = "获取预览文件流", httpMethod="POST")
|
||||
// @GetMapping("/preview")
|
||||
// public void download(@RequestParam(value = "fileUrl", required = true) String fileUrl, HttpServletResponse response) throws Exception {
|
||||
// // 获取文件信息
|
||||
// fileDetailService.download(fileUrl, response);
|
||||
// }
|
||||
}
|
||||
|
||||
@ -57,7 +57,12 @@ public class SystemRole implements Serializable {
|
||||
@Excel(name = "政务、企业或项目sn", width = 15)
|
||||
@ApiModelProperty(value = "政务、企业或项目sn")
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 政务、企业或项目sn
|
||||
*/
|
||||
@Excel(name = "政务、企业或项目sn", width = 15)
|
||||
@ApiModelProperty(value = "政务、企业或项目sn")
|
||||
private Integer roleType;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@ -56,4 +56,6 @@ public interface IBaseMenuService extends IService<BaseMenu> {
|
||||
Set<String> queryRouter();
|
||||
|
||||
List<MenuHzDto> getAllForHz(Map<String, Object> map);
|
||||
|
||||
List<MenuTreeDto> getMenusForHz(Map<String, Object> map);
|
||||
}
|
||||
|
||||
@ -11,10 +11,7 @@ import com.zhgd.xmgl.handler.exception.CustomException;
|
||||
import com.zhgd.xmgl.modules.basicdata.dto.MenuHzDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.dto.MenuTreeDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.*;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.BaseActionMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.BaseMenuMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.ModuleTemplateMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.*;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.*;
|
||||
import com.zhgd.xmgl.security.SecurityUser;
|
||||
import com.zhgd.xmgl.security.SecurityUtil;
|
||||
@ -55,6 +52,18 @@ public class BaseMenuServiceImpl extends ServiceImpl<BaseMenuMapper, BaseMenu> i
|
||||
|
||||
@Autowired
|
||||
private IGovernmentService governmentService;
|
||||
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Autowired
|
||||
private EnterpriseMapper enterpriseMapper;
|
||||
|
||||
@Autowired
|
||||
private EnterpriseMainMapper enterpriseMainMapper;
|
||||
|
||||
@Autowired
|
||||
private ISystemRoleService systemRoleService;
|
||||
// @Autowired
|
||||
// private IBaseAuthorityService baseAuthorityService;
|
||||
// @Autowired
|
||||
@ -181,6 +190,63 @@ public class BaseMenuServiceImpl extends ServiceImpl<BaseMenuMapper, BaseMenu> i
|
||||
return TreeUtil.formatHz(baseMenus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuTreeDto> getMenusForHz(Map<String, Object> map) {
|
||||
String roleId = MapUtils.getString(map, "roleId");
|
||||
SystemRole systemRole = systemRoleService.getById(roleId);
|
||||
Integer accountType = systemRole.getRoleType();
|
||||
List<EnterpriseMain> enterpriseMainList = new ArrayList<>();
|
||||
if (systemRole.getPriority() <= 3) {
|
||||
EnterpriseMain enterpriseMain = new EnterpriseMain();
|
||||
if (systemRole.getRoleCode().equals("BUILD")) {
|
||||
enterpriseMain.setMainType(1);
|
||||
} else if (systemRole.getRoleCode().equals("SUPERVISOR")) {
|
||||
enterpriseMain.setMainType(2);
|
||||
} else if (systemRole.getRoleCode().equals("OP")) {
|
||||
enterpriseMain.setMainType(3);
|
||||
}
|
||||
enterpriseMainList.add(enterpriseMain);
|
||||
} else if (accountType == 3) {
|
||||
Enterprise enterprise = enterpriseMapper.selectOne(Wrappers.<Enterprise>lambdaQuery().eq(Enterprise::getEnterpriseSn, systemRole.getSn()));
|
||||
enterpriseMainList = enterpriseMainMapper.selectList(Wrappers.<EnterpriseMain>lambdaQuery().eq(EnterpriseMain::getEnterpriseSn, enterprise.getEnterpriseSn()));
|
||||
}
|
||||
Long moduleId = 0L;
|
||||
if (accountType == 2) {
|
||||
moduleId = 1670639811581595650L;
|
||||
} else if (accountType == 3) {
|
||||
moduleId = 1681837103227502594L;
|
||||
} else {
|
||||
moduleId = 1670603312504918018L;
|
||||
}
|
||||
Set<BaseMenu> baseMenus = new HashSet<>();
|
||||
List<BaseMenu> baseMenuList = new ArrayList<>();
|
||||
if (accountType != 3) {
|
||||
// 查询相对应的菜单
|
||||
List<BaseMenu> res = baseMenuMapper.selectList(Wrappers.<BaseMenu>lambdaQuery().in(BaseMenu::getModuleId, moduleId)
|
||||
.eq(BaseMenu::getStatus, 1).orderByAsc(BaseMenu::getPriority));
|
||||
baseMenus.addAll(res);
|
||||
} else {
|
||||
for (EnterpriseMain main : enterpriseMainList) {
|
||||
String code = "";
|
||||
if (main.getMainType() == 1) {
|
||||
code = "BUILD";
|
||||
} else if (main.getMainType() == 2) {
|
||||
code = "SUPERVISOR";
|
||||
} else if (main.getMainType() == 3) {
|
||||
code = "OP";
|
||||
}
|
||||
String iRoleId = systemRoleService.getOne(Wrappers.<SystemRole>lambdaQuery()
|
||||
.eq(SystemRole::getRoleCode, code)).getRoleId();
|
||||
if (iRoleId != null) {
|
||||
List<BaseMenu> res = baseMenuMapper.getMenuIdByFilter(iRoleId, moduleId);
|
||||
baseMenus.addAll(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
baseMenuList.addAll(baseMenus);
|
||||
return TreeUtil.build(TreeUtil.formatMenu(baseMenuList), 1, moduleId, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getProjectModuleAndMenu(Map<String, Object> map) {
|
||||
map.put("styleType",getStyleType(MapUtils.getString(map,"projectSn")));
|
||||
|
||||
@ -39,11 +39,13 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
|
||||
public Page<SystemRole> pageList(Map<String, Object> map) {
|
||||
SecurityUser user = SecurityUtil.getUser();
|
||||
QueryWrapper<SystemRole> queryWrapper = QueryGenerator.initPageQueryWrapper(SystemRole.class, map);
|
||||
queryWrapper.eq("sn", user.getSn());
|
||||
queryWrapper.orderByAsc("priority");
|
||||
if (!user.isManager()) {
|
||||
queryWrapper.eq("create_by", user.getUserId());
|
||||
if (user.getAccountType() == 4) {
|
||||
queryWrapper.eq("sn", user.getSn());
|
||||
if (!user.isManager()) {
|
||||
queryWrapper.eq("create_by", user.getUserId());
|
||||
}
|
||||
}
|
||||
queryWrapper.orderByAsc("priority");
|
||||
Page<SystemRole> page = PageUtil.getPage(map);
|
||||
return baseMapper.selectPage(page, queryWrapper);
|
||||
}
|
||||
@ -68,7 +70,8 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
|
||||
if (systemRoleEntity != null) {
|
||||
throw new CustomException("角色名称已存在,请重新输入!");
|
||||
}
|
||||
systemRole.setSn(user.getSn());
|
||||
systemRole.setSn(systemRole.getSn() == null ? user.getSn() : systemRole.getSn());
|
||||
systemRole.setRoleType(systemRole.getRoleType() == null ? user.getAccountType() : systemRole.getRoleType());
|
||||
systemRole.setCreateBy(user.getUserId());
|
||||
systemRole.setCreateTime(new Date());
|
||||
return this.save(systemRole);
|
||||
@ -82,7 +85,8 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
|
||||
if (systemRoleEntity != null) {
|
||||
throw new CustomException("角色名称已存在,请重新输入!");
|
||||
}
|
||||
systemRole.setSn(user.getSn());
|
||||
systemRole.setSn(systemRole.getSn() == null ? user.getSn() : systemRole.getSn());
|
||||
systemRole.setRoleType(systemRole.getRoleType() == null ? user.getAccountType() : systemRole.getRoleType());
|
||||
return this.updateById(systemRole);
|
||||
}
|
||||
|
||||
|
||||
@ -57,11 +57,13 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
SecurityUser user = SecurityUtil.getUser();
|
||||
QueryWrapper<SystemUser> wrapper = QueryGenerator.initPageQueryWrapper(SystemUser.class, map);
|
||||
wrapper.eq("u.account_type", user.getAccountType());
|
||||
wrapper.eq("u.sn", user.getSn());
|
||||
wrapper.eq("u.is_manager", 0);
|
||||
if (!user.isManager()) {
|
||||
wrapper.eq("u.create_by", user.getUserId());
|
||||
if (user.getAccountType() == 4) {
|
||||
wrapper.eq("u.sn", user.getSn());
|
||||
if (!user.isManager()) {
|
||||
wrapper.eq("u.create_by", user.getUserId());
|
||||
}
|
||||
}
|
||||
// wrapper.eq("u.is_manager", 0);
|
||||
String deptId = MapUtils.getString(map, "deptId");
|
||||
if (StringUtils.isNotBlank(deptId)) {
|
||||
String deptIds = systemDeptMapper.getChildrenByDeptId(deptId);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user