no message
This commit is contained in:
parent
04406080dc
commit
fb5a30c699
4 changed files with 123 additions and 1 deletions
|
|
@ -95,7 +95,6 @@ export class OrganizationController extends Controller {
|
||||||
activeName: orgRevisionActive == null ? null : orgRevisionActive.orgRevisionName,
|
activeName: orgRevisionActive == null ? null : orgRevisionActive.orgRevisionName,
|
||||||
draftId: orgRevisionDraf == null ? null : orgRevisionDraf.id,
|
draftId: orgRevisionDraf == null ? null : orgRevisionDraf.id,
|
||||||
draftName: orgRevisionDraf == null ? null : orgRevisionDraf.orgRevisionName,
|
draftName: orgRevisionDraf == null ? null : orgRevisionDraf.orgRevisionName,
|
||||||
|
|
||||||
orgPublishDate: orgRevisionDraf == null ? null : orgRevisionDraf.orgPublishDate,
|
orgPublishDate: orgRevisionDraf == null ? null : orgRevisionDraf.orgPublishDate,
|
||||||
isPublic: orgRevisionDraf == null || orgRevisionDraf.orgRevisionName == null ? false : true,
|
isPublic: orgRevisionDraf == null || orgRevisionDraf.orgRevisionName == null ? false : true,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -337,6 +337,105 @@ export class PositionController extends Controller {
|
||||||
return new HttpSuccess(posDict.id);
|
return new HttpSuccess(posDict.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขตำแหน่ง
|
||||||
|
*
|
||||||
|
* @summary แก้ไขตำแหน่ง (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Put("position/executive/{id}")
|
||||||
|
@Example([
|
||||||
|
{
|
||||||
|
positionName: "นักบริหาร",
|
||||||
|
positionField: "บริหาร",
|
||||||
|
posTypeId: "08db9e81-fc46-4e95-8b33-be4ca0016abf",
|
||||||
|
posLevelId: "08db9e81-fc46-4e95-8b33-be4ca0016abf",
|
||||||
|
posExecutiveId: "08db9e81-fc46-4e95-8b33-be4ca0016abf",
|
||||||
|
positionExecutiveField: "นักบริหาร",
|
||||||
|
positionArea: "บริหาร",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
async updatePositionExecutive(
|
||||||
|
@Path() id: string,
|
||||||
|
@Body()
|
||||||
|
requestBody: UpdatePosDict,
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
|
// await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||||
|
const posDict = await this.posDictRepository.findOne({
|
||||||
|
where: { id: id },
|
||||||
|
});
|
||||||
|
if (!posDict) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkPosTypeId = await this.posTypeRepository.findOne({
|
||||||
|
where: { id: requestBody.posTypeId },
|
||||||
|
});
|
||||||
|
if (!checkPosTypeId) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosTypeId");
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkPosLevelId = await this.posLevelRepository.findOne({
|
||||||
|
where: { id: requestBody.posLevelId },
|
||||||
|
});
|
||||||
|
if (!checkPosLevelId) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosLevelId");
|
||||||
|
}
|
||||||
|
|
||||||
|
const _null: any = null;
|
||||||
|
if (requestBody.posExecutiveId == "") {
|
||||||
|
requestBody.posExecutiveId = _null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestBody.posExecutiveId != null && requestBody.posExecutiveId != "") {
|
||||||
|
const checkPosExecutiveId = await this.posExecutiveRepository.findOne({
|
||||||
|
where: { id: requestBody.posExecutiveId },
|
||||||
|
});
|
||||||
|
if (!checkPosExecutiveId) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosExecutiveId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rowRepeated = await this.posDictRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: Not(id),
|
||||||
|
posDictName: requestBody.posDictName,
|
||||||
|
posDictField: requestBody.posDictField,
|
||||||
|
posTypeId: requestBody.posTypeId,
|
||||||
|
posLevelId: requestBody.posLevelId,
|
||||||
|
posExecutiveId: requestBody.posExecutiveId ? requestBody.posExecutiveId : "",
|
||||||
|
posDictExecutiveField: requestBody.posDictExecutiveField
|
||||||
|
? requestBody.posDictExecutiveField
|
||||||
|
: "",
|
||||||
|
posDictArea: requestBody.posDictArea ? requestBody.posDictArea : "",
|
||||||
|
isSpecial: requestBody.isSpecial,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (rowRepeated) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ข้อมูล Row นี้มีอยู่ในระบบแล้ว");
|
||||||
|
}
|
||||||
|
const before = structuredClone(posDict);
|
||||||
|
Object.assign(posDict, requestBody);
|
||||||
|
posDict.lastUpdateUserId = request.user.sub;
|
||||||
|
posDict.lastUpdateFullName = request.user.name;
|
||||||
|
posDict.lastUpdatedAt = new Date();
|
||||||
|
posDict.posDictName = requestBody.posDictName;
|
||||||
|
posDict.posDictField = requestBody.posDictField;
|
||||||
|
posDict.posTypeId = requestBody.posTypeId;
|
||||||
|
posDict.posLevelId = requestBody.posLevelId;
|
||||||
|
posDict.posExecutiveId = requestBody.posExecutiveId ? requestBody.posExecutiveId : null;
|
||||||
|
posDict.posDictExecutiveField = requestBody.posDictExecutiveField
|
||||||
|
? requestBody.posDictExecutiveField
|
||||||
|
: "";
|
||||||
|
posDict.posDictArea = requestBody.posDictArea ? requestBody.posDictArea : "";
|
||||||
|
posDict.isSpecial = requestBody.isSpecial;
|
||||||
|
// this.posDictRepository.merge(posDict, requestBody);
|
||||||
|
await this.posDictRepository.save(posDict, { data: request });
|
||||||
|
setLogDataDiff(request, { before, after: posDict });
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API แก้ไขตำแหน่ง
|
* API แก้ไขตำแหน่ง
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,13 @@ export class OrgRevision extends EntityBase {
|
||||||
})
|
})
|
||||||
orgRevisionName: string;
|
orgRevisionName: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "หมายเหตุ",
|
||||||
|
length: 255,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
remark: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment: "สถานะเป็นโครงสร้างปัจจุบันหรือไม่",
|
comment: "สถานะเป็นโครงสร้างปัจจุบันหรือไม่",
|
||||||
default: false,
|
default: false,
|
||||||
|
|
@ -82,5 +89,8 @@ export class CreateOrgRevision {
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
orgRevisionId?: string;
|
orgRevisionId?: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
remark: string;
|
||||||
}
|
}
|
||||||
export type UpdateOrgRevision = Partial<OrgRevision>;
|
export type UpdateOrgRevision = Partial<OrgRevision>;
|
||||||
|
|
|
||||||
14
src/migration/1732163306077-updata_org_add_remark.ts
Normal file
14
src/migration/1732163306077-updata_org_add_remark.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdataOrgAddRemark1732163306077 implements MigrationInterface {
|
||||||
|
name = 'UpdataOrgAddRemark1732163306077'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRevision\` ADD \`remark\` varchar(255) NULL COMMENT 'หมายเหตุ'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRevision\` DROP COLUMN \`remark\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue