ค้นหาโครงการ
This commit is contained in:
parent
8a5a7ac360
commit
daf4188144
1 changed files with 49 additions and 0 deletions
|
|
@ -316,6 +316,55 @@ export class DevelopmentController extends Controller {
|
|||
return new HttpSuccess(development.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ค้นหาโครงการ
|
||||
*
|
||||
* @summary DEV_00 - ค้นหาโครงการ #
|
||||
*
|
||||
* @param {string} id Id โครงการ
|
||||
*/
|
||||
@Get("search")
|
||||
async ListDevelopemt(
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query() searchField?: "year" | "projectName",
|
||||
@Query() searchKeyword: string = "",
|
||||
) {
|
||||
let queryLike = "developer.projectName LIKE :keyword";
|
||||
if (searchField == "year") {
|
||||
queryLike = "developer.year LIKE :keyword";
|
||||
}
|
||||
const [record, total] = await this.developmentRepository
|
||||
.createQueryBuilder("developer")
|
||||
.andWhere(
|
||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||
? queryLike
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${searchKeyword}%`,
|
||||
},
|
||||
)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
return {
|
||||
id: _data.id,
|
||||
year: _data.year,
|
||||
projectName: _data.projectName,
|
||||
dateStart: _data.dateStart,
|
||||
dateEnd: _data.dateEnd,
|
||||
totalDate: _data.totalDate,
|
||||
addressAcademic: _data.addressAcademic,
|
||||
topicAcademic: _data.topicAcademic,
|
||||
};
|
||||
}),
|
||||
);
|
||||
return new HttpSuccess({ data: data, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบโครงการ/หลักสูตรการฝึกอบรม
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue