This commit is contained in:
AdisakKanthawilang 2025-03-11 16:12:32 +07:00
parent 7d572b18d2
commit f31ecf1c2b
11 changed files with 349 additions and 19 deletions

View file

@ -12,7 +12,7 @@ import {
Request,
Example,
} from "tsoa";
import { CreateOrgRoot, OrgRoot } from "../entities/OrgRoot";
import { CreateOrgRoot, OrgRoot, UpdateOrgRoot } from "../entities/OrgRoot";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import { OrgChild1 } from "../entities/OrgChild1";
@ -226,7 +226,7 @@ export class OrgRootController extends Controller {
async update(
@Path() id: string,
@Body()
requestBody: CreateOrgRoot,
requestBody: UpdateOrgRoot,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_ORG");
@ -332,11 +332,18 @@ export class OrgRootController extends Controller {
// if(chkShortChild1 != null){
// throw new HttpError(HttpStatusCode.NOT_FOUND, "อักษรย่อนี้ซ้ำกับอักษรย่อส่วนราชการ");
// }
const _null:any = null;
const before = structuredClone(orgRoot);
orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateFullName = request.user.name;
orgRoot.lastUpdatedAt = new Date();
this.orgRootRepository.merge(orgRoot, requestBody);
this.orgRootRepository.merge(orgRoot, {
...requestBody,
DEPARTMENT_CODE: requestBody.DEPARTMENT_CODE != null ? requestBody.DEPARTMENT_CODE : _null,
DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null,
SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null,
JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null,
});
await this.orgRootRepository.save(orgRoot, { data: request });
setLogDataDiff(request, { before, after: orgRoot });