From 22f288a860ce6a67ef19afba852efc437c33c2a0 Mon Sep 17 00:00:00 2001 From: pengjie <17373303529@163.com> Date: Mon, 6 Nov 2023 11:40:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/zhgd/config/CorsConfig.java | 2 +- .../controller/admin/BaseMenuController.java | 11 ++ .../controller/admin/FileController.java | 110 +++++++++--------- .../modules/basicdata/entity/SystemRole.java | 7 +- .../basicdata/service/IBaseMenuService.java | 2 + .../service/impl/BaseMenuServiceImpl.java | 74 +++++++++++- .../service/impl/SystemRoleServiceImpl.java | 16 ++- .../service/impl/SystemUserServiceImpl.java | 10 +- 8 files changed, 163 insertions(+), 69 deletions(-) diff --git a/src/main/java/com/zhgd/config/CorsConfig.java b/src/main/java/com/zhgd/config/CorsConfig.java index e924f6e..e24c6b3 100644 --- a/src/main/java/com/zhgd/config/CorsConfig.java +++ b/src/main/java/com/zhgd/config/CorsConfig.java @@ -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(); diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/admin/BaseMenuController.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/admin/BaseMenuController.java index eefd80d..2feadc6 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/admin/BaseMenuController.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/admin/BaseMenuController.java @@ -230,4 +230,15 @@ public class BaseMenuController { public Result> getAll(@RequestBody Map map) { return Result.success(baseMenuService.getAllForHz(map)); } + + /** + * 查询相对应角色的全部菜单列表(项目管理子系统) + * @return + */ + @OperLog(operModul = "系统菜单管理", operType = "查询", operDesc = "查询相对应角色的全部菜单列表(项目管理子系统)") + @ApiOperation(value = "查询相对应角色的全部菜单列表(项目管理子系统)", notes = "查询相对应角色的全部菜单列表(项目管理子系统)" , httpMethod="POST") + @PostMapping(value = "/getMenus") + public Result> getMenus(@RequestBody Map map) { + return Result.success(baseMenuService.getMenusForHz(map)); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/admin/FileController.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/admin/FileController.java index 6fdc003..66347ff 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/admin/FileController.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/admin/FileController.java @@ -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 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> upload(MultipartFile file) { - return Result.success(fileDetailService.upload(file)); + public Result 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> 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> uploadBase64(@ApiIgnore @RequestBody Map map) { + public Result uploadBase64(@ApiIgnore @RequestBody Map 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 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 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); +// } } diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/entity/SystemRole.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/entity/SystemRole.java index 8608c02..252a8e0 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/entity/SystemRole.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/entity/SystemRole.java @@ -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; /** * 创建时间 */ diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/IBaseMenuService.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/IBaseMenuService.java index 2a180b0..c30fa25 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/IBaseMenuService.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/IBaseMenuService.java @@ -56,4 +56,6 @@ public interface IBaseMenuService extends IService { Set queryRouter(); List getAllForHz(Map map); + + List getMenusForHz(Map map); } diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/BaseMenuServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/BaseMenuServiceImpl.java index e730900..6837432 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/BaseMenuServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/BaseMenuServiceImpl.java @@ -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 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 i return TreeUtil.formatHz(baseMenus); } + @Override + public List getMenusForHz(Map map) { + String roleId = MapUtils.getString(map, "roleId"); + SystemRole systemRole = systemRoleService.getById(roleId); + Integer accountType = systemRole.getRoleType(); + List 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.lambdaQuery().eq(Enterprise::getEnterpriseSn, systemRole.getSn())); + enterpriseMainList = enterpriseMainMapper.selectList(Wrappers.lambdaQuery().eq(EnterpriseMain::getEnterpriseSn, enterprise.getEnterpriseSn())); + } + Long moduleId = 0L; + if (accountType == 2) { + moduleId = 1670639811581595650L; + } else if (accountType == 3) { + moduleId = 1681837103227502594L; + } else { + moduleId = 1670603312504918018L; + } + Set baseMenus = new HashSet<>(); + List baseMenuList = new ArrayList<>(); + if (accountType != 3) { + // 查询相对应的菜单 + List res = baseMenuMapper.selectList(Wrappers.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.lambdaQuery() + .eq(SystemRole::getRoleCode, code)).getRoleId(); + if (iRoleId != null) { + List res = baseMenuMapper.getMenuIdByFilter(iRoleId, moduleId); + baseMenus.addAll(res); + } + } + } + baseMenuList.addAll(baseMenus); + return TreeUtil.build(TreeUtil.formatMenu(baseMenuList), 1, moduleId, 2); + } + @Override public Map getProjectModuleAndMenu(Map map) { map.put("styleType",getStyleType(MapUtils.getString(map,"projectSn"))); diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/SystemRoleServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/SystemRoleServiceImpl.java index 1179a32..fa0f1f3 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/SystemRoleServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/SystemRoleServiceImpl.java @@ -39,11 +39,13 @@ public class SystemRoleServiceImpl extends ServiceImpl pageList(Map map) { SecurityUser user = SecurityUtil.getUser(); QueryWrapper 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 page = PageUtil.getPage(map); return baseMapper.selectPage(page, queryWrapper); } @@ -68,7 +70,8 @@ public class SystemRoleServiceImpl extends ServiceImpl 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);