migrate + api บันทึกผู้ตรวจสอบและส่งไปพิจาณา #2109
Some checks failed
release-dev / release-dev (push) Failing after 12s
Some checks failed
release-dev / release-dev (push) Failing after 12s
This commit is contained in:
parent
59fd20c879
commit
0a58075428
8 changed files with 1722 additions and 4 deletions
|
|
@ -955,7 +955,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
approver.ApproveStatus = "APPROVE";
|
approver.ApproveStatus = "APPROVE";
|
||||||
approver.Comment = reason;
|
approver.Comment = reason;
|
||||||
|
approver.LastUpdateFullName = FullName ?? "";
|
||||||
|
approver.LastUpdateUserId = userId.ToString("D");
|
||||||
|
approver.LastUpdatedAt = DateTime.Now;
|
||||||
//await _dbContext.SaveChangesAsync();
|
//await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
if (approver.Seq != maxSeq)
|
if (approver.Seq != maxSeq)
|
||||||
|
|
@ -1045,7 +1047,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
approver.ApproveStatus = "REJECT";
|
approver.ApproveStatus = "REJECT";
|
||||||
approver.Comment = reason;
|
approver.Comment = reason;
|
||||||
|
approver.LastUpdateFullName = FullName ?? "";
|
||||||
|
approver.LastUpdateUserId = userId.ToString("D");
|
||||||
|
approver.LastUpdatedAt = DateTime.Now;
|
||||||
if (approver.Seq != maxSeq)
|
if (approver.Seq != maxSeq)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -1141,7 +1145,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
approver.ApproveStatus = "APPROVE";
|
approver.ApproveStatus = "APPROVE";
|
||||||
approver.Comment = reason;
|
approver.Comment = reason;
|
||||||
|
approver.LastUpdateFullName = FullName ?? "";
|
||||||
|
approver.LastUpdateUserId = userId.ToString("D");
|
||||||
|
approver.LastUpdatedAt = DateTime.Now;
|
||||||
if (approver.Seq != maxSeq)
|
if (approver.Seq != maxSeq)
|
||||||
{
|
{
|
||||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||||
|
|
@ -1294,7 +1300,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
approver.ApproveStatus = "REJECT";
|
approver.ApproveStatus = "REJECT";
|
||||||
approver.Comment = reason;
|
approver.Comment = reason;
|
||||||
|
approver.LastUpdateFullName = FullName ?? "";
|
||||||
|
approver.LastUpdateUserId = userId.ToString("D");
|
||||||
|
approver.LastUpdatedAt = DateTime.Now;
|
||||||
if (approver.Seq != maxSeq)
|
if (approver.Seq != maxSeq)
|
||||||
{
|
{
|
||||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using BMA.EHR.Domain.Models.Base;
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace BMA.EHR.Domain.Models.Leave.Requests
|
namespace BMA.EHR.Domain.Models.Leave.Requests
|
||||||
{
|
{
|
||||||
|
|
@ -16,6 +17,9 @@ namespace BMA.EHR.Domain.Models.Leave.Requests
|
||||||
|
|
||||||
public string PositionName { get; set; } = string.Empty;
|
public string PositionName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Comment("ตำแหน่งใต้ลายเช็นต์")]
|
||||||
|
public string? PositionSign { get; set; } = string.Empty;
|
||||||
|
|
||||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||||
|
|
||||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,30 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class update_LeaveRequestApprover_add_PositionSign : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionSign",
|
||||||
|
table: "LeaveRequestApprovers",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ตำแหน่งใต้ลายเช็นต์")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionSign",
|
||||||
|
table: "LeaveRequestApprovers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -731,6 +731,10 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("PositionSign")
|
||||||
|
.HasColumnType("longtext")
|
||||||
|
.HasComment("ตำแหน่งใต้ลายเช็นต์");
|
||||||
|
|
||||||
b.Property<string>("Prefix")
|
b.Property<string>("Prefix")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
FirstName = r.FirstName,
|
FirstName = r.FirstName,
|
||||||
LastName = r.LastName,
|
LastName = r.LastName,
|
||||||
PositionName = r.PositionName,
|
PositionName = r.PositionName,
|
||||||
|
PositionSign = r.PositionSign,
|
||||||
ProfileId = r.ProfileId,
|
ProfileId = r.ProfileId,
|
||||||
KeycloakId = r.KeycloakId,
|
KeycloakId = r.KeycloakId,
|
||||||
ApproveStatus = "PENDING",
|
ApproveStatus = "PENDING",
|
||||||
|
|
@ -1944,6 +1945,73 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
return Success(result);
|
return Success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เพิ่มชื่อผู้ส่งไปพิจารณา (ADMIN)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("admin/sender/{id:guid}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> SenderLeaveRequestAsync(Guid id)
|
||||||
|
{
|
||||||
|
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||||
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||||
|
if (jsonData["status"]?.ToString() != "200")
|
||||||
|
{
|
||||||
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
|
}
|
||||||
|
|
||||||
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(Guid.Parse(UserId!), AccessToken);
|
||||||
|
|
||||||
|
if (profile == null)
|
||||||
|
{
|
||||||
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var rawData = await _leaveRequestRepository.GetByIdAsync(id);
|
||||||
|
|
||||||
|
if (rawData == null)
|
||||||
|
{
|
||||||
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var sender = rawData.Approvers
|
||||||
|
.Where(x => x.ApproveType!.ToUpper() == "SENDER")
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
if (sender == null)
|
||||||
|
{
|
||||||
|
await _leaveRequestRepository.AddApproversAsync(id, new List<LeaveRequestApprover>
|
||||||
|
{
|
||||||
|
new LeaveRequestApprover
|
||||||
|
{
|
||||||
|
Prefix = profile.Prefix,
|
||||||
|
FirstName = profile.FirstName,
|
||||||
|
LastName = profile.LastName,
|
||||||
|
PositionName = profile.Position,
|
||||||
|
ProfileId = profile.Id,
|
||||||
|
KeycloakId = Guid.Parse(UserId!),
|
||||||
|
ApproveType = "SENDER",
|
||||||
|
|
||||||
|
CreatedFullName = FullName ?? "",
|
||||||
|
CreatedUserId = UserId!,
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "",
|
||||||
|
LastUpdateUserId = UserId!,
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// LV2_018 - ผู้มีอำนาจอนุมัติขอยกเลิกการลา(ADMIN)
|
/// LV2_018 - ผู้มีอำนาจอนุมัติขอยกเลิกการลา(ADMIN)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -2460,6 +2528,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
FirstName = x.FirstName,
|
FirstName = x.FirstName,
|
||||||
LastName = x.LastName,
|
LastName = x.LastName,
|
||||||
PositionName = x.PositionName,
|
PositionName = x.PositionName,
|
||||||
|
PositionSign = x.PositionSign,
|
||||||
ApproveStatus = x.ApproveStatus,
|
ApproveStatus = x.ApproveStatus,
|
||||||
Comment = x.Comment,
|
Comment = x.Comment,
|
||||||
ProfileId = x.ProfileId,
|
ProfileId = x.ProfileId,
|
||||||
|
|
@ -2474,6 +2543,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
FirstName = x.FirstName,
|
FirstName = x.FirstName,
|
||||||
LastName = x.LastName,
|
LastName = x.LastName,
|
||||||
PositionName = x.PositionName,
|
PositionName = x.PositionName,
|
||||||
|
PositionSign = x.PositionSign,
|
||||||
ApproveStatus = x.ApproveStatus,
|
ApproveStatus = x.ApproveStatus,
|
||||||
Comment = x.Comment,
|
Comment = x.Comment,
|
||||||
ProfileId = x.ProfileId,
|
ProfileId = x.ProfileId,
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,8 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||||
|
|
||||||
public string PositionName { get; set; } = string.Empty;
|
public string PositionName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PositionSign { get; set; } = string.Empty;
|
||||||
|
|
||||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||||
|
|
||||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||||
[JsonProperty("positionName")]
|
[JsonProperty("positionName")]
|
||||||
public string PositionName { get; set; } = string.Empty;
|
public string PositionName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("positionSign")]
|
||||||
|
public string? PositionSign { get; set; } = string.Empty;
|
||||||
|
|
||||||
[JsonProperty("profileId")]
|
[JsonProperty("profileId")]
|
||||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue