ผูกสิทกับ list ทะเบียน

This commit is contained in:
kittapath 2024-08-19 21:04:09 +07:00
parent 078b1acdd4
commit 224a53e933
3 changed files with 125 additions and 41 deletions

View file

@ -2599,7 +2599,7 @@ export class ProfileController extends Controller {
} else if (node === 4 && nodeId) {
nodeCondition = "current_holders.orgChild4Id = :nodeId";
}
// let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
const [record, total] = await this.profileRepo
.createQueryBuilder("profile")
.leftJoinAndSelect("profile.posLevel", "posLevel")
@ -2612,46 +2612,46 @@ export class ProfileController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
// .andWhere(
// _data.root != undefined && _data.root != null
// ? `current_holders.orgRootId IN (:...node)`
// : "1=1",
// {
// node: _data.root,
// },
// )
// .andWhere(
// _data.child1 != undefined && _data.child1 != null
// ? `current_holders.orgChild1Id IN (:...node)`
// : "1=1",
// {
// node: _data.child1,
// },
// )
// .andWhere(
// _data.child2 != undefined && _data.child2 != null
// ? `current_holders.orgChild2Id IN (:...node)`
// : "1=1",
// {
// node: _data.child2,
// },
// )
// .andWhere(
// _data.child3 != undefined && _data.child3 != null
// ? `current_holders.orgChild3Id IN (:...node)`
// : "1=1",
// {
// node: _data.child3,
// },
// )
// .andWhere(
// _data.child4 != undefined && _data.child4 != null
// ? `current_holders.orgChild4Id IN (:...node)`
// : "1=1",
// {
// node: _data.child4,
// },
// )
.andWhere(
_data.root != undefined && _data.root != null
? `current_holders.orgRootId IN (:...root)`
: "1=1",
{
root: _data.root,
},
)
.andWhere(
_data.child1 != undefined && _data.child1 != null
? `current_holders.orgChild1Id IN (:...child1)`
: "1=1",
{
child1: _data.child1,
},
)
.andWhere(
_data.child2 != undefined && _data.child2 != null
? `current_holders.orgChild2Id IN (:...child2)`
: "1=1",
{
child2: _data.child2,
},
)
.andWhere(
_data.child3 != undefined && _data.child3 != null
? `current_holders.orgChild3Id IN (:...child3)`
: "1=1",
{
child3: _data.child3,
},
)
.andWhere(
_data.child4 != undefined && _data.child4 != null
? `current_holders.orgChild4Id IN (:...child4)`
: "1=1",
{
child4: _data.child4,
},
)
.andWhere(
posType != undefined && posType != null && posType != ""
? "posType.posTypeName LIKE :keyword1"

View file

@ -1079,6 +1079,7 @@ export class ProfileEmployeeController extends Controller {
*/
@Get()
async listProfile(
@Request() request: RequestWithUser,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query() searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position",
@ -1097,6 +1098,7 @@ export class ProfileEmployeeController extends Controller {
} else if (searchField == "position") {
queryLike = "profileEmployee.position LIKE :keyword";
}
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_EMP");
const [record, total] = await this.profileRepo
.createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
@ -1109,6 +1111,46 @@ export class ProfileEmployeeController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.andWhere(
_data.root != undefined && _data.root != null
? `current_holders.orgRootId IN (:...root)`
: "1=1",
{
root: _data.root,
},
)
.andWhere(
_data.child1 != undefined && _data.child1 != null
? `current_holders.orgChild1Id IN (:...child1)`
: "1=1",
{
child1: _data.child1,
},
)
.andWhere(
_data.child2 != undefined && _data.child2 != null
? `current_holders.orgChild2Id IN (:...child2)`
: "1=1",
{
child2: _data.child2,
},
)
.andWhere(
_data.child3 != undefined && _data.child3 != null
? `current_holders.orgChild3Id IN (:...child3)`
: "1=1",
{
child3: _data.child3,
},
)
.andWhere(
_data.child4 != undefined && _data.child4 != null
? `current_holders.orgChild4Id IN (:...child4)`
: "1=1",
{
child4: _data.child4,
},
)
.andWhere(
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? queryLike

View file

@ -1078,6 +1078,7 @@ export class ProfileEmployeeTempController extends Controller {
*/
@Get()
async listProfile(
@Request() request: RequestWithUser,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query() searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position",
@ -1096,6 +1097,7 @@ export class ProfileEmployeeTempController extends Controller {
} else if (searchField == "position") {
queryLike = "profileEmployee.position LIKE :keyword";
}
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_TEMP");
const [record, total] = await this.profileRepo
.createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
@ -1108,6 +1110,46 @@ export class ProfileEmployeeTempController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.andWhere(
_data.root != undefined && _data.root != null
? `current_holders.orgRootId IN (:...root)`
: "1=1",
{
root: _data.root,
},
)
.andWhere(
_data.child1 != undefined && _data.child1 != null
? `current_holders.orgChild1Id IN (:...child1)`
: "1=1",
{
child1: _data.child1,
},
)
.andWhere(
_data.child2 != undefined && _data.child2 != null
? `current_holders.orgChild2Id IN (:...child2)`
: "1=1",
{
child2: _data.child2,
},
)
.andWhere(
_data.child3 != undefined && _data.child3 != null
? `current_holders.orgChild3Id IN (:...child3)`
: "1=1",
{
child3: _data.child3,
},
)
.andWhere(
_data.child4 != undefined && _data.child4 != null
? `current_holders.orgChild4Id IN (:...child4)`
: "1=1",
{
child4: _data.child4,
},
)
.andWhere(
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? queryLike