add api web service

This commit is contained in:
Warunee Tamkoo 2025-08-07 13:05:58 +07:00
parent dab30e6325
commit 89d22b0274
4 changed files with 779 additions and 0 deletions

View file

@ -0,0 +1,39 @@
import { ApiName } from "./ApiName";
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("apiAttribute")
export class ApiAttribute extends EntityBase {
@Column({
nullable: false,
comment: "ชื่อตาราง",
length: 50,
})
tbName: string;
@Column({
nullable: false,
comment: "คีย์ของแอตทริบิวต์",
length: 255,
})
propertyKey: string;
@Column({
nullable: false,
comment: "ลำดับการแสดงผล",
default: 0,
type: "int",
})
ordering: number;
@Column({
nullable: false,
comment: "ไอดีของ API Name",
length: 36, // UUID length
})
apiNameId: string;
@ManyToOne(() => ApiName, (apiName) => apiName.apiAttributes)
@JoinColumn({ name: "apiNameId" })
apiName: ApiName;
}

View file

@ -1,3 +1,4 @@
import { ApiAttribute } from "./ApiAttribute";
import { Entity, Column, ManyToMany, JoinTable, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { ApiKey } from "./ApiKey";
@ -29,10 +30,61 @@ export class ApiName extends EntityBase {
})
methodApi: string;
@Column({
nullable: false,
comment: "code สำหรับการเรียก API",
length: 8,
})
code: string;
@Column({
nullable: false,
comment: "code ระบบสำหรับการเรียก API",
length: 50,
default: "registry",
})
system: string;
@Column({
nullable: false,
comment: "สถานะการใช้งาน",
type: "boolean",
default: false,
})
isActive: boolean;
@ManyToMany(() => ApiKey, (apiKey) => apiKey.apiNames)
@JoinTable()
apiKeys: ApiKey[];
@OneToMany(() => ApiHistory, (v) => v.apiName)
apiHistorys: ApiHistory[];
@OneToMany(() => ApiAttribute, (v) => v.apiName)
apiAttributes: ApiAttribute[];
}
export class CreateApi {
@Column()
name: string;
@Column()
methodApi: "GET" | "POST" | "PUT";
@Column()
system: string;
@Column()
isActive: boolean;
@Column()
apiAttributes: CreateApiAttribute[];
}
export class CreateApiAttribute {
@Column()
tbName: string;
@Column()
propertyKey: string[];
}