no message

This commit is contained in:
kittapath 2024-08-27 13:21:13 +07:00
parent 5a688215e7
commit 8382335f24
5 changed files with 440 additions and 282 deletions

View file

@ -19,7 +19,11 @@ import HttpError from "../interfaces/http-error";
import { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory"; import { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { CreateProfileDevelopment, ProfileDevelopment, UpdateProfileDevelopment } from "../entities/ProfileDevelopment"; import {
CreateProfileDevelopment,
ProfileDevelopment,
UpdateProfileDevelopment,
} from "../entities/ProfileDevelopment";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { DevelopmentProject } from "../entities/developmentProject"; import { DevelopmentProject } from "../entities/developmentProject";
@Route("api/v1/org/profile/development") @Route("api/v1/org/profile/development")
@ -39,6 +43,7 @@ export class ProfileDevelopmentController extends Controller {
} }
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
relations: ["developmentProjects"],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -63,6 +68,7 @@ export class ProfileDevelopmentController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
relations: ["developmentProjects"],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -93,13 +99,17 @@ export class ProfileDevelopmentController extends Controller {
} }
const record = await this.developmentHistoryRepository.find({ const record = await this.developmentHistoryRepository.find({
where: { profileDevelopmentId: developmentId }, where: { profileDevelopmentId: developmentId },
relations: ["developmentHistoryProjects"],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Post() @Post()
public async newDevelopment(@Request() req: RequestWithUser, @Body() body: CreateProfileDevelopment) { public async newDevelopment(
@Request() req: RequestWithUser,
@Body() body: CreateProfileDevelopment,
) {
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -128,27 +138,27 @@ export class ProfileDevelopmentController extends Controller {
await this.developmentHistoryRepository.save(history); await this.developmentHistoryRepository.save(history);
if (body.developmentProjects != null) { if (body.developmentProjects != null) {
await Promise.all( await Promise.all(
body.developmentProjects.map(async (x) => { body.developmentProjects.map(async (x) => {
let data1 = new DevelopmentProject(); let data1 = new DevelopmentProject();
data1.name = x; data1.name = x;
data1.createdUserId = req.user.sub; data1.createdUserId = req.user.sub;
data1.createdFullName = req.user.name; data1.createdFullName = req.user.name;
data1.lastUpdateUserId = req.user.sub; data1.lastUpdateUserId = req.user.sub;
data1.lastUpdateFullName = req.user.name; data1.lastUpdateFullName = req.user.name;
data1.profileDevelopmentId = data.id; data1.profileDevelopmentId = data.id;
await this.developmentProjectRepository.save(data1); await this.developmentProjectRepository.save(data1);
let data2 = new DevelopmentProject(); let data2 = new DevelopmentProject();
data2.name = x; data2.name = x;
data2.createdUserId = req.user.sub; data2.createdUserId = req.user.sub;
data2.createdFullName = req.user.name; data2.createdFullName = req.user.name;
data2.lastUpdateUserId = req.user.sub; data2.lastUpdateUserId = req.user.sub;
data2.lastUpdateFullName = req.user.name; data2.lastUpdateFullName = req.user.name;
data2.profileDevelopmentId = data.id; data2.profileDevelopmentId = data.id;
await this.developmentProjectRepository.save(data2); await this.developmentProjectRepository.save(data2);
}), }),
); );
} }
return new HttpSuccess(); return new HttpSuccess();
} }
@ -158,8 +168,10 @@ export class ProfileDevelopmentController extends Controller {
@Body() body: UpdateProfileDevelopment, @Body() body: UpdateProfileDevelopment,
@Path() developmentId: string, @Path() developmentId: string,
) { ) {
const record = await this.developmentRepository.findOne({ where:{id: developmentId}, const record = await this.developmentRepository.findOne({
relations: ["developmentProjects"], }); where: { id: developmentId },
relations: ["developmentProjects"],
});
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
@ -183,39 +195,45 @@ export class ProfileDevelopmentController extends Controller {
await this.developmentProjectRepository.remove(record.developmentProjects); await this.developmentProjectRepository.remove(record.developmentProjects);
if (body.developmentProjects != null) { if (body.developmentProjects != null) {
await Promise.all( await Promise.all(
body.developmentProjects.map(async (x) => { body.developmentProjects.map(async (x) => {
let data1 = new DevelopmentProject(); let data1 = new DevelopmentProject();
data1.name = x; data1.name = x;
data1.createdUserId = req.user.sub; data1.createdUserId = req.user.sub;
data1.createdFullName = req.user.name; data1.createdFullName = req.user.name;
data1.lastUpdateUserId = req.user.sub; data1.lastUpdateUserId = req.user.sub;
data1.lastUpdateFullName = req.user.name; data1.lastUpdateFullName = req.user.name;
data1.profileDevelopmentId = record.id; data1.profileDevelopmentId = record.id;
await this.developmentProjectRepository.save(data1); await this.developmentProjectRepository.save(data1);
let data2 = new DevelopmentProject(); let data2 = new DevelopmentProject();
data2.name = x; data2.name = x;
data2.createdUserId = req.user.sub; data2.createdUserId = req.user.sub;
data2.createdFullName = req.user.name; data2.createdFullName = req.user.name;
data2.lastUpdateUserId = req.user.sub; data2.lastUpdateUserId = req.user.sub;
data2.lastUpdateFullName = req.user.name; data2.lastUpdateFullName = req.user.name;
data2.profileDevelopmentId = history.id; data2.profileDevelopmentId = history.id;
await this.developmentProjectRepository.save(data2); await this.developmentProjectRepository.save(data2);
}), }),
); );
} }
return new HttpSuccess(); return new HttpSuccess();
} }
@Delete("{developmentId}") @Delete("{developmentId}")
public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) { public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) {
const _record = await this.developmentRepository.findOneBy({ id: developmentId }); const _record = await this.developmentRepository.findOneBy({ id: developmentId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
} req,
await this.developmentProjectRepository.delete({profileDevelopmentId:developmentId}); "SYS_REGISTRY_OFFICER",
await this.developmentProjectRepository.delete({profileDevelopmentHistory:{profileDevelopmentId:developmentId}}); _record.profileId,
);
}
await this.developmentProjectRepository.delete({ profileDevelopmentId: developmentId });
await this.developmentProjectRepository.delete({
profileDevelopmentHistory: { profileDevelopmentId: developmentId },
});
await this.developmentHistoryRepository.delete({ await this.developmentHistoryRepository.delete({
profileDevelopmentId: developmentId, profileDevelopmentId: developmentId,
}); });

View file

@ -25,6 +25,7 @@ import {
UpdateProfileDevelopment, UpdateProfileDevelopment,
} from "../entities/ProfileDevelopment"; } from "../entities/ProfileDevelopment";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { DevelopmentProject } from "../entities/developmentProject";
@Route("api/v1/org/profile-employee/development") @Route("api/v1/org/profile-employee/development")
@Tags("ProfileDevelopment") @Tags("ProfileDevelopment")
@Security("bearerAuth") @Security("bearerAuth")
@ -32,6 +33,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
private profileRepository = AppDataSource.getRepository(ProfileEmployee); private profileRepository = AppDataSource.getRepository(ProfileEmployee);
private developmentRepository = AppDataSource.getRepository(ProfileDevelopment); private developmentRepository = AppDataSource.getRepository(ProfileDevelopment);
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory); private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
private developmentProjectRepository = AppDataSource.getRepository(DevelopmentProject);
@Get("user") @Get("user")
public async getDevelopmentUser(@Request() request: RequestWithUser) { public async getDevelopmentUser(@Request() request: RequestWithUser) {
@ -41,6 +43,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
} }
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
relations: ["developmentProjects"],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -50,6 +53,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileId); await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileId);
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
relations: ["developmentProjects"],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -58,17 +62,25 @@ export class ProfileDevelopmentEmployeeController extends Controller {
public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) { public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) {
const _record = await this.developmentRepository.findOneBy({ id: developmentId }); const _record = await this.developmentRepository.findOneBy({ id: developmentId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.developmentHistoryRepository.find({ const record = await this.developmentHistoryRepository.find({
where: { profileDevelopmentId: developmentId }, where: { profileDevelopmentId: developmentId },
relations: ["developmentHistoryProjects"],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Post() @Post()
public async newDevelopment(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDevelopment) { public async newDevelopment(
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeDevelopment,
) {
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -96,6 +108,28 @@ export class ProfileDevelopmentEmployeeController extends Controller {
history.profileDevelopmentId = data.id; history.profileDevelopmentId = data.id;
await this.developmentHistoryRepository.save(history); await this.developmentHistoryRepository.save(history);
if (body.developmentProjects != null) {
await Promise.all(
body.developmentProjects.map(async (x) => {
let data1 = new DevelopmentProject();
data1.name = x;
data1.createdUserId = req.user.sub;
data1.createdFullName = req.user.name;
data1.lastUpdateUserId = req.user.sub;
data1.lastUpdateFullName = req.user.name;
data1.profileDevelopmentId = data.id;
await this.developmentProjectRepository.save(data1);
let data2 = new DevelopmentProject();
data2.name = x;
data2.createdUserId = req.user.sub;
data2.createdFullName = req.user.name;
data2.lastUpdateUserId = req.user.sub;
data2.lastUpdateFullName = req.user.name;
data2.profileDevelopmentId = data.id;
await this.developmentProjectRepository.save(data2);
}),
);
}
return new HttpSuccess(); return new HttpSuccess();
} }
@ -105,10 +139,16 @@ export class ProfileDevelopmentEmployeeController extends Controller {
@Body() body: UpdateProfileDevelopment, @Body() body: UpdateProfileDevelopment,
@Path() developmentId: string, @Path() developmentId: string,
) { ) {
const record = await this.developmentRepository.findOne({
const record = await this.developmentRepository.findOneBy({ id: developmentId }); where: { id: developmentId },
relations: ["developmentProjects"],
});
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileDevelopmentHistory(); const history = new ProfileDevelopmentHistory();
@ -127,6 +167,30 @@ export class ProfileDevelopmentEmployeeController extends Controller {
this.developmentRepository.save(record), this.developmentRepository.save(record),
this.developmentHistoryRepository.save(history), this.developmentHistoryRepository.save(history),
]); ]);
await this.developmentProjectRepository.remove(record.developmentProjects);
if (body.developmentProjects != null) {
await Promise.all(
body.developmentProjects.map(async (x) => {
let data1 = new DevelopmentProject();
data1.name = x;
data1.createdUserId = req.user.sub;
data1.createdFullName = req.user.name;
data1.lastUpdateUserId = req.user.sub;
data1.lastUpdateFullName = req.user.name;
data1.profileDevelopmentId = record.id;
await this.developmentProjectRepository.save(data1);
let data2 = new DevelopmentProject();
data2.name = x;
data2.createdUserId = req.user.sub;
data2.createdFullName = req.user.name;
data2.lastUpdateUserId = req.user.sub;
data2.lastUpdateFullName = req.user.name;
data2.profileDevelopmentId = history.id;
await this.developmentProjectRepository.save(data2);
}),
);
}
return new HttpSuccess(); return new HttpSuccess();
} }
@ -135,8 +199,16 @@ export class ProfileDevelopmentEmployeeController extends Controller {
public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) { public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) {
const _record = await this.developmentRepository.findOneBy({ id: developmentId }); const _record = await this.developmentRepository.findOneBy({ id: developmentId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.developmentProjectRepository.delete({ profileDevelopmentId: developmentId });
await this.developmentProjectRepository.delete({
profileDevelopmentHistory: { profileDevelopmentId: developmentId },
});
await this.developmentHistoryRepository.delete({ await this.developmentHistoryRepository.delete({
profileDevelopmentId: developmentId, profileDevelopmentId: developmentId,

View file

@ -25,6 +25,7 @@ import {
UpdateProfileDevelopment, UpdateProfileDevelopment,
} from "../entities/ProfileDevelopment"; } from "../entities/ProfileDevelopment";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { DevelopmentProject } from "../entities/developmentProject";
@Route("api/v1/org/profile-temp/development") @Route("api/v1/org/profile-temp/development")
@Tags("ProfileDevelopment") @Tags("ProfileDevelopment")
@Security("bearerAuth") @Security("bearerAuth")
@ -32,6 +33,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
private profileRepository = AppDataSource.getRepository(ProfileEmployee); private profileRepository = AppDataSource.getRepository(ProfileEmployee);
private developmentRepository = AppDataSource.getRepository(ProfileDevelopment); private developmentRepository = AppDataSource.getRepository(ProfileDevelopment);
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory); private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
private developmentProjectRepository = AppDataSource.getRepository(DevelopmentProject);
@Get("user") @Get("user")
public async getDevelopmentUser(@Request() request: { user: Record<string, any> }) { public async getDevelopmentUser(@Request() request: { user: Record<string, any> }) {
@ -41,6 +43,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
} }
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
relations: ["developmentProjects"],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -50,6 +53,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
relations: ["developmentProjects"],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -59,13 +63,17 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");
const record = await this.developmentHistoryRepository.find({ const record = await this.developmentHistoryRepository.find({
where: { profileDevelopmentId: developmentId }, where: { profileDevelopmentId: developmentId },
relations: ["developmentHistoryProjects"],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Post() @Post()
public async newDevelopment(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDevelopment) { public async newDevelopment(
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeDevelopment,
) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
@ -94,6 +102,28 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
history.profileDevelopmentId = data.id; history.profileDevelopmentId = data.id;
await this.developmentHistoryRepository.save(history); await this.developmentHistoryRepository.save(history);
if (body.developmentProjects != null) {
await Promise.all(
body.developmentProjects.map(async (x) => {
let data1 = new DevelopmentProject();
data1.name = x;
data1.createdUserId = req.user.sub;
data1.createdFullName = req.user.name;
data1.lastUpdateUserId = req.user.sub;
data1.lastUpdateFullName = req.user.name;
data1.profileDevelopmentId = data.id;
await this.developmentProjectRepository.save(data1);
let data2 = new DevelopmentProject();
data2.name = x;
data2.createdUserId = req.user.sub;
data2.createdFullName = req.user.name;
data2.lastUpdateUserId = req.user.sub;
data2.lastUpdateFullName = req.user.name;
data2.profileDevelopmentId = data.id;
await this.developmentProjectRepository.save(data2);
}),
);
}
return new HttpSuccess(); return new HttpSuccess();
} }
@ -104,7 +134,10 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
@Path() developmentId: string, @Path() developmentId: string,
) { ) {
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const record = await this.developmentRepository.findOneBy({ id: developmentId }); const record = await this.developmentRepository.findOne({
where: { id: developmentId },
relations: ["developmentProjects"],
});
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -125,6 +158,30 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
this.developmentRepository.save(record), this.developmentRepository.save(record),
this.developmentHistoryRepository.save(history), this.developmentHistoryRepository.save(history),
]); ]);
await this.developmentProjectRepository.remove(record.developmentProjects);
if (body.developmentProjects != null) {
await Promise.all(
body.developmentProjects.map(async (x) => {
let data1 = new DevelopmentProject();
data1.name = x;
data1.createdUserId = req.user.sub;
data1.createdFullName = req.user.name;
data1.lastUpdateUserId = req.user.sub;
data1.lastUpdateFullName = req.user.name;
data1.profileDevelopmentId = record.id;
await this.developmentProjectRepository.save(data1);
let data2 = new DevelopmentProject();
data2.name = x;
data2.createdUserId = req.user.sub;
data2.createdFullName = req.user.name;
data2.lastUpdateUserId = req.user.sub;
data2.lastUpdateFullName = req.user.name;
data2.profileDevelopmentId = history.id;
await this.developmentProjectRepository.save(data2);
}),
);
}
return new HttpSuccess(); return new HttpSuccess();
} }
@ -132,6 +189,10 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
@Delete("{developmentId}") @Delete("{developmentId}")
public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) { public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
await this.developmentProjectRepository.delete({ profileDevelopmentId: developmentId });
await this.developmentProjectRepository.delete({
profileDevelopmentHistory: { profileDevelopmentId: developmentId },
});
await this.developmentHistoryRepository.delete({ await this.developmentHistoryRepository.delete({
profileDevelopmentId: developmentId, profileDevelopmentId: developmentId,
}); });

View file

@ -7,118 +7,121 @@ import { DevelopmentProject } from "./developmentProject";
@Entity("profileDevelopment") @Entity("profileDevelopment")
export class ProfileDevelopment extends EntityBase { export class ProfileDevelopment extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
length: 40, length: 40,
comment: "คีย์นอก(FK)ของตาราง Profile", comment: "คีย์นอก(FK)ของตาราง Profile",
default: null, default: null,
}) })
profileId: string; profileId: string;
@Column({ @Column({
nullable: true, nullable: true,
length: 40, length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
default: null, default: null,
}) })
profileEmployeeId: string; profileEmployeeId: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ชื่อเรื่อง", comment: "ชื่อเรื่อง",
default: null, default: null,
}) })
name: string; name: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เป้าหมาย", comment: "เป้าหมาย",
default: null, default: null,
}) })
target: string; target: string;
@Column({ @Column({
type: "double", type: "double",
nullable: true, nullable: true,
default: null, default: null,
comment: "ผลการประเมิน", comment: "ผลการประเมิน",
}) })
summary: number; summary: number;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ระดับคะแนน", comment: "ระดับคะแนน",
default: null, default: null,
}) })
point: number; point: number;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เกณฑ์การประเมิน 10", comment: "เกณฑ์การประเมิน 10",
default: null, default: null,
}) })
achievement10: string; achievement10: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เกณฑ์การประเมิน 5", comment: "เกณฑ์การประเมิน 5",
default: null, default: null,
}) })
achievement5: string; achievement5: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เกณฑ์การประเมิน 0", comment: "เกณฑ์การประเมิน 0",
default: null, default: null,
}) })
achievement0: string; achievement0: string;
@Column({ @Column({
comment: "วิธีพัฒนา70", comment: "วิธีพัฒนา70",
default: false, default: false,
}) })
isDevelopment70: boolean; isDevelopment70: boolean;
@Column({ @Column({
comment: "วิธีพัฒนา20", comment: "วิธีพัฒนา20",
default: false, default: false,
}) })
isDevelopment20: boolean; isDevelopment20: boolean;
@Column({ @Column({
comment: "วิธีพัฒนา10", comment: "วิธีพัฒนา10",
default: false, default: false,
}) })
isDevelopment10: boolean; isDevelopment10: boolean;
@Column({ @Column({
nullable: true, nullable: true,
comment: "รายละเอียดอื่นๆ 70 แผน", comment: "รายละเอียดอื่นๆ 70 แผน",
default: null, default: null,
}) })
reasonDevelopment70: string; reasonDevelopment70: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "รายละเอียดอื่นๆ 20 แผน", comment: "รายละเอียดอื่นๆ 20 แผน",
default: null, default: null,
}) })
reasonDevelopment20: string; reasonDevelopment20: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "รายละเอียดอื่นๆ 10 แผน", comment: "รายละเอียดอื่นๆ 10 แผน",
default: null, default: null,
}) })
reasonDevelopment10: string; reasonDevelopment10: string;
@OneToMany( @OneToMany(
() => DevelopmentProject, () => DevelopmentProject,
(developmentProject: DevelopmentProject) => developmentProject.profileDevelopment, (developmentProject: DevelopmentProject) => developmentProject.profileDevelopment,
) )
developmentProjects: DevelopmentProject[]; developmentProjects: DevelopmentProject[];
@OneToMany(() => ProfileDevelopmentHistory, (profileDevelopmentHistory) => profileDevelopmentHistory.histories) @OneToMany(
() => ProfileDevelopmentHistory,
(profileDevelopmentHistory) => profileDevelopmentHistory.histories,
)
profileDevelopmentHistories: ProfileDevelopmentHistory[]; profileDevelopmentHistories: ProfileDevelopmentHistory[];
@ManyToOne(() => Profile, (profile) => profile.profileDevelopments) @ManyToOne(() => Profile, (profile) => profile.profileDevelopments)
@ -167,18 +170,18 @@ export class CreateProfileEmployeeDevelopment {
} }
export type UpdateProfileDevelopment = { export type UpdateProfileDevelopment = {
name: string; name: string;
target: string | null; target: string | null;
achievement10?: string | null; achievement10?: string | null;
achievement5?: string | null; achievement5?: string | null;
achievement0?: string | null; achievement0?: string | null;
developmentProjects?: string[]; developmentProjects?: string[];
reasonDevelopment70?: string; reasonDevelopment70?: string;
reasonDevelopment20?: string; reasonDevelopment20?: string;
reasonDevelopment10?: string; reasonDevelopment10?: string;
isDevelopment70: boolean; isDevelopment70: boolean;
isDevelopment20: boolean; isDevelopment20: boolean;
isDevelopment10: boolean; isDevelopment10: boolean;
summary?: number; summary?: number;
point?: number; point?: number;
}; };

View file

@ -5,100 +5,101 @@ import { DevelopmentProject } from "./developmentProject";
@Entity("profileDevelopmentHistory") @Entity("profileDevelopmentHistory")
export class ProfileDevelopmentHistory extends EntityBase { export class ProfileDevelopmentHistory extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
comment: "ชื่อเรื่อง", comment: "ชื่อเรื่อง",
default: null, default: null,
}) })
name: string; name: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เป้าหมาย", comment: "เป้าหมาย",
default: null, default: null,
}) })
target: string; target: string;
@Column({ @Column({
type: "double", type: "double",
nullable: true, nullable: true,
default: null, default: null,
comment: "ผลการประเมิน", comment: "ผลการประเมิน",
}) })
summary: number; summary: number;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ระดับคะแนน", comment: "ระดับคะแนน",
default: null, default: null,
}) })
point: number; point: number;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เกณฑ์การประเมิน 10", comment: "เกณฑ์การประเมิน 10",
default: null, default: null,
}) })
achievement10: string; achievement10: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เกณฑ์การประเมิน 5", comment: "เกณฑ์การประเมิน 5",
default: null, default: null,
}) })
achievement5: string; achievement5: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เกณฑ์การประเมิน 0", comment: "เกณฑ์การประเมิน 0",
default: null, default: null,
}) })
achievement0: string; achievement0: string;
@Column({ @Column({
comment: "วิธีพัฒนา70", comment: "วิธีพัฒนา70",
default: false, default: false,
}) })
isDevelopment70: boolean; isDevelopment70: boolean;
@Column({ @Column({
comment: "วิธีพัฒนา20", comment: "วิธีพัฒนา20",
default: false, default: false,
}) })
isDevelopment20: boolean; isDevelopment20: boolean;
@Column({ @Column({
comment: "วิธีพัฒนา10", comment: "วิธีพัฒนา10",
default: false, default: false,
}) })
isDevelopment10: boolean; isDevelopment10: boolean;
@Column({ @Column({
nullable: true, nullable: true,
comment: "รายละเอียดอื่นๆ 70 แผน", comment: "รายละเอียดอื่นๆ 70 แผน",
default: null, default: null,
}) })
reasonDevelopment70: string; reasonDevelopment70: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "รายละเอียดอื่นๆ 20 แผน", comment: "รายละเอียดอื่นๆ 20 แผน",
default: null, default: null,
}) })
reasonDevelopment20: string; reasonDevelopment20: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "รายละเอียดอื่นๆ 10 แผน", comment: "รายละเอียดอื่นๆ 10 แผน",
default: null, default: null,
}) })
reasonDevelopment10: string; reasonDevelopment10: string;
@OneToMany( @OneToMany(
() => DevelopmentProject, () => DevelopmentProject,
(developmentHistoryProject: DevelopmentProject) => developmentHistoryProject.profileDevelopmentHistory, (developmentHistoryProject: DevelopmentProject) =>
) developmentHistoryProject.profileDevelopmentHistory,
developmentHistoryProjects: DevelopmentProject[]; )
developmentHistoryProjects: DevelopmentProject[];
@Column({ @Column({
nullable: true, nullable: true,
@ -108,7 +109,10 @@ export class ProfileDevelopmentHistory extends EntityBase {
}) })
profileDevelopmentId: string; profileDevelopmentId: string;
@ManyToOne(() => ProfileDevelopment, (profileDevelopment) => profileDevelopment.profileDevelopmentHistories) @ManyToOne(
() => ProfileDevelopment,
(profileDevelopment) => profileDevelopment.profileDevelopmentHistories,
)
@JoinColumn({ name: "profileDevelopmentId" }) @JoinColumn({ name: "profileDevelopmentId" })
histories: ProfileDevelopment; histories: ProfileDevelopment;
} }