Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
08ff15c1
Commit
08ff15c1
authored
Mar 05, 2021
by
钟博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改切换角色权限问题
parent
5170999d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
performance/Performance.Api/Controllers/AccountController.cs
+9
-5
No files found.
performance/Performance.Api/Controllers/AccountController.cs
View file @
08ff15c1
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment