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

@ -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[];
}