Merge branch 'develop' into adiDev
This commit is contained in:
commit
7490c446da
1 changed files with 117 additions and 0 deletions
|
|
@ -21,6 +21,10 @@ import { Profile } from "../entities/Profile";
|
|||
import { Brackets, In, IsNull, Not } from "typeorm";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { OrgChild1 } from "../entities/OrgChild1";
|
||||
import { OrgChild2 } from "../entities/OrgChild2";
|
||||
import { OrgChild3 } from "../entities/OrgChild3";
|
||||
import { OrgChild4 } from "../entities/OrgChild4";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { Position } from "../entities/Position";
|
||||
import { Insignia } from "../entities/Insignia";
|
||||
|
|
@ -40,6 +44,10 @@ import Extension from "../interfaces/extension";
|
|||
@SuccessResponse(HttpStatus.OK, "สำเร็จ")
|
||||
export class OrganizationDotnetController extends Controller {
|
||||
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
||||
private orgChild1Repo = AppDataSource.getRepository(OrgChild1);
|
||||
private orgChild2Repo = AppDataSource.getRepository(OrgChild2);
|
||||
private orgChild3Repo = AppDataSource.getRepository(OrgChild3);
|
||||
private orgChild4Repo = AppDataSource.getRepository(OrgChild4);
|
||||
private orgRevisionRepo = AppDataSource.getRepository(OrgRevision);
|
||||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
|
|
@ -4187,6 +4195,115 @@ export class OrganizationDotnetController extends Controller {
|
|||
return new HttpSuccess(profile_);
|
||||
}
|
||||
|
||||
/**
|
||||
* ค้นหาชื่อหน่วยงาน ส่วนราชการ
|
||||
*
|
||||
* @summary ค้นหาชื่อหน่วยงาน ส่วนราชการ
|
||||
*
|
||||
*/
|
||||
@Post("find-node-name")
|
||||
async findNodeName(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body()
|
||||
body: {
|
||||
node: number;
|
||||
nodeId: string;
|
||||
},
|
||||
) {
|
||||
let findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }
|
||||
});
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
let orgRoot = await this.orgRootRepo.findOne({
|
||||
where: {
|
||||
id: body.nodeId,
|
||||
orgRevisionId: findRevision?.id
|
||||
}
|
||||
});
|
||||
return new HttpSuccess({
|
||||
rootName: orgRoot?.orgRootName ?? null,
|
||||
child1Name: null,
|
||||
child2Name: null,
|
||||
child3Name: null,
|
||||
child4Name: null,
|
||||
});
|
||||
|
||||
case 1:
|
||||
let orgChild1 = await this.orgChild1Repo.findOne({
|
||||
relations: ["orgRoot"],
|
||||
where: {
|
||||
id: body.nodeId,
|
||||
orgRevisionId: findRevision?.id
|
||||
}
|
||||
});
|
||||
return new HttpSuccess({
|
||||
rootName: orgChild1?.orgRoot.orgRootName ?? null,
|
||||
child1Name: orgChild1?.orgChild1Name ?? null,
|
||||
child2Name: null,
|
||||
child3Name: null,
|
||||
child4Name: null,
|
||||
});
|
||||
|
||||
case 2:
|
||||
let orgChild2 = await this.orgChild2Repo.findOne({
|
||||
relations: ["orgRoot", "orgChild1"],
|
||||
where: {
|
||||
id: body.nodeId,
|
||||
orgRevisionId: findRevision?.id
|
||||
}
|
||||
});
|
||||
return new HttpSuccess({
|
||||
rootName: orgChild2?.orgRoot.orgRootName ?? null,
|
||||
child1Name: orgChild2?.orgChild1.orgChild1Name ?? null,
|
||||
child2Name: orgChild2?.orgChild2Name ?? null,
|
||||
child3Name: null,
|
||||
child4Name: null,
|
||||
});
|
||||
|
||||
case 3:
|
||||
let orgChild3 = await this.orgChild3Repo.findOne({
|
||||
relations: ["orgRoot", "orgChild1", "orgChild2"],
|
||||
where: {
|
||||
id: body.nodeId,
|
||||
orgRevisionId: findRevision?.id
|
||||
}
|
||||
});
|
||||
return new HttpSuccess({
|
||||
rootName: orgChild3?.orgRoot.orgRootName ?? null,
|
||||
child1Name: orgChild3?.orgChild1.orgChild1Name ?? null,
|
||||
child2Name: orgChild3?.orgChild2.orgChild2Name ?? null,
|
||||
child3Name: orgChild3?.orgChild3Name ?? null,
|
||||
child4Name: null,
|
||||
});
|
||||
|
||||
case 4:
|
||||
let orgChild4 = await this.orgChild4Repo.findOne({
|
||||
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"],
|
||||
where: {
|
||||
id: body.nodeId,
|
||||
orgRevisionId: findRevision?.id
|
||||
}
|
||||
});
|
||||
return new HttpSuccess({
|
||||
rootName: orgChild4?.orgRoot.orgRootName ?? null,
|
||||
child1Name: orgChild4?.orgChild1.orgChild1Name ?? null,
|
||||
child2Name: orgChild4?.orgChild2.orgChild2Name ?? null,
|
||||
child3Name: orgChild4?.orgChild3.orgChild3Name ?? null,
|
||||
child4Name: orgChild4?.orgChild4Name ?? null,
|
||||
});
|
||||
|
||||
default:
|
||||
return new HttpSuccess({
|
||||
rootName: null,
|
||||
child1Name: null,
|
||||
child2Name: null,
|
||||
child3Name: null,
|
||||
child4Name: null,
|
||||
});;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* รายชื่อขรก. ตามสิทธิ์ admin
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue