add field org_053

This commit is contained in:
AdisakKanthawilang 2024-02-06 11:30:41 +07:00
parent cea12a540f
commit 31a7357c19
3 changed files with 16 additions and 14 deletions

View file

@ -712,7 +712,7 @@ export class PositionController extends Controller {
const [posMaster, total] = await this.posMasterRepository.findAndCount({
where: keywordConditions,
order: { posMasterOrder: "ASC" },
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"],
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4" ,"current_holder" ,"next_holder"],
skip: (body.page - 1) * body.pageSize,
take: body.pageSize,
});
@ -736,6 +736,8 @@ export class PositionController extends Controller {
posMasterNoPrefix: posMaster.posMasterNoPrefix,
posMasterNo: posMaster.posMasterNo,
posMasterNoSuffix: posMaster.posMasterNoSuffix,
fullNameNextHolder: posMaster.current_holder.prefix+posMaster.current_holder.firstName+" "+posMaster.current_holder.lastName,
fullNameCurrentHolder: posMaster.next_holder.prefix+posMaster.next_holder.firstName+" "+posMaster.next_holder.lastName,
orgShortname:
body.type === 0
? posMaster.orgRoot.orgRootShortName

View file

@ -137,15 +137,13 @@ export class PosMaster extends EntityBase {
default: null,
})
profileIdNextHolder: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง orgRevision",
})
orgRevisionId: string; //fk
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@ -170,12 +168,12 @@ export class PosMaster extends EntityBase {
@JoinColumn({ name: "orgChild4Id" })
orgChild4: OrgChild4;
@ManyToOne(() => Profile, (profile) => profile.posMasters)
@JoinColumn({ name: "profileIdCurrentHolder" })
profile: Profile;
@OneToOne(() => Profile)
@JoinColumn()
current_holder: Profile;
@ManyToOne(() => Profile, (profile) => profile.next_holder_posMasters)
@JoinColumn({ name: "profileIdNextHolder" })
@OneToOne(() => Profile)
@JoinColumn()
next_holder: Profile;
@OneToMany(() => Position, (position) => position.posMaster)

View file

@ -1,4 +1,4 @@
import { Entity, Column, OneToMany} from "typeorm";
import { Entity, Column, OneToMany, OneToOne, JoinColumn} from "typeorm";
import { EntityBase } from "./base/Base";
import { PosMaster } from "./PosMaster";
@ -36,11 +36,13 @@ export class Profile extends EntityBase {
})
citizenId: string;
@OneToMany(() => PosMaster, (posMaster) => posMaster.profile)
posMasters: PosMaster[];
@OneToOne(() => PosMaster)
@JoinColumn()
current_holder: PosMaster;
@OneToMany(() => PosMaster, (posMaster) => posMaster.next_holder)
next_holder_posMasters: PosMaster[];
@OneToOne(() => PosMaster)
@JoinColumn()
next_holder: PosMaster;
}
export class CreateProfile {