|
@@ -20,6 +20,7 @@ import com.poteviohealth.cgp.sso.module.system.enums.ErrorCodeConstants;
|
|
|
import com.poteviohealth.cgp.sso.module.system.enums.common.SexEnum;
|
|
import com.poteviohealth.cgp.sso.module.system.enums.common.SexEnum;
|
|
|
import com.poteviohealth.cgp.sso.module.system.service.dept.DeptService;
|
|
import com.poteviohealth.cgp.sso.module.system.service.dept.DeptService;
|
|
|
import com.poteviohealth.cgp.sso.module.system.service.oauth2.OAuth2ClientService;
|
|
import com.poteviohealth.cgp.sso.module.system.service.oauth2.OAuth2ClientService;
|
|
|
|
|
+import com.poteviohealth.cgp.sso.module.system.service.permission.PermissionService;
|
|
|
import com.poteviohealth.cgp.sso.module.system.service.user.AdminUserService;
|
|
import com.poteviohealth.cgp.sso.module.system.service.user.AdminUserService;
|
|
|
import com.poteviohealth.cgp.sso.module.system.service.userclient.UserClientService;
|
|
import com.poteviohealth.cgp.sso.module.system.service.userclient.UserClientService;
|
|
|
import com.poteviohealth.cgp.sso.module.system.util.transmit.GuanRsa;
|
|
import com.poteviohealth.cgp.sso.module.system.util.transmit.GuanRsa;
|
|
@@ -41,6 +42,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
+import java.security.Permission;
|
|
|
import java.security.interfaces.RSAPrivateKey;
|
|
import java.security.interfaces.RSAPrivateKey;
|
|
|
import java.security.spec.InvalidKeySpecException;
|
|
import java.security.spec.InvalidKeySpecException;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -57,7 +59,6 @@ import static com.poteviohealth.cgp.sso.module.system.enums.ErrorCodeConstants.*
|
|
|
@RequestMapping("/system/user")
|
|
@RequestMapping("/system/user")
|
|
|
@Validated
|
|
@Validated
|
|
|
public class UserController {
|
|
public class UserController {
|
|
|
-
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private AdminUserService userService;
|
|
private AdminUserService userService;
|
|
|
@Resource
|
|
@Resource
|
|
@@ -67,6 +68,9 @@ public class UserController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private UserClientService userClientService;
|
|
private UserClientService userClientService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private PermissionService permissionService;
|
|
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "新增用户")
|
|
@Operation(summary = "新增用户")
|
|
|
@PreAuthorize("@ss.hasPermission('system:user:create')")
|
|
@PreAuthorize("@ss.hasPermission('system:user:create')")
|
|
@@ -75,9 +79,22 @@ public class UserController {
|
|
|
//增加
|
|
//增加
|
|
|
reqVO.setId(id);
|
|
reqVO.setId(id);
|
|
|
updateUserClient(reqVO);
|
|
updateUserClient(reqVO);
|
|
|
|
|
+ updateUserRoles(reqVO);
|
|
|
return success(id);
|
|
return success(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void updateUserRoles(UserSaveReqVO reqVO) {
|
|
|
|
|
+ Set<Long> roleIds = new HashSet<>();
|
|
|
|
|
+ if(reqVO.getRoleType().equals(CommonStatusEnum.ENABLE.getStatus())){
|
|
|
|
|
+ //可创建用户
|
|
|
|
|
+ roleIds.add(112L);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //不可创建用户
|
|
|
|
|
+ roleIds.add(113L);
|
|
|
|
|
+ }
|
|
|
|
|
+ permissionService.assignUserRole(reqVO.getId(),roleIds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void updateUserClient(UserSaveReqVO reqVO) {
|
|
private void updateUserClient(UserSaveReqVO reqVO) {
|
|
|
Set<Long> clientIds = reqVO.getAssociatedSystem();
|
|
Set<Long> clientIds = reqVO.getAssociatedSystem();
|
|
|
if(CollectionUtils.isNotEmpty(clientIds)){
|
|
if(CollectionUtils.isNotEmpty(clientIds)){
|
|
@@ -127,6 +144,7 @@ public class UserController {
|
|
|
userService.updateUser(reqVO);
|
|
userService.updateUser(reqVO);
|
|
|
//增加
|
|
//增加
|
|
|
updateUserClient(reqVO);
|
|
updateUserClient(reqVO);
|
|
|
|
|
+ updateUserRoles(reqVO);
|
|
|
return success(true);
|
|
return success(true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -324,7 +342,4 @@ public class UserController {
|
|
|
userClientService.updateTokenById(userClient.getId(),token);
|
|
userClientService.updateTokenById(userClient.getId(),token);
|
|
|
return oAuth2Client.getLoginUrl()+"?timestamp="+timestamp+"&user="+loginUserName+"&token="+token;
|
|
return oAuth2Client.getLoginUrl()+"?timestamp="+timestamp+"&user="+loginUserName+"&token="+token;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|