use of com.vip.saturn.job.console.mybatis.entity.UserRole in project Saturn by vipshop.
the class AuthorizationController method updateUserRole.
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/updateUserRole")
public SuccessResponseEntity updateUserRole(@AuditParam("preUserName") @RequestParam String preUserName, @AuditParam("preRoleKey") @RequestParam String preRoleKey, @AuditParam("preNamespace") @RequestParam String preNamespace, @AuditParam("userName") @RequestParam String userName, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespace") @RequestParam String namespace, @AuditParam("needApproval") @RequestParam Boolean needApproval, HttpSession httpSession) throws SaturnJobConsoleException {
assertIsSystemAdmin();
String currentLoginUserName = getCurrentLoginUserName();
Date now = new Date();
UserRole pre = new UserRole();
pre.setUserName(preUserName);
pre.setRoleKey(preRoleKey);
pre.setNamespace(preNamespace);
pre.setLastUpdateTime(now);
pre.setLastUpdatedBy(currentLoginUserName);
UserRole cur = new UserRole();
cur.setUserName(userName);
cur.setRoleKey(roleKey);
cur.setNamespace(namespace);
cur.setNeedApproval(needApproval);
cur.setCreatedBy(currentLoginUserName);
cur.setCreateTime(now);
cur.setLastUpdatedBy(currentLoginUserName);
cur.setLastUpdateTime(now);
cur.setIsDeleted(false);
authorizationService.updateUserRole(pre, cur);
return new SuccessResponseEntity();
}
use of com.vip.saturn.job.console.mybatis.entity.UserRole in project Saturn by vipshop.
the class AuthorizationManageController method addUserRoles.
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/addUserRoles")
public SuccessResponseEntity addUserRoles(@AuditParam("userNames") @RequestParam String userNames, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespaces") @RequestParam String namespaces, @AuditParam("needApproval") @RequestParam Boolean needApproval) throws SaturnJobConsoleException {
assertIsSystemAdmin();
String currentLoginUserName = getCurrentLoginUserName();
List<String> userNameList = strSplitToList(userNames);
List<String> namespaceList = strSplitToList(namespaces);
// if add user to global role, the namespaces is empty
if (namespaceList.isEmpty()) {
namespaceList.add("");
}
for (String userName : userNameList) {
for (String namespace : namespaceList) {
Date now = new Date();
UserRole userRole = new UserRole();
userRole.setUserName(userName);
userRole.setRoleKey(roleKey);
userRole.setNamespace(namespace);
userRole.setNeedApproval(needApproval);
userRole.setIsDeleted(false);
userRole.setCreatedBy(currentLoginUserName);
userRole.setCreateTime(now);
userRole.setLastUpdatedBy(currentLoginUserName);
userRole.setLastUpdateTime(now);
authorizationManageService.addUserRole(userRole);
}
}
return new SuccessResponseEntity();
}
use of com.vip.saturn.job.console.mybatis.entity.UserRole in project Saturn by vipshop.
the class AuthorizationManageController method deleteUserRole.
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/deleteUserRole")
public SuccessResponseEntity deleteUserRole(@AuditParam("userName") @RequestParam String userName, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespace") @RequestParam String namespace) throws SaturnJobConsoleException {
assertIsSystemAdmin();
UserRole userRole = new UserRole();
userRole.setUserName(userName);
userRole.setRoleKey(roleKey);
userRole.setNamespace(namespace);
String currentLoginUserName = getCurrentLoginUserName();
userRole.setLastUpdatedBy(currentLoginUserName);
authorizationManageService.deleteUserRole(userRole);
return new SuccessResponseEntity();
}
Aggregations