Merge branch 'develop' into develop-tee

This commit is contained in:
setthawutttty 2023-07-14 09:08:37 +07:00
commit 5393b8ca23
54 changed files with 28278 additions and 436 deletions

View file

@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>9d934a68-d1dd-449d-bde0-3078a774ad0f</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerfileContext>.</DockerfileContext>
<RootNamespace>BMA.EHR.Placement.Service</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.31.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.33.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
</ItemGroup>
</Project>

View file

@ -36,7 +36,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BMA.EHR.API.Command\BMA.EHR.API.Command.csproj" />
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
</ItemGroup>

View file

@ -16,10 +16,10 @@ using System.Security.Cryptography;
namespace BMA.EHR.Placement.Service.Controllers
{
[Route("api/v{version:apiVersion}/placement")]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("ระบบบรรจุ")]
public class PlacementController : BaseController
{
@ -316,9 +316,82 @@ namespace BMA.EHR.Placement.Service.Controllers
ExamRound = x.ExamRound,
Pass = x.Pass,
IsProperty = x.IsProperty == null ? null : Newtonsoft.Json.JsonConvert.DeserializeObject<List<PersonPropertyRequest>>(x.IsProperty),
BmaOfficer = "",
}).FirstOrDefaultAsync(x => x.PersonalId == personalId);
return Success(data);
var _data = new
{
data.PersonalId,
data.IdCard,
data.Prefix,
data.PrefixId,
data.FullName,
data.Firstname,
data.Lastname,
data.Nationality,
data.Race,
data.DateOfBirth,
data.Age,
data.Telephone,
data.Gender,
data.GenderId,
data.Relationship,
data.RelationshipId,
data.BloodGroup,
data.BloodGroupId,
data.Religion,
data.ReligionId,
data.Address,
data.Education,
data.RegistAddress,
data.RegistSubDistrict,
data.RegistSubDistrictId,
data.RegistZipCode,
data.RegistDistrict,
data.RegistDistrictId,
data.RegistProvince,
data.RegistProvinceId,
data.CurrentAddress,
data.CurrentSubDistrict,
data.CurrentSubDistrictId,
data.CurrentZipCode,
data.CurrentDistrict,
data.CurrentDistrictId,
data.CurrentProvince,
data.CurrentProvinceId,
data.RegistSame,
data.MarryPrefix,
data.MarryPrefixId,
data.Couple,
data.MarryFirstName,
data.MarryLastName,
data.MarryOccupation,
data.FatherPrefix,
data.FatherPrefixId,
data.FatherFirstName,
data.FatherLastName,
data.FatherOccupation,
data.MotherPrefix,
data.MotherPrefixId,
data.MotherFirstName,
data.MotherLastName,
data.MotherOccupation,
data.Certificates,
data.PointA,
data.PointB,
data.PointC,
data.PointTotalA,
data.PointTotalB,
data.PointTotalC,
data.Point,
data.PointTotal,
data.ExamNumber,
data.ExamRound,
data.Pass,
data.IsProperty,
BmaOfficer = await _documentService.CheckBmaOfficer(data.IdCard),
};
return Success(_data);
}
[HttpPut("property/{personalId:length(36)}")]
@ -647,7 +720,8 @@ namespace BMA.EHR.Placement.Service.Controllers
return Error(GlobalMessages.ProvinceNotFound, 404);
person.CurrentProvince = save;
}
person.CurrentAddress = req.CurrentAddress;
person.RegistAddress = req.RegistrationAddress;
person.RegistSame = req.RegistrationSame;
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
@ -719,6 +793,36 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpPost("certificate/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> CreateCertificate([FromBody] PersonCertificateRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles
.Include(x => x.PlacementCertificates)
.FirstOrDefaultAsync(x => x.Id == personalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
var data = new PlacementCertificate
{
PlacementProfile = person,
CertificateNo = req.CertificateNo,
Issuer = req.Issuer,
IssueDate = req.IssueDate,
ExpireDate = req.ExpireDate,
CertificateType = req.CertificateType,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementCertificates.AddAsync(data);
_context.SaveChanges();
return Success();
}
[HttpPut("certificate/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateCertificate([FromBody] PersonCertificateRequest req, Guid personalId)
{
@ -728,39 +832,17 @@ namespace BMA.EHR.Placement.Service.Controllers
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
if (req.Id == null)
{
var data = new PlacementCertificate
{
PlacementProfile = person,
CertificateNo = req.CertificateNo,
Issuer = req.Issuer,
IssueDate = req.IssueDate,
ExpireDate = req.ExpireDate,
CertificateType = req.CertificateType,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementCertificates.AddAsync(data);
}
else
{
var certificate = person.PlacementCertificates.FirstOrDefault(x => x.Id == req.Id);
if (certificate == null)
return Error(GlobalMessages.CertificateNotFound, 404);
certificate.CertificateNo = req.CertificateNo;
certificate.Issuer = req.Issuer;
certificate.IssueDate = req.IssueDate;
certificate.ExpireDate = req.ExpireDate;
certificate.CertificateType = req.CertificateType;
certificate.LastUpdateFullName = FullName ?? "System Administrator";
certificate.LastUpdateUserId = UserId ?? "";
certificate.LastUpdatedAt = DateTime.Now;
}
var certificate = person.PlacementCertificates.FirstOrDefault(x => x.Id == req.Id);
if (certificate == null)
return Error(GlobalMessages.CertificateNotFound, 404);
certificate.CertificateNo = req.CertificateNo;
certificate.Issuer = req.Issuer;
certificate.IssueDate = req.IssueDate;
certificate.ExpireDate = req.ExpireDate;
certificate.CertificateType = req.CertificateType;
certificate.LastUpdateFullName = FullName ?? "System Administrator";
certificate.LastUpdateUserId = UserId ?? "";
certificate.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
@ -783,12 +865,9 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpPut("education/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateEducation([FromBody] PersonEducationRequest req, Guid personalId)
[HttpPost("education/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> CreateEducation([FromBody] PersonEducationRequest req, Guid personalId)
{
// var education = await _context.PlacementEducations
// .Include(x => x.PlacementProfile)
// .FirstOrDefaultAsync(x => x.Id == personalId);
var profile = await _context.PlacementProfiles.FirstOrDefaultAsync(x => x.Id == personalId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
@ -801,58 +880,71 @@ namespace BMA.EHR.Placement.Service.Controllers
if (positionPath == null && req.PositionPathId != null)
return Error(GlobalMessages.DataNotFound, 404);
if (req.Id == null)
var data = new PlacementEducation
{
var data = new PlacementEducation
{
PlacementProfile = profile,
EducationLevel = educationLevel,
PositionPath = positionPath,
Institute = req.Institute,
Degree = req.Degree,
Field = req.Field,
Gpa = req.Gpa,
Country = req.Country,
Duration = req.Duration,
DurationYear = req.DurationYear,
Other = req.Other,
FundName = req.FundName,
FinishDate = req.FinishDate,
StartDate = req.StartDate,
EndDate = req.EndDate,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementEducations.AddAsync(data);
}
else
{
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == req.Id);
if (education == null)
return Error(GlobalMessages.EducationNotFound, 404);
PlacementProfile = profile,
EducationLevel = educationLevel,
PositionPath = positionPath,
Institute = req.Institute,
Degree = req.Degree,
Field = req.Field,
Gpa = req.Gpa,
Country = req.Country,
Duration = req.Duration,
DurationYear = req.DurationYear,
Other = req.Other,
FundName = req.FundName,
FinishDate = req.FinishDate,
StartDate = req.StartDate,
EndDate = req.EndDate,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementEducations.AddAsync(data);
await _context.SaveChangesAsync();
return Success();
}
education.EducationLevel = educationLevel;
education.PositionPath = positionPath;
education.Institute = req.Institute;
education.Degree = req.Degree;
education.Field = req.Field;
education.Gpa = req.Gpa;
education.Country = req.Country;
education.Duration = req.Duration;
education.DurationYear = req.DurationYear;
education.Other = req.Other;
education.FundName = req.FundName;
education.FinishDate = req.FinishDate;
education.StartDate = req.StartDate;
education.EndDate = req.EndDate;
education.LastUpdateFullName = FullName ?? "System Administrator";
education.LastUpdateUserId = UserId ?? "";
education.LastUpdatedAt = DateTime.Now;
}
[HttpPut("education/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateEducation([FromBody] PersonEducationRequest req, Guid personalId)
{
var profile = await _context.PlacementProfiles.FirstOrDefaultAsync(x => x.Id == personalId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var educationLevel = await _context.EducationLevels.FirstOrDefaultAsync(x => x.Id == req.EducationLevelId);
if (educationLevel == null && req.EducationLevelId != null)
return Error(GlobalMessages.DataNotFound, 404);
var positionPath = await _context.PositionPaths.FirstOrDefaultAsync(x => x.Id == req.PositionPathId);
if (positionPath == null && req.PositionPathId != null)
return Error(GlobalMessages.DataNotFound, 404);
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == req.Id);
if (education == null)
return Error(GlobalMessages.EducationNotFound, 404);
education.EducationLevel = educationLevel;
education.PositionPath = positionPath;
education.Institute = req.Institute;
education.Degree = req.Degree;
education.Field = req.Field;
education.Gpa = req.Gpa;
education.Country = req.Country;
education.Duration = req.Duration;
education.DurationYear = req.DurationYear;
education.Other = req.Other;
education.FundName = req.FundName;
education.FinishDate = req.FinishDate;
education.StartDate = req.StartDate;
education.EndDate = req.EndDate;
education.LastUpdateFullName = FullName ?? "System Administrator";
education.LastUpdateUserId = UserId ?? "";
education.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
@ -869,5 +961,16 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("position/use")]
public async Task<ActionResult<ResponseObject>> GetPositionUse()
{
var position = await _context.PlacementProfiles
.Where(x => x.PositionNumber != null)
.Select(x => x.PositionNumber.Id)
.ToListAsync();
return Success(position);
}
}
}

View file

@ -8,12 +8,12 @@ EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["BMA.EHR.Application.csproj", "./BMA.EHR.Application"]
COPY ["BMA.EHR.Domain.csproj", "./BMA.EHR.Domain"]
COPY ["BMA.EHR.Infrastructure.csproj", "./BMA.EHR.Infrastructure"]
COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"]
COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"]
COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"]
COPY ["BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj", "BMA.EHR.Placement.Service/"]
COPY ["BMA.EHR.Placement.Service.csproj", "./BMA.EHR.Placement.Service"]
RUN dotnet restore "./BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj"
RUN dotnet restore "BMA.EHR.Placement.Service/BMA.EHR.Placement.Service.csproj"
COPY . .
WORKDIR "/src/BMA.EHR.Placement.Service"
RUN dotnet build "BMA.EHR.Placement.Service.csproj" -c Release -o /app/build

View file

@ -111,7 +111,7 @@ var app = builder.Build();
app.MapHealthChecks("/health");
app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseHttpsRedirection();
app.UseCors();
app.UseAuthentication();
@ -119,6 +119,7 @@ var app = builder.Build();
app.UseDefaultFiles();
app.UseStaticFiles();
app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>();
// apply migrations
await using var scope = app.Services.CreateAsyncScope();