แก้บัคค้นหาเกณลูกจ้าง
This commit is contained in:
parent
e1e16cabc7
commit
a6fb4c28f1
1 changed files with 20 additions and 19 deletions
|
|
@ -228,25 +228,26 @@ export class SalaryFormulaEmployeeController extends Controller {
|
|||
@Query("keyword") keyword?: string,
|
||||
@Query("posTypeId") posTypeId?: string,
|
||||
) {
|
||||
let whereClause: any = {};
|
||||
if (keyword != undefined && keyword !== "") {
|
||||
whereClause = {
|
||||
where: [
|
||||
{ details: Like(`%${keyword}%`) },
|
||||
{ position: Like(`%${keyword}%`) },
|
||||
{ posLevel: { posLevelName: Like(`%${keyword}%`) } },
|
||||
{ posTypeId: Like(`%${posTypeId}%`) },
|
||||
],
|
||||
};
|
||||
}
|
||||
const [getFormula, total] = await this.salaryFormulaEmployeeRepository.findAndCount({
|
||||
relations: ["salaryEmployee", "posType", "posLevel", "salaryEmployeeMins"],
|
||||
...whereClause,
|
||||
order: {
|
||||
lastUpdatedAt: "DESC",
|
||||
},
|
||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||
});
|
||||
const [getFormula, total] = await AppDataSource.getRepository(SalaryFormulaEmployee)
|
||||
.createQueryBuilder("salaryFormulaEmployee")
|
||||
.leftJoinAndSelect("salaryFormulaEmployee.salaryEmployee", "salaryEmployee")
|
||||
.leftJoinAndSelect("salaryFormulaEmployee.posType", "posType")
|
||||
.leftJoinAndSelect("salaryFormulaEmployee.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("salaryFormulaEmployee.salaryEmployeeMins", "salaryEmployeeMins")
|
||||
.andWhere(
|
||||
keyword == undefined
|
||||
? "1=1"
|
||||
: [
|
||||
{ details: Like(`%${keyword}%`) },
|
||||
{ position: Like(`%${keyword}%`) },
|
||||
{ posLevel: { posLevelName: Like(`%${keyword}%`) } },
|
||||
],
|
||||
)
|
||||
.andWhere(posTypeId == undefined ? "1=1" : { posTypeId: Like(`%${posTypeId}%`) })
|
||||
.orderBy("salaryFormulaEmployee.lastUpdatedAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapFormula = getFormula.map((item) => ({
|
||||
id: item.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue