|
|
@ -30,7 +30,6 @@ import org.opsli.api.base.result.ResultVo;
|
|
|
|
import org.opsli.api.web.system.user.UserApi;
|
|
|
|
import org.opsli.api.web.system.user.UserApi;
|
|
|
|
import org.opsli.api.wrapper.system.menu.MenuModel;
|
|
|
|
import org.opsli.api.wrapper.system.menu.MenuModel;
|
|
|
|
import org.opsli.api.wrapper.system.options.OptionsModel;
|
|
|
|
import org.opsli.api.wrapper.system.options.OptionsModel;
|
|
|
|
import org.opsli.api.wrapper.system.role.RoleModel;
|
|
|
|
|
|
|
|
import org.opsli.api.wrapper.system.tenant.TenantModel;
|
|
|
|
import org.opsli.api.wrapper.system.tenant.TenantModel;
|
|
|
|
import org.opsli.api.wrapper.system.user.*;
|
|
|
|
import org.opsli.api.wrapper.system.user.*;
|
|
|
|
import org.opsli.common.annotation.ApiRestController;
|
|
|
|
import org.opsli.common.annotation.ApiRestController;
|
|
|
@ -45,15 +44,14 @@ import org.opsli.common.utils.WrapperUtil;
|
|
|
|
import org.opsli.core.base.controller.BaseRestController;
|
|
|
|
import org.opsli.core.base.controller.BaseRestController;
|
|
|
|
import org.opsli.core.msg.TokenMsg;
|
|
|
|
import org.opsli.core.msg.TokenMsg;
|
|
|
|
import org.opsli.core.persistence.Page;
|
|
|
|
import org.opsli.core.persistence.Page;
|
|
|
|
import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
|
|
|
|
|
|
|
|
import org.opsli.core.persistence.querybuilder.QueryBuilder;
|
|
|
|
import org.opsli.core.persistence.querybuilder.QueryBuilder;
|
|
|
|
import org.opsli.core.persistence.querybuilder.WebQueryBuilder;
|
|
|
|
import org.opsli.core.persistence.querybuilder.WebQueryBuilder;
|
|
|
|
|
|
|
|
import org.opsli.core.persistence.querybuilder.conf.WebQueryConf;
|
|
|
|
import org.opsli.core.utils.OptionsUtil;
|
|
|
|
import org.opsli.core.utils.OptionsUtil;
|
|
|
|
import org.opsli.core.utils.OrgUtil;
|
|
|
|
import org.opsli.core.utils.OrgUtil;
|
|
|
|
import org.opsli.core.utils.TenantUtil;
|
|
|
|
import org.opsli.core.utils.TenantUtil;
|
|
|
|
import org.opsli.core.utils.UserUtil;
|
|
|
|
import org.opsli.core.utils.UserUtil;
|
|
|
|
import org.opsli.modulars.system.SystemMsg;
|
|
|
|
import org.opsli.modulars.system.SystemMsg;
|
|
|
|
import org.opsli.modulars.system.tenant.entity.SysTenant;
|
|
|
|
|
|
|
|
import org.opsli.modulars.system.user.entity.SysUser;
|
|
|
|
import org.opsli.modulars.system.user.entity.SysUser;
|
|
|
|
import org.opsli.modulars.system.user.entity.SysUserWeb;
|
|
|
|
import org.opsli.modulars.system.user.entity.SysUserWeb;
|
|
|
|
import org.opsli.modulars.system.user.service.IUserRoleRefService;
|
|
|
|
import org.opsli.modulars.system.user.service.IUserRoleRefService;
|
|
|
@ -62,7 +60,6 @@ import org.opsli.plugins.oss.OssStorageFactory;
|
|
|
|
import org.opsli.plugins.oss.service.BaseOssStorageService;
|
|
|
|
import org.opsli.plugins.oss.service.BaseOssStorageService;
|
|
|
|
import org.opsli.plugins.oss.service.OssStorageService;
|
|
|
|
import org.opsli.plugins.oss.service.OssStorageService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
|
|
|
|
|
|
|
|
@ -96,8 +93,8 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
@ApiOperation(value = "当前登陆用户信息", notes = "当前登陆用户信息")
|
|
|
|
@ApiOperation(value = "当前登陆用户信息", notes = "当前登陆用户信息")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ResultVo<UserInfo> getInfo(HttpServletRequest request) {
|
|
|
|
public ResultVo<UserInfo> getInfo(HttpServletRequest request) {
|
|
|
|
UserModel user = UserUtil.getUser();
|
|
|
|
UserModel currUser = UserUtil.getUserBySource();
|
|
|
|
return this.getInfoById(user.getId());
|
|
|
|
return this.getInfoById(currUser.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -107,20 +104,31 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
@ApiOperation(value = "当前登陆用户信息 By Id", notes = "当前登陆用户信息 By Id")
|
|
|
|
@ApiOperation(value = "当前登陆用户信息 By Id", notes = "当前登陆用户信息 By Id")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ResultVo<UserInfo> getInfoById(String userId) {
|
|
|
|
public ResultVo<UserInfo> getInfoById(String userId) {
|
|
|
|
UserModel user = UserUtil.getUser(userId);
|
|
|
|
UserModel currUser = UserUtil.getUserBySource(userId);
|
|
|
|
if(user == null){
|
|
|
|
if(currUser == null){
|
|
|
|
throw new TokenException(TokenMsg.EXCEPTION_TOKEN_LOSE_EFFICACY);
|
|
|
|
throw new TokenException(TokenMsg.EXCEPTION_TOKEN_LOSE_EFFICACY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<String> userRolesByUserId = UserUtil.getUserRolesByUserId(user.getId());
|
|
|
|
// 判断是否是 切换租户状态
|
|
|
|
List<String> userAllPermsByUserId = UserUtil.getUserAllPermsByUserId(user.getId());
|
|
|
|
String userIdTemp = currUser.getId();
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(currUser.getSwitchTenantUserId())){
|
|
|
|
|
|
|
|
UserModel switchUser = UserUtil.getUser(currUser.getSwitchTenantUserId());
|
|
|
|
|
|
|
|
if(switchUser == null){
|
|
|
|
|
|
|
|
// 不允许切换租户
|
|
|
|
|
|
|
|
throw new ServiceException(SystemMsg.EXCEPTION_USER_SWITCH_NOT_ALLOWED);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
userIdTemp = switchUser.getId();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> userRolesByUserId = UserUtil.getUserRolesByUserId(userIdTemp);
|
|
|
|
|
|
|
|
List<String> userAllPermsByUserId = UserUtil.getUserAllPermsByUserId(userIdTemp);
|
|
|
|
|
|
|
|
|
|
|
|
UserInfo userInfo = WrapperUtil.transformInstance(user, UserInfo.class);
|
|
|
|
UserInfo userInfo = WrapperUtil.transformInstance(currUser, UserInfo.class);
|
|
|
|
userInfo.setRoles(userRolesByUserId);
|
|
|
|
userInfo.setRoles(userRolesByUserId);
|
|
|
|
userInfo.setPerms(userAllPermsByUserId);
|
|
|
|
userInfo.setPerms(userAllPermsByUserId);
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否是超级管理员
|
|
|
|
// 判断是否是超级管理员
|
|
|
|
if(StringUtils.equals(UserUtil.SUPER_ADMIN, user.getUsername())){
|
|
|
|
if(StringUtils.equals(UserUtil.SUPER_ADMIN, currUser.getUsername())){
|
|
|
|
userInfo.setIzSuperAdmin(true);
|
|
|
|
userInfo.setIzSuperAdmin(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -175,9 +183,9 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
// 演示模式 不允许操作
|
|
|
|
// 演示模式 不允许操作
|
|
|
|
super.demoError();
|
|
|
|
super.demoError();
|
|
|
|
|
|
|
|
|
|
|
|
UserModel user = UserUtil.getUser();
|
|
|
|
UserModel user = UserUtil.getUserBySource();
|
|
|
|
userPassword.setUserId(user.getId());
|
|
|
|
userPassword.setUserId(user.getId());
|
|
|
|
IService.updatePassword(userPassword);
|
|
|
|
IService.updatePasswordByCheckOld(userPassword);
|
|
|
|
return ResultVo.success();
|
|
|
|
return ResultVo.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -204,7 +212,7 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
BaseOssStorageService.FileAttr fileAttr = ossStorageService.upload(
|
|
|
|
BaseOssStorageService.FileAttr fileAttr = ossStorageService.upload(
|
|
|
|
files.get(0).getInputStream(), "jpg");
|
|
|
|
files.get(0).getInputStream(), "jpg");
|
|
|
|
|
|
|
|
|
|
|
|
UserModel user = UserUtil.getUser();
|
|
|
|
UserModel user = UserUtil.getUserBySource();
|
|
|
|
// 更新头像至数据库
|
|
|
|
// 更新头像至数据库
|
|
|
|
UserModel userModel = new UserModel();
|
|
|
|
UserModel userModel = new UserModel();
|
|
|
|
userModel.setId(user.getId());
|
|
|
|
userModel.setId(user.getId());
|
|
|
@ -231,11 +239,11 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
@RequiresPermissions("system_user_updatePassword")
|
|
|
|
@RequiresPermissions("system_user_updatePassword")
|
|
|
|
@EnableLog
|
|
|
|
@EnableLog
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ResultVo<?> updatePasswordById(UserPassword userPassword) {
|
|
|
|
public ResultVo<?> updatePasswordById(ToUserPassword userPassword) {
|
|
|
|
// 演示模式 不允许操作
|
|
|
|
// 演示模式 不允许操作
|
|
|
|
super.demoError();
|
|
|
|
super.demoError();
|
|
|
|
|
|
|
|
|
|
|
|
IService.updatePassword(userPassword);
|
|
|
|
IService.updatePasswordByNotCheckOld(userPassword);
|
|
|
|
return ResultVo.success();
|
|
|
|
return ResultVo.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -325,7 +333,7 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
String orgIdGroup,
|
|
|
|
String orgIdGroup,
|
|
|
|
HttpServletRequest request) {
|
|
|
|
HttpServletRequest request) {
|
|
|
|
QueryBuilder<SysUserWeb> queryBuilder = new WebQueryBuilder<>(
|
|
|
|
QueryBuilder<SysUserWeb> queryBuilder = new WebQueryBuilder<>(
|
|
|
|
SysUserWeb.class, request.getParameterMap());
|
|
|
|
SysUserWeb.class, request.getParameterMap(), "a.update_time");
|
|
|
|
Page<SysUserWeb, UserWebModel> page = new Page<>(pageNo, pageSize);
|
|
|
|
Page<SysUserWeb, UserWebModel> page = new Page<>(pageNo, pageSize);
|
|
|
|
QueryWrapper<SysUserWeb> queryWrapper = queryBuilder.build();
|
|
|
|
QueryWrapper<SysUserWeb> queryWrapper = queryBuilder.build();
|
|
|
|
|
|
|
|
|
|
|
@ -347,7 +355,7 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 用户信息 查询分页
|
|
|
|
* 租户管理员信息 查询分页
|
|
|
|
* @param pageNo 当前页
|
|
|
|
* @param pageNo 当前页
|
|
|
|
* @param pageSize 每页条数
|
|
|
|
* @param pageSize 每页条数
|
|
|
|
* @param request request
|
|
|
|
* @param request request
|
|
|
@ -358,16 +366,18 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ResultVo<?> findPageByTenant(Integer pageNo, Integer pageSize,
|
|
|
|
public ResultVo<?> findPageByTenant(Integer pageNo, Integer pageSize,
|
|
|
|
HttpServletRequest request) {
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
|
|
|
// 转换字段
|
|
|
|
|
|
|
|
WebQueryConf conf = new WebQueryConf();
|
|
|
|
|
|
|
|
conf.pub(SysUserWeb::getTenantId, "a.tenant_id");
|
|
|
|
|
|
|
|
|
|
|
|
QueryBuilder<SysUserWeb> queryBuilder = new WebQueryBuilder<>(
|
|
|
|
QueryBuilder<SysUserWeb> queryBuilder = new WebQueryBuilder<>(
|
|
|
|
SysUserWeb.class, request.getParameterMap());
|
|
|
|
SysUserWeb.class, request.getParameterMap(),"a.update_time", conf);
|
|
|
|
|
|
|
|
|
|
|
|
Page<SysUserWeb, UserWebModel> page = new Page<>(pageNo, pageSize);
|
|
|
|
Page<SysUserWeb, UserWebModel> page = new Page<>(pageNo, pageSize);
|
|
|
|
QueryWrapper<SysUserWeb> queryWrapper = queryBuilder.build();
|
|
|
|
|
|
|
|
// 只查看 为租户管理员的用户
|
|
|
|
|
|
|
|
queryWrapper.eq("iz_tenant_admin", DictType.NO_YES_YES.getValue());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
page.setQueryWrapper(queryWrapper);
|
|
|
|
page.setQueryWrapper(queryBuilder.build());
|
|
|
|
page = IService.findPageByCus(page);
|
|
|
|
|
|
|
|
|
|
|
|
page = IService.findPageByTenant(page);
|
|
|
|
// 密码防止分页泄露处理
|
|
|
|
// 密码防止分页泄露处理
|
|
|
|
for (UserWebModel userModel : page.getList()) {
|
|
|
|
for (UserWebModel userModel : page.getList()) {
|
|
|
|
userModel.setSecretKey(null);
|
|
|
|
userModel.setSecretKey(null);
|
|
|
@ -418,7 +428,7 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
@EnableLog
|
|
|
|
@EnableLog
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ResultVo<?> updateSelf(UserModel model) {
|
|
|
|
public ResultVo<?> updateSelf(UserModel model) {
|
|
|
|
UserModel currUser = UserUtil.getUser();
|
|
|
|
UserModel currUser = UserUtil.getUserBySource();
|
|
|
|
if(!StringUtils.equals(currUser.getId(), model.getId())){
|
|
|
|
if(!StringUtils.equals(currUser.getId(), model.getId())){
|
|
|
|
// 非法参数 防止其他用户 通过该接口 修改非自身用户数据
|
|
|
|
// 非法参数 防止其他用户 通过该接口 修改非自身用户数据
|
|
|
|
throw new ServiceException(SystemMsg.EXCEPTION_USER_ILLEGAL_PARAMETER);
|
|
|
|
throw new ServiceException(SystemMsg.EXCEPTION_USER_ILLEGAL_PARAMETER);
|
|
|
@ -534,9 +544,9 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
* @return ResultVo
|
|
|
|
* @return ResultVo
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "切换租户", notes = "切换租户")
|
|
|
|
@ApiOperation(value = "切换租户", notes = "切换租户")
|
|
|
|
@GetMapping("/switchTenant")
|
|
|
|
@Override
|
|
|
|
public ResultVo<?> switchTenant(String tenantId) {
|
|
|
|
public ResultVo<?> switchTenant(String tenantId) {
|
|
|
|
UserModel currUser = UserUtil.getUser();
|
|
|
|
UserModel currUser = UserUtil.getUserBySource();
|
|
|
|
if (!DictType.NO_YES_YES.getValue().equals(currUser.getEnableSwitchTenant())){
|
|
|
|
if (!DictType.NO_YES_YES.getValue().equals(currUser.getEnableSwitchTenant())){
|
|
|
|
// 不允许切换租户
|
|
|
|
// 不允许切换租户
|
|
|
|
throw new ServiceException(SystemMsg.EXCEPTION_USER_SWITCH_NOT_ALLOWED);
|
|
|
|
throw new ServiceException(SystemMsg.EXCEPTION_USER_SWITCH_NOT_ALLOWED);
|
|
|
@ -597,9 +607,13 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
|
|
|
|
* @return ResultVo
|
|
|
|
* @return ResultVo
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "切换回自己账户", notes = "切换回自己账户")
|
|
|
|
@ApiOperation(value = "切换回自己账户", notes = "切换回自己账户")
|
|
|
|
@GetMapping("/switchOneself")
|
|
|
|
@Override
|
|
|
|
public ResultVo<?> switchOneself() {
|
|
|
|
public ResultVo<?> switchOneself() {
|
|
|
|
UserModel currUser = UserUtil.getUser();
|
|
|
|
UserModel currUser = UserUtil.getUserBySource();
|
|
|
|
|
|
|
|
if (!DictType.NO_YES_YES.getValue().equals(currUser.getEnableSwitchTenant())){
|
|
|
|
|
|
|
|
// 不允许切换租户
|
|
|
|
|
|
|
|
throw new ServiceException(SystemMsg.EXCEPTION_USER_SWITCH_NOT_ALLOWED);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
currUser.setSwitchTenantId(null);
|
|
|
|
currUser.setSwitchTenantId(null);
|
|
|
|
currUser.setSwitchTenantUserId(null);
|
|
|
|
currUser.setSwitchTenantUserId(null);
|
|
|
|