add permission brother
This commit is contained in:
parent
43aeb144d4
commit
c73fe877a0
3 changed files with 184 additions and 172 deletions
|
|
@ -66,7 +66,7 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
}
|
||||
|
||||
const chkName = await this.kpiUserDevelopmentRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
name: requestBody.name,
|
||||
},
|
||||
|
|
@ -393,7 +393,7 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `kpiUserEvaluation.child1DnaId IN (:...child1)`
|
||||
: `kpiUserEvaluation.child1DnaId is null`
|
||||
: `kpiUserEvaluation.child1DnaId is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
|
|
@ -458,66 +458,69 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
.orWhere("kpiUserDevelopment.name LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere( "kpiUserEvaluation.org LIKE :keyword", {
|
||||
.orWhere("kpiUserEvaluation.org LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere( "CONCAT(kpiUserEvaluation.child1,' ', kpiUserEvaluation.org) LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere( "CONCAT(kpiUserEvaluation.child2,' ', kpiUserEvaluation.child1,' ', kpiUserEvaluation.org) LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere( "CONCAT(kpiUserEvaluation.child3,' ', kpiUserEvaluation.child2,' ', kpiUserEvaluation.child1,' ', kpiUserEvaluation.org) LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere( "CONCAT(kpiUserEvaluation.child4,' ', kpiUserEvaluation.child3,' ', kpiUserEvaluation.child2,' ', kpiUserEvaluation.child1,' ', kpiUserEvaluation.org) LIKE :keyword", {
|
||||
.orWhere("CONCAT(kpiUserEvaluation.child1,' ', kpiUserEvaluation.org) LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere(
|
||||
"CONCAT(kpiUserEvaluation.child2,' ', kpiUserEvaluation.child1,' ', kpiUserEvaluation.org) LIKE :keyword",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
"CONCAT(kpiUserEvaluation.child3,' ', kpiUserEvaluation.child2,' ', kpiUserEvaluation.child1,' ', kpiUserEvaluation.org) LIKE :keyword",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
"CONCAT(kpiUserEvaluation.child4,' ', kpiUserEvaluation.child3,' ', kpiUserEvaluation.child2,' ', kpiUserEvaluation.child1,' ', kpiUserEvaluation.org) LIKE :keyword",
|
||||
{
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(conditionFullName, {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
});
|
||||
}),
|
||||
)
|
||||
);
|
||||
|
||||
if (requestBody.sortBy) {
|
||||
if(requestBody.sortBy === "developmentName"){
|
||||
query = query.orderBy(
|
||||
`kpiUserDevelopment.name`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if (requestBody.sortBy === "organization"){
|
||||
query = query
|
||||
if (requestBody.sortBy) {
|
||||
if (requestBody.sortBy === "developmentName") {
|
||||
query = query.orderBy(`kpiUserDevelopment.name`, requestBody.descending ? "DESC" : "ASC");
|
||||
} else if (requestBody.sortBy === "organization") {
|
||||
query = query
|
||||
.orderBy(`kpiUserEvaluation.child4`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child3`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child2`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child1`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.org`, requestBody.descending ? "DESC" : "ASC");
|
||||
}else if(requestBody.sortBy === "firstname"){
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.firstName`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(requestBody.sortBy === "lastname"){
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.lastName`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(requestBody.sortBy === "root"){
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.org`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.${requestBody.sortBy}`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
query = query.orderBy("kpiUserDevelopment.createdAt", "ASC")
|
||||
} else if (requestBody.sortBy === "firstname") {
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.firstName`,
|
||||
requestBody.descending ? "DESC" : "ASC",
|
||||
);
|
||||
} else if (requestBody.sortBy === "lastname") {
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.lastName`,
|
||||
requestBody.descending ? "DESC" : "ASC",
|
||||
);
|
||||
} else if (requestBody.sortBy === "root") {
|
||||
query = query.orderBy(`kpiUserEvaluation.org`, requestBody.descending ? "DESC" : "ASC");
|
||||
} else {
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.${requestBody.sortBy}`,
|
||||
requestBody.descending ? "DESC" : "ASC",
|
||||
);
|
||||
}
|
||||
} else {
|
||||
query = query.orderBy("kpiUserDevelopment.createdAt", "ASC");
|
||||
}
|
||||
|
||||
const [kpiUserDevelopment, total] = await query
|
||||
const [kpiUserDevelopment, total] = await query
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue