edit search
This commit is contained in:
parent
4ca001e2ff
commit
176924a268
4 changed files with 270 additions and 66 deletions
|
|
@ -24,6 +24,8 @@ import {
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Brackets } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
|
||||
@Route("api/v1/org/profile-employee/edit")
|
||||
@Tags("ProfileEmployeeEdit")
|
||||
|
|
@ -31,6 +33,7 @@ import { Brackets } from "typeorm";
|
|||
export class ProfileEditEmployeeController extends Controller {
|
||||
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private profileEditRepository = AppDataSource.getRepository(ProfileEdit);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
|
||||
@Get("user")
|
||||
public async detailProfileEditUserEmp(
|
||||
|
|
@ -60,17 +63,19 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
new Brackets((qb) => {
|
||||
qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
}).orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
).orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.remark LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
})
|
||||
.orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.remark LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
|
|
@ -100,42 +105,107 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
|
||||
@Get("admin")
|
||||
public async detailProfileEditAdminEmp(
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword: string = "",
|
||||
@Query("status") status: string = "",
|
||||
) {
|
||||
let data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_EMP");
|
||||
const orgRevisionPublish = await this.orgRevisionRepository
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
let [getProfileEdit, total] = await AppDataSource.getRepository(ProfileEdit)
|
||||
.createQueryBuilder("ProfileEdit")
|
||||
.leftJoinAndSelect("ProfileEdit.profileEmployee", "profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
|
||||
.leftJoinAndSelect("current_holders.orgRevision", "orgRevision")
|
||||
.where((qb) => {
|
||||
if (status != "" && status != null) {
|
||||
qb.andWhere("ProfileEdit.status = :status", { status: status });
|
||||
}
|
||||
qb.andWhere("ProfileEdit.profileEmployeeId IS NOT NULL");
|
||||
})
|
||||
.andWhere(orgRevisionPublish ? `current_holders.orgRevisionId = :revisionId` : "1=1", {
|
||||
revisionId: orgRevisionPublish?.id,
|
||||
})
|
||||
.andWhere(
|
||||
data.root != undefined && data.root != null
|
||||
? data.root[0] != null
|
||||
? `current_holders.orgRootId IN (:...root)`
|
||||
: `current_holders.orgRootId is null`
|
||||
: "1=1",
|
||||
{
|
||||
root: data.root,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
data.child1 != undefined && data.child1 != null
|
||||
? data.child1[0] != null
|
||||
? `current_holders.orgChild1Id IN (:...child1)`
|
||||
: `current_holders.orgChild1Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child1: data.child1,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
data.child2 != undefined && data.child2 != null
|
||||
? data.child2[0] != null
|
||||
? `current_holders.orgChild2Id IN (:...child2)`
|
||||
: `current_holders.orgChild2Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child2: data.child2,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
data.child3 != undefined && data.child3 != null
|
||||
? data.child3[0] != null
|
||||
? `current_holders.orgChild3Id IN (:...child3)`
|
||||
: `current_holders.orgChild3Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child3: data.child3,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
data.child4 != undefined && data.child4 != null
|
||||
? data.child4[0] != null
|
||||
? `current_holders.orgChild4Id IN (:...child4)`
|
||||
: `current_holders.orgChild4Id is null`
|
||||
: "1=1",
|
||||
{
|
||||
child4: data.child4,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
}).orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
).orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.remark LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
).orWhere(
|
||||
keyword != "" && keyword != null ?
|
||||
"CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
})
|
||||
.orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.remark LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != "" && keyword != null
|
||||
? "CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue