接口调试
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -27,10 +27,6 @@
|
|||||||
<spring.boot.version>2.7.18</spring.boot.version>
|
<spring.boot.version>2.7.18</spring.boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 系统二方包 -->
|
<!-- 系统二方包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.xiang.xs.api.client;
|
|
||||||
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
|
|
||||||
@FeignClient(name = "xservice-auth-center", fallback = TokenApiFallback.class)
|
|
||||||
public interface TokenApi {
|
|
||||||
|
|
||||||
@GetMapping("/private/user/getUserId/{token}")
|
|
||||||
Long getUserId(@PathVariable("token") String token);
|
|
||||||
|
|
||||||
@GetMapping("/private/user/getTenantId/{token}")
|
|
||||||
Long getTenantId(@PathVariable("token") String token);
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.xiang.xs.api.client;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class TokenApiFallback implements TokenApi {
|
|
||||||
@Override
|
|
||||||
public Long getUserId(String token) {
|
|
||||||
log.warn("[rpc] 请求auth center 获取userId 异常, time:{}", System.currentTimeMillis());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getTenantId(String token) {
|
|
||||||
log.warn("[rpc] 请求auth center tenantId 异常, time:{}", System.currentTimeMillis());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.xiang.xs.api.pojo.request;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PermissionRegisterRequest {
|
||||||
|
|
||||||
|
private String serviceName;
|
||||||
|
/**
|
||||||
|
* 类名+方法名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 服务名称+方法+接口地址
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
/**
|
||||||
|
* 接口地址
|
||||||
|
*/
|
||||||
|
private String apiPath;
|
||||||
|
/**
|
||||||
|
* 请求方式
|
||||||
|
*/
|
||||||
|
private String method;
|
||||||
|
/**
|
||||||
|
* 类型 接口为3
|
||||||
|
*/
|
||||||
|
private Integer type = 3; // 接口
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackages = "com.xiang.xs")
|
@SpringBootApplication(scanBasePackages = "com.xiang.xs")
|
||||||
@EnableFeignClients
|
@EnableFeignClients(basePackages = "com.xiang.xs.api")
|
||||||
@MapperScan("com.xiang.xs.service.repository.mapper")
|
@MapperScan("com.xiang.xs.service.repository.mapper")
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ public class SysDeptController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
public Result<SysDept> getInfo(@PathVariable Long deptId, HttpServletRequest request) {
|
public Result<SysDept> getInfo(@PathVariable Long deptId, HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String userId = request.getHeader("X-User-Id");
|
||||||
deptService.checkDeptDataScope(deptId, token);
|
deptService.checkDeptDataScope(deptId, Long.parseLong(userId));
|
||||||
return Result.data(deptService.selectDeptById(deptId));
|
return Result.data(deptService.selectDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,8 @@ public class SysDeptController {
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
public Result<Boolean> edit(@Validated @RequestBody SysDept dept, HttpServletRequest request) {
|
public Result<Boolean> edit(@Validated @RequestBody SysDept dept, HttpServletRequest request) {
|
||||||
Long deptId = dept.getDeptId();
|
Long deptId = dept.getDeptId();
|
||||||
deptService.checkDeptDataScope(deptId, getToken(request));
|
String userId = request.getHeader("X-User-Id");
|
||||||
|
deptService.checkDeptDataScope(deptId, Long.parseLong(userId));
|
||||||
if (!deptService.checkDeptNameUnique(dept)) {
|
if (!deptService.checkDeptNameUnique(dept)) {
|
||||||
return Result.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return Result.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
} else if (dept.getParentId().equals(deptId)) {
|
} else if (dept.getParentId().equals(deptId)) {
|
||||||
@@ -100,7 +101,8 @@ public class SysDeptController {
|
|||||||
if (deptService.checkDeptExistUser(deptId)) {
|
if (deptService.checkDeptExistUser(deptId)) {
|
||||||
return Result.error("部门存在用户,不允许删除");
|
return Result.error("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
deptService.checkDeptDataScope(deptId, token);
|
String userId = request.getHeader("X-User-Id");
|
||||||
|
deptService.checkDeptDataScope(deptId, Long.parseLong(userId));
|
||||||
return Result.data(deptService.deleteDeptById(deptId) > 0);
|
return Result.data(deptService.deleteDeptById(deptId) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.xiang.xs.server.controller;
|
package com.xiang.xs.server.controller;
|
||||||
|
|
||||||
import com.xiang.xs.api.client.TokenApi;
|
|
||||||
import com.xiang.xs.service.biz.ISysMenuService;
|
import com.xiang.xs.service.biz.ISysMenuService;
|
||||||
import com.xiang.xs.service.contants.UserConstants;
|
import com.xiang.xs.service.contants.UserConstants;
|
||||||
import com.xiang.xs.service.entity.SysMenu;
|
import com.xiang.xs.service.entity.SysMenu;
|
||||||
@@ -8,7 +7,6 @@ import com.xiang.xs.service.entity.TreeSelect;
|
|||||||
import com.xiang.xs.service.entity.vo.RoleTreeVo;
|
import com.xiang.xs.service.entity.vo.RoleTreeVo;
|
||||||
import com.xiang.xservice.basic.common.resp.Result;
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
import com.xiang.xservice.basic.utils.MyStringUtils;
|
import com.xiang.xservice.basic.utils.MyStringUtils;
|
||||||
import lombok.extern.java.Log;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
@@ -33,16 +31,14 @@ import java.util.List;
|
|||||||
public class SysMenuController {
|
public class SysMenuController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysMenuService menuService;
|
private ISysMenuService menuService;
|
||||||
@Autowired
|
|
||||||
private TokenApi tokenApi;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取菜单列表
|
* 获取菜单列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<List<SysMenu>> list(SysMenu menu, HttpServletRequest request) {
|
public Result<List<SysMenu>> list(SysMenu menu, HttpServletRequest request) {
|
||||||
Long userId = tokenApi.getUserId(request.getHeader("Authorization"));
|
String userId = request.getHeader("X-User_id");
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
List<SysMenu> menus = menuService.selectMenuList(menu, Long.parseLong(userId));
|
||||||
return Result.data(menus);
|
return Result.data(menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +55,8 @@ public class SysMenuController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public Result<List<TreeSelect>> treeselect(SysMenu menu, HttpServletRequest request) {
|
public Result<List<TreeSelect>> treeselect(SysMenu menu, HttpServletRequest request) {
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, tokenApi.getUserId(request.getHeader("Authorization")));
|
String userId = request.getHeader("X-User_id");
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(menu, Long.parseLong(userId));
|
||||||
return Result.data(menuService.buildMenuTreeSelect(menus));
|
return Result.data(menuService.buildMenuTreeSelect(menus));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +65,8 @@ public class SysMenuController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
public Result<RoleTreeVo> roleMenuTreeselect(@PathVariable("roleId") Long roleId, HttpServletRequest request) {
|
public Result<RoleTreeVo> roleMenuTreeselect(@PathVariable("roleId") Long roleId, HttpServletRequest request) {
|
||||||
List<SysMenu> menus = menuService.selectMenuList(tokenApi.getUserId(request.getHeader("Authorization")));
|
String userId = request.getHeader("X-User_id");
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(Long.parseLong(userId));
|
||||||
return Result.data(new RoleTreeVo(menuService.selectMenuListByRoleId(roleId), menuService.buildMenuTreeSelect(menus)));
|
return Result.data(new RoleTreeVo(menuService.selectMenuListByRoleId(roleId), menuService.buildMenuTreeSelect(menus)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ public class SysRoleController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping(value = "/{roleId}")
|
@GetMapping(value = "/{roleId}")
|
||||||
public Result<SysRole> getInfo(@PathVariable Long roleId, HttpServletRequest request) {
|
public Result<SysRole> getInfo(@PathVariable Long roleId, HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String userId = request.getHeader("X-User-Id");
|
||||||
roleService.checkRoleDataScope(token, roleId);
|
roleService.checkRoleDataScope(Long.parseLong(userId), roleId);
|
||||||
return Result.data(roleService.selectRoleById(roleId));
|
return Result.data(roleService.selectRoleById(roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +75,9 @@ public class SysRoleController {
|
|||||||
*/
|
*/
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result<Boolean> edit(@Validated @RequestBody SysRole role, HttpServletRequest request) {
|
public Result<Boolean> edit(@Validated @RequestBody SysRole role, HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String userId = request.getHeader("X-User-Id");
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(token, role.getRoleId());
|
roleService.checkRoleDataScope(Long.parseLong(userId), role.getRoleId());
|
||||||
if (!roleService.checkRoleNameUnique(role)) {
|
if (!roleService.checkRoleNameUnique(role)) {
|
||||||
return Result.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return Result.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
} else if (!roleService.checkRoleKeyUnique(role)) {
|
} else if (!roleService.checkRoleKeyUnique(role)) {
|
||||||
@@ -92,9 +92,9 @@ public class SysRoleController {
|
|||||||
*/
|
*/
|
||||||
@PutMapping("/dataScope")
|
@PutMapping("/dataScope")
|
||||||
public Result<Boolean> dataScope(@RequestBody SysRole role, HttpServletRequest request) {
|
public Result<Boolean> dataScope(@RequestBody SysRole role, HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String userId = request.getHeader("X-User-Id");
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(token, role.getRoleId());
|
roleService.checkRoleDataScope(Long.parseLong(userId), role.getRoleId());
|
||||||
return Result.data(roleService.authDataScope(role) > 0);
|
return Result.data(roleService.authDataScope(role) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,9 +103,9 @@ public class SysRoleController {
|
|||||||
*/
|
*/
|
||||||
@PutMapping("/changeStatus")
|
@PutMapping("/changeStatus")
|
||||||
public Result<Boolean> changeStatus(@RequestBody SysRole role, HttpServletRequest request) {
|
public Result<Boolean> changeStatus(@RequestBody SysRole role, HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String userId = request.getHeader("X-User-Id");
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
roleService.checkRoleDataScope(token, role.getRoleId());
|
roleService.checkRoleDataScope(Long.parseLong(userId), role.getRoleId());
|
||||||
return Result.data(roleService.updateRoleStatus(role) > 0);
|
return Result.data(roleService.updateRoleStatus(role) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,8 +114,8 @@ public class SysRoleController {
|
|||||||
*/
|
*/
|
||||||
@DeleteMapping("/{roleIds}")
|
@DeleteMapping("/{roleIds}")
|
||||||
public Result<Boolean> remove(@PathVariable Long[] roleIds, HttpServletRequest request) {
|
public Result<Boolean> remove(@PathVariable Long[] roleIds, HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String userId = request.getHeader("X-User-Id");
|
||||||
return Result.data(roleService.deleteRoleByIds(token, roleIds) > 0);
|
return Result.data(roleService.deleteRoleByIds(Long.parseLong(userId), roleIds) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,8 +165,8 @@ public class SysRoleController {
|
|||||||
*/
|
*/
|
||||||
@PutMapping("/authUser/selectAll")
|
@PutMapping("/authUser/selectAll")
|
||||||
public Result<Boolean> selectAuthUserAll(Long roleId, Long[] userIds, HttpServletRequest request) {
|
public Result<Boolean> selectAuthUserAll(Long roleId, Long[] userIds, HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String userId = request.getHeader("X-User-Id");
|
||||||
roleService.checkRoleDataScope(token, roleId);
|
roleService.checkRoleDataScope(Long.parseLong(userId), roleId);
|
||||||
return Result.data(roleService.insertAuthUsers(roleId, userIds) > 0);
|
return Result.data(roleService.insertAuthUsers(roleId, userIds) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.xiang.xs.server.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.xiang.xs.service.biz.ISysDeptService;
|
||||||
|
import com.xiang.xs.service.biz.ISysRoleService;
|
||||||
|
import com.xiang.xs.service.biz.ISysUserService;
|
||||||
|
import com.xiang.xs.service.entity.SysDept;
|
||||||
|
import com.xiang.xs.service.entity.SysRole;
|
||||||
|
import com.xiang.xs.service.entity.SysUser;
|
||||||
|
import com.xiang.xs.service.entity.TreeSelect;
|
||||||
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/user")
|
||||||
|
public class SysUserController {
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户编号获取授权角色
|
||||||
|
*/
|
||||||
|
@GetMapping("/authRole/{userId}")
|
||||||
|
public Result<JSONObject> authRole(@PathVariable("userId") Long userId) {
|
||||||
|
JSONObject ajax = new JSONObject();
|
||||||
|
SysUser user = userService.selectUserById(userId);
|
||||||
|
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||||
|
ajax.put("user", user);
|
||||||
|
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
|
return Result.data(ajax);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户授权角色
|
||||||
|
*/
|
||||||
|
@PutMapping("/authRole")
|
||||||
|
public Result<Void> insertAuthRole(Long userId, Long[] roleIds) {
|
||||||
|
userService.checkUserDataScope(userId);
|
||||||
|
roleService.checkRoleDataScope(userId, roleIds);
|
||||||
|
userService.insertUserAuth(userId, roleIds);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门树列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/deptTree")
|
||||||
|
public Result<List<TreeSelect>> deptTree(SysDept dept) {
|
||||||
|
return Result.data(deptService.selectDeptTreeList(dept));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -107,7 +107,7 @@ public interface ISysDeptService {
|
|||||||
*
|
*
|
||||||
* @param deptId 部门id
|
* @param deptId 部门id
|
||||||
*/
|
*/
|
||||||
void checkDeptDataScope(Long deptId, String token);
|
void checkDeptDataScope(Long deptId, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存部门信息
|
* 新增保存部门信息
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public interface ISysRoleService {
|
|||||||
*
|
*
|
||||||
* @param roleIds 角色id
|
* @param roleIds 角色id
|
||||||
*/
|
*/
|
||||||
void checkRoleDataScope(String token, Long... roleIds);
|
void checkRoleDataScope(Long userId, Long... roleIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过角色ID查询角色使用数量
|
* 通过角色ID查询角色使用数量
|
||||||
@@ -158,7 +158,7 @@ public interface ISysRoleService {
|
|||||||
*
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deleteRoleByIds(String token, Long[] roleIds);
|
int deleteRoleByIds(Long userId, Long[] roleIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消授权用户角色
|
* 取消授权用户角色
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.xiang.xs.service.biz.impl;
|
package com.xiang.xs.service.biz.impl;
|
||||||
|
|
||||||
import com.xiang.xs.api.client.TokenApi;
|
|
||||||
import com.xiang.xs.service.biz.ISysDeptService;
|
import com.xiang.xs.service.biz.ISysDeptService;
|
||||||
import com.xiang.xs.service.contants.UserConstants;
|
import com.xiang.xs.service.contants.UserConstants;
|
||||||
import com.xiang.xs.service.entity.SysDept;
|
import com.xiang.xs.service.entity.SysDept;
|
||||||
@@ -35,9 +34,6 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleMapper roleMapper;
|
private SysRoleMapper roleMapper;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TokenApi tokenApi;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
*
|
*
|
||||||
@@ -186,8 +182,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||||||
* @param deptId 部门id
|
* @param deptId 部门id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkDeptDataScope(Long deptId, String token) {
|
public void checkDeptDataScope(Long deptId, Long userId) {
|
||||||
if (!SysUser.isAdmin(tokenApi.getUserId(token)) && Objects.nonNull(deptId)) {
|
|
||||||
|
if (!SysUser.isAdmin(userId) && Objects.nonNull(deptId)) {
|
||||||
SysDept dept = new SysDept();
|
SysDept dept = new SysDept();
|
||||||
dept.setDeptId(deptId);
|
dept.setDeptId(deptId);
|
||||||
List<SysDept> depts = selectDeptList(dept);
|
List<SysDept> depts = selectDeptList(dept);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.xiang.xs.service.biz.impl;
|
package com.xiang.xs.service.biz.impl;
|
||||||
|
|
||||||
import com.xiang.xs.api.client.TokenApi;
|
|
||||||
import com.xiang.xs.service.biz.ISysRoleService;
|
import com.xiang.xs.service.biz.ISysRoleService;
|
||||||
import com.xiang.xs.service.contants.UserConstants;
|
import com.xiang.xs.service.contants.UserConstants;
|
||||||
import com.xiang.xs.service.entity.SysRole;
|
import com.xiang.xs.service.entity.SysRole;
|
||||||
@@ -12,7 +11,6 @@ import com.xiang.xs.service.repository.mapper.SysRoleDeptMapper;
|
|||||||
import com.xiang.xs.service.repository.mapper.SysRoleMapper;
|
import com.xiang.xs.service.repository.mapper.SysRoleMapper;
|
||||||
import com.xiang.xs.service.repository.mapper.SysRoleMenuMapper;
|
import com.xiang.xs.service.repository.mapper.SysRoleMenuMapper;
|
||||||
import com.xiang.xs.service.repository.mapper.SysUserRoleMapper;
|
import com.xiang.xs.service.repository.mapper.SysUserRoleMapper;
|
||||||
import com.xiang.xservice.basic.exception.BusinessException;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -44,9 +42,6 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleDeptMapper roleDeptMapper;
|
private SysRoleDeptMapper roleDeptMapper;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TokenApi tokenApi;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询角色数据
|
* 根据条件分页查询角色数据
|
||||||
*
|
*
|
||||||
@@ -186,9 +181,9 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
* @param roleIds 角色id
|
* @param roleIds 角色id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkRoleDataScope(String token, Long... roleIds) {
|
public void checkRoleDataScope(Long userId, Long... roleIds) {
|
||||||
|
|
||||||
if (!SysUser.isAdmin(tokenApi.getUserId(token))) {
|
if (!SysUser.isAdmin(userId)) {
|
||||||
for (Long roleId : roleIds) {
|
for (Long roleId : roleIds) {
|
||||||
SysRole role = new SysRole();
|
SysRole role = new SysRole();
|
||||||
role.setRoleId(roleId);
|
role.setRoleId(roleId);
|
||||||
@@ -342,10 +337,10 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int deleteRoleByIds(String token, Long[] roleIds) {
|
public int deleteRoleByIds(Long userId, Long[] roleIds) {
|
||||||
for (Long roleId : roleIds) {
|
for (Long roleId : roleIds) {
|
||||||
checkRoleAllowed(new SysRole(roleId));
|
checkRoleAllowed(new SysRole(roleId));
|
||||||
checkRoleDataScope(token, roleId);
|
checkRoleDataScope(userId, roleId);
|
||||||
SysRole role = selectRoleById(roleId);
|
SysRole role = selectRoleById(roleId);
|
||||||
if (countUserRoleByRoleId(roleId) > 0) {
|
if (countUserRoleByRoleId(roleId) > 0) {
|
||||||
throw new com.xiang.xservice.basic.exception.BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
throw new com.xiang.xservice.basic.exception.BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||||
|
|||||||
Reference in New Issue
Block a user