relation
This commit is contained in:
parent
a7d13ac00b
commit
18510b1419
3 changed files with 32 additions and 1 deletions
|
|
@ -17,8 +17,10 @@ import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { AuthRole, CreateAuthRole, UpdateAuthRole } from "../entities/AuthRole";
|
import { AuthRole, CreateAuthRole, UpdateAuthRole, CreateAddAuthRole } from "../entities/AuthRole";
|
||||||
import { AuthRoleAttr } from "../entities/AuthRoleAttr";
|
import { AuthRoleAttr } from "../entities/AuthRoleAttr";
|
||||||
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
|
|
||||||
@Route("api/v1/org/auth/authRole")
|
@Route("api/v1/org/auth/authRole")
|
||||||
@Tags("AuthRole")
|
@Tags("AuthRole")
|
||||||
|
|
@ -72,6 +74,12 @@ export class AuthRoleController extends Controller {
|
||||||
return new HttpSuccess(data.id);
|
return new HttpSuccess(data.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post("assign")
|
||||||
|
public async AddAuthRole(@Request() req: RequestWithUser, @Body() body: CreateAddAuthRole) {
|
||||||
|
// console pasMater = await this
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
@Patch("{roleId}")
|
@Patch("{roleId}")
|
||||||
public async editAuthRole(
|
public async editAuthRole(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { Entity, Column, OneToMany, OneToOne } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { AuthRoleAttr } from "./AuthRoleAttr";
|
import { AuthRoleAttr } from "./AuthRoleAttr";
|
||||||
import { PosMaster } from "./PosMaster";
|
import { PosMaster } from "./PosMaster";
|
||||||
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
|
|
||||||
@Entity("authRole")
|
@Entity("authRole")
|
||||||
export class AuthRole extends EntityBase {
|
export class AuthRole extends EntityBase {
|
||||||
|
|
@ -26,6 +27,9 @@ export class AuthRole extends EntityBase {
|
||||||
|
|
||||||
@OneToOne(() => PosMaster, (posMaster) => posMaster.authRole)
|
@OneToOne(() => PosMaster, (posMaster) => posMaster.authRole)
|
||||||
posMaster: PosMaster;
|
posMaster: PosMaster;
|
||||||
|
|
||||||
|
@OneToOne(() => EmployeePosMaster, (posMasters) => posMasters.authRole)
|
||||||
|
posMasters: EmployeePosMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateAuthRole {
|
export class CreateAuthRole {
|
||||||
|
|
@ -37,3 +41,11 @@ export class CreateAuthRole {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateAuthRole = Partial<CreateAuthRole>;
|
export type UpdateAuthRole = Partial<CreateAuthRole>;
|
||||||
|
|
||||||
|
export class CreateAddAuthRole {
|
||||||
|
@Column()
|
||||||
|
authRoleId: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
posMasterId: string;
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ import { OrgChild3 } from "./OrgChild3";
|
||||||
import { OrgChild4 } from "./OrgChild4";
|
import { OrgChild4 } from "./OrgChild4";
|
||||||
import { Profile } from "./Profile";
|
import { Profile } from "./Profile";
|
||||||
import { ProfileEmployee } from "./ProfileEmployee";
|
import { ProfileEmployee } from "./ProfileEmployee";
|
||||||
|
import { AuthRole } from "./AuthRole";
|
||||||
|
|
||||||
enum EmployeePosMasterLine {
|
enum EmployeePosMasterLine {
|
||||||
MAIN = "MAIN",
|
MAIN = "MAIN",
|
||||||
|
|
@ -171,6 +172,16 @@ export class EmployeePosMaster extends EntityBase {
|
||||||
})
|
})
|
||||||
orgRevisionId: string; //fk
|
orgRevisionId: string; //fk
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง authRole",
|
||||||
|
})
|
||||||
|
authRoleId: string;
|
||||||
|
|
||||||
|
@OneToOne(() => AuthRole, (authRole) => authRole.posMasters)
|
||||||
|
@JoinColumn({ name: "authRoleId" })
|
||||||
|
authRole: AuthRole;
|
||||||
|
|
||||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
|
||||||
@JoinColumn({ name: "orgRevisionId" })
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
orgRevision: OrgRevision;
|
orgRevision: OrgRevision;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue