|
@@ -10,6 +10,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
+import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
@@ -53,10 +54,17 @@ public class UserTenantController extends BaseController {
|
|
|
/**
|
|
|
* 新增用户
|
|
|
*/
|
|
|
-// @RepeatSubmit
|
|
|
-// @PostMapping
|
|
|
+ @RepeatSubmit
|
|
|
+ @PostMapping
|
|
|
public void add(@Validated @RequestBody SysUser user) {
|
|
|
String tenantId = user.getTenantId();
|
|
|
+
|
|
|
+ //如果不是超管赋值登录用户所在租户
|
|
|
+ SysUser loginUser = SecurityUtils.getLoginUser().getUser();
|
|
|
+ if (loginUser.getUserId() != 1) {
|
|
|
+ tenantId = loginUser.getTenantId();
|
|
|
+ }
|
|
|
+
|
|
|
if (ObjectUtil.isEmpty(tenantId)) {
|
|
|
throw new ServiceException("租户id不能为空");
|
|
|
}
|
|
@@ -72,9 +80,15 @@ public class UserTenantController extends BaseController {
|
|
|
/**
|
|
|
* 修改用户
|
|
|
*/
|
|
|
-// @PutMapping
|
|
|
+ @PutMapping
|
|
|
public void edit(@Validated @RequestBody SysUser user) {
|
|
|
String tenantId = user.getTenantId();
|
|
|
+ //如果不是超管赋值登录用户所在租户
|
|
|
+ SysUser loginUser = SecurityUtils.getLoginUser().getUser();
|
|
|
+ if (loginUser.getUserId() != 1) {
|
|
|
+ tenantId = loginUser.getTenantId();
|
|
|
+ }
|
|
|
+
|
|
|
if (ObjectUtil.isEmpty(tenantId)) {
|
|
|
throw new ServiceException("租户id不能为空");
|
|
|
}
|
|
@@ -96,7 +110,7 @@ public class UserTenantController extends BaseController {
|
|
|
/**
|
|
|
* 删除用户
|
|
|
*/
|
|
|
-// @DeleteMapping("/{userIds}")
|
|
|
+ @DeleteMapping("/{userIds}")
|
|
|
public AjaxResult remove(@PathVariable Long[] userIds) {
|
|
|
if (ArrayUtils.contains(userIds, getUserId())) {
|
|
|
return error("当前用户不能删除");
|
|
@@ -107,7 +121,7 @@ public class UserTenantController extends BaseController {
|
|
|
/**
|
|
|
* 重置密码
|
|
|
*/
|
|
|
-// @PutMapping("/resetPwd")
|
|
|
+ @PutMapping("/resetPwd")
|
|
|
public void resetPwd(@RequestBody SysUser user) {
|
|
|
userService.checkUserAllowed(user);
|
|
|
userService.checkUserDataScope(user.getUserId());
|