แก้ api เพิ่มเติมการ upload image and document
This commit is contained in:
parent
86ec5de116
commit
6acd497afe
23 changed files with 4081 additions and 53 deletions
|
|
@ -336,6 +336,10 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
try
|
||||
{
|
||||
var data = await _context.RecruitImports.AsQueryable()
|
||||
.Include(x => x.RecruitImages)
|
||||
.ThenInclude(x => x.Document)
|
||||
.Include(x => x.RecruitDocuments)
|
||||
.ThenInclude(x => x.Document)
|
||||
.Include(x => x.ImportFile)
|
||||
.Include(x => x.Recruits)
|
||||
.ThenInclude(x => x.Addresses)
|
||||
|
|
@ -352,7 +356,34 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
.ThenInclude(x => x.DocumentFile)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
return Success(data);
|
||||
var new_image = new List<dynamic>();
|
||||
foreach (var p in data.RecruitImages)
|
||||
{
|
||||
new_image.Add(new
|
||||
{
|
||||
p.Id,
|
||||
p.Document.FileName,
|
||||
p.Document.FileSize,
|
||||
p.Document.FileType,
|
||||
detail = _minioService.GetFilePath(p.Document.Id).Result,
|
||||
});
|
||||
}
|
||||
|
||||
// re create doc list
|
||||
var new_doc = new List<dynamic>();
|
||||
foreach (var p in data.RecruitDocuments)
|
||||
{
|
||||
new_doc.Add(new
|
||||
{
|
||||
p.Id,
|
||||
p.Document.FileName,
|
||||
p.Document.FileSize,
|
||||
p.Document.FileType,
|
||||
detail = _minioService.GetFilePath(p.Document.Id).Result,
|
||||
});
|
||||
}
|
||||
|
||||
return Success(new { periods = data, images = new_image, files = new_doc });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -382,7 +413,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
if (req == null)
|
||||
return Error(GlobalMessages.InvalidRequestParam, (int)HttpStatusCode.BadRequest);
|
||||
|
||||
await _context.RecruitImports.AddAsync(new RecruitImport
|
||||
var import = new RecruitImport
|
||||
{
|
||||
Year = req.Year,
|
||||
Name = req.Name,
|
||||
|
|
@ -398,11 +429,12 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
PaymentEndDate = req.PaymentEndDate,
|
||||
Note = req.Note,
|
||||
AnnouncementDate = req.AnnouncementDate,
|
||||
});
|
||||
};
|
||||
await _context.RecruitImports.AddAsync(import);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
return Success(import);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -451,7 +483,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
return Success(data);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -1462,33 +1494,82 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var periods = _context.RecruitImports.AsQueryable()
|
||||
.Where(x => x.Year.ToCeYear() == DateTime.Now.Year.ToCeYear())
|
||||
.Select(r => new
|
||||
{
|
||||
id = r.Id,
|
||||
title = $"{r.Name} ครั้งที่ {r.Order}/{r.Year.ToThaiYear()}",
|
||||
category = "สำนักงาน ก.ก.",
|
||||
category_id = 1,
|
||||
announcement_startDate = r.AnnouncementStartDate == null ? "" : r.AnnouncementStartDate.Value.ToString("yyyy-mm-dd"),
|
||||
announcement_endDate = r.AnnouncementEndDate == null ? "" : r.AnnouncementEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
announcementExam = true,
|
||||
register_startDate = r.RegisterStartDate == null ? "" : r.RegisterStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
register_endDate = r.RegisterEndDate == null ? "" : r.RegisterEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_startDate = r.PaymentStartDate == null ? "" : r.PaymentStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_endDate = r.PaymentEndDate == null ? "" : r.PaymentEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
exam_date = r.ExamDate == null ? "" : r.ExamDate.Value.ToString("yyyy-MM-dd")
|
||||
var this_year = DateTime.Now.Year.ToCeYear();
|
||||
|
||||
var periods = (from r in _context.RecruitImports.AsQueryable().Include(x => x.RecruitImages)
|
||||
where r.Year == this_year
|
||||
orderby r.AnnouncementStartDate descending
|
||||
select new
|
||||
{
|
||||
id = r.Id,
|
||||
title = $"{r.Name} ครั้งที่ {r.Order}/{r.Year.ToThaiYear()}",
|
||||
category = "สำนักงาน ก.ก.",
|
||||
category_id = 1,
|
||||
announcement_startDate = r.AnnouncementStartDate == null ? "" : r.AnnouncementStartDate.Value.ToString("yyyy-mm-dd"),
|
||||
announcement_endDate = r.AnnouncementEndDate == null ? "" : r.AnnouncementEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
announcementExam = true,
|
||||
register_startDate = r.RegisterStartDate == null ? "" : r.RegisterStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
register_endDate = r.RegisterEndDate == null ? "" : r.RegisterEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_startDate = r.PaymentStartDate == null ? "" : r.PaymentStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_endDate = r.PaymentEndDate == null ? "" : r.PaymentEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
exam_date = r.ExamDate == null ? "" : r.ExamDate.Value.ToString("yyyy-MM-dd"),
|
||||
image = r.RecruitImages.OrderBy(o => o.CreatedAt).FirstOrDefault() == null ? "" :
|
||||
r.RecruitImages.OrderBy(o => o.CreatedAt).FirstOrDefault().Document.Id.ToString("D")
|
||||
})
|
||||
|
||||
.ToList();
|
||||
|
||||
|
||||
//var periods = _context.RecruitImports.AsQueryable()
|
||||
// .Where(x => x.Year == this_year)
|
||||
// .Include(x => x.RecruitImages)
|
||||
// .Select(r => new
|
||||
// {
|
||||
// id = r.Id,
|
||||
// title = $"{r.Name} ครั้งที่ {r.Order}/{r.Year.ToThaiYear()}",
|
||||
// category = "สำนักงาน ก.ก.",
|
||||
// category_id = 1,
|
||||
// announcement_startDate = r.AnnouncementStartDate == null ? "" : r.AnnouncementStartDate.Value.ToString("yyyy-mm-dd"),
|
||||
// announcement_endDate = r.AnnouncementEndDate == null ? "" : r.AnnouncementEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
// announcementExam = true,
|
||||
// register_startDate = r.RegisterStartDate == null ? "" : r.RegisterStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
// register_endDate = r.RegisterEndDate == null ? "" : r.RegisterEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
// payment_startDate = r.PaymentStartDate == null ? "" : r.PaymentStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
// payment_endDate = r.PaymentEndDate == null ? "" : r.PaymentEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
// exam_date = r.ExamDate == null ? "" : r.ExamDate.Value.ToString("yyyy-MM-dd"),
|
||||
// image = r.RecruitImages.OrderBy(o => o.CreatedAt).FirstOrDefault() == null ? "" :
|
||||
// r.RecruitImages.OrderBy(o => o.CreatedAt).FirstOrDefault().Document.Id.ToString("D")
|
||||
// })
|
||||
// .OrderByDescending(x => x.announcement_startDate)
|
||||
// .ToList();
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (limit > 0)
|
||||
periods = periods.Take(limit);
|
||||
periods = periods.Take(limit).ToList();
|
||||
|
||||
periods = periods.AsQueryable()
|
||||
.OrderByDescending(x => x.announcement_startDate);
|
||||
|
||||
return Ok(periods.ToList());
|
||||
var result = new List<dynamic>();
|
||||
foreach (var p in periods)
|
||||
{
|
||||
result.Add(new
|
||||
{
|
||||
p.id,
|
||||
p.title,
|
||||
p.category,
|
||||
p.category_id,
|
||||
p.announcementExam,
|
||||
p.announcement_startDate,
|
||||
p.announcement_endDate,
|
||||
p.register_endDate,
|
||||
p.register_startDate,
|
||||
p.payment_startDate,
|
||||
p.payment_endDate,
|
||||
p.exam_date,
|
||||
image = p.image == "" ? "" : _minioService.GetFilePath(Guid.Parse(p.image)).Result,
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -1502,29 +1583,86 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var periods = _context.RecruitImports.AsQueryable()
|
||||
.Where(x => x.Id == id)
|
||||
.Select(r => new
|
||||
{
|
||||
id = r.Id,
|
||||
title = $"{r.Name} ครั้งที่ {r.Order}/{r.Year.ToThaiYear()}",
|
||||
detail = r.Detail,
|
||||
category = "สำนักงาน ก.ก.",
|
||||
category_id = 1,
|
||||
announcement_startDate = r.AnnouncementStartDate == null ? "" : r.AnnouncementStartDate.Value.ToString("yyyy-mm-dd"),
|
||||
announcement_endDate = r.AnnouncementEndDate == null ? "" : r.AnnouncementEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
start = r.AnnouncementStartDate == null ? "" : r.AnnouncementStartDate.Value.ToString("yyyy-mm-dd"),
|
||||
end = r.AnnouncementEndDate == null ? "" : r.AnnouncementEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
announcementExam = true,
|
||||
register_startDate = r.RegisterStartDate == null ? "" : r.RegisterStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
register_endDate = r.RegisterEndDate == null ? "" : r.RegisterEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_startDate = r.PaymentStartDate == null ? "" : r.PaymentStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_endDate = r.PaymentEndDate == null ? "" : r.PaymentEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
examDate = r.ExamDate == null ? "" : r.ExamDate.Value.ToString("yyyy-MM-dd")
|
||||
|
||||
});
|
||||
var periods = (from r in _context.RecruitImports.AsQueryable()
|
||||
.Include(x => x.RecruitDocuments)
|
||||
.ThenInclude(x => x.Document)
|
||||
.Include(x => x.RecruitImages)
|
||||
.ThenInclude(x => x.Document)
|
||||
where r.Id == id
|
||||
select new
|
||||
{
|
||||
id = r.Id,
|
||||
title = $"{r.Name} ครั้งที่ {r.Order}/{r.Year.ToThaiYear()}",
|
||||
detail = r.Detail,
|
||||
category = "สำนักงาน ก.ก.",
|
||||
category_id = 1,
|
||||
announcement_startDate = r.AnnouncementStartDate == null ? "" : r.AnnouncementStartDate.Value.ToString("yyyy-mm-dd"),
|
||||
announcement_endDate = r.AnnouncementEndDate == null ? "" : r.AnnouncementEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
start = r.AnnouncementStartDate == null ? "" : r.AnnouncementStartDate.Value.ToString("yyyy-mm-dd"),
|
||||
end = r.AnnouncementEndDate == null ? "" : r.AnnouncementEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
announcementExam = true,
|
||||
register_startDate = r.RegisterStartDate == null ? "" : r.RegisterStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
register_endDate = r.RegisterEndDate == null ? "" : r.RegisterEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_startDate = r.PaymentStartDate == null ? "" : r.PaymentStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_endDate = r.PaymentEndDate == null ? "" : r.PaymentEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
examDate = r.ExamDate == null ? "" : r.ExamDate.Value.ToString("yyyy-MM-dd"),
|
||||
Images = r.RecruitImages.OrderBy(x => x.CreatedAt).Select(s => new
|
||||
{
|
||||
Title = s.Document.FileName,
|
||||
Url = s.Document.Id.ToString("D")
|
||||
}).ToList(),
|
||||
Files = r.RecruitDocuments.OrderBy(x => x.CreatedAt).Select(s => new
|
||||
{
|
||||
Title = s.Document.FileName,
|
||||
Url = s.Document.Id.ToString("D")
|
||||
}).ToList(),
|
||||
}).FirstOrDefault();
|
||||
|
||||
return Ok(periods.FirstOrDefault());
|
||||
// re create image list
|
||||
var new_image = new List<dynamic>();
|
||||
foreach (var p in periods.Images)
|
||||
{
|
||||
new_image.Add(new
|
||||
{
|
||||
Title = p.Title,
|
||||
Url = _minioService.GetFilePath(Guid.Parse(p.Url)).Result,
|
||||
});
|
||||
}
|
||||
|
||||
// re create doc list
|
||||
var new_doc = new List<dynamic>();
|
||||
foreach (var p in periods.Files)
|
||||
{
|
||||
new_doc.Add(new
|
||||
{
|
||||
Title = p.Title,
|
||||
Url = _minioService.GetFilePath(Guid.Parse(p.Url)).Result,
|
||||
});
|
||||
}
|
||||
|
||||
var result = new
|
||||
{
|
||||
periods.id,
|
||||
periods.title,
|
||||
periods.detail,
|
||||
periods.category,
|
||||
periods.category_id,
|
||||
periods.announcement_endDate,
|
||||
periods.announcement_startDate,
|
||||
periods.start,
|
||||
periods.end,
|
||||
periods.announcementExam,
|
||||
periods.register_endDate,
|
||||
periods.register_startDate,
|
||||
periods.payment_endDate,
|
||||
periods.payment_startDate,
|
||||
periods.examDate,
|
||||
images = new_image,
|
||||
files = new_doc
|
||||
};
|
||||
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -1825,6 +1963,81 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region " Image and Document "
|
||||
|
||||
/// <summary>
|
||||
/// Upload Image หรือ เอกสารในรอบการสอบ
|
||||
/// </summary>
|
||||
/// <param name="type">ประเภทเอกสาร</param>
|
||||
/// <param name="importId">รหัสรอบสมัคร</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("{type}/{importId:length(36)}"), DisableRequestSizeLimit]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDocAsync(string type, Guid importId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
||||
{
|
||||
return Error(GlobalMessages.NoFileToUpload);
|
||||
}
|
||||
|
||||
var files = Request.Form.Files;
|
||||
if (type == "img")
|
||||
{
|
||||
await _recruitService.UpdateImageAsync(importId, files);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _recruitService.UpdateDocAsync(importId, files);
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบ Image หรือ เอกสารในรอบการสอบ
|
||||
/// </summary>
|
||||
/// <param name="type">ประเภทเอกสาร</param>
|
||||
/// <param name="docId">รหัสไฟล์</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("{type}/{docId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteDocAsync(string type, Guid docId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (type == "img")
|
||||
{
|
||||
await _recruitService.DeleteImageAsync(docId);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _recruitService.DeleteDocAsync(docId);
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "ไม่สามารถลบไฟล์ได้");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -45,5 +45,9 @@ namespace BMA.EHR.Recruit.Service.Data
|
|||
public DbSet<RecruitDocument> RecruitDocuments { get; set; }
|
||||
|
||||
public DbSet<RecruitImportHistory> RecruitImportHistories { get; set; }
|
||||
|
||||
public DbSet<RecruitImportDocument> RecruitImportDocuments { get; set; }
|
||||
|
||||
public DbSet<RecruitImportImage> RecruitImportImages { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1534
Migrations/20230502123322_Add Import Image and Document Table.Designer.cs
generated
Normal file
1534
Migrations/20230502123322_Add Import Image and Document Table.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
117
Migrations/20230502123322_Add Import Image and Document Table.cs
Normal file
117
Migrations/20230502123322_Add Import Image and Document Table.cs
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recruit.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddImportImageandDocumentTable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RecruitImportDocument",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
RecruitImportId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "Id รอบสมัครสอบ", collation: "ascii_general_ci"),
|
||||
DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "Id เอกสาร", collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RecruitImportDocument", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecruitImportDocument_Documents_DocumentId",
|
||||
column: x => x.DocumentId,
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecruitImportDocument_RecruitImports_RecruitImportId",
|
||||
column: x => x.RecruitImportId,
|
||||
principalTable: "RecruitImports",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RecruitImportImage",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
RecruitImportId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "Id รอบสมัครสอบ", collation: "ascii_general_ci"),
|
||||
DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "Id ไฟล์รูป", collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RecruitImportImage", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecruitImportImage_Documents_DocumentId",
|
||||
column: x => x.DocumentId,
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecruitImportImage_RecruitImports_RecruitImportId",
|
||||
column: x => x.RecruitImportId,
|
||||
principalTable: "RecruitImports",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecruitImportDocument_DocumentId",
|
||||
table: "RecruitImportDocument",
|
||||
column: "DocumentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecruitImportDocument_RecruitImportId",
|
||||
table: "RecruitImportDocument",
|
||||
column: "RecruitImportId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecruitImportImage_DocumentId",
|
||||
table: "RecruitImportImage",
|
||||
column: "DocumentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecruitImportImage_RecruitImportId",
|
||||
table: "RecruitImportImage",
|
||||
column: "RecruitImportId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "RecruitImportDocument");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RecruitImportImage");
|
||||
}
|
||||
}
|
||||
}
|
||||
1534
Migrations/20230502124309_Add Import Image and Document Table2.Designer.cs
generated
Normal file
1534
Migrations/20230502124309_Add Import Image and Document Table2.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,206 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recruit.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddImportImageandDocumentTable2 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RecruitImportDocument_Documents_DocumentId",
|
||||
table: "RecruitImportDocument");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RecruitImportDocument_RecruitImports_RecruitImportId",
|
||||
table: "RecruitImportDocument");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RecruitImportImage_Documents_DocumentId",
|
||||
table: "RecruitImportImage");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RecruitImportImage_RecruitImports_RecruitImportId",
|
||||
table: "RecruitImportImage");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_RecruitImportImage",
|
||||
table: "RecruitImportImage");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_RecruitImportDocument",
|
||||
table: "RecruitImportDocument");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "RecruitImportImage",
|
||||
newName: "RecruitImportImages");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "RecruitImportDocument",
|
||||
newName: "RecruitImportDocuments");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_RecruitImportImage_RecruitImportId",
|
||||
table: "RecruitImportImages",
|
||||
newName: "IX_RecruitImportImages_RecruitImportId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_RecruitImportImage_DocumentId",
|
||||
table: "RecruitImportImages",
|
||||
newName: "IX_RecruitImportImages_DocumentId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_RecruitImportDocument_RecruitImportId",
|
||||
table: "RecruitImportDocuments",
|
||||
newName: "IX_RecruitImportDocuments_RecruitImportId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_RecruitImportDocument_DocumentId",
|
||||
table: "RecruitImportDocuments",
|
||||
newName: "IX_RecruitImportDocuments_DocumentId");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_RecruitImportImages",
|
||||
table: "RecruitImportImages",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_RecruitImportDocuments",
|
||||
table: "RecruitImportDocuments",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RecruitImportDocuments_Documents_DocumentId",
|
||||
table: "RecruitImportDocuments",
|
||||
column: "DocumentId",
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RecruitImportDocuments_RecruitImports_RecruitImportId",
|
||||
table: "RecruitImportDocuments",
|
||||
column: "RecruitImportId",
|
||||
principalTable: "RecruitImports",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RecruitImportImages_Documents_DocumentId",
|
||||
table: "RecruitImportImages",
|
||||
column: "DocumentId",
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RecruitImportImages_RecruitImports_RecruitImportId",
|
||||
table: "RecruitImportImages",
|
||||
column: "RecruitImportId",
|
||||
principalTable: "RecruitImports",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RecruitImportDocuments_Documents_DocumentId",
|
||||
table: "RecruitImportDocuments");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RecruitImportDocuments_RecruitImports_RecruitImportId",
|
||||
table: "RecruitImportDocuments");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RecruitImportImages_Documents_DocumentId",
|
||||
table: "RecruitImportImages");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RecruitImportImages_RecruitImports_RecruitImportId",
|
||||
table: "RecruitImportImages");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_RecruitImportImages",
|
||||
table: "RecruitImportImages");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_RecruitImportDocuments",
|
||||
table: "RecruitImportDocuments");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "RecruitImportImages",
|
||||
newName: "RecruitImportImage");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "RecruitImportDocuments",
|
||||
newName: "RecruitImportDocument");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_RecruitImportImages_RecruitImportId",
|
||||
table: "RecruitImportImage",
|
||||
newName: "IX_RecruitImportImage_RecruitImportId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_RecruitImportImages_DocumentId",
|
||||
table: "RecruitImportImage",
|
||||
newName: "IX_RecruitImportImage_DocumentId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_RecruitImportDocuments_RecruitImportId",
|
||||
table: "RecruitImportDocument",
|
||||
newName: "IX_RecruitImportDocument_RecruitImportId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_RecruitImportDocuments_DocumentId",
|
||||
table: "RecruitImportDocument",
|
||||
newName: "IX_RecruitImportDocument_DocumentId");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_RecruitImportImage",
|
||||
table: "RecruitImportImage",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_RecruitImportDocument",
|
||||
table: "RecruitImportDocument",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RecruitImportDocument_Documents_DocumentId",
|
||||
table: "RecruitImportDocument",
|
||||
column: "DocumentId",
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RecruitImportDocument_RecruitImports_RecruitImportId",
|
||||
table: "RecruitImportDocument",
|
||||
column: "RecruitImportId",
|
||||
principalTable: "RecruitImports",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RecruitImportImage_Documents_DocumentId",
|
||||
table: "RecruitImportImage",
|
||||
column: "DocumentId",
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RecruitImportImage_RecruitImports_RecruitImportId",
|
||||
table: "RecruitImportImage",
|
||||
column: "RecruitImportId",
|
||||
principalTable: "RecruitImports",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -716,6 +716,70 @@ namespace BMA.EHR.Recruit.Service.Migrations
|
|||
b.ToTable("RecruitImports");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportDocument", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(100)
|
||||
.HasComment("สร้างข้อมูลเมื่อ");
|
||||
|
||||
b.Property<string>("CreatedFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(104)
|
||||
.HasComment("ชื่อ User ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<string>("CreatedUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(101)
|
||||
.HasComment("User Id ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<Guid>("DocumentId")
|
||||
.HasColumnType("char(36)")
|
||||
.HasComment("Id เอกสาร");
|
||||
|
||||
b.Property<string>("LastUpdateFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(105)
|
||||
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<string>("LastUpdateUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(103)
|
||||
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<DateTime?>("LastUpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(102)
|
||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||
|
||||
b.Property<Guid>("RecruitImportId")
|
||||
.HasColumnType("char(36)")
|
||||
.HasComment("Id รอบสมัครสอบ");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("RecruitImportId");
|
||||
|
||||
b.ToTable("RecruitImportDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportHistory", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -779,6 +843,70 @@ namespace BMA.EHR.Recruit.Service.Migrations
|
|||
b.ToTable("RecruitImportHistories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportImage", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(100)
|
||||
.HasComment("สร้างข้อมูลเมื่อ");
|
||||
|
||||
b.Property<string>("CreatedFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(104)
|
||||
.HasComment("ชื่อ User ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<string>("CreatedUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(101)
|
||||
.HasComment("User Id ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<Guid>("DocumentId")
|
||||
.HasColumnType("char(36)")
|
||||
.HasComment("Id ไฟล์รูป");
|
||||
|
||||
b.Property<string>("LastUpdateFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(105)
|
||||
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<string>("LastUpdateUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(103)
|
||||
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<DateTime?>("LastUpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(102)
|
||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||
|
||||
b.Property<Guid>("RecruitImportId")
|
||||
.HasColumnType("char(36)")
|
||||
.HasComment("Id รอบสมัครสอบ");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("RecruitImportId");
|
||||
|
||||
b.ToTable("RecruitImportImages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitOccupation", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -1263,6 +1391,25 @@ namespace BMA.EHR.Recruit.Service.Migrations
|
|||
b.Navigation("ImportFile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportDocument", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Recruit.Service.Models.Documents.Document", "Document")
|
||||
.WithMany()
|
||||
.HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport")
|
||||
.WithMany("RecruitDocuments")
|
||||
.HasForeignKey("RecruitImportId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("RecruitImport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportHistory", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport")
|
||||
|
|
@ -1274,6 +1421,25 @@ namespace BMA.EHR.Recruit.Service.Migrations
|
|||
b.Navigation("RecruitImport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportImage", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Recruit.Service.Models.Documents.Document", "Document")
|
||||
.WithMany()
|
||||
.HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport")
|
||||
.WithMany("RecruitImages")
|
||||
.HasForeignKey("RecruitImportId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("RecruitImport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitOccupation", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit")
|
||||
|
|
@ -1345,6 +1511,10 @@ namespace BMA.EHR.Recruit.Service.Migrations
|
|||
{
|
||||
b.Navigation("ImportHostories");
|
||||
|
||||
b.Navigation("RecruitDocuments");
|
||||
|
||||
b.Navigation("RecruitImages");
|
||||
|
||||
b.Navigation("Recruits");
|
||||
|
||||
b.Navigation("ScoreImport")
|
||||
|
|
|
|||
|
|
@ -56,5 +56,11 @@ namespace BMA.EHR.Recruit.Service.Models.Recruits
|
|||
public ScoreImport ScoreImport { get; set; }
|
||||
|
||||
public List<RecruitImportHistory> ImportHostories { get; set; } = new List<RecruitImportHistory>();
|
||||
|
||||
[Comment("รูป")]
|
||||
public virtual List<RecruitImportImage> RecruitImages { get; set; } = new();
|
||||
|
||||
[Comment("เอกสาร")]
|
||||
public virtual List<RecruitImportDocument> RecruitDocuments { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
19
Models/Recruits/RecruitImportDocument.cs
Normal file
19
Models/Recruits/RecruitImportDocument.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using BMA.EHR.Recruit.Service.Models.Documents;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BMA.EHR.Recruit.Service.Models.Recruits
|
||||
{
|
||||
public class RecruitImportDocument : EntityBase
|
||||
{
|
||||
[Required, Comment("Id รอบสมัครสอบ")]
|
||||
public Guid RecruitImportId { get; set; }
|
||||
|
||||
public virtual RecruitImport? RecruitImport { get; set; }
|
||||
|
||||
[Required, Comment("Id เอกสาร")]
|
||||
public Guid DocumentId { get; set; }
|
||||
|
||||
public virtual Document? Document { get; set; }
|
||||
}
|
||||
}
|
||||
19
Models/Recruits/RecruitImportImage.cs
Normal file
19
Models/Recruits/RecruitImportImage.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using BMA.EHR.Recruit.Service.Models.Documents;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BMA.EHR.Recruit.Service.Models.Recruits
|
||||
{
|
||||
public class RecruitImportImage: EntityBase
|
||||
{
|
||||
[Required, Comment("Id รอบสมัครสอบ")]
|
||||
public Guid RecruitImportId { get; set; }
|
||||
|
||||
public virtual RecruitImport? RecruitImport { get; set; }
|
||||
|
||||
[Required, Comment("Id ไฟล์รูป")]
|
||||
public Guid DocumentId { get; set; }
|
||||
|
||||
public virtual Document? Document { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -185,6 +186,33 @@ namespace BMA.EHR.Recruit.Service.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<string> GetFilePath(Guid fileId)
|
||||
{
|
||||
|
||||
var doc = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == fileId);
|
||||
|
||||
if (doc == null)
|
||||
throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
||||
|
||||
//var config = new AmazonS3Config
|
||||
//{
|
||||
// ServiceURL = Configuration.GetValue<string>("MinIO:Endpoint"),
|
||||
// ForcePathStyle = true
|
||||
//};
|
||||
|
||||
DateTime expires = DateTime.UtcNow.AddHours(6);
|
||||
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
|
||||
{
|
||||
BucketName = _bucketName,
|
||||
Key = doc?.ObjectRefId.ToString("D"),
|
||||
Expires = expires,
|
||||
};
|
||||
string path = _s3Client.GetPreSignedURL(request);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -5,16 +5,20 @@ using System.Threading.Tasks;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using BMA.EHR.Recruit.Service.Data;
|
||||
using BMA.EHR.Recruit.Service.Models.Recruits;
|
||||
using BMA.EHR.Recruit.Service.Core;
|
||||
|
||||
namespace BMA.EHR.Recruit.Service.Services
|
||||
{
|
||||
public class RecruitService
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly MinIOService _minIOService;
|
||||
|
||||
public RecruitService(ApplicationDbContext context)
|
||||
public RecruitService(ApplicationDbContext context,
|
||||
MinIOService minIOService)
|
||||
{
|
||||
_context = context;
|
||||
_minIOService = minIOService;
|
||||
}
|
||||
|
||||
public int GetExamCount(string citizenId)
|
||||
|
|
@ -61,5 +65,87 @@ namespace BMA.EHR.Recruit.Service.Services
|
|||
return valid;
|
||||
}
|
||||
|
||||
public async Task UpdateDocAsync(Guid ImportId, IFormFileCollection files)
|
||||
{
|
||||
var periodExam = await _context.RecruitImports.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == ImportId);
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var doc = await _minIOService.UploadFileAsync(file);
|
||||
|
||||
|
||||
|
||||
var periodExamDocument = new RecruitImportDocument
|
||||
{
|
||||
RecruitImportId = ImportId,
|
||||
DocumentId = doc.Id,
|
||||
};
|
||||
|
||||
await _context.RecruitImportDocuments.AddAsync(periodExamDocument);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateImageAsync(Guid ImportId, IFormFileCollection files)
|
||||
{
|
||||
var periodExam = await _context.RecruitImports.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == ImportId);
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var doc = await _minIOService.UploadFileAsync(file);
|
||||
|
||||
|
||||
|
||||
var periodExamImage = new RecruitImportImage
|
||||
{
|
||||
RecruitImportId = ImportId,
|
||||
DocumentId = doc.Id,
|
||||
};
|
||||
|
||||
await _context.RecruitImportImages.AddAsync(periodExamImage);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteImageAsync(Guid id)
|
||||
{
|
||||
var image = await _context.RecruitImportImages.AsQueryable()
|
||||
.Include(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (image == null)
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
||||
var doc_id = image.Document.Id;
|
||||
_context.RecruitImportImages.Remove(image);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
await _minIOService.DeleteFileAsync(doc_id);
|
||||
}
|
||||
|
||||
public async Task DeleteDocAsync(Guid id)
|
||||
{
|
||||
var doc = await _context.RecruitImportDocuments.AsQueryable()
|
||||
.Include(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (doc == null)
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
||||
var doc_id = doc.Document.Id;
|
||||
_context.RecruitImportDocuments.Remove(doc);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
await _minIOService.DeleteFileAsync(doc_id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"MongoConnection": "mongodb://127.0.0.1:27017",
|
||||
"DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_recruit;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
"DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_recruit;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -149,6 +149,28 @@
|
|||
แสดงข้อมูลสำหรับหน้าจอ : รายการข้อมูลผู้สมัครสอบ
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Controllers.RecruitController.UpdateDocAsync(System.String,System.Guid)">
|
||||
<summary>
|
||||
Upload Image หรือ เอกสารในรอบการสอบ
|
||||
</summary>
|
||||
<param name="type">ประเภทเอกสาร</param>
|
||||
<param name="importId">รหัสรอบสมัคร</param>
|
||||
<returns></returns>
|
||||
<response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||
<response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
<response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Controllers.RecruitController.DeleteDocAsync(System.String,System.Guid)">
|
||||
<summary>
|
||||
ลบ Image หรือ เอกสารในรอบการสอบ
|
||||
</summary>
|
||||
<param name="type">ประเภทเอกสาร</param>
|
||||
<param name="docId">รหัสไฟล์</param>
|
||||
<returns></returns>
|
||||
<response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
<response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
<response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
</member>
|
||||
<member name="T:BMA.EHR.Recruit.Service.Migrations.InitialProject">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
|
|
@ -341,6 +363,30 @@
|
|||
<member name="M:BMA.EHR.Recruit.Service.Migrations.ChangeimportdetailField.BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable.Up(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable.Down(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable.BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable2">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable2.Up(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable2.Down(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable2.BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:BMA.EHR.Recruit.Service.Requests.Recruits.PostRecruitImportRequest">
|
||||
<summary>
|
||||
ตัวแปรสำหรับสร้างข้อมูลการสอบแข่งขัน
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"MongoConnection": "mongodb://127.0.0.1:27017",
|
||||
"DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_recruit;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
"DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_recruit;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
265b13bdac59f0115955370c1f20fa05f07764aa
|
||||
18236251b3f3725026b46738126686572dc71236
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -149,6 +149,28 @@
|
|||
แสดงข้อมูลสำหรับหน้าจอ : รายการข้อมูลผู้สมัครสอบ
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Controllers.RecruitController.UpdateDocAsync(System.String,System.Guid)">
|
||||
<summary>
|
||||
Upload Image หรือ เอกสารในรอบการสอบ
|
||||
</summary>
|
||||
<param name="type">ประเภทเอกสาร</param>
|
||||
<param name="importId">รหัสรอบสมัคร</param>
|
||||
<returns></returns>
|
||||
<response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||
<response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
<response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Controllers.RecruitController.DeleteDocAsync(System.String,System.Guid)">
|
||||
<summary>
|
||||
ลบ Image หรือ เอกสารในรอบการสอบ
|
||||
</summary>
|
||||
<param name="type">ประเภทเอกสาร</param>
|
||||
<param name="docId">รหัสไฟล์</param>
|
||||
<returns></returns>
|
||||
<response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
<response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
<response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
</member>
|
||||
<member name="T:BMA.EHR.Recruit.Service.Migrations.InitialProject">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
|
|
@ -341,6 +363,30 @@
|
|||
<member name="M:BMA.EHR.Recruit.Service.Migrations.ChangeimportdetailField.BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable.Up(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable.Down(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable.BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable2">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable2.Up(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable2.Down(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:BMA.EHR.Recruit.Service.Migrations.AddImportImageandDocumentTable2.BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:BMA.EHR.Recruit.Service.Requests.Recruits.PostRecruitImportRequest">
|
||||
<summary>
|
||||
ตัวแปรสำหรับสร้างข้อมูลการสอบแข่งขัน
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue