แก้กรองตามสิทธิ์ #2104
This commit is contained in:
parent
7778f6cccd
commit
08fb06ca84
2 changed files with 71 additions and 2 deletions
|
|
@ -1222,11 +1222,40 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> GetLeaveRequestCalendarAsync(
|
||||
[FromBody] GetLeaveRequestCalendarDto req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
string role = jsonData["result"]?.ToString();
|
||||
var nodeId = string.Empty;
|
||||
var profileAdmin = new GetUserOCAllDto();
|
||||
profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken);
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
nodeId = profileAdmin?.Node == 4
|
||||
? profileAdmin?.Child4DnaId
|
||||
: profileAdmin?.Node == 3
|
||||
? profileAdmin?.Child3DnaId
|
||||
: profileAdmin?.Node == 2
|
||||
? profileAdmin?.Child2DnaId
|
||||
: profileAdmin?.Node == 1
|
||||
? profileAdmin?.Child1DnaId
|
||||
: profileAdmin?.Node == 0
|
||||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT" || role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
//var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
//var thisYear = DateTime.Now.Year;
|
||||
var data = await _leaveRequestRepository.GetLeaveRequestByYearAsync(req.Year, userId);
|
||||
//var data = await _leaveRequestRepository.GetLeaveRequestByYearAsync(req.Year, userId);
|
||||
var data = await _leaveRequestRepository.GetLeaveRequestByYearForAdminAsync(req.Year, role, nodeId, profileAdmin.Node);
|
||||
|
||||
// var profileList = await _userProfileRepository.GetProfileWithKeycloak(AccessToken);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue