diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 069bc57e..7f60eb08 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -2330,6 +2330,11 @@ export class OrganizationController extends Controller { }; } + const _revision = await this.orgRevisionRepository.findOne({ + where: { id: id }, + }); + if (!_revision) throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); + const orgRootData = await AppDataSource.getRepository(OrgRoot) .createQueryBuilder("orgRoot") .where("orgRoot.orgRevisionId = :id", { id }) @@ -3095,7 +3100,7 @@ export class OrganizationController extends Controller { }), ); - return new HttpSuccess(formattedData); + return new HttpSuccess({ remark: _revision.remark, data: formattedData }); } /** diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 314ff314..2c468dca 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1875,10 +1875,10 @@ export class ProfileController extends Controller { return new HttpSuccess(profile.id); } - async sendVerifyEmail( - @Request() req:RequestWithUser, - @Body() - body: { + async sendVerifyEmail( + @Request() req: RequestWithUser, + @Body() + body: { profileId: string; email: string; subject: string; @@ -1890,7 +1890,7 @@ export class ProfileController extends Controller { const link = process.env.URL + "/verifyemail/" + token; // console.log("[link]",link); - await new CallAPI() + await new CallAPI() .PostData(req, "/placement/noti/send-mail", { subject: body.subject, body: link, @@ -1898,42 +1898,39 @@ export class ProfileController extends Controller { }) .catch((error) => { console.error("Error calling API:", error); - }); - return new HttpSuccess(); - } - - /** + }); + return new HttpSuccess(); + } + + /** * API ยืนยัน Email * * @summary ยืนยัน Email * */ - @Post("verify-email") - async genLinkVerifyEmail( - @Body() body:{ - token: string; - }, - ) { - const jwt = require('jsonwebtoken'); + @Post("verify-email") + async genLinkVerifyEmail(@Body() body: { token: string }) { + const jwt = require("jsonwebtoken"); const secretKey = process.env.AUTH_ACCOUNT_SECRET || "defaultSecretKey"; const decodedToken = jwt.verify(body.token, secretKey); // console.log("[email]",decodedToken); // console.log("[1]",decodedToken.email_id); - - const profile = await this.profileRepo.findOne({ - where:{ - id: decodedToken.profileId, - email: decodedToken.email_id, - } - }); - if(!profile){ throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");} - Object.assign(profile, body); - profile.statusEmail = "VERIFIED"; - await this.profileRepo.save(profile) + const profile = await this.profileRepo.findOne({ + where: { + id: decodedToken.profileId, + email: decodedToken.email_id, + }, + }); + if (!profile) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); } - - + + Object.assign(profile, body); + profile.statusEmail = "VERIFIED"; + await this.profileRepo.save(profile); + } + /** * API ออกคำสั่ง คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป * @@ -4509,7 +4506,11 @@ export class ProfileController extends Controller { }, }); if (!profile) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); + if (request.user.role.includes("SUPER_ADMIN")) { + return new HttpSuccess(null); + } else { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); + } } let orgRevisionPublish: any = await this.orgRevisionRepo @@ -7984,8 +7985,8 @@ export class ProfileController extends Controller { profileId: profile.id, email: body.email, subject: "ยืนยันอีเมล", - } - this.sendVerifyEmail(request,verifyemailBody); + }; + this.sendVerifyEmail(request, verifyemailBody); return new HttpSuccess(); } diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 06de5896..001ae53a 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1854,7 +1854,11 @@ export class ProfileEmployeeController extends Controller { }, }); if (!profile) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); + if (request.user.role.includes("SUPER_ADMIN")) { + return new HttpSuccess(null); + } else { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); + } } let orgRevisionPublish: any = await this.orgRevisionRepo diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index ab3ff5bb..22e1a1f2 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -1755,7 +1755,11 @@ export class ProfileEmployeeTempController extends Controller { }, }); if (!profile) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); + if (request.user.role.includes("SUPER_ADMIN")) { + return new HttpSuccess(null); + } else { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); + } } let orgRevisionPublish: any = await this.orgRevisionRepo diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index 54aa5f0b..dafa6c60 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -231,6 +231,7 @@ export class KeycloakController extends Controller { profile.keycloak = null_; profile.roleKeycloaks = []; await this.profileRepo.save(profile); + return new HttpSuccess(); } } // @Security("bearerAuth", ["system", "admin"]) @@ -280,6 +281,7 @@ export class KeycloakController extends Controller { ); if (!result) throw new Error("Failed. Cannot set user's role."); + return new HttpSuccess(); } @Delete("{userId}/role/{roleId}") @@ -310,6 +312,7 @@ export class KeycloakController extends Controller { list.filter((v) => roleId === v.id), ); if (!result) throw new Error("Failed. Cannot remove user's role."); + return new HttpSuccess(); } /*@Get("user") @@ -517,6 +520,7 @@ export class KeycloakController extends Controller { ); }), ) + .orderBy("profile.citizenId", "ASC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); @@ -546,6 +550,7 @@ export class KeycloakController extends Controller { ); }), ) + .orderBy("profileEmployee.citizenId", "ASC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); diff --git a/src/entities/OrgRevision.ts b/src/entities/OrgRevision.ts index 48175f0f..47864ab8 100644 --- a/src/entities/OrgRevision.ts +++ b/src/entities/OrgRevision.ts @@ -18,8 +18,9 @@ export class OrgRevision extends EntityBase { orgRevisionName: string; @Column({ + nullable: true, comment: "หมายเหตุ", - length: 255, + type: "text", default: null, }) remark: string; diff --git a/src/migration/1732165078861-updata_org_add_remark1.ts b/src/migration/1732165078861-updata_org_add_remark1.ts new file mode 100644 index 00000000..a00b5504 --- /dev/null +++ b/src/migration/1732165078861-updata_org_add_remark1.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdataOrgAddRemark11732165078861 implements MigrationInterface { + name = 'UpdataOrgAddRemark11732165078861' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`orgRevision\` DROP COLUMN \`remark\``); + await queryRunner.query(`ALTER TABLE \`orgRevision\` ADD \`remark\` text NULL COMMENT 'หมายเหตุ'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`orgRevision\` DROP COLUMN \`remark\``); + await queryRunner.query(`ALTER TABLE \`orgRevision\` ADD \`remark\` varchar(255) NULL COMMENT 'หมายเหตุ'`); + } + +}