ข้อมูลผลงาน ทะเบียนประวัติลูกจ้าง

This commit is contained in:
Bright 2024-05-13 17:09:34 +07:00
parent 497db161c4
commit 4faefe54f3
10 changed files with 860 additions and 13 deletions

View file

@ -0,0 +1,196 @@
import {
Controller,
Post,
Put,
Delete,
Route,
Security,
Tags,
Body,
Path,
Request,
SuccessResponse,
Response,
Get,
Query,
Patch,
Example,
} from "tsoa";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileEmployeeAssessment,
ProfileAssessment,
UpdateProfileAssessment,
} from "../entities/ProfileAssessment";
import { ProfileAssessmentHistory } from "../entities/ProfileAssessmentHistory";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import { RequestWithUser } from "../middlewares/user";
@Route("api/v1/org/profile-employee/assessments")
@Tags("ProfileEmployeeAssessments")
@Security("bearerAuth")
export class ProfileEmployeeAssessmentsController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private profileAssessmentsRepository = AppDataSource.getRepository(ProfileAssessment);
private profileAssessmentsHistoryRepository =
AppDataSource.getRepository(ProfileAssessmentHistory);
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
createdAt: "2024-03-12T20:56:45.986Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T20:56:45.986Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 0,
point1Total: 0,
point2: 0,
point2Total: 0,
pointSum: 0,
pointSumTotal: 0,
},
],
})
public async detailProfileAssessments(@Path() profileEmployeeId: string) {
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({ profileEmployeeId });
if (!getProfileAssessments) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileAssessments);
}
@Get("history/{assessmentId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "47b3e370-be05-4469-a34f-e4a04747f54e",
createdAt: "2024-03-12T20:59:39.774Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:59:39.774Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 0,
point1Total: 0,
point2: 100,
point2Total: 100,
pointSum: 100,
pointSumTotal: 100,
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
},
{
id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7",
createdAt: "2024-03-12T20:58:19.450Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:58:19.450Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 50,
point1Total: 50,
point2: 100,
point2Total: 100,
pointSum: 150,
pointSumTotal: 150,
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
},
],
})
public async getProfileAssessmentsHistory(@Path() assessmentId: string) {
const record = await this.profileAssessmentsHistoryRepository.findBy({
profileAssessmentId: assessmentId,
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Post()
public async profileAssessment(
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeAssessment,
) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const data = new ProfileAssessment();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
};
Object.assign(data, { ...body, ...meta });
await this.profileAssessmentsRepository.save(data);
return new HttpSuccess();
}
@Patch("{assessmentId}")
public async editProfileAssessment(
@Body() requestBody: UpdateProfileAssessment,
@Request() req: RequestWithUser,
@Path() assessmentId: string,
) {
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileAssessmentHistory();
Object.assign(history, { ...record, id: undefined });
Object.assign(record, requestBody);
history.profileAssessmentId = assessmentId;
history.lastUpdateFullName = req.user.name;
record.lastUpdateFullName = req.user.name;
await Promise.all([
this.profileAssessmentsRepository.save(record),
this.profileAssessmentsHistoryRepository.save(history),
]);
return new HttpSuccess();
}
@Delete("{assessmentId}")
public async deleteProfileAssessment(@Path() assessmentId: string) {
await this.profileAssessmentsHistoryRepository.delete({
profileAssessmentId: assessmentId,
});
const result = await this.profileAssessmentsRepository.delete({ id: assessmentId });
if (result.affected && result.affected <= 0)
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess();
}
}

View file

