แนบไฟล์คำสั่ง
This commit is contained in:
parent
9d755fc8ff
commit
d3aa76b3f8
6 changed files with 107 additions and 6 deletions
|
|
@ -41,9 +41,9 @@ export class CommandSalaryController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("list")
|
@Get("list")
|
||||||
async Get() {
|
async Get(@Query() commandSysId: string) {
|
||||||
const _commandSalary = await this.commandSalaryRepository.find({
|
const _commandSalary = await this.commandSalaryRepository.find({
|
||||||
where: { isActive: true },
|
where: { isActive: true, commandSysId: commandSysId },
|
||||||
select: [
|
select: [
|
||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ export class CommandTypeController extends Controller {
|
||||||
"name",
|
"name",
|
||||||
"commandSysId",
|
"commandSysId",
|
||||||
"code",
|
"code",
|
||||||
|
"fileCover",
|
||||||
|
"fileAttachment",
|
||||||
"detailHeader",
|
"detailHeader",
|
||||||
"detailBody",
|
"detailBody",
|
||||||
"detailFooter",
|
"detailFooter",
|
||||||
|
|
@ -57,7 +59,7 @@ export class CommandTypeController extends Controller {
|
||||||
"createdFullName",
|
"createdFullName",
|
||||||
"lastUpdateFullName",
|
"lastUpdateFullName",
|
||||||
],
|
],
|
||||||
order: { name: "ASC" },
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(_commandType);
|
return new HttpSuccess(_commandType);
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +85,7 @@ export class CommandTypeController extends Controller {
|
||||||
isActive == null || isActive == undefined ? null : `${isActive == true ? 1 : 0}`,
|
isActive == null || isActive == undefined ? null : `${isActive == true ? 1 : 0}`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.orderBy("commandType.name", "ASC")
|
.orderBy("commandType.createdAt", "ASC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
@ -106,6 +108,8 @@ export class CommandTypeController extends Controller {
|
||||||
"name",
|
"name",
|
||||||
"commandSysId",
|
"commandSysId",
|
||||||
"code",
|
"code",
|
||||||
|
"fileCover",
|
||||||
|
"fileAttachment",
|
||||||
"isActive",
|
"isActive",
|
||||||
"detailHeader",
|
"detailHeader",
|
||||||
"detailBody",
|
"detailBody",
|
||||||
|
|
@ -229,6 +233,60 @@ export class CommandTypeController extends Controller {
|
||||||
return new HttpSuccess(_commandType.id);
|
return new HttpSuccess(_commandType.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขรายการ body ประเภทคำสั่ง
|
||||||
|
*
|
||||||
|
* @summary ORG_056 - CRUD ประเภทคำสั่ง (ADMIN) #61
|
||||||
|
*
|
||||||
|
* @param {string} id Id ประเภทคำสั่ง
|
||||||
|
*/
|
||||||
|
@Put("cover/{id}")
|
||||||
|
async PutCover(
|
||||||
|
@Path() id: string,
|
||||||
|
@Body()
|
||||||
|
requestBody: { name: string },
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
) {
|
||||||
|
const _commandType = await this.commandTypeRepository.findOne({ where: { id: id } });
|
||||||
|
if (!_commandType) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทคำสั่งชื่อนี้");
|
||||||
|
}
|
||||||
|
_commandType.fileCover = requestBody.name;
|
||||||
|
_commandType.lastUpdateUserId = request.user.sub;
|
||||||
|
_commandType.lastUpdateFullName = request.user.name;
|
||||||
|
_commandType.lastUpdatedAt = new Date();
|
||||||
|
this.commandTypeRepository.merge(_commandType, requestBody);
|
||||||
|
await this.commandTypeRepository.save(_commandType);
|
||||||
|
return new HttpSuccess(_commandType.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขรายการ body ประเภทคำสั่ง
|
||||||
|
*
|
||||||
|
* @summary ORG_056 - CRUD ประเภทคำสั่ง (ADMIN) #61
|
||||||
|
*
|
||||||
|
* @param {string} id Id ประเภทคำสั่ง
|
||||||
|
*/
|
||||||
|
@Put("attachment/{id}")
|
||||||
|
async PutAttachment(
|
||||||
|
@Path() id: string,
|
||||||
|
@Body()
|
||||||
|
requestBody: { name: string },
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
) {
|
||||||
|
const _commandType = await this.commandTypeRepository.findOne({ where: { id: id } });
|
||||||
|
if (!_commandType) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทคำสั่งชื่อนี้");
|
||||||
|
}
|
||||||
|
_commandType.fileAttachment = requestBody.name;
|
||||||
|
_commandType.lastUpdateUserId = request.user.sub;
|
||||||
|
_commandType.lastUpdateFullName = request.user.name;
|
||||||
|
_commandType.lastUpdatedAt = new Date();
|
||||||
|
this.commandTypeRepository.merge(_commandType, requestBody);
|
||||||
|
await this.commandTypeRepository.save(_commandType);
|
||||||
|
return new HttpSuccess(_commandType.id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ลบรายการประเภทคำสั่ง
|
* API ลบรายการประเภทคำสั่ง
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ export class ImportDataController extends Controller {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
profiles.map(async (_item) => {
|
profiles.map(async (_item) => {
|
||||||
const existingProfile = await this.HR_POSITION_OFFICERRepo.find({
|
const existingProfile = await this.HR_POSITION_OFFICERRepo.find({
|
||||||
where: { CIT: _item.citizenId },
|
where: { CIT: _item.citizenId, FLAG_PERSON_TYPE: "1" },
|
||||||
select: [
|
select: [
|
||||||
"CIT",
|
"CIT",
|
||||||
"MP_POS_DATE",
|
"MP_POS_DATE",
|
||||||
|
|
@ -319,7 +319,9 @@ export class ImportDataController extends Controller {
|
||||||
rowCount++;
|
rowCount++;
|
||||||
const profileSalary = new ProfileSalary();
|
const profileSalary = new ProfileSalary();
|
||||||
profileSalary.date =
|
profileSalary.date =
|
||||||
item.MP_POS_DATE == "" ? null_ : Extension.ConvertToDateTimeV2(item.MP_POS_DATE);
|
item.MP_POS_DATE == ""
|
||||||
|
? null_
|
||||||
|
: new Date(item.MP_POS_DATE.replace(" +0700 +07:00", ""));
|
||||||
const SALARY: any =
|
const SALARY: any =
|
||||||
item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY);
|
item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY);
|
||||||
profileSalary.amount = SALARY;
|
profileSalary.amount = SALARY;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,22 @@ export class CommandType extends EntityBase {
|
||||||
})
|
})
|
||||||
code: string;
|
code: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "คำสั่งเรื่อง",
|
||||||
|
length: 255,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
fileCover: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "คำสั่งเรื่อง",
|
||||||
|
length: 255,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
fileAttachment: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "เนื้อหาคำสั่งส่วนต้น",
|
comment: "เนื้อหาคำสั่งส่วนต้น",
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,13 @@ export class HR_POSITION_OFFICER {
|
||||||
@PrimaryGeneratedColumn()
|
@PrimaryGeneratedColumn()
|
||||||
id!: number;
|
id!: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
FLAG_PERSON_TYPE: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
|
|
|
||||||
18
src/migration/1726474393379-add_CommandSalary.ts
Normal file
18
src/migration/1726474393379-add_CommandSalary.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddCommandSalary1726474393379 implements MigrationInterface {
|
||||||
|
name = 'AddCommandSalary1726474393379'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`commandType\` ADD \`fileCover\` varchar(255) NULL COMMENT 'คำสั่งเรื่อง'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`commandType\` ADD \`fileAttachment\` varchar(255) NULL COMMENT 'คำสั่งเรื่อง'`);
|
||||||
|
// await queryRunner.query(`ALTER TABLE \`HR_POSITION_OFFICER\` ADD \`FLAG_PERSON_TYPE\` text NULL`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
// await queryRunner.query(`ALTER TABLE \`HR_POSITION_OFFICER\` DROP COLUMN \`FLAG_PERSON_TYPE\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`commandType\` DROP COLUMN \`fileAttachment\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`commandType\` DROP COLUMN \`fileCover\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue