DEV_009 ลูกจ้าง
This commit is contained in:
parent
2e5d98d546
commit
e52e986d3b
1 changed files with 85 additions and 6 deletions
|
|
@ -13,7 +13,7 @@ import {
|
||||||
Query,
|
Query,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { Not } from "typeorm";
|
import { Brackets, Not } from "typeorm";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
|
|
@ -193,16 +193,95 @@ export class DevelopmentEmployeeHistoryController extends Controller {
|
||||||
const type = "EMPLOYEE";
|
const type = "EMPLOYEE";
|
||||||
const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
|
const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
|
||||||
.createQueryBuilder("developmentHistory")
|
.createQueryBuilder("developmentHistory")
|
||||||
// .andWhere(year == null ? "developmentHistory.year LIKE :year" : "1=1", { year: `${year}` })
|
.leftJoinAndSelect("developmentHistory.development", "development")
|
||||||
// .orWhere("developmentHistory.projectName LIKE :keyword", { keyword: `${keyword}` })
|
.leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel")
|
||||||
// .select(["development.id", "development.projectName", "development.year"])
|
.leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType")
|
||||||
// .orderBy("developmentHistory.year", "DESC")
|
.andWhere("development.year = :year", { year: year })
|
||||||
|
.andWhere("developmentHistory.type = :type", { type: type })
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.where(
|
||||||
|
keyword != null && keyword != ""
|
||||||
|
? "developmentHistory.prefix LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
keyword != null && keyword != ""
|
||||||
|
? "developmentHistory.firstName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
keyword != null && keyword != ""
|
||||||
|
? "developmentHistory.lastName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
keyword != null && keyword != ""
|
||||||
|
? "developmentHistory.position LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
keyword != null && keyword != ""
|
||||||
|
? "developmentHistory.position LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
keyword != null && keyword != ""
|
||||||
|
? "development.projectName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
keyword != null && keyword != ""
|
||||||
|
? "employeePosType.posTypeName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
keyword != null && keyword != ""
|
||||||
|
? "employeePosLevel.posLevelName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
.orderBy("developmentHistory.createdAt", "DESC")
|
.orderBy("developmentHistory.createdAt", "DESC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
return new HttpSuccess({ data: development, total });
|
const formattedData = development.map(item => ({
|
||||||
|
id: item.id,
|
||||||
|
citizenId: item.citizenId,
|
||||||
|
fullName: item.prefix+item.firstName+" "+item.lastName,
|
||||||
|
position: item.position,
|
||||||
|
posType: item.employeePosType.posTypeName,
|
||||||
|
posLevel: item.employeePosLevel.posLevelName,
|
||||||
|
projectName: item.development.projectName,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return new HttpSuccess({ data: formattedData, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue