Commit 08ff15c1 by 钟博

修改切换角色权限问题

parent 5170999d
......@@ -297,14 +297,14 @@ public ApiResponse<UserResponse> Password(int userId)
#region 多角色
/// <summary>
/// 查询用户信息
/// </summary>
/// <returns></returns>
[Route("selfInfos")]
[HttpPost]
public ApiResponse SelfInfos()
public ApiResponse SelfInfos([FromBody] UserRequest request)
{
var userid = _claim.GetUserId();
var user = _userService.GetUser(userid);
......@@ -312,7 +312,10 @@ public ApiResponse SelfInfos()
user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
if (request.Role <= 0)
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
else
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First(t=>t.RoleID==request.Role).Type ?? 0) : false;
return new ApiResponse(ResponseType.OK, user);
}
......@@ -345,7 +348,7 @@ public ApiResponse<UserResponse> UpdateUser([CustomizeValidator(RuleSet = "Updat
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUsersRole(userId);
//var roleType = roles.Select(c => c.Type).ToArray();
var intersect= roleArray.Intersect(roles.Select(c=>(int)c.Type).ToArray());
var intersect = roleArray.Intersect(roles.Select(c => (int)c.Type).ToArray());
var isAgainAdmin = roles != null ? intersect.Any() : false;
var user = _userService.UpdateUser(request, isAgainAdmin);
......@@ -364,7 +367,7 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody]
{
return _userService.DeleteUser(request.ID);
}
#endregion
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment