add idcard
This commit is contained in:
parent
9f66786502
commit
76d9be4da1
4 changed files with 71 additions and 30 deletions
|
|
@ -26,7 +26,7 @@ import { Assign } from "../entities/Assign";
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class PersonalController extends Controller {
|
export class PersonalController extends Controller {
|
||||||
|
|
@ -40,37 +40,60 @@ export class PersonalController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("add")
|
@Post("add")
|
||||||
async AddPersonal(@Body() requestBody: PostPersonal, @Request() request: RequestWithUser) {
|
async AddPersonal(
|
||||||
|
@Body() requestBody: PostPersonal,
|
||||||
|
@Request() request: RequestWithUser
|
||||||
|
) {
|
||||||
await new permission().PermissionCreate(request, "SYS_PROBATION");
|
await new permission().PermissionCreate(request, "SYS_PROBATION");
|
||||||
|
|
||||||
const checkPersonal: number = await this.personalRepository.count({
|
const checkPersonal: number = await this.personalRepository.count({
|
||||||
where: { personal_id: requestBody.id },
|
where: { personal_id: requestBody.id },
|
||||||
});
|
});
|
||||||
if (checkPersonal > 0) {
|
if (checkPersonal > 0) {
|
||||||
throw new HttpError(HttpStatusCode.BAD_REQUEST, "ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.BAD_REQUEST,
|
||||||
|
"ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let organization = await (requestBody.orgChild4Name ? requestBody.orgChild4Name + "/" : "");
|
let organization = await (requestBody.orgChild4Name
|
||||||
organization += await (requestBody.orgChild3Name ? requestBody.orgChild3Name + "/" : "");
|
? requestBody.orgChild4Name + "/"
|
||||||
organization += await (requestBody.orgChild2Name ? requestBody.orgChild2Name + "/" : "");
|
: "");
|
||||||
organization += await (requestBody.orgChild1Name ? requestBody.orgChild1Name + "/" : "");
|
organization += await (requestBody.orgChild3Name
|
||||||
organization += await (requestBody.orgRootName ? requestBody.orgRootName : "");
|
? requestBody.orgChild3Name + "/"
|
||||||
|
: "");
|
||||||
|
organization += await (requestBody.orgChild2Name
|
||||||
|
? requestBody.orgChild2Name + "/"
|
||||||
|
: "");
|
||||||
|
organization += await (requestBody.orgChild1Name
|
||||||
|
? requestBody.orgChild1Name + "/"
|
||||||
|
: "");
|
||||||
|
organization += await (requestBody.orgRootName
|
||||||
|
? requestBody.orgRootName
|
||||||
|
: "");
|
||||||
|
|
||||||
const personalData = Object.assign(new Personal());
|
const personalData = Object.assign(new Personal());
|
||||||
personalData.personal_id = requestBody.id;
|
personalData.personal_id = requestBody.id;
|
||||||
personalData.order_number = requestBody.order_number ? requestBody.order_number : "";
|
personalData.order_number = requestBody.order_number
|
||||||
|
? requestBody.order_number
|
||||||
|
: "";
|
||||||
personalData.probation_status = 1;
|
personalData.probation_status = 1;
|
||||||
personalData.createdUserId = request.user.sub;
|
personalData.createdUserId = request.user.sub;
|
||||||
personalData.createdFullName = request.user.name;
|
personalData.createdFullName = request.user.name;
|
||||||
personalData.updateUserId = request.user.sub;
|
personalData.updateUserId = request.user.sub;
|
||||||
personalData.updateFullName = request.user.name;
|
personalData.updateFullName = request.user.name;
|
||||||
|
|
||||||
|
personalData.idcard = requestBody.idcard;
|
||||||
personalData.prefixName = requestBody.prefix;
|
personalData.prefixName = requestBody.prefix;
|
||||||
personalData.firstName = requestBody.firstName;
|
personalData.firstName = requestBody.firstName;
|
||||||
personalData.lastName = requestBody.lastName;
|
personalData.lastName = requestBody.lastName;
|
||||||
personalData.isProbation = requestBody.isProbation ? 1 : 0;
|
personalData.isProbation = requestBody.isProbation ? 1 : 0;
|
||||||
personalData.positionLevelName = requestBody.posLevelName ? requestBody.posLevelName : "";
|
personalData.positionLevelName = requestBody.posLevelName
|
||||||
personalData.positionName = requestBody.position ? requestBody.position : "";
|
? requestBody.posLevelName
|
||||||
|
: "";
|
||||||
|
personalData.positionName = requestBody.position
|
||||||
|
? requestBody.position
|
||||||
|
: "";
|
||||||
personalData.positionLineName = requestBody.posLineName;
|
personalData.positionLineName = requestBody.posLineName;
|
||||||
personalData.positionTypeName = requestBody.posTypeName;
|
personalData.positionTypeName = requestBody.posTypeName;
|
||||||
personalData.posNo = requestBody.posNo ? requestBody.posNo : "";
|
personalData.posNo = requestBody.posNo ? requestBody.posNo : "";
|
||||||
|
|
@ -104,7 +127,7 @@ export class PersonalController extends Controller {
|
||||||
if (status) {
|
if (status) {
|
||||||
conditions.probation_status = status;
|
conditions.probation_status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [lists, total] = await this.personalRepository.findAndCount({
|
const [lists, total] = await this.personalRepository.findAndCount({
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
where: conditions,
|
where: conditions,
|
||||||
|
|
@ -113,7 +136,10 @@ export class PersonalController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!lists) {
|
if (!lists) {
|
||||||
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ไม่สามารถแสดงข้อมูลได้");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"ไม่สามารถแสดงข้อมูลได้"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result: any = [];
|
let result: any = [];
|
||||||
|
|
@ -130,6 +156,10 @@ export class PersonalController extends Controller {
|
||||||
personal_id: item.personal_id,
|
personal_id: item.personal_id,
|
||||||
ordering: index + 1,
|
ordering: index + 1,
|
||||||
name: item.prefixName + item.firstName + " " + item.lastName,
|
name: item.prefixName + item.firstName + " " + item.lastName,
|
||||||
|
idcard: item.idcard,
|
||||||
|
prefixName: item.prefixName,
|
||||||
|
firstName: item.firstName,
|
||||||
|
lastName: item.lastName,
|
||||||
position_line: item.positionName,
|
position_line: item.positionName,
|
||||||
position_level: item.positionLevelName,
|
position_level: item.positionLevelName,
|
||||||
position_type: item.positionTypeName,
|
position_type: item.positionTypeName,
|
||||||
|
|
@ -138,7 +168,7 @@ export class PersonalController extends Controller {
|
||||||
order_number: item.order_number,
|
order_number: item.order_number,
|
||||||
probation_status: item.probation_status,
|
probation_status: item.probation_status,
|
||||||
});
|
});
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return new HttpSuccess({ data: result, total: total });
|
return new HttpSuccess({ data: result, total: total });
|
||||||
|
|
@ -151,7 +181,10 @@ export class PersonalController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
async GetPersonal(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Query() personal_id: string
|
||||||
|
) {
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: { personal_id: personal_id },
|
where: { personal_id: personal_id },
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,12 @@ export class Personal extends EntityBase {
|
||||||
})
|
})
|
||||||
organization: string;
|
organization: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "เลขบัตรประจำตัวประชาชน",
|
||||||
|
})
|
||||||
|
idcard: string;
|
||||||
|
|
||||||
@OneToMany(() => Assign, (assign: Assign) => assign.personal_id)
|
@OneToMany(() => Assign, (assign: Assign) => assign.personal_id)
|
||||||
@JoinColumn({ name: "personal_id" })
|
@JoinColumn({ name: "personal_id" })
|
||||||
assign: Assign[];
|
assign: Assign[];
|
||||||
|
|
@ -147,6 +153,8 @@ export class CreatePersonal {
|
||||||
orgRootName: string;
|
orgRootName: string;
|
||||||
@Column()
|
@Column()
|
||||||
organization: string;
|
organization: string;
|
||||||
|
@Column()
|
||||||
|
idcard: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PostPersonal {
|
export class PostPersonal {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class UpdateAssigntb1725594553970 implements MigrationInterface {
|
|
||||||
name = "UpdateAssigntb1725594553970";
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`assign\` ADD \`other_desc\` varchar(255) NULL COMMENT 'กฎหมายอื่นๆ'`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`assign\` DROP COLUMN \`other_desc\``);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
15
src/migration/1728384119754-add-idcard.ts
Normal file
15
src/migration/1728384119754-add-idcard.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddIdcard1728384119754 implements MigrationInterface {
|
||||||
|
name = "AddIdcard1728384119754";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE \`personal\` ADD \`idcard\` varchar(255) NULL COMMENT 'เลขบัตรประจำตัวประชาชน'`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`personal\` DROP COLUMN \`idcard\``);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue