แก้ วันที่ update
This commit is contained in:
parent
6d36c9b05f
commit
218886b3f4
83 changed files with 1671 additions and 3483 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -9,12 +8,8 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
|
|
@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
}
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAssessments) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@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, @Request() req: RequestWithUser) {
|
||||
public async detailProfileAssessments(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({
|
||||
profileEmployeeId,
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||
where: {
|
||||
profileEmployeeId: profileEmployeeId,
|
||||
},
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAssessments) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -90,52 +68,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@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, @Request() req: RequestWithUser) {
|
||||
public async getProfileAssessmentsHistory(
|
||||
@Path() assessmentId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.profileAssessmentsHistoryRepository.findBy({
|
||||
profileAssessmentId: assessmentId,
|
||||
const record = await this.profileAssessmentsHistoryRepository.find({
|
||||
where: {
|
||||
profileAssessmentId: assessmentId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
|
||||
if (!record) {
|
||||
|
|
@ -166,6 +108,8 @@ export class ProfileAssessmentsEmployeeTempController 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 });
|
||||
const history = new ProfileAssessmentHistory();
|
||||
|
|
@ -191,15 +135,18 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
const history = new ProfileAssessmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
|
||||
history.profileAssessmentId = assessmentId;
|
||||
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.profileAssessmentsRepository.save(record),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue