แก้ วันที่ update

This commit is contained in:
kittapath 2024-08-30 18:02:34 +07:00
parent 6d36c9b05f
commit 218886b3f4
83 changed files with 1671 additions and 3483 deletions

View file

@ -1,7 +1,6 @@
import {
Controller,
Post,
Put,
Delete,
Route,
Security,
@ -9,24 +8,18 @@ import {
Body,
Path,
Request,
SuccessResponse,
Response,
Get,
Query,
Patch,
Example,
} from "tsoa";
import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import {
ProfileEducation,
CreateProfileEducation,
UpdateProfileEducation,
CreateProfileEducationEmployee,
} from "../entities/ProfileEducation";
import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
import { AppDataSource } from "../database/data-source";
import { ProfileEmployee } from "../entities/ProfileEmployee";
@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeTempController extends Controller {
}
const getProfileEducation = await this.profileEducationRepo.find({
where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
});
if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeTempController extends Controller {
}
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
createdAt: "2024-03-12T20:26:42.621Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T20:33:09.000Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค ชั้นสูง",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
},
],
})
public async detailProfileEducation(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
public async detailProfileEducation(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const getProfileEducation = await this.profileEducationRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -103,76 +65,16 @@ export class ProfileEducationsEmployeeTempController extends Controller {
}
@Get("history/{educationId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a",
createdAt: "2024-03-12T20:29:45.251Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:29:45.251Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
},
{
id: "2f00bd59-be3e-46d8-92a2-c4700baabf12",
createdAt: "2024-03-12T20:33:09.128Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:33:09.128Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค ชั้นสูง",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
},
],
})
public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) {
public async getProfileEducationHistory(
@Path() educationId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.profileEducationHistoryRepo.findBy({
profileEducationId: educationId,
const record = await this.profileEducationHistoryRepo.find({
where: {
profileEducationId: educationId,
},
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -201,6 +103,8 @@ export class ProfileEducationsEmployeeTempController extends Controller {
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
Object.assign(data, { ...body, ...meta });
@ -227,15 +131,18 @@ export class ProfileEducationsEmployeeTempController extends Controller {
const history = new ProfileEducationHistory();
Object.assign(record, body);
Object.assign(history, body);
Object.assign(history, { ...body, id: undefined });
history.profileEducationId = educationId;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileEducationRepo.save(record),