Merge branch 'develop' into adiDev
This commit is contained in:
commit
2701359a88
8 changed files with 306 additions and 35 deletions
|
|
@ -59,6 +59,7 @@ import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
|||
import { CreateProfileCertificate, ProfileCertificate } from "../entities/ProfileCertificate";
|
||||
import { ProfileCertificateHistory } from "../entities/ProfileCertificateHistory";
|
||||
import permission from "../interfaces/permission";
|
||||
import { CommandSign } from "../entities/CommandSign";
|
||||
|
||||
@Route("api/v1/org/command")
|
||||
@Tags("Command")
|
||||
|
|
@ -93,6 +94,7 @@ export class CommandController extends Controller {
|
|||
private certificateRepo = AppDataSource.getRepository(ProfileCertificate);
|
||||
private certificateHistoryRepo = AppDataSource.getRepository(ProfileCertificateHistory);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private commandSignRepository = AppDataSource.getRepository(CommandSign);
|
||||
|
||||
/**
|
||||
* API list รายการคำสั่ง
|
||||
|
|
@ -249,9 +251,16 @@ export class CommandController extends Controller {
|
|||
new Brackets((qb) => {
|
||||
qb.where(keyword != null && keyword != "" ? "command.commandNo LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
}).orWhere(keyword != null && keyword != "" ? "command.issue LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
});
|
||||
})
|
||||
.orWhere(keyword != null && keyword != "" ? "command.issue LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
})
|
||||
.orWhere(
|
||||
keyword != null && keyword != "" ? "command.createdFullName LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("command.createdAt", "DESC")
|
||||
|
|
@ -1187,7 +1196,7 @@ export class CommandController extends Controller {
|
|||
await new permission().PermissionGet(request, "COMMAND");
|
||||
const command = await this.commandRepository.findOne({
|
||||
where: { id },
|
||||
relations: ["commandType"],
|
||||
relations: ["commandType", "commandRecives"],
|
||||
});
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
|
|
@ -1217,7 +1226,18 @@ export class CommandController extends Controller {
|
|||
}
|
||||
}
|
||||
if (issue == null) issue = "...................................";
|
||||
const _command = {
|
||||
|
||||
let res: any[] = [];
|
||||
if (command.commandRecives.length > 0) {
|
||||
await new CallAPI()
|
||||
.GetData(request, `/probation/report/command10/appoints/${command.commandRecives[0].refId}`)
|
||||
.then((x) => {
|
||||
res = x;
|
||||
})
|
||||
.catch((x) => {});
|
||||
}
|
||||
|
||||
let _command = {
|
||||
issue: issue,
|
||||
commandNo: command.commandNo == null ? "" : Extension.ToThaiNumber(command.commandNo),
|
||||
commandYear:
|
||||
|
|
@ -1241,7 +1261,24 @@ export class CommandController extends Controller {
|
|||
authorizedUserFullName: "...................................",
|
||||
authorizedPosition: "...................................",
|
||||
commandAffectDate: "...................................",
|
||||
name1:
|
||||
res && res.length > 0
|
||||
? `๑. ${res[0].name}.........${res[0].role}`
|
||||
: "๑. ..........................ประธาน",
|
||||
name2:
|
||||
res && res.length > 1
|
||||
? `๒. ${res[1].name}.........${res[1].role}`
|
||||
: "๒. ..........................กรรมการ",
|
||||
name3:
|
||||
res && res.length > 2
|
||||
? `๓. ${res[2].name}.........${res[2].role}`
|
||||
: "๓. ..........................กรรมการ",
|
||||
name4:
|
||||
res && res.length > 3
|
||||
? `๔. ${res[3].name}.........${res[3].role}`
|
||||
: "๔. ..........................กรรมการ",
|
||||
};
|
||||
|
||||
return new HttpSuccess({
|
||||
template: command.commandType.fileCover,
|
||||
reportName: "docx-report",
|
||||
|
|
@ -1338,6 +1375,118 @@ export class CommandController extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดรายการคำสั่ง step
|
||||
*
|
||||
* @summary API รายละเอียดรายการคำสั่ง step
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Get("step/{id}")
|
||||
async GetByIdStep(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionGet(request, "COMMAND");
|
||||
const command = await this.commandRepository.findOne({
|
||||
where: { id },
|
||||
relations: ["commandSigns"],
|
||||
});
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
|
||||
const _command = command.commandSigns.map((item) => ({
|
||||
id: item.id,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
profileId: item.profileId,
|
||||
}));
|
||||
return new HttpSuccess(_command);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขรายการ body คำสั่ง step
|
||||
*
|
||||
* @summary API แก้ไขรายการ body คำสั่ง step
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Put("step-add/{id}")
|
||||
async PutStepAdd(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: {
|
||||
profileId: string;
|
||||
isSignatory: boolean;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "COMMAND");
|
||||
const command = await this.commandRepository.findOne({ where: { id: id } });
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
const profile = await this.profileRepository.findOne({ where: { id: requestBody.profileId } });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งานนี้");
|
||||
}
|
||||
command.status = "PENDING";
|
||||
command.isDraft = true;
|
||||
const commandSign = new CommandSign();
|
||||
commandSign.prefix = profile.prefix;
|
||||
commandSign.firstName = profile.firstName;
|
||||
commandSign.lastName = profile.lastName;
|
||||
commandSign.position = profile.position;
|
||||
commandSign.isSignatory = requestBody.isSignatory;
|
||||
commandSign.profileId = requestBody.profileId;
|
||||
commandSign.commandId = command.id;
|
||||
commandSign.createdUserId = request.user.sub;
|
||||
commandSign.createdFullName = request.user.name;
|
||||
commandSign.createdAt = new Date();
|
||||
commandSign.lastUpdateUserId = request.user.sub;
|
||||
commandSign.lastUpdateFullName = request.user.name;
|
||||
commandSign.lastUpdatedAt = new Date();
|
||||
await this.commandSignRepository.save(commandSign);
|
||||
await this.commandRepository.save(command);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขรายการ body คำสั่ง step-comment
|
||||
*
|
||||
* @summary API แก้ไขรายการ body คำสั่ง step-comment
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Put("step-comment/{id}")
|
||||
async PutStepComment(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: {
|
||||
comment: string;
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "COMMAND");
|
||||
const commandSign = await this.commandSignRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: ["command"],
|
||||
});
|
||||
if (!commandSign) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
commandSign.comment = requestBody.comment;
|
||||
commandSign.lastUpdateUserId = request.user.sub;
|
||||
commandSign.lastUpdateFullName = request.user.name;
|
||||
commandSign.lastUpdatedAt = new Date();
|
||||
await this.commandSignRepository.save(commandSign);
|
||||
if(commandSign.isSignatory == true)
|
||||
await this.PutSelectPending(commandSign.commandId, { sign: true }, request);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API สร้างรายการ body คำสั่ง
|
||||
*
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ export class CommandTypeController extends Controller {
|
|||
if (!_commandType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
if(_commandType.code == "C-PM-10") {
|
||||
let _commandType10: any
|
||||
if (_commandType.code == "C-PM-10") {
|
||||
let _commandType10: any;
|
||||
_commandType10 = {
|
||||
id: _commandType.id,
|
||||
name: _commandType.name,
|
||||
|
|
@ -135,11 +135,11 @@ export class CommandTypeController extends Controller {
|
|||
detailFooter: _commandType.detailFooter,
|
||||
subtitle: _commandType.subtitle,
|
||||
isAttachment: _commandType.isAttachment,
|
||||
name1: "..........................ประธาน",
|
||||
name2: "..........................ผู้บังคับบัญชา",
|
||||
name3: "..........................ผู้ดูแล",
|
||||
name4: "..........................ผู้ดูแล",
|
||||
}
|
||||
name1: "๑. ..........................ประธาน",
|
||||
name2: "๒. ..........................กรรมการ",
|
||||
name3: "๓. ..........................กรรมการ",
|
||||
name4: "๔. ..........................กรรมการ",
|
||||
};
|
||||
_commandType = _commandType10;
|
||||
}
|
||||
return new HttpSuccess(_commandType);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { CommandSalary } from "./CommandSalary";
|
|||
import { CommandRecive } from "./CommandRecive";
|
||||
import { ProfileSalary } from "./ProfileSalary";
|
||||
import { ProfileSalaryHistory } from "./ProfileSalaryHistory";
|
||||
import { CommandSign } from "./CommandSign";
|
||||
|
||||
@Entity("command")
|
||||
export class Command extends EntityBase {
|
||||
|
|
@ -151,6 +152,9 @@ export class Command extends EntityBase {
|
|||
@OneToMany(() => CommandSend, (commandSend) => commandSend.command)
|
||||
commandSends: CommandSend[];
|
||||
|
||||
@OneToMany(() => CommandSign, (commandSign) => commandSign.command)
|
||||
commandSigns: CommandSign[];
|
||||
|
||||
@OneToMany(() => CommandRecive, (commandRecive) => commandRecive.command)
|
||||
commandRecives: CommandRecive[];
|
||||
|
||||
|
|
|
|||
80
src/entities/CommandSign.ts
Normal file
80
src/entities/CommandSign.ts
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import { Entity, Column, JoinColumn, ManyToOne, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { Command } from "./Command";
|
||||
import { Profile } from "./Profile";
|
||||
|
||||
@Entity("commandSign")
|
||||
export class CommandSign extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คำนำหน้า",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
prefix: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
firstName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "สกุล",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
lastName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ตำแหน่ง",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
position: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ความเห็น",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
comment: string;
|
||||
|
||||
@Column({
|
||||
comment: "เป็นผู้มีอำนาจลงนาม",
|
||||
default: false,
|
||||
})
|
||||
isSignatory: boolean;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง command",
|
||||
})
|
||||
commandId: string;
|
||||
|
||||
@ManyToOne(() => Command, (command) => command.commandSigns)
|
||||
@JoinColumn({ name: "commandId" })
|
||||
command: Command;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง profile",
|
||||
})
|
||||
profileId: string;
|
||||
|
||||
@ManyToOne(() => Profile, (profile) => profile.commandSigns)
|
||||
@JoinColumn({ name: "profileId" })
|
||||
profile: Profile;
|
||||
}
|
||||
|
||||
export class CreateCommandSign {
|
||||
@Column()
|
||||
name: string;
|
||||
}
|
||||
|
||||
// export type UpdateCommandSign = Partial<CreateCommandSign>;
|
||||
|
|
@ -34,6 +34,7 @@ import { CommandSend } from "./CommandSend";
|
|||
import { DevelopmentRequest } from "./DevelopmentRequest";
|
||||
import { StateOperatorUser } from "./StateOperatorUser";
|
||||
import { StateUserComment } from "./StateUserComment";
|
||||
import { CommandSign } from "./CommandSign";
|
||||
|
||||
@Entity("profile")
|
||||
export class Profile extends EntityBase {
|
||||
|
|
@ -122,7 +123,7 @@ export class Profile extends EntityBase {
|
|||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "สถานะอีเมล",//VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน
|
||||
comment: "สถานะอีเมล", //VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน
|
||||
default: null,
|
||||
})
|
||||
statusEmail: string;
|
||||
|
|
@ -387,6 +388,9 @@ export class Profile extends EntityBase {
|
|||
@OneToMany(() => CommandSend, (v) => v.profile)
|
||||
commandSends: CommandSend[];
|
||||
|
||||
@OneToMany(() => CommandSign, (v) => v.profile)
|
||||
commandSigns: CommandSign[];
|
||||
|
||||
@OneToMany(() => StateOperatorUser, (v) => v.profile)
|
||||
stateOperatorUsers: StateOperatorUser[];
|
||||
|
||||
|
|
|
|||
|
|
@ -52,30 +52,32 @@ class CallAPI {
|
|||
api_key: process.env.API_KEY,
|
||||
},
|
||||
});
|
||||
if (log) addLogSequence(request, {
|
||||
action: "request",
|
||||
status: "success",
|
||||
description: "connected",
|
||||
request: {
|
||||
method: "POST",
|
||||
url: url,
|
||||
payload: JSON.stringify(sendData),
|
||||
response: JSON.stringify(response.data.result),
|
||||
},
|
||||
});
|
||||
if (log)
|
||||
addLogSequence(request, {
|
||||
action: "request",
|
||||
status: "success",
|
||||
description: "connected",
|
||||
request: {
|
||||
method: "POST",
|
||||
url: url,
|
||||
payload: JSON.stringify(sendData),
|
||||
response: JSON.stringify(response.data.result),
|
||||
},
|
||||
});
|
||||
return response.data.result;
|
||||
} catch (error) {
|
||||
if (log) addLogSequence(request, {
|
||||
action: "request",
|
||||
status: "error",
|
||||
description: "unconnected",
|
||||
request: {
|
||||
method: "POST",
|
||||
url: url,
|
||||
payload: JSON.stringify(sendData),
|
||||
response: JSON.stringify(error),
|
||||
},
|
||||
});
|
||||
if (log)
|
||||
addLogSequence(request, {
|
||||
action: "request",
|
||||
status: "error",
|
||||
description: "unconnected",
|
||||
request: {
|
||||
method: "POST",
|
||||
url: url,
|
||||
payload: JSON.stringify(sendData),
|
||||
response: JSON.stringify(error),
|
||||
},
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
18
src/migration/1730456393834-add_table_commandSign.ts
Normal file
18
src/migration/1730456393834-add_table_commandSign.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTableCommandSign1730456393834 implements MigrationInterface {
|
||||
name = 'AddTableCommandSign1730456393834'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`commandSign\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'สกุล', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`comment\` varchar(255) NULL COMMENT 'ความเห็น', \`isActive\` tinyint NOT NULL COMMENT 'เป็นผู้มีอำนาจลงนาม' DEFAULT 0, \`commandId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง command', \`profileId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง profile', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` ADD CONSTRAINT \`FK_143488a80d2317daa9333e1a726\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` ADD CONSTRAINT \`FK_748a443f8f9d4fa32dfddad0b2e\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` DROP FOREIGN KEY \`FK_748a443f8f9d4fa32dfddad0b2e\``);
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` DROP FOREIGN KEY \`FK_143488a80d2317daa9333e1a726\``);
|
||||
await queryRunner.query(`DROP TABLE \`commandSign\``);
|
||||
}
|
||||
|
||||
}
|
||||
14
src/migration/1730463698383-add_table_commandSign1.ts
Normal file
14
src/migration/1730463698383-add_table_commandSign1.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTableCommandSign11730463698383 implements MigrationInterface {
|
||||
name = 'AddTableCommandSign11730463698383'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` CHANGE \`isActive\` \`isSignatory\` tinyint NOT NULL COMMENT 'เป็นผู้มีอำนาจลงนาม' DEFAULT '0'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` CHANGE \`isSignatory\` \`isActive\` tinyint NOT NULL COMMENT 'เป็นผู้มีอำนาจลงนาม' DEFAULT '0'`);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue