updated appoint by permission

This commit is contained in:
Warunee Tamkoo 2024-11-05 10:31:52 +07:00
parent ad5c953aa8
commit ff2edc685c
3 changed files with 43 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import {
Post,
Path,
Delete,
Query,
} from "tsoa";
import { setLogDataDiff } from "../interfaces/utils";
@ -42,11 +43,40 @@ export class AppointController extends Controller {
*
*/
@Get("")
async GetList(@Request() request: RequestWithUser) {
async GetList(
@Query() keyword: string = "",
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Request() request: RequestWithUser,
) {
await new permission().PermissionList(request, "SYS_PROBATION");
const _data = await new permission().PermissionOrgList(request, "SYS_PROBATION");
const conditions: any = {};
if (_data.root != undefined && _data.root != null && _data.root[0] != null) {
conditions.root = _data.root;
}
if (_data.child1 != undefined && _data.child1 != null && _data.child1[0] != null) {
conditions.child1 = _data.child1;
}
if (_data.child2 != undefined && _data.child2 != null && _data.child2[0] != null) {
conditions.child2 = _data.child2;
}
if (_data.child3 != undefined && _data.child3 != null && _data.child3[0] != null) {
conditions.child3 = _data.child3;
}
if (_data.child4 != undefined && _data.child4 != null && _data.child4[0] != null) {
conditions.child4 = _data.child4;
}
const appoint = await this.appointRepository.find({
where: { createdUserId: request.user.sub },
relations: ["personal"],
where: { personal: conditions },
});
return new HttpSuccess(appoint);

View file

@ -1,6 +1,7 @@
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, JoinColumn } from "typeorm";
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, JoinColumn, OneToOne } from "typeorm";
import { EntityBase } from "./base/Base";
import { AppointDirector } from "./AppointDirector";
import { Personal } from "./Personal";
@Entity("appoint")
export class Appoint extends EntityBase {
@ -37,6 +38,10 @@ export class Appoint extends EntityBase {
@OneToMany(() => AppointDirector, (director: AppointDirector) => director.appoint)
@JoinColumn({ name: "id" })
directors: AppointDirector[];
@OneToOne(() => Personal, (personal: Personal) => personal.personal_id)
@JoinColumn({ name: "profileId" })
personal: Personal;
}
export class CreateAppoint {

View file

@ -1,6 +1,7 @@
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Assign } from "./Assign";
import { Appoint } from "./Appoint";
@Entity("personal")
export class Personal extends EntityBase {
@ -119,6 +120,10 @@ export class Personal extends EntityBase {
@OneToMany(() => Assign, (assign: Assign) => assign.personal_id)
@JoinColumn({ name: "personal_id" })
assign: Assign[];
@OneToOne(() => Appoint, (appoint: Appoint) => appoint.profileId)
@JoinColumn({ name: "personal_id" })
appoint: Appoint;
}
export class CreatePersonal {