บันทึกหน่วยงาน
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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,6 +14,34 @@ import { DevelopmentProjectTechniqueActual } from "./DevelopmentProjectTechnique
|
|||
|
||||
@Entity("development")
|
||||
export class Development extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "id หน่วยงาน",
|
||||
default: null,
|
||||
})
|
||||
rootId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อหน่วยงาน",
|
||||
default: null,
|
||||
})
|
||||
root: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อย่ิหน่วยงาน",
|
||||
default: null,
|
||||
})
|
||||
orgRootShortName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "id revision",
|
||||
default: null,
|
||||
})
|
||||
orgRevisionId: string;
|
||||
|
||||
@Column({
|
||||
// กำลังดำเนินการ (ONGOING)
|
||||
// เสร็จสิ้น (FINISH)
|
||||
|
|
@ -380,6 +408,14 @@ export class CreateDevelopment {
|
|||
year: number;
|
||||
@Column()
|
||||
projectName: string;
|
||||
@Column()
|
||||
root: string;
|
||||
@Column()
|
||||
rootId: string;
|
||||
@Column()
|
||||
orgRootShortName: string;
|
||||
@Column()
|
||||
orgRevisionId: string;
|
||||
}
|
||||
|
||||
export class UpdateDevelopment1 {
|
||||
|
|
@ -391,6 +427,14 @@ export class UpdateDevelopment1 {
|
|||
reason: string | null;
|
||||
@Column()
|
||||
objective: string | null;
|
||||
@Column()
|
||||
root: string;
|
||||
@Column()
|
||||
rootId: string;
|
||||
@Column()
|
||||
orgRootShortName: string;
|
||||
@Column()
|
||||
orgRevisionId: string;
|
||||
}
|
||||
export class UpdateDevelopment2_1 {
|
||||
@Column()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableDevelopmentAddRoot1712904313381 implements MigrationInterface {
|
||||
name = 'UpdateTableDevelopmentAddRoot1712904313381'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`root\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootId\``);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableDevelopmentAddRootshortname1712904744359 implements MigrationInterface {
|
||||
name = 'UpdateTableDevelopmentAddRootshortname1712904744359'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRevisionId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRootShortName\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue