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.Comment = reason;
|
||||
|
||||
approver.LastUpdateFullName = FullName ?? "";
|
||||
approver.LastUpdateUserId = userId.ToString("D");
|
||||
approver.LastUpdatedAt = DateTime.Now;
|
||||
//await _dbContext.SaveChangesAsync();
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
|
|
@ -1045,7 +1047,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
|
||||
approver.LastUpdateFullName = FullName ?? "";
|
||||
approver.LastUpdateUserId = userId.ToString("D");
|
||||
approver.LastUpdatedAt = DateTime.Now;
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
||||
|
|
@ -1141,7 +1145,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
|
||||
approver.LastUpdateFullName = FullName ?? "";
|
||||
approver.LastUpdateUserId = userId.ToString("D");
|
||||
approver.LastUpdatedAt = DateTime.Now;
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
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.Comment = reason;
|
||||
|
||||
approver.LastUpdateFullName = FullName ?? "";
|
||||
approver.LastUpdateUserId = userId.ToString("D");
|
||||
approver.LastUpdatedAt = DateTime.Now;
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Domain.Models.Base;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
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;
|
||||
|
||||
[Comment("ตำแหน่งใต้ลายเช็นต์")]
|
||||
public string? PositionSign { get; set; } = string.Empty;
|
||||
|
||||
public Guid ProfileId { 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()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PositionSign")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("ตำแหน่งใต้ลายเช็นต์");
|
||||
|
||||
b.Property<string>("Prefix")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
FirstName = r.FirstName,
|
||||
LastName = r.LastName,
|
||||
PositionName = r.PositionName,
|
||||
PositionSign = r.PositionSign,
|
||||
ProfileId = r.ProfileId,
|
||||
KeycloakId = r.KeycloakId,
|
||||
ApproveStatus = "PENDING",
|
||||
|
|
@ -1944,6 +1945,73 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
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>
|
||||
/// LV2_018 - ผู้มีอำนาจอนุมัติขอยกเลิกการลา(ADMIN)
|
||||
/// </summary>
|
||||
|
|
@ -2460,6 +2528,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
PositionName = x.PositionName,
|
||||
PositionSign = x.PositionSign,
|
||||
ApproveStatus = x.ApproveStatus,
|
||||
Comment = x.Comment,
|
||||
ProfileId = x.ProfileId,
|
||||
|
|
@ -2474,6 +2543,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
PositionName = x.PositionName,
|
||||
PositionSign = x.PositionSign,
|
||||
ApproveStatus = x.ApproveStatus,
|
||||
Comment = x.Comment,
|
||||
ProfileId = x.ProfileId,
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
|||
|
||||
public string PositionName { get; set; } = string.Empty;
|
||||
|
||||
public string PositionSign { get; set; } = string.Empty;
|
||||
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
|||
[JsonProperty("positionName")]
|
||||
public string PositionName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("positionSign")]
|
||||
public string? PositionSign { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("profileId")]
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue