mirror of https://gitee.com/maxjhandsome/pig
重命名VO DTO
This commit is contained in:
parent
6201c9b278
commit
fbbca0ee4c
|
@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||||
* @date 2017/11/20
|
* @date 2017/11/20
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class LogVo implements Serializable {
|
public class LogVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private SysLog sysLog;
|
private SysLog sysLog;
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
||||||
* @since 2017-11-08
|
* @since 2017-11-08
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class MenuVo implements Serializable {
|
public class MenuVO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.github.pig.gateway.feign;
|
package com.github.pig.gateway.feign;
|
||||||
|
|
||||||
import com.github.pig.common.vo.MenuVo;
|
import com.github.pig.common.vo.MenuVO;
|
||||||
import com.github.pig.gateway.feign.fallback.MenuServiceFallbackImpl;
|
import com.github.pig.gateway.feign.fallback.MenuServiceFallbackImpl;
|
||||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -21,5 +21,5 @@ public interface MenuService {
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/menu/findMenuByRole/{role}")
|
@GetMapping(value = "/menu/findMenuByRole/{role}")
|
||||||
Set<MenuVo> findMenuByRole(@PathVariable("role") String role);
|
Set<MenuVO> findMenuByRole(@PathVariable("role") String role);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.github.pig.gateway.feign.fallback;
|
package com.github.pig.gateway.feign.fallback;
|
||||||
|
|
||||||
import com.github.pig.common.vo.MenuVo;
|
import com.github.pig.common.vo.MenuVO;
|
||||||
import com.github.pig.gateway.feign.MenuService;
|
import com.github.pig.gateway.feign.MenuService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -18,7 +18,7 @@ import java.util.Set;
|
||||||
public class MenuServiceFallbackImpl implements MenuService {
|
public class MenuServiceFallbackImpl implements MenuService {
|
||||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
@Override
|
@Override
|
||||||
public Set<MenuVo> findMenuByRole(String role) {
|
public Set<MenuVO> findMenuByRole(String role) {
|
||||||
logger.error("调用{}异常{}","findMenuByRole",role);
|
logger.error("调用{}异常{}","findMenuByRole",role);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.github.pig.common.constant.CommonConstant;
|
||||||
import com.github.pig.common.constant.MqQueueConstant;
|
import com.github.pig.common.constant.MqQueueConstant;
|
||||||
import com.github.pig.common.entity.SysLog;
|
import com.github.pig.common.entity.SysLog;
|
||||||
import com.github.pig.common.util.UserUtils;
|
import com.github.pig.common.util.UserUtils;
|
||||||
import com.github.pig.common.vo.LogVo;
|
import com.github.pig.common.vo.LogVO;
|
||||||
import com.github.pig.gateway.service.LogSendService;
|
import com.github.pig.gateway.service.LogSendService;
|
||||||
import com.netflix.zuul.context.RequestContext;
|
import com.netflix.zuul.context.RequestContext;
|
||||||
import com.xiaoleilu.hutool.http.HttpUtil;
|
import com.xiaoleilu.hutool.http.HttpUtil;
|
||||||
|
@ -98,7 +98,7 @@ public class LogSendServiceImpl implements LogSendService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//保存发往MQ(只保存授权)
|
//保存发往MQ(只保存授权)
|
||||||
LogVo logVo = new LogVo();
|
LogVO logVo = new LogVO();
|
||||||
logVo.setSysLog(log);
|
logVo.setSysLog(log);
|
||||||
if (StringUtils.isNotEmpty(request.getHeader(CommonConstant.REQ_HEADER))) {
|
if (StringUtils.isNotEmpty(request.getHeader(CommonConstant.REQ_HEADER))) {
|
||||||
logVo.setToken(request.getHeader(CommonConstant.REQ_HEADER));
|
logVo.setToken(request.getHeader(CommonConstant.REQ_HEADER));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.github.pig.gateway.service.impl;
|
package com.github.pig.gateway.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.toolkit.StringUtils;
|
||||||
import com.github.pig.common.vo.MenuVo;
|
import com.github.pig.common.vo.MenuVO;
|
||||||
import com.github.pig.gateway.feign.MenuService;
|
import com.github.pig.gateway.feign.MenuService;
|
||||||
import com.github.pig.gateway.service.PermissionService;
|
import com.github.pig.gateway.service.PermissionService;
|
||||||
import com.xiaoleilu.hutool.collection.CollectionUtil;
|
import com.xiaoleilu.hutool.collection.CollectionUtil;
|
||||||
|
@ -42,12 +42,12 @@ public class PermissionServiceImpl implements PermissionService {
|
||||||
return hasPermission;
|
return hasPermission;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<MenuVo> urls = new HashSet<>();
|
Set<MenuVO> urls = new HashSet<>();
|
||||||
for (SimpleGrantedAuthority authority : grantedAuthorityList) {
|
for (SimpleGrantedAuthority authority : grantedAuthorityList) {
|
||||||
urls.addAll(menuService.findMenuByRole(authority.getAuthority()));
|
urls.addAll(menuService.findMenuByRole(authority.getAuthority()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MenuVo menu : urls) {
|
for (MenuVO menu : urls) {
|
||||||
if (StringUtils.isNotEmpty(menu.getUrl()) && antPathMatcher.match(menu.getUrl(), request.getRequestURI())
|
if (StringUtils.isNotEmpty(menu.getUrl()) && antPathMatcher.match(menu.getUrl(), request.getRequestURI())
|
||||||
&& request.getMethod().equalsIgnoreCase(menu.getMethod())) {
|
&& request.getMethod().equalsIgnoreCase(menu.getMethod())) {
|
||||||
hasPermission = true;
|
hasPermission = true;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.github.pig.admin.service.SysLogService;
|
||||||
import com.github.pig.common.constant.MqQueueConstant;
|
import com.github.pig.common.constant.MqQueueConstant;
|
||||||
import com.github.pig.common.entity.SysLog;
|
import com.github.pig.common.entity.SysLog;
|
||||||
import com.github.pig.common.util.UserUtils;
|
import com.github.pig.common.util.UserUtils;
|
||||||
import com.github.pig.common.vo.LogVo;
|
import com.github.pig.common.vo.LogVO;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
@ -24,7 +24,7 @@ public class LogReceiveListener {
|
||||||
private SysLogService sysLogService;
|
private SysLogService sysLogService;
|
||||||
|
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void receive(LogVo logVo) {
|
public void receive(LogVO logVo) {
|
||||||
SysLog sysLog = logVo.getSysLog();
|
SysLog sysLog = logVo.getSysLog();
|
||||||
String username = UserUtils.getUserName(logVo.getToken());
|
String username = UserUtils.getUserName(logVo.getToken());
|
||||||
MDC.put(KEY_USER, username);
|
MDC.put(KEY_USER, username);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import com.github.pig.admin.model.entity.SysMenu;
|
||||||
import com.github.pig.admin.service.SysMenuService;
|
import com.github.pig.admin.service.SysMenuService;
|
||||||
import com.github.pig.common.constant.CommonConstant;
|
import com.github.pig.common.constant.CommonConstant;
|
||||||
import com.github.pig.common.util.R;
|
import com.github.pig.common.util.R;
|
||||||
import com.github.pig.common.vo.MenuVo;
|
import com.github.pig.common.vo.MenuVO;
|
||||||
import com.github.pig.common.web.BaseController;
|
import com.github.pig.common.web.BaseController;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -33,7 +33,7 @@ public class MenuController extends BaseController {
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/findMenuByRole/{role}")
|
@GetMapping("/findMenuByRole/{role}")
|
||||||
public Set<MenuVo> findMenuByRole(@PathVariable String role) {
|
public Set<MenuVO> findMenuByRole(@PathVariable String role) {
|
||||||
return sysMenuService.findMenuByRole(role);
|
return sysMenuService.findMenuByRole(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +65,9 @@ public class MenuController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/userTree")
|
@GetMapping("/userTree")
|
||||||
public List<Integer> userTree() {
|
public List<Integer> userTree() {
|
||||||
Set<MenuVo> menus = sysMenuService.findMenuByRole(getRole().get(0));
|
Set<MenuVO> menus = sysMenuService.findMenuByRole(getRole().get(0));
|
||||||
List<Integer> menuList = new ArrayList<>();
|
List<Integer> menuList = new ArrayList<>();
|
||||||
for (MenuVo menuVo : menus) {
|
for (MenuVO menuVo : menus) {
|
||||||
menuList.add(menuVo.getMenuId());
|
menuList.add(menuVo.getMenuId());
|
||||||
}
|
}
|
||||||
return menuList;
|
return menuList;
|
||||||
|
@ -81,9 +81,9 @@ public class MenuController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/roleTree/{roleName}")
|
@GetMapping("/roleTree/{roleName}")
|
||||||
public List<Integer> roleTree(@PathVariable String roleName) {
|
public List<Integer> roleTree(@PathVariable String roleName) {
|
||||||
Set<MenuVo> menus = sysMenuService.findMenuByRole(roleName);
|
Set<MenuVO> menus = sysMenuService.findMenuByRole(roleName);
|
||||||
List<Integer> menuList = new ArrayList<>();
|
List<Integer> menuList = new ArrayList<>();
|
||||||
for (MenuVo menuVo : menus) {
|
for (MenuVO menuVo : menus) {
|
||||||
menuList.add(menuVo.getMenuId());
|
menuList.add(menuVo.getMenuId());
|
||||||
}
|
}
|
||||||
return menuList;
|
return menuList;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.github.pig.admin.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||||
import com.baomidou.mybatisplus.plugins.Page;
|
import com.baomidou.mybatisplus.plugins.Page;
|
||||||
import com.github.pig.admin.model.dto.RoleDto;
|
import com.github.pig.admin.model.dto.RoleDTO;
|
||||||
import com.github.pig.admin.model.entity.SysRole;
|
import com.github.pig.admin.model.entity.SysRole;
|
||||||
import com.github.pig.admin.service.SysRoleMenuService;
|
import com.github.pig.admin.service.SysRoleMenuService;
|
||||||
import com.github.pig.admin.service.SysRoleService;
|
import com.github.pig.admin.service.SysRoleService;
|
||||||
|
@ -46,7 +46,7 @@ public class RoleController extends BaseController {
|
||||||
* @return success、false
|
* @return success、false
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Boolean> role(@RequestBody RoleDto roleDto) {
|
public R<Boolean> role(@RequestBody RoleDTO roleDto) {
|
||||||
return new R<>(sysRoleService.insertRole(roleDto));
|
return new R<>(sysRoleService.insertRole(roleDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class RoleController extends BaseController {
|
||||||
* @return success/false
|
* @return success/false
|
||||||
*/
|
*/
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Boolean> roleUpdate(@RequestBody RoleDto roleDto) {
|
public R<Boolean> roleUpdate(@RequestBody RoleDTO roleDto) {
|
||||||
return new R<>(sysRoleService.updateRoleById(roleDto));
|
return new R<>(sysRoleService.updateRoleById(roleDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.github.pig.admin.controller;
|
package com.github.pig.admin.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.plugins.Page;
|
import com.baomidou.mybatisplus.plugins.Page;
|
||||||
import com.github.pig.admin.model.dto.UserDto;
|
import com.github.pig.admin.model.dto.UserDTO;
|
||||||
import com.github.pig.admin.model.dto.UserInfo;
|
import com.github.pig.admin.model.dto.UserInfo;
|
||||||
import com.github.pig.admin.model.entity.SysUser;
|
import com.github.pig.admin.model.entity.SysUser;
|
||||||
import com.github.pig.admin.model.entity.SysUserRole;
|
import com.github.pig.admin.model.entity.SysUserRole;
|
||||||
|
@ -89,7 +89,7 @@ public class UserController extends BaseController {
|
||||||
* @return success/false
|
* @return success/false
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public R<Boolean> user(@RequestBody UserDto userDto) {
|
public R<Boolean> user(@RequestBody UserDTO userDto) {
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
BeanUtils.copyProperties(userDto, sysUser);
|
BeanUtils.copyProperties(userDto, sysUser);
|
||||||
sysUser.setDelFlag(CommonConstant.STATUS_NORMAL);
|
sysUser.setDelFlag(CommonConstant.STATUS_NORMAL);
|
||||||
|
@ -108,7 +108,7 @@ public class UserController extends BaseController {
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Boolean> userUpdate(@RequestBody UserDto userDto) {
|
public R<Boolean> userUpdate(@RequestBody UserDTO userDto) {
|
||||||
SysUser user = userService.selectById(userDto.getUserId());
|
SysUser user = userService.selectById(userDto.getUserId());
|
||||||
return new R<>(userService.updateUser(userDto, user.getUsername()));
|
return new R<>(userService.updateUser(userDto, user.getUsername()));
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ public class UserController extends BaseController {
|
||||||
* @return success/false
|
* @return success/false
|
||||||
*/
|
*/
|
||||||
@PutMapping("/editInfo")
|
@PutMapping("/editInfo")
|
||||||
public R<Boolean> editInfo(@RequestBody UserDto userDto, UserVo userVo) {
|
public R<Boolean> editInfo(@RequestBody UserDTO userDto, UserVo userVo) {
|
||||||
return new R<>(userService.updateUserInfo(userDto, userVo.getUsername()));
|
return new R<>(userService.updateUserInfo(userDto, userVo.getUsername()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.github.pig.admin.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||||
import com.github.pig.admin.model.entity.SysMenu;
|
import com.github.pig.admin.model.entity.SysMenu;
|
||||||
import com.github.pig.common.vo.MenuVo;
|
import com.github.pig.common.vo.MenuVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -23,5 +23,5 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||||
* @param role 角色名称
|
* @param role 角色名称
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
Set<MenuVo> findMenuByRoleName(@Param("role") String role);
|
Set<MenuVO> findMenuByRoleName(@Param("role") String role);
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package com.github.pig.admin.model.dto;
|
package com.github.pig.admin.model.dto;
|
||||||
|
|
||||||
import com.github.pig.common.vo.MenuVo;
|
import com.github.pig.common.vo.MenuVO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +38,7 @@ public class MenuTree extends TreeNode {
|
||||||
this.label = name;
|
this.label = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MenuTree(MenuVo menuVo) {
|
public MenuTree(MenuVO menuVo) {
|
||||||
this.id = menuVo.getMenuId();
|
this.id = menuVo.getMenuId();
|
||||||
this.parentId = menuVo.getParentId();
|
this.parentId = menuVo.getParentId();
|
||||||
this.icon = menuVo.getIcon();
|
this.icon = menuVo.getIcon();
|
||||||
|
|
|
@ -9,7 +9,7 @@ import lombok.Data;
|
||||||
* 角色Dto
|
* 角色Dto
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RoleDto extends SysRole {
|
public class RoleDTO extends SysRole {
|
||||||
/**
|
/**
|
||||||
* 角色部门Id
|
* 角色部门Id
|
||||||
*/
|
*/
|
|
@ -8,7 +8,7 @@ import lombok.Data;
|
||||||
* @date 2017/11/5
|
* @date 2017/11/5
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class UserDto extends SysUser {
|
public class UserDTO extends SysUser {
|
||||||
/**
|
/**
|
||||||
* 角色ID
|
* 角色ID
|
||||||
*/
|
*/
|
|
@ -4,7 +4,7 @@ package com.github.pig.admin.service;
|
||||||
import com.baomidou.mybatisplus.service.IService;
|
import com.baomidou.mybatisplus.service.IService;
|
||||||
import com.github.pig.admin.model.dto.MenuTree;
|
import com.github.pig.admin.model.dto.MenuTree;
|
||||||
import com.github.pig.admin.model.entity.SysMenu;
|
import com.github.pig.admin.model.entity.SysMenu;
|
||||||
import com.github.pig.common.vo.MenuVo;
|
import com.github.pig.common.vo.MenuVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -24,7 +24,7 @@ public interface SysMenuService extends IService<SysMenu> {
|
||||||
* @param role 角色名称
|
* @param role 角色名称
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
Set<MenuVo> findMenuByRole(String role);
|
Set<MenuVO> findMenuByRole(String role);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过角色获取菜单权限列表
|
* 通过角色获取菜单权限列表
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.github.pig.admin.service;
|
||||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||||
import com.baomidou.mybatisplus.plugins.Page;
|
import com.baomidou.mybatisplus.plugins.Page;
|
||||||
import com.baomidou.mybatisplus.service.IService;
|
import com.baomidou.mybatisplus.service.IService;
|
||||||
import com.github.pig.admin.model.dto.RoleDto;
|
import com.github.pig.admin.model.dto.RoleDTO;
|
||||||
import com.github.pig.admin.model.entity.SysRole;
|
import com.github.pig.admin.model.entity.SysRole;
|
||||||
import com.github.pig.common.util.Query;
|
import com.github.pig.common.util.Query;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public interface SysRoleService extends IService<SysRole> {
|
||||||
* @param roleDto 角色信息
|
* @param roleDto 角色信息
|
||||||
* @return 成功、失败
|
* @return 成功、失败
|
||||||
*/
|
*/
|
||||||
Boolean insertRole(RoleDto roleDto);
|
Boolean insertRole(RoleDTO roleDto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查角色列表
|
* 分页查角色列表
|
||||||
|
@ -41,7 +41,7 @@ public interface SysRoleService extends IService<SysRole> {
|
||||||
* @param roleDto 含有部门信息
|
* @param roleDto 含有部门信息
|
||||||
* @return 成功、失败
|
* @return 成功、失败
|
||||||
*/
|
*/
|
||||||
Boolean updateRoleById(RoleDto roleDto);
|
Boolean updateRoleById(RoleDTO roleDto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过部门ID查询角色列表
|
* 通过部门ID查询角色列表
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.github.pig.admin.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.plugins.Page;
|
import com.baomidou.mybatisplus.plugins.Page;
|
||||||
import com.baomidou.mybatisplus.service.IService;
|
import com.baomidou.mybatisplus.service.IService;
|
||||||
import com.github.pig.admin.model.dto.UserDto;
|
import com.github.pig.admin.model.dto.UserDTO;
|
||||||
import com.github.pig.admin.model.dto.UserInfo;
|
import com.github.pig.admin.model.dto.UserInfo;
|
||||||
import com.github.pig.admin.model.entity.SysUser;
|
import com.github.pig.admin.model.entity.SysUser;
|
||||||
import com.github.pig.common.util.Query;
|
import com.github.pig.common.util.Query;
|
||||||
|
@ -57,7 +57,7 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
Boolean updateUserInfo(UserDto userDto, String username);
|
Boolean updateUserInfo(UserDTO userDto, String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新指定用户信息
|
* 更新指定用户信息
|
||||||
|
@ -65,7 +65,7 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
* @param username 用户信息
|
* @param username 用户信息
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean updateUser(UserDto userDto, String username);
|
Boolean updateUser(UserDTO userDto, String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过手机号查询用户信息
|
* 通过手机号查询用户信息
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.github.pig.admin.model.entity.SysMenu;
|
||||||
import com.github.pig.admin.service.SysMenuService;
|
import com.github.pig.admin.service.SysMenuService;
|
||||||
import com.github.pig.common.constant.CommonConstant;
|
import com.github.pig.common.constant.CommonConstant;
|
||||||
import com.github.pig.common.util.Assert;
|
import com.github.pig.common.util.Assert;
|
||||||
import com.github.pig.common.vo.MenuVo;
|
import com.github.pig.common.vo.MenuVO;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
@ -36,20 +36,20 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "menu_details", key = "#role + '_menu'")
|
@Cacheable(value = "menu_details", key = "#role + '_menu'")
|
||||||
public Set<MenuVo> findMenuByRole(String role) {
|
public Set<MenuVO> findMenuByRole(String role) {
|
||||||
return sysMenuMapper.findMenuByRoleName(role);
|
return sysMenuMapper.findMenuByRoleName(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] findPermission(String[] roles) {
|
public String[] findPermission(String[] roles) {
|
||||||
Set<MenuVo> menuVoSet = new HashSet<>();
|
Set<MenuVO> menuVoSet = new HashSet<>();
|
||||||
for (String role : roles) {
|
for (String role : roles) {
|
||||||
Set<MenuVo> menuVos = findMenuByRole(role);
|
Set<MenuVO> menuVos = findMenuByRole(role);
|
||||||
menuVoSet.addAll(menuVos);
|
menuVoSet.addAll(menuVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> permissions = new HashSet<>();
|
Set<String> permissions = new HashSet<>();
|
||||||
for (MenuVo menuVo : menuVoSet) {
|
for (MenuVO menuVo : menuVoSet) {
|
||||||
if (StringUtils.isNotEmpty(menuVo.getPermission())) {
|
if (StringUtils.isNotEmpty(menuVo.getPermission())) {
|
||||||
String permission = menuVo.getPermission();
|
String permission = menuVo.getPermission();
|
||||||
permissions.add(permission);
|
permissions.add(permission);
|
||||||
|
@ -92,7 +92,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
@Override
|
@Override
|
||||||
public List<MenuTree> findUserMenuTree(String roleName) {
|
public List<MenuTree> findUserMenuTree(String roleName) {
|
||||||
// 获取符合条件得菜单
|
// 获取符合条件得菜单
|
||||||
Set<MenuVo> all = findMenuByRole(roleName);
|
Set<MenuVO> all = findMenuByRole(roleName);
|
||||||
final List<MenuTree> menuTreeList = new ArrayList<>();
|
final List<MenuTree> menuTreeList = new ArrayList<>();
|
||||||
all.stream().forEach((menuVo -> {
|
all.stream().forEach((menuVo -> {
|
||||||
if (CommonConstant.MENU.equals(menuVo.getType())) {
|
if (CommonConstant.MENU.equals(menuVo.getType())) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.plugins.Page;
|
||||||
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
||||||
import com.github.pig.admin.mapper.SysRoleDeptMapper;
|
import com.github.pig.admin.mapper.SysRoleDeptMapper;
|
||||||
import com.github.pig.admin.mapper.SysRoleMapper;
|
import com.github.pig.admin.mapper.SysRoleMapper;
|
||||||
import com.github.pig.admin.model.dto.RoleDto;
|
import com.github.pig.admin.model.dto.RoleDTO;
|
||||||
import com.github.pig.admin.model.entity.SysRole;
|
import com.github.pig.admin.model.entity.SysRole;
|
||||||
import com.github.pig.admin.model.entity.SysRoleDept;
|
import com.github.pig.admin.model.entity.SysRoleDept;
|
||||||
import com.github.pig.admin.service.SysRoleService;
|
import com.github.pig.admin.service.SysRoleService;
|
||||||
|
@ -39,7 +39,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
* @return 成功、失败
|
* @return 成功、失败
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertRole(RoleDto roleDto) {
|
public Boolean insertRole(RoleDTO roleDto) {
|
||||||
SysRole sysRole = new SysRole();
|
SysRole sysRole = new SysRole();
|
||||||
BeanUtils.copyProperties(roleDto, sysRole);
|
BeanUtils.copyProperties(roleDto, sysRole);
|
||||||
sysRoleMapper.insert(sysRole);
|
sysRoleMapper.insert(sysRole);
|
||||||
|
@ -71,7 +71,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateRoleById(RoleDto roleDto) {
|
public Boolean updateRoleById(RoleDTO roleDto) {
|
||||||
//删除原有的角色部门关系
|
//删除原有的角色部门关系
|
||||||
SysRoleDept condition = new SysRoleDept();
|
SysRoleDept condition = new SysRoleDept();
|
||||||
condition.setRoleId(roleDto.getRoleId());
|
condition.setRoleId(roleDto.getRoleId());
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||||
import com.baomidou.mybatisplus.plugins.Page;
|
import com.baomidou.mybatisplus.plugins.Page;
|
||||||
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
||||||
import com.github.pig.admin.mapper.SysUserMapper;
|
import com.github.pig.admin.mapper.SysUserMapper;
|
||||||
import com.github.pig.admin.model.dto.UserDto;
|
import com.github.pig.admin.model.dto.UserDTO;
|
||||||
import com.github.pig.admin.model.dto.UserInfo;
|
import com.github.pig.admin.model.dto.UserInfo;
|
||||||
import com.github.pig.admin.model.entity.SysDeptRelation;
|
import com.github.pig.admin.model.entity.SysDeptRelation;
|
||||||
import com.github.pig.admin.model.entity.SysUser;
|
import com.github.pig.admin.model.entity.SysUser;
|
||||||
|
@ -203,7 +203,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "user_details", key = "#username")
|
@CacheEvict(value = "user_details", key = "#username")
|
||||||
public Boolean updateUserInfo(UserDto userDto, String username) {
|
public Boolean updateUserInfo(UserDTO userDto, String username) {
|
||||||
UserVo userVo = this.findUserByUsername(username);
|
UserVo userVo = this.findUserByUsername(username);
|
||||||
|
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
|
@ -217,7 +217,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "user_details", key = "#username")
|
@CacheEvict(value = "user_details", key = "#username")
|
||||||
public Boolean updateUser(UserDto userDto, String username) {
|
public Boolean updateUser(UserDTO userDto, String username) {
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
BeanUtils.copyProperties(userDto, sysUser);
|
BeanUtils.copyProperties(userDto, sysUser);
|
||||||
sysUser.setUpdateTime(new Date());
|
sysUser.setUpdateTime(new Date());
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<result column="del_flag" property="delFlag" />
|
<result column="del_flag" property="delFlag" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="MenuVoResultMap" type="com.github.pig.common.vo.MenuVo">
|
<resultMap id="MenuVoResultMap" type="com.github.pig.common.vo.MenuVO">
|
||||||
<id column="menu_id" property="menuId" />
|
<id column="menu_id" property="menuId" />
|
||||||
<result column="name" property="name" />
|
<result column="name" property="name" />
|
||||||
<result column="permission" property="permission" />
|
<result column="permission" property="permission" />
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!--roleDto-->
|
<!--roleDto-->
|
||||||
<resultMap id="RoleDtoMap" type="com.github.pig.admin.model.dto.RoleDto">
|
<resultMap id="RoleDtoMap" type="com.github.pig.admin.model.dto.RoleDTO">
|
||||||
<id column="role_id" property="roleId" />
|
<id column="role_id" property="roleId" />
|
||||||
<result column="role_name" property="roleName" />
|
<result column="role_name" property="roleName" />
|
||||||
<result column="role_code" property="roleCode" />
|
<result column="role_code" property="roleCode" />
|
||||||
|
|
Loading…
Reference in New Issue