@ -14,7 +14,7 @@ import {
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileCertificate,
CreateProfileEmployeeCertificate,
ProfileCertificate,
UpdateProfileCertificate,
} from "../entities/ProfileCertificate";
@ -28,7 +28,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
@Route("api/v1/org/profile-employee/certificate")
@Tags("ProfileEmployeeCertificate")
@Security("bearerAuth")
export class ProfileCertificateEmployeeController extends Controller {
export class ProfileEmployeeCertificateController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private certificateRepo = AppDataSource.getRepository(ProfileCertificate);
private certificateHistoryRepo = AppDataSource.getRepository(ProfileCertificateHistory);
@ -107,7 +107,7 @@ export class ProfileCertificateEmployeeController extends Controller {
@Post()
public async newCertificate(
@Request() req: RequestWithUser,
@Body() body: CreateProfileCertificate,
@Body() body: CreateProfileEmployeeCertificate,
) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");

View file

@ -0,0 +1,171 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { CreateProfileEmployeeHonor, ProfileHonor, UpdateProfileHonor } from "../entities/ProfileHonor";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { ProfileHonorHistory } from "../entities/ProfileHonorHistory";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
@Route("api/v1/org/profile-employee/honor")
@Tags("ProfileEmployeeHonor")
@Security("bearerAuth")
export class ProfileEmployeeHonorController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private honorRepo = AppDataSource.getRepository(ProfileHonor);
private honorHistoryRepo = AppDataSource.getRepository(ProfileHonorHistory);
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
createdAt: "2024-03-12T03:10:05.594Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:10:05.594Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
detail: "string",
issueDate: "2024-03-12T10:09:47.000Z",
issuer: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
refCommandNo: "string",
isDate: true,
},
],
})
public async getHonor(@Path() profileEmployeeId: string) {
const record = await this.honorRepo.findBy({ profileEmployeeId });
return new HttpSuccess(record);
}
@Get("history/{honorId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3bedb365-4a41-4df5-8f47-b6e143221d2c",
createdAt: "2024-03-12T03:11:01.395Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:11:01.395Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
detail: "detail",
issueDate: "2024-03-12T10:10:31.000Z",
issuer: "issuer",
refCommandDate: "2024-03-12T10:10:31.000Z",
refCommandNo: "refCommandNo",
isDate: true,
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
},
{
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
createdAt: "2024-03-12T03:10:05.657Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:10:05.657Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
detail: "string",
issueDate: "2024-03-12T10:09:47.000Z",
issuer: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
refCommandNo: "string",
isDate: true,
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
},
],
})
public async honorHistory(@Path() honorId: string) {
const record = await this.honorHistoryRepo.findBy({
profileHonorId: honorId,
});
return new HttpSuccess(record);
}
@Post()
public async newHonor(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeHonor) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const data = new ProfileHonor();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
};
Object.assign(data, { ...body, ...meta });
await this.honorRepo.save(data);
return new HttpSuccess();
}
@Patch("{honorId}")
public async editHonor(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileHonor,
@Path() honorId: string,
) {
const record = await this.honorRepo.findOneBy({ id: honorId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileHonorHistory();
Object.assign(history, { ...record, id: undefined });
Object.assign(record, body);
history.profileHonorId = honorId;
record.lastUpdateFullName = req.user.name;
history.lastUpdateFullName = req.user.name;
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
return new HttpSuccess();
}
@Delete("{honorId}")
public async deleteTraning(@Path() honorId: string) {
await this.honorHistoryRepo.delete({
profileHonorId: honorId,
});
const result = await this.honorRepo.delete({ id: honorId });
if (result.affected && result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
}

View file

@ -0,0 +1,229 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileEmployeeInsignia,
ProfileInsignia,
UpdateProfileInsignia,
} from "../entities/ProfileInsignia";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { ProfileInsigniaHistory } from "../entities/ProfileInsigniaHistory";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import { Insignia } from "../entities/Insignia";
@Route("api/v1/org/profile-employee/insignia")
@Tags("ProfileEmployeeInsignia")
@Security("bearerAuth")
export class ProfileEmployeeInsigniaController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private insigniaHistoryRepo = AppDataSource.getRepository(ProfileInsigniaHistory);
private insigniaMetaRepo = AppDataSource.getRepository(Insignia);
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:05:09.393Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
},
],
})
public async getInsignia(@Path() profileEmployeeId: string) {
const record = await this.insigniaRepo.find({
relations: {
insignia: {
insigniaType: true,
},
},
where: { profileEmployeeId },
});
return new HttpSuccess(record);
}
@Get("history/{InsigniaId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30",
createdAt: "2024-03-12T03:06:31.062Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:06:31.062Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "no",
volume: "volume",
section: "section",
page: "page",
receiveDate: "2024-03-12T10:05:44.000Z",
insigniaId: "insigniaId",
insigniaType: "insigniaType",
dateAnnounce: "2024-03-12T10:05:44.000Z",
issue: "string",
volumeNo: "volumeNo",
refCommandDate: "2024-03-12T10:05:44.000Z",
refCommandNo: "refCommandNo",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:09:04.905Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
],
})
public async getInsigniaHistory(@Path() InsigniaId: string) {
const record = await this.insigniaHistoryRepo.find({
relations: {
insignia: {
insigniaType: true,
},
},
where: {
profileInsigniaId: InsigniaId,
},
});
return new HttpSuccess(record);
}
@Post()
public async newInsignia(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeInsignia) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const insignia = await this.insigniaMetaRepo.findOne({
where: { id: body.insigniaId },
});
if (!insignia) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชฯ นี้");
}
const data = new ProfileInsignia();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
};
Object.assign(data, { ...body, ...meta });
await this.insigniaRepo.save(data);
return new HttpSuccess();
}
@Patch("{insigniaId}")
public async editInsignia(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileInsignia,
@Path() insigniaId: string,
) {
const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const insignia = await this.insigniaMetaRepo.findOne({
where: { id: body.insigniaId },
});
if (!insignia) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชฯ นี้");
}
const history = new ProfileInsigniaHistory();
Object.assign(history, { ...record, id: undefined });
Object.assign(record, body);
history.profileInsigniaId = insigniaId;
record.lastUpdateFullName = req.user.name;
history.lastUpdateFullName = req.user.name;
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
return new HttpSuccess();
}
@Delete("{insigniaId}")
public async deleteInsignia(@Path() insigniaId: string) {
await this.insigniaHistoryRepo.delete({
profileInsigniaId: insigniaId,
});
const result = await this.insigniaRepo.delete({ id: insigniaId });
if (result.affected && result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
}

View file

@ -0,0 +1,193 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileEmployeeTraining,
ProfileTraining,
UpdateProfileTraining,
} from "../entities/ProfileTraining";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { ProfileTrainingHistory } from "../entities/ProfileTrainingHistory";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
@Route("api/v1/org/profile-employee/training")
@Tags("ProfileEmployeeTraining")
@Security("bearerAuth")
export class ProfileEmployeeTrainingController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private trainingRepo = AppDataSource.getRepository(ProfileTraining);
private trainingHistoryRepo = AppDataSource.getRepository(ProfileTrainingHistory);
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
createdAt: "2024-03-12T02:55:56.915Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
},
],
})
public async getTraining(@Path() profileEmployeeId: string) {
const record = await this.trainingRepo.findBy({ profileEmployeeId });
return new HttpSuccess(record);
}
@Get("history/{trainingId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
createdAt: "2024-03-12T02:55:56.971Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
{
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
createdAt: "2024-03-12T02:58:17.917Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:57:44.000Z",
endDate: "2024-03-12T09:57:44.000Z",
numberOrder: "string",
topic: "topic",
place: "place",
dateOrder: "2024-03-12T09:57:44.000Z",
department: "department",
duration: "string",
name: "name",
yearly: 0,
isDate: true,
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
],
})
public async trainingHistory(@Path() trainingId: string) {
const record = await this.trainingHistoryRepo.findBy({
profileTrainingId: trainingId,
});
return new HttpSuccess(record);
}
@Post()
public async newTraining(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeTraining) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const data = new ProfileTraining();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
};
Object.assign(data, { ...body, ...meta });
await this.trainingRepo.save(data);
return new HttpSuccess();
}
@Patch("{trainingId}")
public async editTraining(
@Request() req: RequestWithUser,
@Body() body: UpdateProfileTraining,
@Path() trainingId: string,
) {
const record = await this.trainingRepo.findOneBy({ id: trainingId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileTrainingHistory();
Object.assign(history, { ...record, id: undefined });
Object.assign(record, body);
history.profileTrainingId = trainingId;
record.lastUpdateFullName = req.user.name;
history.lastUpdateFullName = req.user.name;
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
return new HttpSuccess();
}
@Delete("{trainingId}")
public async deleteTraining(@Path() trainingId: string) {
await this.trainingHistoryRepo.delete({
profileTrainingId: trainingId,
});
const result = await this.trainingRepo.delete({ id: trainingId });
if (result.affected && result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
}

View file

@ -102,8 +102,19 @@ export class ProfileAssessment extends EntityBase {
}
export class CreateProfileAssessment {
profileId?: string | null;
profileEmployeeId?: string | null;
profileId: string | null;
name: string | null;
date: Date | null;
point1: number | null;
point1Total: number | null;
point2: number | null;
point2Total: number | null;
pointSum: number | null;
pointSumTotal: number | null;
}
export class CreateProfileEmployeeAssessment {
profileEmployeeId: string | null;
name: string | null;
date: Date | null;
point1: number | null;

View file

@ -78,8 +78,16 @@ export class ProfileCertificate extends EntityBase {
}
export class CreateProfileCertificate {
profileId?: string | null;
profileEmployeeId?: string | null;
profileId: string | null;
expireDate: Date | null;
issueDate: Date | null;
certificateNo: string | null;
certificateType: string | null;
issuer: string | null;
}
export class CreateProfileEmployeeCertificate {
profileEmployeeId: string | null;
expireDate: Date | null;
issueDate: Date | null;
certificateNo: string | null;

View file

@ -82,8 +82,17 @@ export class ProfileHonor extends EntityBase {
}
export class CreateProfileHonor {
profileId?: string | null;
profileEmployeeId?: string | null;
profileId: string | null;
detail: string | null;
issueDate: Date | null;
issuer: string | null;
refCommandDate: Date | null;
refCommandNo: string | null;
isDate: boolean | null;
}
export class CreateProfileEmployeeHonor {
profileEmployeeId: string | null;
detail: string | null;
issueDate: Date | null;
issuer: string | null;

View file

@ -142,8 +142,24 @@ export class ProfileInsignia extends EntityBase {
}
export class CreateProfileInsignia {
profileId?: string | null;
profileEmployeeId?: string | null;
profileId: string | null;
year: number;
no: string | null;
volume: string | null;
section: string | null;
page: string | null;
receiveDate: Date | null;
insigniaId: string;
dateAnnounce: Date | null;
issue: string | null;
volumeNo: string | null;
refCommandDate: Date | null;
refCommandNo: string | null;
note: string | null;
}
export class CreateProfileEmployeeInsignia {
profileEmployeeId: string | null;
year: number;
no: string | null;
volume: string | null;

View file

@ -124,8 +124,22 @@ export class ProfileTraining extends EntityBase {
}
export class CreateProfileTraining {
profileId?: string | null;
profileEmployeeId?: string | null;
profileId: string | null;
startDate: Date | null;
endDate: Date | null;
numberOrder: string | null;
topic: string | null;
place: string | null;
dateOrder: Date | null;
department: string | null;
duration: string | null;
name: string | null;
yearly: number | null;
isDate: boolean | null;
}
export class CreateProfileEmployeeTraining {
profileEmployeeId: string | null;
startDate: Date | null;
endDate: Date | null;
numberOrder: string | null;