diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index cf5dc1b..5312d3e 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -638,6 +638,22 @@ export class EvaluationController { await this.assessmentRepository.save(assessment, { data: request }); setLogDataDiff(request, { before, after: assessment }); }); + + //Portfolio + // if (requestBody.portfolios != null) + // requestBody.portfolios.forEach(async (pfo) => { + // const portfolio = new Portfolio(); + // portfolio.createdUserId = request.user.sub; + // portfolio.createdFullName = request.user.name; + // portfolio.createdAt = new Date(); + // portfolio.lastUpdateUserId = request.user.sub; + // portfolio.lastUpdateFullName = request.user.name; + // portfolio.lastUpdatedAt = new Date(); + // portfolio.name = pfo.name ?? _null; + // portfolio.detail = pfo.detail ?? _null; + // await this.assessmentRepository.save(assessment, { data: request }); + // setLogDataDiff(request, { before, after: assessment }); + // }); //EvaluationLogs const evaluationLogs = new EvaluationLogs(); @@ -1143,6 +1159,10 @@ export class EvaluationController { pointSumTotal: assessment.pointSumTotal, pointSum: assessment.pointSum, })), + // portfolios: evaluation.portfolio.map((portfolio) => ({ + // name: portfolio.name, + // detail: portfolio.detail, + // })), // years: years }; diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 2a1934e..5c5ab84 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -8,6 +8,7 @@ import { Training } from "./Training"; import { Assessment } from "./Assessment"; import { Director } from "./Director"; import { Meeting } from "./Meeting"; +import { Portfolio } from "./Portfolio"; @Entity("evaluation") export class Evaluation extends EntityBase { @@ -275,6 +276,10 @@ export class Evaluation extends EntityBase { @ManyToMany(() => Meeting, (meeting) => meeting.evaluations) @JoinTable() meetings: Meeting[]; + + @ManyToMany(() => Portfolio, (portfolio) => portfolio.evaluations) + @JoinTable() + portfolios: Portfolio[]; } export class CreateEvaluation { @@ -356,6 +361,9 @@ export class CreateEvaluation { @Column() assessments?: CreateAssessment[]; + @Column() + portfolios?: CreatePortfolio[]; + @Column() root?: string | null; @@ -516,6 +524,14 @@ export class CreateAssessment { @Column() pointSum?: number | null; } + +export class CreatePortfolio { + @Column() + name?: string | null; + + @Column() + detail?: string | null; +} export class CreateEvaluationExpertise { @Column() author?: string | null; diff --git a/src/entities/Portfolio.ts b/src/entities/Portfolio.ts new file mode 100644 index 0000000..3814e57 --- /dev/null +++ b/src/entities/Portfolio.ts @@ -0,0 +1,34 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToOne } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Evaluation } from "./Evaluation"; + +@Entity("portfolio") +export class Portfolio extends EntityBase { + @Column({ + comment: "Id การทำรายการระบบประเมิน", + length: 40, + default: "00000000-0000-0000-0000-000000000000", + }) + evaluationId: string; + + @Column({ + nullable: true, + comment: "ชื่อเอกสาร/ผลงาน", + default: null, + }) + name: string; + + @Column({ + type: "longtext", + nullable: true, + comment: "รายละเอียดเอกสาร/ผลงาน", + default: null, + }) + detail: string; + + @ManyToOne(() => Evaluation, (Evaluation) => Evaluation.portfolios) + @JoinColumn({ name: "evaluationId" }) + evaluations: Evaluation; +} + +export type UpdatePortfolio = Partial;