From c20a71b9790bcc09ffe2237ffe4a4ca65351c0bb Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 24 Aug 2020 17:10:17 +0800 Subject: [PATCH] =?UTF-8?q?web=E5=B7=A5=E4=BD=9C=E7=AB=AF-=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gov-access/gov-access-server/pom.xml | 6 + .../controller/OperLanguageController.java | 85 ++++++ .../epmet/controller/OperMenuController.java | 156 +++++++++++ .../controller/OperResourceController.java | 84 ++++++ .../epmet/controller/OperRoleController.java | 104 ++++++++ .../controller/OperRoleMenuController.java | 85 ++++++ .../controller/OperRoleUserController.java | 132 +++++++++ .../java/com/epmet/dao/OperLanguageDao.java | 28 ++ .../main/java/com/epmet/dao/OperMenuDao.java | 52 ++++ .../java/com/epmet/dao/OperResourceDao.java | 48 ++++ .../main/java/com/epmet/dao/OperRoleDao.java | 24 ++ .../java/com/epmet/dao/OperRoleMenuDao.java | 49 ++++ .../java/com/epmet/dao/OperRoleUserDao.java | 57 ++++ .../com/epmet/entity/OperLanguageEntity.java | 49 ++++ .../java/com/epmet/entity/OperMenuEntity.java | 64 +++++ .../com/epmet/entity/OperResourceEntity.java | 53 ++++ .../java/com/epmet/entity/OperRoleEntity.java | 44 +++ .../com/epmet/entity/OperRoleMenuEntity.java | 36 +++ .../com/epmet/entity/OperRoleUserEntity.java | 37 +++ .../com/epmet/feign/EpmetUserFeignClient.java | 13 + .../EpmetUserFeignClientFallback.java | 7 + .../com/epmet/redis/OperLanguageRedis.java | 47 ++++ .../java/com/epmet/redis/OperMenuRedis.java | 74 ++++++ .../com/epmet/redis/OperResourceRedis.java | 50 ++++ .../com/epmet/redis/OperRoleMenuRedis.java | 47 ++++ .../java/com/epmet/redis/OperRoleRedis.java | 47 ++++ .../com/epmet/redis/OperRoleUserRedis.java | 47 ++++ .../epmet/service/OperLanguageService.java | 105 ++++++++ .../com/epmet/service/OperMenuService.java | 144 ++++++++++ .../epmet/service/OperResourceService.java | 110 ++++++++ .../epmet/service/OperRoleMenuService.java | 125 +++++++++ .../com/epmet/service/OperRoleService.java | 95 +++++++ .../epmet/service/OperRoleUserService.java | 133 ++++++++++ .../service/impl/OperLanguageServiceImpl.java | 121 +++++++++ .../service/impl/OperMenuServiceImpl.java | 250 ++++++++++++++++++ .../service/impl/OperResourceServiceImpl.java | 143 ++++++++++ .../service/impl/OperRoleMenuServiceImpl.java | 150 +++++++++++ .../service/impl/OperRoleServiceImpl.java | 118 +++++++++ .../service/impl/OperRoleUserServiceImpl.java | 156 +++++++++++ .../main/resources/mapper/OperLanguageDao.xml | 21 ++ .../src/main/resources/mapper/OperMenuDao.xml | 42 +++ .../main/resources/mapper/OperResourceDao.xml | 25 ++ .../src/main/resources/mapper/OperRoleDao.xml | 6 + .../main/resources/mapper/OperRoleMenuDao.xml | 25 ++ .../main/resources/mapper/OperRoleUserDao.xml | 32 +++ 45 files changed, 3326 insertions(+) create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperLanguageController.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperMenuController.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperResourceController.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleController.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleMenuController.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleUserController.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperLanguageDao.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperMenuDao.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperResourceDao.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleDao.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleMenuDao.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleUserDao.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperLanguageEntity.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperMenuEntity.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperResourceEntity.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleEntity.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleMenuEntity.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleUserEntity.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperLanguageRedis.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperMenuRedis.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperResourceRedis.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleMenuRedis.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleRedis.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleUserRedis.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperLanguageService.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperMenuService.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperResourceService.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleMenuService.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleService.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleUserService.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperLanguageServiceImpl.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperMenuServiceImpl.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperResourceServiceImpl.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleMenuServiceImpl.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleServiceImpl.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleUserServiceImpl.java create mode 100644 epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperLanguageDao.xml create mode 100644 epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperMenuDao.xml create mode 100644 epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperResourceDao.xml create mode 100644 epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleDao.xml create mode 100644 epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleMenuDao.xml create mode 100644 epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleUserDao.xml diff --git a/epmet-module/gov-access/gov-access-server/pom.xml b/epmet-module/gov-access/gov-access-server/pom.xml index f8d9426042..b7bc8e27bc 100644 --- a/epmet-module/gov-access/gov-access-server/pom.xml +++ b/epmet-module/gov-access/gov-access-server/pom.xml @@ -72,6 +72,12 @@ feign-httpclient 10.3.0 + + com.epmet + oper-access-client + 2.0.0 + compile + diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperLanguageController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperLanguageController.java new file mode 100644 index 0000000000..e14545c317 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperLanguageController.java @@ -0,0 +1,85 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.OperLanguageDTO; +import com.epmet.service.OperLanguageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("operlanguage") +public class OperLanguageController { + + @Autowired + private OperLanguageService operLanguageService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = operLanguageService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + OperLanguageDTO data = operLanguageService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody OperLanguageDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + operLanguageService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody OperLanguageDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + operLanguageService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + operLanguageService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperMenuController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperMenuController.java new file mode 100644 index 0000000000..b1f96c1692 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperMenuController.java @@ -0,0 +1,156 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.exception.ErrorCode; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.OperMenuDTO; +import com.epmet.dto.result.MenuResourceDTO; +import com.epmet.service.OperMenuService; +import com.epmet.service.OperResourceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * + * 菜单管理 + * + * @author zhaoqifeng + * @date 2020/3/17 16:35 + */ +@RestController +@RequestMapping("menu") +public class OperMenuController { + + @Autowired + private OperMenuService operMenuService; + + @Autowired + private OperResourceService operResourceService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = operMenuService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + OperMenuDTO data = operMenuService.get(id); + + //菜单资源列表 + List resourceList = operResourceService.getMenuResourceList(id); + + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody OperMenuDTO dto, @LoginUser TokenDto tokenDto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + operMenuService.save(dto,tokenDto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody OperMenuDTO dto, @LoginUser TokenDto tokenDto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + operMenuService.update(dto,tokenDto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + operMenuService.delete(ids); + return new Result(); + } + + @DeleteMapping("{id}") + public Result delete(@PathVariable("id") String id, @LoginUser TokenDto tokenDto){ + //效验数据 + AssertUtils.isNull(id, "id"); + + //判断是否有子菜单或按钮 + List list = operMenuService.getListPid(id); + if(list.size() > 0){ + return new Result().error(ErrorCode.SUB_MENU_EXIST); + } + + operMenuService.delete(id, tokenDto); + + return new Result(); + } + + + /** + * 获取菜单列表 + * @param type 类型 + * @return Result> + */ + @GetMapping("list") + public Result> list(Integer type){ + List list = operMenuService.getMenuList(type); + + return new Result>().ok(list); + } + + /** + * 导航 + * @param tokenDto token + * @return List + */ + @GetMapping("nav") + public Result> nav(@LoginUser TokenDto tokenDto){ + List list = operMenuService.getUserMenuNavList(tokenDto); + return new Result>().ok(list); + } + + /** + * 权限标识 + * @param tokenDto token + * @return Set + */ + @GetMapping("permissions") + public Result> permissions(@LoginUser TokenDto tokenDto){ + Set set = operMenuService.getUserPermissions(tokenDto); + return new Result>().ok(set); + } + + /** + * 角色菜单权限 + * @param tokenDto token + * @return + */ + @GetMapping("select") + public Result> select(@LoginUser TokenDto tokenDto){ + List list = operMenuService.getUserMenuList(tokenDto, null); + + return new Result>().ok(list); + } + + /** + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 运营端用户退出系统,清空菜单和操作权限 + * @Date 2020/5/21 18:07 + **/ + @GetMapping("clearoperuseraccess") + public Result clearOperUserAccess(@LoginUser TokenDto tokenDto) { + operMenuService.clearOperUserAccess(tokenDto.getApp(), tokenDto.getClient(), tokenDto.getUserId()); + return new Result(); + } +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperResourceController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperResourceController.java new file mode 100644 index 0000000000..8bda911e28 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperResourceController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.OperResourceDTO; +import com.epmet.service.OperResourceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("operresource") +public class OperResourceController { + + @Autowired + private OperResourceService operResourceService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = operResourceService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + OperResourceDTO data = operResourceService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody OperResourceDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + operResourceService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody OperResourceDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + operResourceService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + operResourceService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleController.java new file mode 100644 index 0000000000..33659c8c03 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleController.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.OperRoleDTO; +import com.epmet.service.OperRoleMenuService; +import com.epmet.service.OperRoleService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("operrole") +public class OperRoleController { + + @Autowired + private OperRoleService operRoleService; + @Autowired + private OperRoleMenuService operRoleMenuService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = operRoleService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + OperRoleDTO data = operRoleService.get(id); + + //查询角色对应的菜单 + List menuIdList = operRoleMenuService.getMenuIdList(id); + data.setMenuIdList(menuIdList); + + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody OperRoleDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + operRoleService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody OperRoleDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + operRoleService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + operRoleService.delete(ids); + return new Result(); + } + + + @GetMapping("list") + @ApiOperation("列表") + public Result> list(){ + List data = operRoleService.list(new HashMap<>(1)); + + return new Result>().ok(data); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleMenuController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleMenuController.java new file mode 100644 index 0000000000..6520623e16 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleMenuController.java @@ -0,0 +1,85 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.OperRoleMenuDTO; +import com.epmet.service.OperRoleMenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("operrolemenu") +public class OperRoleMenuController { + + @Autowired + private OperRoleMenuService operRoleMenuService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = operRoleMenuService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + OperRoleMenuDTO data = operRoleMenuService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody OperRoleMenuDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + operRoleMenuService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody OperRoleMenuDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + operRoleMenuService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + operRoleMenuService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleUserController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleUserController.java new file mode 100644 index 0000000000..b58bfd322b --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleUserController.java @@ -0,0 +1,132 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.OperRoleUserDTO; +import com.epmet.service.OperRoleUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("operroleuser") +public class OperRoleUserController { + + @Autowired + private OperRoleUserService operRoleUserService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = operRoleUserService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + OperRoleUserDTO data = operRoleUserService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody OperRoleUserDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + operRoleUserService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody OperRoleUserDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + operRoleUserService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + operRoleUserService.delete(ids); + return new Result(); + } + + + /** + * 获取权限id列表 + * @param id 用户id + * @return List + * @author zhaoqifeng + */ + @GetMapping("getRoleIdList/{id}") + public Result>getRoleIdList(@PathVariable("id") String id) { + List list = operRoleUserService.getRoleIdList(id); + return new Result>().ok(list); + } + + /** + * 保存更新权限 + * @param userId 用户id + * @param roleIdList 权限列表 + * @author zhaoqifeng + */ + @PostMapping("saveOrUpdateRole") + public Result saveOrUpdate(@RequestParam("userId") String userId, @RequestBody List roleIdList) { + operRoleUserService.saveOrUpdate(userId, roleIdList); + return new Result(); + } + + /** + * 根据用户id,删除角色用户关系 + * @param id 用户id + * @return Result + */ + @PostMapping("deleteByUserId") + public Result deleteByUserId(String id) { + operRoleUserService.deleteByUserId(id); + return new Result(); + } + + /** + * 根据用户ids,删除角色用户关系 + * @param ids 用户ids + * @return Result + */ + @PostMapping("deleteByUserIds") + public Result deleteByUserIds(@RequestBody String[] ids) { + operRoleUserService.deleteByUserIds(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperLanguageDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperLanguageDao.java new file mode 100644 index 0000000000..dfca54a9ab --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperLanguageDao.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.OperLanguageEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 国际化 + * + * @author Mark sunlightcs@gmail.com + */ +@Mapper +public interface OperLanguageDao extends BaseDao { + + OperLanguageEntity getLanguage(OperLanguageEntity entity); + + void updateLanguage(OperLanguageEntity entity); + + void insertOperLanguageEntity(OperLanguageEntity entity); +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperMenuDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperMenuDao.java new file mode 100644 index 0000000000..2858a76f24 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperMenuDao.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.OperMenuEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 菜单管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface OperMenuDao extends BaseDao { + + OperMenuEntity getById(@Param("id") String id, @Param("language") String language); + + /** + * 查询所有菜单列表 + * + * @param type 菜单类型 + * @param language 语言 + */ + List getMenuList(@Param("type") Integer type, @Param("language") String language); + + /** + * 查询用户菜单列表 + * + * @param userId 用户ID + * @param type 菜单类型 + * @param language 语言 + */ + List getUserMenuList(@Param("userId") String userId, @Param("type") Integer type, @Param("language") String language); + + + /** + * 根据父菜单,查询子菜单 + * @param pid 父菜单ID + */ + List getListPid(String pid); +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperResourceDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperResourceDao.java new file mode 100644 index 0000000000..b92caee0d7 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperResourceDao.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.OperResourceEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 资源管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface OperResourceDao extends BaseDao { + /** + * 根据资源编码,删除对应的资源 + * @param code 资源编码 + */ + void deleteByCode(String code); + + /** + * 获取资源列表 + * @param menuId 菜单ID + */ + List getMenuResourceList(String menuId); + + /** + * 获取所有资源列表 + */ + List getResourceList(); + + /** + * 获取用户资源列表 + * @param userId 用户ID + */ + List getUserResourceList(@Param("userId") String userId); +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleDao.java new file mode 100644 index 0000000000..408a5275f5 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleDao.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.OperRoleEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 角色管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface OperRoleDao extends BaseDao { + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleMenuDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleMenuDao.java new file mode 100644 index 0000000000..005f9e44ac --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleMenuDao.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.OperRoleMenuEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 角色菜单关系 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface OperRoleMenuDao extends BaseDao { + + /** + * 根据角色ID,获取菜单ID列表 + */ + List getMenuIdList(String roleId); + + /** + * 根据角色id,删除角色菜单关系 + * @param roleId 角色id + */ + void deleteByRoleId(String roleId); + + /** + * 根据菜单id,删除角色菜单关系 + * @param menuId 菜单id + */ + void deleteByMenuId(String menuId); + + + /** + * 根据角色ids,删除角色菜单关系 + * @param roleIds 角色ids + */ + void deleteByRoleIds(String[] roleIds); +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleUserDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleUserDao.java new file mode 100644 index 0000000000..f33c5a241a --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleUserDao.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.OperRoleUserEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 角色用户关系 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface OperRoleUserDao extends BaseDao { + + /** + * 根据角色ids,删除角色用户关系 + * @param roleIds 角色ids + */ + void deleteByRoleIds(String[] roleIds); + + /** + * 根据用户ids,删除角色用户关系 + * @param userIds 用户ids + */ + void deleteByUserIds(String[] userIds); + + /** + * 根据角色id,删除角色用户关系 + * @param roleId 角色id + */ + void deleteByRoleId(String roleId); + + /** + * 根据用户id,删除角色用户关系 + * @param userId 用户id + */ + void deleteByUserId(String userId); + + /** + * 角色ID列表 + * @param userId 用户ID + * + * @return + */ + List getRoleIdList(String userId); +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperLanguageEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperLanguageEntity.java new file mode 100644 index 0000000000..3e822d5665 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperLanguageEntity.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * 国际化 + * + * @author Mark sunlightcs@gmail.com + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("oper_language") +public class OperLanguageEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 表名 + */ + private String tableName; + /** + * 表主键 + */ + private String tableId; + /** + * 字段名 + */ + private String fieldName; + /** + * 字段值 + */ + private String fieldValue; + /** + * 语言 + */ + private String language; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperMenuEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperMenuEntity.java new file mode 100644 index 0000000000..ba621edcc0 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperMenuEntity.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 菜单管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("oper_menu") +public class OperMenuEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + + /** + * 上级ID,一级菜单为0 + */ + private String pid; + /** + * 菜单名称 + */ + @TableField(exist = false) + private String name; + /** + * 菜单URL + */ + private String url; + /** + * 类型 0:菜单 1:按钮 + */ + private Integer type; + /** + * 菜单图标 + */ + private String icon; + /** + * 权限标识,如:sys:menu:save + */ + private String permissions; + /** + * 排序 + */ + private Integer sort; + /** + * 上级菜单名称 + */ + @TableField(exist = false) + private String parentName; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperResourceEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperResourceEntity.java new file mode 100644 index 0000000000..7afd722bd2 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperResourceEntity.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 资源管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("oper_resource") +public class OperResourceEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + + /** + * 资源编码,如菜单ID + */ + private String resourceCode; + /** + * 资源名称 + */ + private String resourceName; + /** + * 资源URL + */ + private String resourceUrl; + /** + * 请求方式(如:GET、POST、PUT、DELETE) + */ + private String resourceMethod; + /** + * 菜单标识 0:非菜单资源 1:菜单资源 + */ + private Integer menuFlag; + /** + * 认证等级 0:权限认证 1:登录认证 2:无需认证 + */ + private Integer authLevel; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleEntity.java new file mode 100644 index 0000000000..7fd5393e7e --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleEntity.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 角色管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("oper_role") +public class OperRoleEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + + /** + * 角色名称 + */ + private String name; + /** + * 备注 + */ + private String remark; + /** + * 部门ID + */ + @TableField(fill = FieldFill.INSERT) + private Long deptId; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleMenuEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleMenuEntity.java new file mode 100644 index 0000000000..650619ffa9 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleMenuEntity.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 角色菜单关系 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("oper_role_menu") +public class OperRoleMenuEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + /** + * 角色ID + */ + private String roleId; + /** + * 菜单ID + */ + private String menuId; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleUserEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleUserEntity.java new file mode 100644 index 0000000000..8eb9612417 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleUserEntity.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 角色用户关系 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("oper_role_user") +public class OperRoleUserEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + /** + * 用户ID + */ + private String userId; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index eaabe43f49..d88b8358a3 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -3,6 +3,7 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.OperUserDTO; import com.epmet.dto.form.LatestGridFormDTO; import com.epmet.dto.form.StaffGridVisitedFormDTO; import com.epmet.dto.form.StaffRoleFormDTO; @@ -60,5 +61,17 @@ public interface EpmetUserFeignClient { */ @PostMapping("/epmetuser/staffrole/staffroles") Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO); + + /** + * + * 根据id查询运营人员详情 + * + * @param operUserId oper_user表主键 + * @return com.epmet.commons.tools.utils.Result> + * @author zhaoqifeng + * @date 2020/3/19 09:28 + **/ + @GetMapping("/operuser/queryOperUserDtoById/{operUserId}") + Result info(@PathVariable("operUserId") String operUserId); } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java index 12a4b4e6c6..cd39c87452 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.OperUserDTO; import com.epmet.dto.form.LatestGridFormDTO; import com.epmet.dto.form.StaffGridVisitedFormDTO; import com.epmet.dto.form.StaffRoleFormDTO; @@ -31,6 +32,12 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { public Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRolesOfStaff"); } + + @Override + public Result info(String operUserId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "info", operUserId); + } + @Override public Result getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffLatestGrid",latestGridFormDTO); diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperLanguageRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperLanguageRedis.java new file mode 100644 index 0000000000..fa479f92ca --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperLanguageRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class OperLanguageRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperMenuRedis.java new file mode 100644 index 0000000000..f1b568f33a --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperMenuRedis.java @@ -0,0 +1,74 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.HttpContextUtils; +import com.epmet.dto.OperMenuDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Set; + +/** + * 菜单管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class OperMenuRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(String userId, String app, String client) { + redisUtils.deleteByPattern(RedisKeys.getUserMenuNavKey(userId, app, client, HttpContextUtils.getLanguage())); + redisUtils.delete(RedisKeys.getUserPermissionsKey(userId, app, client)); + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + + public void setUserMenuNavList(String userId, String app, String client, List menuList){ + String key = RedisKeys.getUserMenuNavKey(userId, app, client, HttpContextUtils.getLanguage()); + redisUtils.set(key, menuList); + } + + public List getUserMenuNavList(String userId, String app, String client){ + String key = RedisKeys.getUserMenuNavKey(userId, app, client, HttpContextUtils.getLanguage()); + return (List)redisUtils.get(key); + } + + public void setUserPermissions(String userId, String app, String client, Set permsSet){ + String key = RedisKeys.getUserPermissionsKey(userId, app, client); + redisUtils.set(key, permsSet); + } + + public Set getUserPermissions(String userId, String app, String client){ + String key = RedisKeys.getUserPermissionsKey(userId, app, client); + return (Set)redisUtils.get(key); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperResourceRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperResourceRedis.java new file mode 100644 index 0000000000..68ea39a15e --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperResourceRedis.java @@ -0,0 +1,50 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class OperResourceRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete() { + String key = RedisKeys.getSysResourceKey(); + + redisUtils.delete(key); + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleMenuRedis.java new file mode 100644 index 0000000000..28f98c5615 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleMenuRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class OperRoleMenuRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleRedis.java new file mode 100644 index 0000000000..15e6682155 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class OperRoleRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleUserRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleUserRedis.java new file mode 100644 index 0000000000..7f6df90fa3 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleUserRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class OperRoleUserRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperLanguageService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperLanguageService.java new file mode 100644 index 0000000000..0f0ad555bc --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperLanguageService.java @@ -0,0 +1,105 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.OperLanguageDTO; +import com.epmet.entity.OperLanguageEntity; + +import java.util.List; +import java.util.Map; + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface OperLanguageService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OperLanguageDTO + * @author generator + * @date 2020-03-18 + */ + OperLanguageDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(OperLanguageDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(OperLanguageDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 保存或更新 + * @param tableName 表名 + * @param tableId 表主键 + * @param fieldName 字段名 + * @param fieldValue 字段值 + * @param language 语言 + */ + void saveOrUpdate(String tableName, String tableId, String fieldName, String fieldValue, String language); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperMenuService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperMenuService.java new file mode 100644 index 0000000000..70794bc18b --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperMenuService.java @@ -0,0 +1,144 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.OperMenuDTO; +import com.epmet.entity.OperMenuEntity; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 菜单管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface OperMenuService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OperMenuDTO + * @author generator + * @date 2020-03-18 + */ + OperMenuDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(OperMenuDTO dto, TokenDto tokenDto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(OperMenuDTO dto, TokenDto tokenDto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 删除 + * + * @param id id + * @author generator + * @date 2020-03-18 + */ + void delete(String id, TokenDto tokenDto); + + /** + * 用户菜单列表 + * + * @param tokenDto 用户信息 + * @param type 菜单类型 + * @return java.util.List + */ + List getUserMenuList(TokenDto tokenDto, Integer type); + + /** + * 菜单列表 + * + * @param type 菜单类型 + */ + List getMenuList(Integer type); + + /** + * 用户菜单导航 + * @param tokenDto 用户信息 + * @return java.util.List + */ + List getUserMenuNavList(TokenDto tokenDto); + + /** + * 获取用户权限标识 + * @param tokenDto 用户信息 + * @return java.util.Set + */ + Set getUserPermissions(TokenDto tokenDto); + + /** + * 根据父菜单,查询子菜单 + * @param pid 父菜单ID + */ + List getListPid(String pid); + + void clearOperUserAccess(String app, String client, String userId); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperResourceService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperResourceService.java new file mode 100644 index 0000000000..560e097c0b --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperResourceService.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.OperResourceDTO; +import com.epmet.dto.result.MenuResourceDTO; +import com.epmet.entity.OperResourceEntity; + +import java.util.List; +import java.util.Map; + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface OperResourceService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OperResourceDTO + * @author generator + * @date 2020-03-18 + */ + OperResourceDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(OperResourceDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(OperResourceDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 保存菜单资源 + * @param menuId 菜单ID + * @param menuName 菜单名称 + * @param resourceList 资源列表 + */ + void saveMenuResource(String menuId, String menuName, List resourceList); + + /** + * 获取菜单资源列表 + * @param menuId 菜单ID + */ + List getMenuResourceList(String menuId); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleMenuService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleMenuService.java new file mode 100644 index 0000000000..84cfe6d996 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleMenuService.java @@ -0,0 +1,125 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.OperRoleMenuDTO; +import com.epmet.entity.OperRoleMenuEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface OperRoleMenuService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OperRoleMenuDTO + * @author generator + * @date 2020-03-18 + */ + OperRoleMenuDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(OperRoleMenuDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(OperRoleMenuDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 根据角色ID,获取菜单ID列表 + */ + List getMenuIdList(String roleId); + + /** + * 保存或修改 + * @param roleId 角色ID + * @param menuIdList 菜单ID列表 + */ + void saveOrUpdate(String roleId, List menuIdList); + + /** + * 根据角色id,删除角色菜单关系 + * @param roleId 角色id + */ + void deleteByRoleId(String roleId); + + /** + * 根据角色ids,删除角色菜单关系 + * @param roleIds + */ + void deleteByRoleIds(String[] roleIds); + + /** + * 根据菜单id,删除角色菜单关系 + * @param menuId 菜单id + */ + void deleteByMenuId(String menuId); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleService.java new file mode 100644 index 0000000000..b4368ca747 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.OperRoleDTO; +import com.epmet.entity.OperRoleEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface OperRoleService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OperRoleDTO + * @author generator + * @date 2020-03-18 + */ + OperRoleDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(OperRoleDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(OperRoleDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleUserService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleUserService.java new file mode 100644 index 0000000000..c2e323528c --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleUserService.java @@ -0,0 +1,133 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.OperRoleUserDTO; +import com.epmet.entity.OperRoleUserEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface OperRoleUserService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OperRoleUserDTO + * @author generator + * @date 2020-03-18 + */ + OperRoleUserDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(OperRoleUserDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(OperRoleUserDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 保存或修改 + * @param userId 用户ID + * @param roleIdList 角色ID列表 + */ + void saveOrUpdate(String userId, List roleIdList); + + /** + * 根据角色id,删除角色用户关系 + * @param roleId 角色id + */ + void deleteByRoleId(String roleId); + + /** + * 根据用户id,删除角色用户关系 + * @param userId 用户id + */ + void deleteByUserId(String userId); + + /** + * 角色ID列表 + * @param userId 用户ID + * @return List + */ + List getRoleIdList(String userId); + + /** + * 根据角色ids,删除角色用户关系 + * @param roleIds 角色ids + */ + void deleteByRoleIds(String[] roleIds); + + /** + * 根据用户ids,删除角色用户关系 + * @param userIds 用户ids + */ + void deleteByUserIds(String[] userIds); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperLanguageServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperLanguageServiceImpl.java new file mode 100644 index 0000000000..bc07525c87 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperLanguageServiceImpl.java @@ -0,0 +1,121 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.OperLanguageDao; +import com.epmet.dto.OperLanguageDTO; +import com.epmet.entity.OperLanguageEntity; +import com.epmet.redis.OperLanguageRedis; +import com.epmet.service.OperLanguageService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class OperLanguageServiceImpl extends BaseServiceImpl implements OperLanguageService { + + @Autowired + private OperLanguageRedis operLanguageRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OperLanguageDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OperLanguageDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public OperLanguageDTO get(String id) { + OperLanguageEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, OperLanguageDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OperLanguageDTO dto) { + OperLanguageEntity entity = ConvertUtils.sourceToTarget(dto, OperLanguageEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OperLanguageDTO dto) { + OperLanguageEntity entity = ConvertUtils.sourceToTarget(dto, OperLanguageEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void saveOrUpdate(String tableName, String tableId, String fieldName, String fieldValue, String language) { + OperLanguageEntity entity = new OperLanguageEntity(); + entity.setTableName(tableName); + entity.setTableId(tableId); + entity.setFieldName(fieldName); + entity.setFieldValue(fieldValue); + entity.setLanguage(language); + + //判断是否有数据 + if(baseDao.getLanguage(entity) == null){ + baseDao.insertOperLanguageEntity(entity); + }else { + baseDao.updateLanguage(entity); + } + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperMenuServiceImpl.java new file mode 100644 index 0000000000..281192dbb8 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperMenuServiceImpl.java @@ -0,0 +1,250 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.Constant; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.enums.SuperAdminEnum; +import com.epmet.commons.tools.exception.ErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpContextUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.TreeUtils; +import com.epmet.dao.OperMenuDao; +import com.epmet.dto.OperMenuDTO; +import com.epmet.dto.OperUserDTO; +import com.epmet.entity.OperMenuEntity; +import com.epmet.enums.MenuTypeEnum; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.redis.OperMenuRedis; +import com.epmet.service.OperLanguageService; +import com.epmet.service.OperMenuService; +import com.epmet.service.OperResourceService; +import com.epmet.service.OperRoleMenuService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 菜单管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class OperMenuServiceImpl extends BaseServiceImpl implements OperMenuService { + protected Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired + private OperMenuRedis operMenuRedis; + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private OperRoleMenuService operRoleMenuService; + @Autowired + private OperResourceService operResourceService; + @Autowired + private OperLanguageService operLanguageService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OperMenuDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OperMenuDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public OperMenuDTO get(String id) { + OperMenuEntity entity = baseDao.getById(id, HttpContextUtils.getLanguage()); + + return ConvertUtils.sourceToTarget(entity, OperMenuDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OperMenuDTO dto, TokenDto tokenDto) { + OperMenuEntity entity = ConvertUtils.sourceToTarget(dto, OperMenuEntity.class); + + //保存菜单 + insert(entity); + saveLanguage(entity.getId(), "name", entity.getName()); + + //保存菜单资源 + operResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); + + //清空当前用户,菜单导航、权限标识 + operMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OperMenuDTO dto, TokenDto tokenDto) { + OperMenuEntity entity = ConvertUtils.sourceToTarget(dto, OperMenuEntity.class); + + //上级菜单不能为自身 + if(entity.getId().equals(entity.getPid())){ + throw new RenException(ErrorCode.SUPERIOR_MENU_ERROR); + } + + //更新菜单 + updateById(entity); + saveLanguage(entity.getId(), "name", entity.getName()); + + //更新菜单资源 + operResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); + + //清空当前用户,菜单导航、权限标识 + operMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String id, TokenDto tokenDto) { + //逻辑删除 + baseDao.deleteBatchIds(Collections.singletonList(id)); + //删除角色菜单关系 + operRoleMenuService.deleteByMenuId(id); + + //清空当前用户,菜单导航、权限标识 + operMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + } + + @Override + public List getUserMenuList(TokenDto tokenDto, Integer type) { + List menuList; + +// Result operUserDTOResult = epmetUserFeignClient.info(tokenDto.getUserId()); + +// //系统管理员,拥有最高权限 +// if(operUserDTOResult.getData().getSuperAdmin() == SuperAdminEnum.YES.value()){ + menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage()); +// }else { +// menuList = baseDao.getUserMenuList(tokenDto.getUserId(), type, HttpContextUtils.getLanguage()); +// } + + List dtoList = ConvertUtils.sourceToTarget(menuList, OperMenuDTO.class); + + return TreeUtils.buildTree(dtoList); + } + + @Override + public List getMenuList(Integer type) { + List menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage()); + + List dtoList = ConvertUtils.sourceToTarget(menuList, OperMenuDTO.class); + + return TreeUtils.buildTree(dtoList, Constant.OPER_MENU_ROOT); + } + + @Override + public List getUserMenuNavList(TokenDto tokenDto) { + List menuList = operMenuRedis.getUserMenuNavList(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + if(menuList == null){ + menuList = getUserMenuList(tokenDto, MenuTypeEnum.MENU.value()); + + operMenuRedis.setUserMenuNavList(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient(), menuList); + } + + return menuList; + } + + @Override + public Set getUserPermissions(TokenDto tokenDto) { + //用户权限列表 + Set permsSet = operMenuRedis.getUserPermissions(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + if(permsSet != null){ + return permsSet; + } + +// Result operUserDTOResult = epmetUserFeignClient.info(tokenDto.getUserId()); + + //超级管理员,拥有最高权限 + List menuList; +// if(operUserDTOResult.getData().getSuperAdmin() == SuperAdminEnum.YES.value()){ + menuList = baseDao.getMenuList(MenuTypeEnum.BUTTON.value(), HttpContextUtils.getLanguage()); +// }else{ +// menuList = baseDao.getUserMenuList(tokenDto.getUserId(), MenuTypeEnum.BUTTON.value(), HttpContextUtils.getLanguage()); +// } + + permsSet = new HashSet<>(); + for(OperMenuEntity menu : menuList){ + if(StringUtils.isNotBlank(menu.getPermissions())){ + permsSet.add(menu.getPermissions()); + } + } + + //保存到缓存 + operMenuRedis.setUserPermissions(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient(), permsSet); + + return permsSet; + } + + @Override + public List getListPid(String pid) { + List menuList = baseDao.getListPid(pid); + + return ConvertUtils.sourceToTarget(menuList, OperMenuDTO.class); + } + + @Override + public void clearOperUserAccess(String app, String client, String userId) { + //清空当前用户,菜单导航、权限标识 + operMenuRedis.delete(userId, app, client); + logger.info(String.format("运营端用户退出系统%s,清空菜单、权限成功",userId)); + } + + private void saveLanguage(String tableId, String fieldName, String fieldValue){ + operLanguageService.saveOrUpdate("oper_menu", tableId, fieldName, fieldValue, HttpContextUtils.getLanguage()); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperResourceServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperResourceServiceImpl.java new file mode 100644 index 0000000000..c12d519b2c --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperResourceServiceImpl.java @@ -0,0 +1,143 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.enums.ResourceAuthEnum; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.OperResourceDao; +import com.epmet.dto.OperResourceDTO; +import com.epmet.dto.result.MenuResourceDTO; +import com.epmet.entity.OperResourceEntity; +import com.epmet.enums.MenuFlagEnum; +import com.epmet.redis.OperResourceRedis; +import com.epmet.service.OperResourceService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class OperResourceServiceImpl extends BaseServiceImpl implements OperResourceService { + + @Autowired + private OperResourceRedis operResourceRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OperResourceDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OperResourceDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public OperResourceDTO get(String id) { + OperResourceEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, OperResourceDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OperResourceDTO dto) { + OperResourceEntity entity = ConvertUtils.sourceToTarget(dto, OperResourceEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OperResourceDTO dto) { + OperResourceEntity entity = ConvertUtils.sourceToTarget(dto, OperResourceEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void saveMenuResource(String menuId, String menuName, List resourceList) { + //先删除菜单资源关系 + baseDao.deleteByCode(menuId+""); + + //删除缓存 + operResourceRedis.delete(); + + //菜单没有一个资源的情况 + if(CollUtil.isEmpty(resourceList)){ + return ; + } + + //保存菜单资源关系 + for(MenuResourceDTO dto : resourceList){ + OperResourceEntity entity = new OperResourceEntity(); + entity.setResourceCode(menuId+""); + entity.setResourceName(menuName); + entity.setResourceUrl(dto.getResourceUrl()); + entity.setResourceMethod(dto.getResourceMethod()); + entity.setAuthLevel(ResourceAuthEnum.PERMISSIONS_AUTH.value()); + entity.setMenuFlag(MenuFlagEnum.YES.value()); + + //保存 + insert(entity); + } + } + + @Override + public List getMenuResourceList(String menuId) { + List entityList = baseDao.getMenuResourceList(menuId+""); + + return ConvertUtils.sourceToTarget(entityList, MenuResourceDTO.class); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleMenuServiceImpl.java new file mode 100644 index 0000000000..f4206928b9 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleMenuServiceImpl.java @@ -0,0 +1,150 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.OperRoleMenuDao; +import com.epmet.dto.OperRoleMenuDTO; +import com.epmet.entity.OperRoleMenuEntity; +import com.epmet.redis.OperRoleMenuRedis; +import com.epmet.service.OperRoleMenuService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class OperRoleMenuServiceImpl extends BaseServiceImpl implements OperRoleMenuService { + + @Autowired + private OperRoleMenuRedis operRoleMenuRedis; + @Autowired + private OperRoleMenuDao operRoleMenuDao; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OperRoleMenuDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OperRoleMenuDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public OperRoleMenuDTO get(String id) { + OperRoleMenuEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, OperRoleMenuDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OperRoleMenuDTO dto) { + OperRoleMenuEntity entity = ConvertUtils.sourceToTarget(dto, OperRoleMenuEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OperRoleMenuDTO dto) { + OperRoleMenuEntity entity = ConvertUtils.sourceToTarget(dto, OperRoleMenuEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List getMenuIdList(String roleId){ + return baseDao.getMenuIdList(roleId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveOrUpdate(String roleId, List menuIdList) { + //先删除角色菜单关系 + deleteByRoleId(roleId); + + //角色没有一个菜单权限的情况 + if(CollUtil.isEmpty(menuIdList)){ + return ; + } + + //保存角色菜单关系 + for(String menuId : menuIdList){ + OperRoleMenuEntity operRoleMenuEntity = new OperRoleMenuEntity(); + operRoleMenuEntity.setMenuId(menuId); + operRoleMenuEntity.setRoleId(roleId); + + //保存 + insert(operRoleMenuEntity); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByRoleId(String roleId) { + baseDao.deleteByRoleId(roleId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByRoleIds(String[] roleIds) { + operRoleMenuDao.deleteByRoleIds(roleIds); + } + + @Override + public void deleteByMenuId(String menuId) { + baseDao.deleteByMenuId(menuId); + } +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleServiceImpl.java new file mode 100644 index 0000000000..ba733194ad --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleServiceImpl.java @@ -0,0 +1,118 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.OperRoleDao; +import com.epmet.dto.OperRoleDTO; +import com.epmet.entity.OperRoleEntity; +import com.epmet.redis.OperRoleRedis; +import com.epmet.service.OperRoleMenuService; +import com.epmet.service.OperRoleService; +import com.epmet.service.OperRoleUserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class OperRoleServiceImpl extends BaseServiceImpl implements OperRoleService { + + @Autowired + private OperRoleRedis operRoleRedis; + @Autowired + private OperRoleMenuService OperRoleMenuService; + @Autowired + private OperRoleUserService operRoleUserService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OperRoleDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OperRoleDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + String name = (String)params.get(FieldConstant.NAME_HUMP); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id).like(StringUtils.isNotBlank(name), FieldConstant.NAME, name); + + return wrapper; + } + + @Override + public OperRoleDTO get(String id) { + OperRoleEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, OperRoleDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OperRoleDTO dto) { + OperRoleEntity entity = ConvertUtils.sourceToTarget(dto, OperRoleEntity.class); + insert(entity); + //保存角色菜单关系 + OperRoleMenuService.saveOrUpdate(entity.getId(), dto.getMenuIdList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OperRoleDTO dto) { + OperRoleEntity entity = ConvertUtils.sourceToTarget(dto, OperRoleEntity.class); + updateById(entity); + //保存角色菜单关系 + OperRoleMenuService.saveOrUpdate(entity.getId(), dto.getMenuIdList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + + OperRoleMenuService.deleteByRoleIds(ids); + + operRoleUserService.deleteByRoleIds(ids); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleUserServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleUserServiceImpl.java new file mode 100644 index 0000000000..3dddda0738 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleUserServiceImpl.java @@ -0,0 +1,156 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.OperRoleUserDao; +import com.epmet.dto.OperRoleUserDTO; +import com.epmet.entity.OperRoleUserEntity; +import com.epmet.redis.OperRoleUserRedis; +import com.epmet.service.OperRoleUserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class OperRoleUserServiceImpl extends BaseServiceImpl implements OperRoleUserService { + + @Autowired + private OperRoleUserRedis operRoleUserRedis; + @Autowired + private OperRoleUserDao operRoleUserDao; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OperRoleUserDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OperRoleUserDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public OperRoleUserDTO get(String id) { + OperRoleUserEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, OperRoleUserDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OperRoleUserDTO dto) { + OperRoleUserEntity entity = ConvertUtils.sourceToTarget(dto, OperRoleUserEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OperRoleUserDTO dto) { + OperRoleUserEntity entity = ConvertUtils.sourceToTarget(dto, OperRoleUserEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveOrUpdate(String userId, List roleIdList) { + //先删除角色用户关系 + deleteByUserId(userId); + + //用户没有一个角色权限的情况 + if(CollUtil.isEmpty(roleIdList)){ + return ; + } + + //保存角色用户关系 + for(String roleId : roleIdList){ + OperRoleUserEntity operRoleUserEntity = new OperRoleUserEntity(); + operRoleUserEntity.setUserId(userId); + operRoleUserEntity.setRoleId(roleId); + + //保存 + insert(operRoleUserEntity); + } + } + + @Override + public void deleteByRoleId(String roleId) { + operRoleUserDao.deleteByRoleId(roleId); + } + + @Override + public void deleteByUserId(String userId) { + operRoleUserDao.deleteByUserId(userId); + } + + @Override + public List getRoleIdList(String userId) { + + return baseDao.getRoleIdList(userId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByRoleIds(String[] roleIds) { + operRoleUserDao.deleteByRoleIds(roleIds); + } + + @Override + public void deleteByUserIds(String[] userIds) { + operRoleUserDao.deleteByUserIds(userIds); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperLanguageDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperLanguageDao.xml new file mode 100644 index 0000000000..a64735e21f --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperLanguageDao.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + INSERT INTO `oper_language` ( `table_name`, `table_id`, `field_name`, `field_value`, `language` ) + VALUES + ( #{tableName}, #{tableId}, #{fieldName}, #{fieldValue}, #{language} ) + + diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperMenuDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperMenuDao.xml new file mode 100644 index 0000000000..e3a61dbd36 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperMenuDao.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperResourceDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperResourceDao.xml new file mode 100644 index 0000000000..94c839c252 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperResourceDao.xml @@ -0,0 +1,25 @@ + + + + + + + delete from oper_resource where resource_code = #{value} + + + + + + + + + diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleDao.xml new file mode 100644 index 0000000000..e1df3a1038 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleDao.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleMenuDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleMenuDao.xml new file mode 100644 index 0000000000..b9075fceda --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleMenuDao.xml @@ -0,0 +1,25 @@ + + + + + + + + + update oper_role_menu set del_flag = 1 where del_flag = 0 and role_id in + + #{roleId} + + + + + update oper_role_menu set del_flag = 1 where role_id = #{value} and del_flag = 0 + + + + update oper_role_menu set del_flag = 1 where menu_id = #{value} and del_flag = 0 + + + diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleUserDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleUserDao.xml new file mode 100644 index 0000000000..005ef2451c --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleUserDao.xml @@ -0,0 +1,32 @@ + + + + + + + update oper_role_user set del_flag = 1 where del_flag = 0 and role_id in + + #{roleId} + + + + + update oper_role_user set del_flag = 1 where del_flag = 0 and user_id in + + #{userId} + + + + + update oper_role_user set del_flag = 1 where role_id = #{value} and del_flag = 0 + + + + update oper_role_user set del_flag = 1 where user_id = #{value} and del_flag = 0 + + + + +