Migrate & Fix รายการวินัยม่ได้กรองสิทธิ์รายการ #7
All checks were successful
Build & Deploy Discipline Service / build (push) Successful in 2m16s
All checks were successful
Build & Deploy Discipline Service / build (push) Successful in 2m16s
This commit is contained in:
parent
2743edf82f
commit
bea7960ea7
11 changed files with 4222 additions and 8 deletions
|
|
@ -125,14 +125,74 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
// กรองสิทธิ์
|
||||
string role = jsonData["result"]?.ToString() ?? "";
|
||||
var profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), token.Replace("Bearer ", ""));
|
||||
var node = profileAdmin?.Node;
|
||||
string? nodeIdStr = null;
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
nodeIdStr = node == 4 ? profileAdmin?.Child4DnaId
|
||||
: node == 3 ? profileAdmin?.Child3DnaId
|
||||
: node == 2 ? profileAdmin?.Child2DnaId
|
||||
: node == 1 ? profileAdmin?.Child1DnaId
|
||||
: node == 0 ? profileAdmin?.RootDnaId
|
||||
: null;
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
nodeIdStr = node == 4 ? profileAdmin?.Child3DnaId
|
||||
: node == 3 ? profileAdmin?.Child2DnaId
|
||||
: node == 2 ? profileAdmin?.Child1DnaId
|
||||
: (node == 1 || node == 0) ? profileAdmin?.RootDnaId
|
||||
: null;
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
{
|
||||
nodeIdStr = profileAdmin?.RootDnaId;
|
||||
}
|
||||
Guid? nodeId = Guid.TryParse(nodeIdStr, out var ng) ? ng : (Guid?)null;
|
||||
|
||||
var page = req.page <= 0 ? 1 : req.page;
|
||||
var pageSize = req.pageSize <= 0 ? 25 : req.pageSize;
|
||||
var keyword = string.IsNullOrEmpty(req.keyword) ? string.Empty : req.keyword;
|
||||
var status = string.IsNullOrEmpty(req.status) ? string.Empty : req.status;
|
||||
|
||||
var data_search = (from x in _context.DisciplineComplaints
|
||||
where x.Title.Contains(keyword) ||
|
||||
(x.Appellant == null ? false : x.Appellant.Contains(keyword))
|
||||
where
|
||||
(
|
||||
x.Title.Contains(keyword) ||
|
||||
(x.Appellant == null ? false : x.Appellant.Contains(keyword))
|
||||
)
|
||||
&&
|
||||
(
|
||||
role == "OWNER" ? true :
|
||||
role == "ROOT" ? x.RootDnaId == nodeId :
|
||||
role == "CHILD" ? (
|
||||
node == 4 ? x.Child4DnaId == nodeId :
|
||||
node == 3 ? x.Child3DnaId == nodeId :
|
||||
node == 2 ? x.Child2DnaId == nodeId :
|
||||
node == 1 ? x.Child1DnaId == nodeId :
|
||||
node == 0 ? x.RootDnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
role == "BROTHER" ? (
|
||||
node == 4 ? x.Child3DnaId == nodeId :
|
||||
node == 3 ? x.Child2DnaId == nodeId :
|
||||
node == 2 ? x.Child1DnaId == nodeId :
|
||||
(node == 1 || node == 0) ? x.RootDnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
role == "NORMAL" ? (
|
||||
node == 0 ? x.RootDnaId == nodeId && x.Child1DnaId == null :
|
||||
node == 1 ? x.Child1DnaId == nodeId && x.Child2DnaId == null :
|
||||
node == 2 ? x.Child2DnaId == nodeId && x.Child3DnaId == null :
|
||||
node == 3 ? x.Child3DnaId == nodeId && x.Child4DnaId == null :
|
||||
node == 4 ? x.Child4DnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
true
|
||||
)
|
||||
select x).ToList();
|
||||
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
|
|
@ -466,6 +526,10 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
Description = req.description,
|
||||
DateReceived = req.dateReceived,
|
||||
RootDnaId = profile.RootDnaId,
|
||||
Child1DnaId = profile.Child1DnaId,
|
||||
Child2DnaId = profile.Child2DnaId,
|
||||
Child3DnaId = profile.Child3DnaId,
|
||||
Child4DnaId = profile.Child4DnaId,
|
||||
LevelConsideration = req.levelConsideration == null ? null : req.levelConsideration.Trim().ToUpper(),
|
||||
DateConsideration = req.dateConsideration,
|
||||
OffenseDetails = req.offenseDetails == null ? null : req.offenseDetails.Trim().ToUpper(),
|
||||
|
|
@ -739,6 +803,10 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
RespondentType = data.RespondentType.Trim().ToUpper(),
|
||||
Organization = data.Organization,
|
||||
RootDnaId = data.RootDnaId,
|
||||
Child1DnaId = data.Child1DnaId,
|
||||
Child2DnaId = data.Child2DnaId,
|
||||
Child3DnaId = data.Child3DnaId,
|
||||
Child4DnaId = data.Child4DnaId,
|
||||
ConsideredAgency = data.ConsideredAgency,
|
||||
OrganizationId = data.OrganizationId,
|
||||
ConsideredAgencyId = data.ConsideredAgencyId,
|
||||
|
|
|
|||
|
|
@ -30,12 +30,14 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly PermissionRepository _permission;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
|
||||
public DisciplineDisciplinaryController(DisciplineDbContext context,
|
||||
MinIODisciplineService documentService,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
PermissionRepository permission)
|
||||
PermissionRepository permission,
|
||||
UserProfileRepository userProfileRepository)
|
||||
{
|
||||
// _repository = repository;
|
||||
_context = context;
|
||||
|
|
@ -43,6 +45,7 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
_httpContextAccessor = httpContextAccessor;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_permission = permission;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -50,6 +53,7 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -118,15 +122,75 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
// กรองสิทธิ์
|
||||
string role = jsonData["result"]?.ToString() ?? "";
|
||||
var profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), token.Replace("Bearer ", ""));
|
||||
var node = profileAdmin?.Node;
|
||||
string? nodeIdStr = null;
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
nodeIdStr = node == 4 ? profileAdmin?.Child4DnaId
|
||||
: node == 3 ? profileAdmin?.Child3DnaId
|
||||
: node == 2 ? profileAdmin?.Child2DnaId
|
||||
: node == 1 ? profileAdmin?.Child1DnaId
|
||||
: node == 0 ? profileAdmin?.RootDnaId
|
||||
: null;
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
nodeIdStr = node == 4 ? profileAdmin?.Child3DnaId
|
||||
: node == 3 ? profileAdmin?.Child2DnaId
|
||||
: node == 2 ? profileAdmin?.Child1DnaId
|
||||
: (node == 1 || node == 0) ? profileAdmin?.RootDnaId
|
||||
: null;
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
{
|
||||
nodeIdStr = profileAdmin?.RootDnaId;
|
||||
}
|
||||
Guid? nodeId = Guid.TryParse(nodeIdStr, out var ng) ? ng : (Guid?)null;
|
||||
|
||||
var page = req.page <= 0 ? 1 : req.page;
|
||||
var pageSize = req.pageSize <= 0 ? 25 : req.pageSize;
|
||||
var keyword = string.IsNullOrEmpty(req.keyword) ? string.Empty : req.keyword;
|
||||
var status = string.IsNullOrEmpty(req.status) ? string.Empty : req.status;
|
||||
|
||||
var data_search = (from x in _context.DisciplineDisciplinarys
|
||||
where x.Title.Contains(keyword) ||
|
||||
x.DisciplinaryFaultLevel.Contains(keyword) ||
|
||||
x.DisciplinaryCaseFault.Contains(keyword)
|
||||
where
|
||||
(
|
||||
x.Title.Contains(keyword) ||
|
||||
x.DisciplinaryFaultLevel.Contains(keyword) ||
|
||||
x.DisciplinaryCaseFault.Contains(keyword)
|
||||
)
|
||||
&&
|
||||
(
|
||||
role == "OWNER" ? true :
|
||||
role == "ROOT" ? x.RootDnaId == nodeId :
|
||||
role == "CHILD" ? (
|
||||
node == 4 ? x.Child4DnaId == nodeId :
|
||||
node == 3 ? x.Child3DnaId == nodeId :
|
||||
node == 2 ? x.Child2DnaId == nodeId :
|
||||
node == 1 ? x.Child1DnaId == nodeId :
|
||||
node == 0 ? x.RootDnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
role == "BROTHER" ? (
|
||||
node == 4 ? x.Child3DnaId == nodeId :
|
||||
node == 3 ? x.Child2DnaId == nodeId :
|
||||
node == 2 ? x.Child1DnaId == nodeId :
|
||||
(node == 1 || node == 0) ? x.RootDnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
role == "NORMAL" ? (
|
||||
node == 0 ? x.RootDnaId == nodeId && x.Child1DnaId == null :
|
||||
node == 1 ? x.Child1DnaId == nodeId && x.Child2DnaId == null :
|
||||
node == 2 ? x.Child2DnaId == nodeId && x.Child3DnaId == null :
|
||||
node == 3 ? x.Child3DnaId == nodeId && x.Child4DnaId == null :
|
||||
node == 4 ? x.Child4DnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
true
|
||||
)
|
||||
select x).ToList();
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
data_search = data_search.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
|
|
|||
|
|
@ -32,13 +32,15 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly PermissionRepository _permission;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
|
||||
public DisciplineInvestigateController(DisciplineDbContext context,
|
||||
MinIODisciplineService documentService,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission)
|
||||
PermissionRepository permission,
|
||||
UserProfileRepository userProfileRepository)
|
||||
{
|
||||
// _repository = repository;
|
||||
_context = context;
|
||||
|
|
@ -47,6 +49,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
_repositoryNoti = repositoryNoti;
|
||||
_permission = permission;
|
||||
_configuration = configuration;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -117,6 +120,35 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
// กรองสิทธิ์
|
||||
string role = jsonData["result"]?.ToString() ?? "";
|
||||
var profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), token.Replace("Bearer ", ""));
|
||||
var node = profileAdmin?.Node;
|
||||
string? nodeIdStr = null;
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
nodeIdStr = node == 4 ? profileAdmin?.Child4DnaId
|
||||
: node == 3 ? profileAdmin?.Child3DnaId
|
||||
: node == 2 ? profileAdmin?.Child2DnaId
|
||||
: node == 1 ? profileAdmin?.Child1DnaId
|
||||
: node == 0 ? profileAdmin?.RootDnaId
|
||||
: null;
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
nodeIdStr = node == 4 ? profileAdmin?.Child3DnaId
|
||||
: node == 3 ? profileAdmin?.Child2DnaId
|
||||
: node == 2 ? profileAdmin?.Child1DnaId
|
||||
: (node == 1 || node == 0) ? profileAdmin?.RootDnaId
|
||||
: null;
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
{
|
||||
nodeIdStr = profileAdmin?.RootDnaId;
|
||||
}
|
||||
Guid? nodeId = Guid.TryParse(nodeIdStr, out var ng) ? ng : (Guid?)null;
|
||||
|
||||
var page = req.page <= 0 ? 1 : req.page;
|
||||
var pageSize = req.pageSize <= 0 ? 25 : req.pageSize;
|
||||
var keyword = string.IsNullOrEmpty(req.keyword) ? string.Empty : req.keyword;
|
||||
|
|
@ -124,6 +156,35 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
|
||||
var data_search = (from x in _context.DisciplineInvestigates
|
||||
where x.Title.Contains(keyword)
|
||||
&&
|
||||
(
|
||||
role == "OWNER" ? true :
|
||||
role == "ROOT" ? x.RootDnaId == nodeId :
|
||||
role == "CHILD" ? (
|
||||
node == 4 ? x.Child4DnaId == nodeId :
|
||||
node == 3 ? x.Child3DnaId == nodeId :
|
||||
node == 2 ? x.Child2DnaId == nodeId :
|
||||
node == 1 ? x.Child1DnaId == nodeId :
|
||||
node == 0 ? x.RootDnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
role == "BROTHER" ? (
|
||||
node == 4 ? x.Child3DnaId == nodeId :
|
||||
node == 3 ? x.Child2DnaId == nodeId :
|
||||
node == 2 ? x.Child1DnaId == nodeId :
|
||||
(node == 1 || node == 0) ? x.RootDnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
role == "NORMAL" ? (
|
||||
node == 0 ? x.RootDnaId == nodeId && x.Child1DnaId == null :
|
||||
node == 1 ? x.Child1DnaId == nodeId && x.Child2DnaId == null :
|
||||
node == 2 ? x.Child2DnaId == nodeId && x.Child3DnaId == null :
|
||||
node == 3 ? x.Child3DnaId == nodeId && x.Child4DnaId == null :
|
||||
node == 4 ? x.Child4DnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
true
|
||||
)
|
||||
select x).ToList();
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
data_search = data_search.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
|
|
|||
|
|
@ -34,12 +34,14 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly PermissionRepository _permission;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
|
||||
public DisciplineResultController(DisciplineDbContext context,
|
||||
MinIODisciplineService documentService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission)
|
||||
PermissionRepository permission,
|
||||
UserProfileRepository userProfileRepository)
|
||||
{
|
||||
// _repository = repository;
|
||||
_context = context;
|
||||
|
|
@ -47,6 +49,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_permission = permission;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -138,6 +141,34 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
// กรองสิทธิ์
|
||||
string role = jsonData["result"]?.ToString() ?? "";
|
||||
var profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), token.Replace("Bearer ", ""));
|
||||
var node = profileAdmin?.Node;
|
||||
string? nodeIdStr = null;
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
nodeIdStr = node == 4 ? profileAdmin?.Child4DnaId
|
||||
: node == 3 ? profileAdmin?.Child3DnaId
|
||||
: node == 2 ? profileAdmin?.Child2DnaId
|
||||
: node == 1 ? profileAdmin?.Child1DnaId
|
||||
: node == 0 ? profileAdmin?.RootDnaId
|
||||
: null;
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
nodeIdStr = node == 4 ? profileAdmin?.Child3DnaId
|
||||
: node == 3 ? profileAdmin?.Child2DnaId
|
||||
: node == 2 ? profileAdmin?.Child1DnaId
|
||||
: (node == 1 || node == 0) ? profileAdmin?.RootDnaId
|
||||
: null;
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
{
|
||||
nodeIdStr = profileAdmin?.RootDnaId;
|
||||
}
|
||||
Guid? nodeId = Guid.TryParse(nodeIdStr, out var ng) ? ng : (Guid?)null;
|
||||
|
||||
var page = req.page <= 0 ? 1 : req.page;
|
||||
var pageSize = req.pageSize <= 0 ? 25 : req.pageSize;
|
||||
var keyword = string.IsNullOrEmpty(req.keyword) ? string.Empty : req.keyword;
|
||||
|
|
@ -150,6 +181,34 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
(x.ResultTitleType == null ? false : x.ResultTitleType.Contains(keyword)) ||
|
||||
(x.ResultYear == null ? false : (x.ResultYear + 543).ToString().Contains(keyword)))
|
||||
.Where(x => x.Status.Contains("DONE") || x.Status.Contains("REPORT"))
|
||||
.Where(x =>
|
||||
role == "OWNER" ? true :
|
||||
role == "ROOT" ? x.RootDnaId == nodeId :
|
||||
role == "CHILD" ? (
|
||||
node == 4 ? x.Child4DnaId == nodeId :
|
||||
node == 3 ? x.Child3DnaId == nodeId :
|
||||
node == 2 ? x.Child2DnaId == nodeId :
|
||||
node == 1 ? x.Child1DnaId == nodeId :
|
||||
node == 0 ? x.RootDnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
role == "BROTHER" ? (
|
||||
node == 4 ? x.Child3DnaId == nodeId :
|
||||
node == 3 ? x.Child2DnaId == nodeId :
|
||||
node == 2 ? x.Child1DnaId == nodeId :
|
||||
(node == 1 || node == 0) ? x.RootDnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
role == "NORMAL" ? (
|
||||
node == 0 ? x.RootDnaId == nodeId && x.Child1DnaId == null :
|
||||
node == 1 ? x.Child1DnaId == nodeId && x.Child2DnaId == null :
|
||||
node == 2 ? x.Child2DnaId == nodeId && x.Child3DnaId == null :
|
||||
node == 3 ? x.Child3DnaId == nodeId && x.Child4DnaId == null :
|
||||
node == 4 ? x.Child4DnaId == nodeId :
|
||||
true
|
||||
) :
|
||||
true
|
||||
)
|
||||
.ToListAsync();
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
data_search = data_search.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue