Browse Source

web工作端-菜单管理

master
zhaoqifeng 5 years ago
parent
commit
c20a71b979
  1. 6
      epmet-module/gov-access/gov-access-server/pom.xml
  2. 85
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperLanguageController.java
  3. 156
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperMenuController.java
  4. 84
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperResourceController.java
  5. 104
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleController.java
  6. 85
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleMenuController.java
  7. 132
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/OperRoleUserController.java
  8. 28
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperLanguageDao.java
  9. 52
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperMenuDao.java
  10. 48
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperResourceDao.java
  11. 24
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleDao.java
  12. 49
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleMenuDao.java
  13. 57
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperRoleUserDao.java
  14. 49
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperLanguageEntity.java
  15. 64
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperMenuEntity.java
  16. 53
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperResourceEntity.java
  17. 44
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleEntity.java
  18. 36
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleMenuEntity.java
  19. 37
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperRoleUserEntity.java
  20. 13
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  21. 7
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
  22. 47
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperLanguageRedis.java
  23. 74
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperMenuRedis.java
  24. 50
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperResourceRedis.java
  25. 47
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleMenuRedis.java
  26. 47
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleRedis.java
  27. 47
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/OperRoleUserRedis.java
  28. 105
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperLanguageService.java
  29. 144
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperMenuService.java
  30. 110
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperResourceService.java
  31. 125
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleMenuService.java
  32. 95
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleService.java
  33. 133
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperRoleUserService.java
  34. 121
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperLanguageServiceImpl.java
  35. 250
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperMenuServiceImpl.java
  36. 143
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperResourceServiceImpl.java
  37. 150
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleMenuServiceImpl.java
  38. 118
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleServiceImpl.java
  39. 156
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperRoleUserServiceImpl.java
  40. 21
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperLanguageDao.xml
  41. 42
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperMenuDao.xml
  42. 25
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperResourceDao.xml
  43. 6
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleDao.xml
  44. 25
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleMenuDao.xml
  45. 32
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleUserDao.xml

6
epmet-module/gov-access/gov-access-server/pom.xml

@ -72,6 +72,12 @@
<artifactId>feign-httpclient</artifactId>
<version>10.3.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>oper-access-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

85
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<OperLanguageDTO>> page(@RequestParam Map<String, Object> params){
PageData<OperLanguageDTO> page = operLanguageService.page(params);
return new Result<PageData<OperLanguageDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<OperLanguageDTO> get(@PathVariable("id") String id){
OperLanguageDTO data = operLanguageService.get(id);
return new Result<OperLanguageDTO>().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();
}
}

156
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<PageData<OperMenuDTO>> page(@RequestParam Map<String, Object> params){
PageData<OperMenuDTO> page = operMenuService.page(params);
return new Result<PageData<OperMenuDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<OperMenuDTO> get(@PathVariable("id") String id){
OperMenuDTO data = operMenuService.get(id);
//菜单资源列表
List<MenuResourceDTO> resourceList = operResourceService.getMenuResourceList(id);
return new Result<OperMenuDTO>().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<OperMenuDTO> 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<List<OperMenuDTO>>
*/
@GetMapping("list")
public Result<List<OperMenuDTO>> list(Integer type){
List<OperMenuDTO> list = operMenuService.getMenuList(type);
return new Result<List<OperMenuDTO>>().ok(list);
}
/**
* 导航
* @param tokenDto token
* @return List<OperMenuDTO>
*/
@GetMapping("nav")
public Result<List<OperMenuDTO>> nav(@LoginUser TokenDto tokenDto){
List<OperMenuDTO> list = operMenuService.getUserMenuNavList(tokenDto);
return new Result<List<OperMenuDTO>>().ok(list);
}
/**
* 权限标识
* @param tokenDto token
* @return Set<String>
*/
@GetMapping("permissions")
public Result<Set<String>> permissions(@LoginUser TokenDto tokenDto){
Set<String> set = operMenuService.getUserPermissions(tokenDto);
return new Result<Set<String>>().ok(set);
}
/**
* 角色菜单权限
* @param tokenDto token
* @return
*/
@GetMapping("select")
public Result<List<OperMenuDTO>> select(@LoginUser TokenDto tokenDto){
List<OperMenuDTO> list = operMenuService.getUserMenuList(tokenDto, null);
return new Result<List<OperMenuDTO>>().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();
}
}

84
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<OperResourceDTO>> page(@RequestParam Map<String, Object> params){
PageData<OperResourceDTO> page = operResourceService.page(params);
return new Result<PageData<OperResourceDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<OperResourceDTO> get(@PathVariable("id") String id){
OperResourceDTO data = operResourceService.get(id);
return new Result<OperResourceDTO>().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();
}
}

104
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<OperRoleDTO>> page(@RequestParam Map<String, Object> params){
PageData<OperRoleDTO> page = operRoleService.page(params);
return new Result<PageData<OperRoleDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<OperRoleDTO> get(@PathVariable("id") String id){
OperRoleDTO data = operRoleService.get(id);
//查询角色对应的菜单
List<String> menuIdList = operRoleMenuService.getMenuIdList(id);
data.setMenuIdList(menuIdList);
return new Result<OperRoleDTO>().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<OperRoleDTO>> list(){
List<OperRoleDTO> data = operRoleService.list(new HashMap<>(1));
return new Result<List<OperRoleDTO>>().ok(data);
}
}

85
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<OperRoleMenuDTO>> page(@RequestParam Map<String, Object> params){
PageData<OperRoleMenuDTO> page = operRoleMenuService.page(params);
return new Result<PageData<OperRoleMenuDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<OperRoleMenuDTO> get(@PathVariable("id") String id){
OperRoleMenuDTO data = operRoleMenuService.get(id);
return new Result<OperRoleMenuDTO>().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();
}
}

132
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<OperRoleUserDTO>> page(@RequestParam Map<String, Object> params){
PageData<OperRoleUserDTO> page = operRoleUserService.page(params);
return new Result<PageData<OperRoleUserDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<OperRoleUserDTO> get(@PathVariable("id") String id){
OperRoleUserDTO data = operRoleUserService.get(id);
return new Result<OperRoleUserDTO>().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<String>
* @author zhaoqifeng
*/
@GetMapping("getRoleIdList/{id}")
public Result<List<String>>getRoleIdList(@PathVariable("id") String id) {
List<String> list = operRoleUserService.getRoleIdList(id);
return new Result<List<String>>().ok(list);
}
/**
* 保存更新权限
* @param userId 用户id
* @param roleIdList 权限列表
* @author zhaoqifeng
*/
@PostMapping("saveOrUpdateRole")
public Result saveOrUpdate(@RequestParam("userId") String userId, @RequestBody List<String> 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();
}
}

28
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> {
OperLanguageEntity getLanguage(OperLanguageEntity entity);
void updateLanguage(OperLanguageEntity entity);
void insertOperLanguageEntity(OperLanguageEntity entity);
}

52
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> {
OperMenuEntity getById(@Param("id") String id, @Param("language") String language);
/**
* 查询所有菜单列表
*
* @param type 菜单类型
* @param language 语言
*/
List<OperMenuEntity> getMenuList(@Param("type") Integer type, @Param("language") String language);
/**
* 查询用户菜单列表
*
* @param userId 用户ID
* @param type 菜单类型
* @param language 语言
*/
List<OperMenuEntity> getUserMenuList(@Param("userId") String userId, @Param("type") Integer type, @Param("language") String language);
/**
* 根据父菜单查询子菜单
* @param pid 父菜单ID
*/
List<OperMenuEntity> getListPid(String pid);
}

48
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<OperResourceEntity> {
/**
* 根据资源编码删除对应的资源
* @param code 资源编码
*/
void deleteByCode(String code);
/**
* 获取资源列表
* @param menuId 菜单ID
*/
List<OperResourceEntity> getMenuResourceList(String menuId);
/**
* 获取所有资源列表
*/
List<OperResourceEntity> getResourceList();
/**
* 获取用户资源列表
* @param userId 用户ID
*/
List<OperResourceEntity> getUserResourceList(@Param("userId") String userId);
}

24
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<OperRoleEntity> {
}

49
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<OperRoleMenuEntity> {
/**
* 根据角色ID获取菜单ID列表
*/
List<String> 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);
}

57
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<OperRoleUserEntity> {
/**
* 根据角色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<String> getRoleIdList(String userId);
}

49
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;
}

64
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;
}

53
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;
/**
* 请求方式GETPOSTPUTDELETE
*/
private String resourceMethod;
/**
* 菜单标识 0非菜单资源 1菜单资源
*/
private Integer menuFlag;
/**
* 认证等级 0权限认证 1登录认证 2无需认证
*/
private Integer authLevel;
}

44
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;
}

36
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;
}

37
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;
}

13
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<List<GovStaffRoleDTO>> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO);
/**
*
* 根据id查询运营人员详情
*
* @param operUserId oper_user表主键
* @return com.epmet.commons.tools.utils.Result<java.util.List <com.epmet.dto.OperUserDTO>>
* @author zhaoqifeng
* @date 2020/3/19 09:28
**/
@GetMapping("/operuser/queryOperUserDtoById/{operUserId}")
Result<OperUserDTO> info(@PathVariable("operUserId") String operUserId);
}

7
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<List<GovStaffRoleDTO>> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRolesOfStaff");
}
@Override
public Result<OperUserDTO> info(String operUserId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "info", operUserId);
}
@Override
public Result<CustomerGridByUserIdResultDTO> getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffLatestGrid",latestGridFormDTO);

47
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

74
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperMenuDTO> menuList){
String key = RedisKeys.getUserMenuNavKey(userId, app, client, HttpContextUtils.getLanguage());
redisUtils.set(key, menuList);
}
public List<OperMenuDTO> getUserMenuNavList(String userId, String app, String client){
String key = RedisKeys.getUserMenuNavKey(userId, app, client, HttpContextUtils.getLanguage());
return (List<OperMenuDTO>)redisUtils.get(key);
}
public void setUserPermissions(String userId, String app, String client, Set<String> permsSet){
String key = RedisKeys.getUserPermissionsKey(userId, app, client);
redisUtils.set(key, permsSet);
}
public Set<String> getUserPermissions(String userId, String app, String client){
String key = RedisKeys.getUserPermissionsKey(userId, app, client);
return (Set<String>)redisUtils.get(key);
}
}

50
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

47
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

47
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

47
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

105
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperLanguageEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<OperLanguageDTO>
* @author generator
* @date 2020-03-18
*/
PageData<OperLanguageDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<OperLanguageDTO>
* @author generator
* @date 2020-03-18
*/
List<OperLanguageDTO> list(Map<String, Object> 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);
}

144
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperMenuEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<OperMenuDTO>
* @author generator
* @date 2020-03-18
*/
PageData<OperMenuDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<OperMenuDTO>
* @author generator
* @date 2020-03-18
*/
List<OperMenuDTO> list(Map<String, Object> 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<OperMenuDTO>
*/
List<OperMenuDTO> getUserMenuList(TokenDto tokenDto, Integer type);
/**
* 菜单列表
*
* @param type 菜单类型
*/
List<OperMenuDTO> getMenuList(Integer type);
/**
* 用户菜单导航
* @param tokenDto 用户信息
* @return java.util.List<OperMenuDTO>
*/
List<OperMenuDTO> getUserMenuNavList(TokenDto tokenDto);
/**
* 获取用户权限标识
* @param tokenDto 用户信息
* @return java.util.Set<OperMenuDTO>
*/
Set<String> getUserPermissions(TokenDto tokenDto);
/**
* 根据父菜单查询子菜单
* @param pid 父菜单ID
*/
List<OperMenuDTO> getListPid(String pid);
void clearOperUserAccess(String app, String client, String userId);
}

110
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperResourceEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<OperResourceDTO>
* @author generator
* @date 2020-03-18
*/
PageData<OperResourceDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<OperResourceDTO>
* @author generator
* @date 2020-03-18
*/
List<OperResourceDTO> list(Map<String, Object> 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<MenuResourceDTO> resourceList);
/**
* 获取菜单资源列表
* @param menuId 菜单ID
*/
List<MenuResourceDTO> getMenuResourceList(String menuId);
}

125
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperRoleMenuEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<OperRoleMenuDTO>
* @author generator
* @date 2020-03-18
*/
PageData<OperRoleMenuDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<OperRoleMenuDTO>
* @author generator
* @date 2020-03-18
*/
List<OperRoleMenuDTO> list(Map<String, Object> 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<String> getMenuIdList(String roleId);
/**
* 保存或修改
* @param roleId 角色ID
* @param menuIdList 菜单ID列表
*/
void saveOrUpdate(String roleId, List<String> menuIdList);
/**
* 根据角色id删除角色菜单关系
* @param roleId 角色id
*/
void deleteByRoleId(String roleId);
/**
* 根据角色ids删除角色菜单关系
* @param roleIds
*/
void deleteByRoleIds(String[] roleIds);
/**
* 根据菜单id删除角色菜单关系
* @param menuId 菜单id
*/
void deleteByMenuId(String menuId);
}

95
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperRoleEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<OperRoleDTO>
* @author generator
* @date 2020-03-18
*/
PageData<OperRoleDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<OperRoleDTO>
* @author generator
* @date 2020-03-18
*/
List<OperRoleDTO> list(Map<String, Object> 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);
}

133
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperRoleUserEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<OperRoleUserDTO>
* @author generator
* @date 2020-03-18
*/
PageData<OperRoleUserDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<OperRoleUserDTO>
* @author generator
* @date 2020-03-18
*/
List<OperRoleUserDTO> list(Map<String, Object> 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<String> roleIdList);
/**
* 根据角色id删除角色用户关系
* @param roleId 角色id
*/
void deleteByRoleId(String roleId);
/**
* 根据用户id删除角色用户关系
* @param userId 用户id
*/
void deleteByUserId(String userId);
/**
* 角色ID列表
* @param userId 用户ID
* @return List<String>
*/
List<String> getRoleIdList(String userId);
/**
* 根据角色ids删除角色用户关系
* @param roleIds 角色ids
*/
void deleteByRoleIds(String[] roleIds);
/**
* 根据用户ids删除角色用户关系
* @param userIds 用户ids
*/
void deleteByUserIds(String[] userIds);
}

121
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperLanguageDao, OperLanguageEntity> implements OperLanguageService {
@Autowired
private OperLanguageRedis operLanguageRedis;
@Override
public PageData<OperLanguageDTO> page(Map<String, Object> params) {
IPage<OperLanguageEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, OperLanguageDTO.class);
}
@Override
public List<OperLanguageDTO> list(Map<String, Object> params) {
List<OperLanguageEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, OperLanguageDTO.class);
}
private QueryWrapper<OperLanguageEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<OperLanguageEntity> 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);
}
}
}

250
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperMenuDao, OperMenuEntity> 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<OperMenuDTO> page(Map<String, Object> params) {
IPage<OperMenuEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, OperMenuDTO.class);
}
@Override
public List<OperMenuDTO> list(Map<String, Object> params) {
List<OperMenuEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, OperMenuDTO.class);
}
private QueryWrapper<OperMenuEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<OperMenuEntity> 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<OperMenuDTO> getUserMenuList(TokenDto tokenDto, Integer type) {
List<OperMenuEntity> menuList;
// Result<OperUserDTO> 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<OperMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, OperMenuDTO.class);
return TreeUtils.buildTree(dtoList);
}
@Override
public List<OperMenuDTO> getMenuList(Integer type) {
List<OperMenuEntity> menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage());
List<OperMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, OperMenuDTO.class);
return TreeUtils.buildTree(dtoList, Constant.OPER_MENU_ROOT);
}
@Override
public List<OperMenuDTO> getUserMenuNavList(TokenDto tokenDto) {
List<OperMenuDTO> 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<String> getUserPermissions(TokenDto tokenDto) {
//用户权限列表
Set<String> permsSet = operMenuRedis.getUserPermissions(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient());
if(permsSet != null){
return permsSet;
}
// Result<OperUserDTO> operUserDTOResult = epmetUserFeignClient.info(tokenDto.getUserId());
//超级管理员,拥有最高权限
List<OperMenuEntity> 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<OperMenuDTO> getListPid(String pid) {
List<OperMenuEntity> 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());
}
}

143
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperResourceDao, OperResourceEntity> implements OperResourceService {
@Autowired
private OperResourceRedis operResourceRedis;
@Override
public PageData<OperResourceDTO> page(Map<String, Object> params) {
IPage<OperResourceEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, OperResourceDTO.class);
}
@Override
public List<OperResourceDTO> list(Map<String, Object> params) {
List<OperResourceEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, OperResourceDTO.class);
}
private QueryWrapper<OperResourceEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<OperResourceEntity> 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<MenuResourceDTO> 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<MenuResourceDTO> getMenuResourceList(String menuId) {
List<OperResourceEntity> entityList = baseDao.getMenuResourceList(menuId+"");
return ConvertUtils.sourceToTarget(entityList, MenuResourceDTO.class);
}
}

150
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperRoleMenuDao, OperRoleMenuEntity> implements OperRoleMenuService {
@Autowired
private OperRoleMenuRedis operRoleMenuRedis;
@Autowired
private OperRoleMenuDao operRoleMenuDao;
@Override
public PageData<OperRoleMenuDTO> page(Map<String, Object> params) {
IPage<OperRoleMenuEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, OperRoleMenuDTO.class);
}
@Override
public List<OperRoleMenuDTO> list(Map<String, Object> params) {
List<OperRoleMenuEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, OperRoleMenuDTO.class);
}
private QueryWrapper<OperRoleMenuEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<OperRoleMenuEntity> 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<String> getMenuIdList(String roleId){
return baseDao.getMenuIdList(roleId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdate(String roleId, List<String> 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);
}
}

118
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperRoleDao, OperRoleEntity> implements OperRoleService {
@Autowired
private OperRoleRedis operRoleRedis;
@Autowired
private OperRoleMenuService OperRoleMenuService;
@Autowired
private OperRoleUserService operRoleUserService;
@Override
public PageData<OperRoleDTO> page(Map<String, Object> params) {
IPage<OperRoleEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, OperRoleDTO.class);
}
@Override
public List<OperRoleDTO> list(Map<String, Object> params) {
List<OperRoleEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, OperRoleDTO.class);
}
private QueryWrapper<OperRoleEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
String name = (String)params.get(FieldConstant.NAME_HUMP);
QueryWrapper<OperRoleEntity> 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);
}
}

156
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<OperRoleUserDao, OperRoleUserEntity> implements OperRoleUserService {
@Autowired
private OperRoleUserRedis operRoleUserRedis;
@Autowired
private OperRoleUserDao operRoleUserDao;
@Override
public PageData<OperRoleUserDTO> page(Map<String, Object> params) {
IPage<OperRoleUserEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, OperRoleUserDTO.class);
}
@Override
public List<OperRoleUserDTO> list(Map<String, Object> params) {
List<OperRoleUserEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, OperRoleUserDTO.class);
}
private QueryWrapper<OperRoleUserEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<OperRoleUserEntity> 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<String> 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<String> 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);
}
}

21
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperLanguageDao.xml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.OperLanguageDao">
<select id="getLanguage" resultType="com.epmet.entity.OperLanguageEntity">
select * from oper_language
where table_name=#{tableName} and table_id=#{tableId} and field_name=#{fieldName} and language=#{language}
</select>
<select id="updateLanguage">
update oper_language set field_value=#{fieldValue}
where table_name=#{tableName} and table_id=#{tableId} and field_name=#{fieldName} and language=#{language}
</select>
<insert id="insertOperLanguageEntity" parameterType="com.epmet.entity.OperLanguageEntity">
INSERT INTO `oper_language` ( `table_name`, `table_id`, `field_name`, `field_value`, `language` )
VALUES
( #{tableName}, #{tableId}, #{fieldName}, #{fieldValue}, #{language} )
</insert>
</mapper>

42
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperMenuDao.xml

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.OperMenuDao">
<select id="getById" resultType="com.epmet.entity.OperMenuEntity">
select t1.*,
(select lang.field_value from oper_language lang where lang.table_name='oper_menu' and lang.field_name='name'
and lang.table_id=t1.pid and lang.language=#{language}) as parentName,
(select lang.field_value from oper_language lang where lang.table_name='oper_menu' and lang.field_name='name'
and lang.table_id=t1.id and lang.language=#{language}) as name
from oper_menu t1
where t1.id = #{id} and t1.del_flag = 0
</select>
<select id="getMenuList" resultType="com.epmet.entity.OperMenuEntity">
select t1.*, (select lang.field_value from oper_language lang where lang.table_name='oper_menu' and lang.field_name='name'
and lang.table_id=t1.id and lang.language=#{language}) as name
from oper_menu t1 where t1.del_flag = 0
<if test="type != null">
and t1.type = #{type}
</if>
order by t1.sort asc
</select>
<select id="getUserMenuList" resultType="com.epmet.entity.OperMenuEntity">
select t3.*, (select lang.field_value from oper_language lang where lang.table_name='oper_menu' and lang.field_name='name'
and lang.table_id=t3.id and lang.language=#{language}) as name from oper_role_user t1
left join oper_role_menu t2 on t1.role_id = t2.role_id
left join oper_menu t3 on t2.menu_id = t3.id
where t1.user_id = #{userId} and t3.del_flag = 0
<if test="type != null">
and t3.type = #{type}
</if>
order by t3.sort asc
</select>
<select id="getListPid" resultType="com.epmet.entity.OperMenuEntity">
select * from oper_menu where del_flag = 0 and pid = #{value}
</select>
</mapper>

25
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperResourceDao.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.OperResourceDao">
<delete id="deleteByCode">
delete from oper_resource where resource_code = #{value}
</delete>
<select id="getMenuResourceList" resultType="com.epmet.entity.OperResourceEntity">
select resource_url, resource_method from oper_resource where resource_code = #{value} order by created_time asc
</select>
<select id="getResourceList" resultType="com.epmet.entity.OperResourceEntity">
select resource_url, resource_method, auth_level from oper_resource order by auth_level desc
</select>
<select id="getUserResourceList" resultType="com.epmet.entity.OperResourceEntity">
select t3.resource_url, t3.resource_method from oper_role_user t1
left join oper_role_menu t2 on t1.role_id = t2.role_id
inner join oper_resource t3 on t2.menu_id = t3.resource_code
where t1.user_id = #{userId}
</select>
</mapper>

6
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleDao.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.OperRoleDao">
</mapper>

25
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleMenuDao.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.OperRoleMenuDao">
<select id="getMenuIdList" resultType="java.lang.String">
select menu_id from oper_role_menu where role_id = #{value}
</select>
<update id="deleteByRoleIds">
update oper_role_menu set del_flag = 1 where del_flag = 0 and role_id in
<foreach item="roleId" collection="array" open="(" separator="," close=")">
#{roleId}
</foreach>
</update>
<update id="deleteByRoleId">
update oper_role_menu set del_flag = 1 where role_id = #{value} and del_flag = 0
</update>
<update id="deleteByMenuId">
update oper_role_menu set del_flag = 1 where menu_id = #{value} and del_flag = 0
</update>
</mapper>

32
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperRoleUserDao.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.OperRoleUserDao">
<update id="deleteByRoleIds">
update oper_role_user set del_flag = 1 where del_flag = 0 and role_id in
<foreach item="roleId" collection="array" open="(" separator="," close=")">
#{roleId}
</foreach>
</update>
<update id="deleteByUserIds">
update oper_role_user set del_flag = 1 where del_flag = 0 and user_id in
<foreach item="userId" collection="array" open="(" separator="," close=")">
#{userId}
</foreach>
</update>
<update id="deleteByRoleId">
update oper_role_user set del_flag = 1 where role_id = #{value} and del_flag = 0
</update>
<update id="deleteByUserId">
update oper_role_user set del_flag = 1 where user_id = #{value} and del_flag = 0
</update>
<select id="getRoleIdList" resultType="java.lang.String">
select role_id from oper_role_user where user_id = #{value} and del_flag = 0
</select>
</mapper>
Loading…
Cancel
Save