report 3 (test)

This commit is contained in:
Bright 2025-02-13 10:28:05 +07:00
parent f8c2433927
commit 6e374d7992

View file

@ -1,4 +1,4 @@
import { Controller, Get, Post, Route, Security, Tags, Body, Path } from "tsoa";
import { Controller, Get, Post, Route, Security, Tags, Body, Path, Query } from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error";
@ -563,14 +563,38 @@ export class ReportController extends Controller {
*
*/
@Get("report3")
async report3() {
async report3(
@Query("year") year: number,
@Query("rootId") rootId?: string,
) {
const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship)
.createQueryBuilder("developmentScholarship")
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
.leftJoinAndSelect("developmentScholarship.posType", "posType")
.andWhere(
year !== 0 && year != null && year != undefined
? "developmentScholarship.scholarshipYear = :scholarshipYear"
: "1=1",
{ scholarshipYear: year },
)
.andWhere(
rootId != "" && rootId != null && rootId != undefined
? "developmentScholarship.rootId = :rootId"
: "1=1",
{ rootId: rootId },
)
.orderBy("developmentScholarship.scholarshipYear", "DESC")
.addOrderBy("developmentScholarship.createdAt", "DESC")
.getManyAndCount();
return new HttpSuccess({
template: "reportFund3",
reportName: "reportFund3",
data: {
data: "",
year: year ? Extension.ToThaiNumber(year.toString()) : "-",
root: null,
developments: development,
total: total
},
});
}