บันทึกหน่วยงาน
This commit is contained in:
parent
371f09c26f
commit
650c6fe3e3
4 changed files with 115 additions and 5 deletions
|
|
@ -799,12 +799,12 @@ export class DevelopmentController extends Controller {
|
|||
@Query() searchField?: "year" | "projectName",
|
||||
@Query() searchKeyword: string = "",
|
||||
) {
|
||||
let queryLike = "developer.projectName LIKE :keyword";
|
||||
let queryLike = "development.projectName LIKE :keyword";
|
||||
if (searchField == "year") {
|
||||
queryLike = "developer.year LIKE :keyword";
|
||||
queryLike = "development.year LIKE :keyword";
|
||||
}
|
||||
const [record, total] = await this.developmentRepository
|
||||
.createQueryBuilder("developer")
|
||||
.createQueryBuilder("development")
|
||||
.andWhere(
|
||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||
? queryLike
|
||||
|
|
@ -899,6 +899,7 @@ export class DevelopmentController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("year") year: number,
|
||||
@Query("status") status: string,
|
||||
@Query("root") root?: string | null,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
const [development, total] = await AppDataSource.getRepository(Development)
|
||||
|
|
@ -906,13 +907,16 @@ export class DevelopmentController extends Controller {
|
|||
.andWhere(year > 0 ? "development.year LIKE :year" : "1=1", {
|
||||
year: `${year.toString()}`,
|
||||
})
|
||||
.andWhere(root != undefined && root != null ? "development.root LIKE :root" : "1=1", {
|
||||
root: `${root}`,
|
||||
})
|
||||
.andWhere(status != undefined ? "development.status LIKE :status" : "1=1", {
|
||||
status: `%${status}%`,
|
||||
})
|
||||
.andWhere(keyword != undefined ? "development.projectName LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
})
|
||||
.select(["development.id", "development.projectName", "development.year"])
|
||||
.select(["development.id", "development.projectName", "development.year", "development.root"])
|
||||
.orderBy("development.year", "DESC")
|
||||
.orderBy("development.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
|
|
@ -974,7 +978,17 @@ export class DevelopmentController extends Controller {
|
|||
async GetDevelopemtTab1ById(@Path() id: string) {
|
||||
const getDevelopment = await this.developmentRepository.findOne({
|
||||
where: { id: id },
|
||||
select: ["id", "year", "projectName", "reason", "objective"],
|
||||
select: [
|
||||
"id",
|
||||
"year",
|
||||
"projectName",
|
||||
"reason",
|
||||
"objective",
|
||||
"root",
|
||||
"rootId",
|
||||
"orgRootShortName",
|
||||
"orgRevisionId",
|
||||
],
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
|
|
@ -1205,6 +1219,26 @@ export class DevelopmentController extends Controller {
|
|||
return new HttpSuccess(_getDevelopment);
|
||||
}
|
||||
|
||||
/**
|
||||
* API list หน่วยงาน
|
||||
*
|
||||
* @summary DEV_00 - list หน่วยงาน #
|
||||
*
|
||||
*/
|
||||
@Get("org/root")
|
||||
async GetOrgDevelopemt(@Request() request: { user: Record<string, any> }) {
|
||||
const getOrg = await this.developmentRepository
|
||||
.createQueryBuilder("development")
|
||||
.select("development.root")
|
||||
.groupBy("development.root")
|
||||
.getRawMany();
|
||||
if (getOrg.length > 0) {
|
||||
return new HttpSuccess(getOrg.map((x) => x.development_root));
|
||||
}
|
||||
|
||||
return new HttpSuccess(getOrg);
|
||||
}
|
||||
|
||||
/**
|
||||
* API upload User
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue