ค้นหารอบตามปี

This commit is contained in:
Kittapath 2024-03-26 10:28:40 +07:00
parent 04d746bb18
commit ec4cf9015f

View file

@ -1418,6 +1418,40 @@ export class SalaryPeriodController extends Controller {
return new HttpSuccess(salaryPeriod);
}
/**
* API by year
*
* @summary SLR_020 - by year
*
*/
@Get("active/{year}")
async GetListsSalaryPeriodByYear(
@Path() year: number,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string,
) {
const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod)
.createQueryBuilder("salaryPeriod")
.andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `${year}` })
.select([
"salaryPeriod.id",
"salaryPeriod.period",
"salaryPeriod.isActive",
"salaryPeriod.isClose",
"salaryPeriod.effectiveDate",
"salaryPeriod.status",
"salaryPeriod.year",
"salaryPeriod.revisionId",
])
.orderBy("salaryPeriod.effectiveDate", "DESC")
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
return new HttpSuccess({ data: salaryPeriod, total });
}
/**
* API
*