This commit is contained in:
AdisakKanthawilang 2024-02-16 16:15:53 +07:00
parent 6740cf5dd8
commit 4663ff3504
3 changed files with 37 additions and 63 deletions

View file

@ -18,12 +18,13 @@ import { Salarys, CreateSalary, UpdateSalary } from "../entities/Salarys";
import { PosType } from "../entities/PosType"; import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel"; import { PosLevel } from "../entities/PosLevel";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { In, IsNull, Not } from "typeorm"; import { In, IsNull, Not } from "typeorm";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status"; import HttpStatusCode from "../interfaces/http-status";
import { SalaryRanks } from "../entities/SalaryRanks"; import { SalaryRanks } from "../entities/SalaryRanks";
import { query } from "express"; import { query } from "express";
import { randomUUID } from "crypto";
@Route("api/v1/salary") @Route("api/v1/salary")
@Tags("Salary") @Tags("Salary")
@ -260,7 +261,7 @@ export class Salary extends Controller {
return error; return error;
} }
} }
/** /**
* API * API
* *
@ -335,63 +336,41 @@ export class Salary extends Controller {
} }
} }
// /** /**
// * API copy ผังเงินเดือน * API copy
// * *
// * @summary SLR_008 - copy ผังเงินเดือน #8 * @summary SLR_008 - copy #8
// * *
// */ */
// @Post("copy") @Post("copy")
// async copySalary( async copySalary(
// @Body() body: { id: string }, @Body() body: { id: string },
// @Request() request: { user: Record<string, any> } @Request() request: { user: Record<string, any> },
// ) { ) {
// const salary = await this.salaryRepository.findOne({ const salary = await this.salaryRepository.findOne({
// relations: ["posLevel_", "posType_", "salaryRanks_"], relations: ["posLevel_", "posType_", "salaryRanks_"],
// where:{id:body.id} where: { id: body.id },
// }); });
// if(!salary){ if (!salary) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเงินเดือนจากไอดีนี้ : " + body.id) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเงินเดือนจากไอดีนี้ : " + body.id);
// } }
// const salaryRank = await this.salaryRankRepository.find({ const salaryRank = await this.salaryRankRepository.find({
// where:{salaryId:salary?.id} where: { salaryId: salary?.id },
// }); });
// try { const newSalary = { ...salary, id: randomUUID() };
// const newSalary = new Salarys();
// newSalary.isActive = false;
// newSalary.salaryType = salary.salaryType;
// newSalary.posTypeId = salary.posTypeId
// newSalary.posLevelId = salary.posLevelId
// newSalary.createdUserId = request.user.sub,
// newSalary.createdFullName = request.user.name,
// newSalary.createdAt = new Date(),
// newSalary.lastUpdateUserId = request.user.sub,
// newSalary.lastUpdateFullName = request.user.name,
// newSalary.lastUpdatedAt = new Date(),
// await this.salaryRepository.save(newSalary);
// const newRanks = salary.salaryRanks_.map((rank) => { await this.salaryRepository.save(newSalary);
// newRanks.forEach(async (x: any) => {
// var dataId = x.id; await Promise.all(
// delete x.id; salaryRank.map(async (v) => {
// const data = Object.assign(new SalaryRanks(), x); const newSalaryRank = { ...v, id: randomUUID() };
// data.salaryId = newSalary.id, await this.salaryRankRepository.save(newSalaryRank);
// data.createdUserId = request.user.sub, }),
// data.createdFullName = request.user.name, );
// data.createdAt = new Date(),
// data.lastUpdateUserId = request.user.sub, return new HttpSuccess({ id: newSalary.id });
// data.lastUpdateFullName = request.user.name, }
// data.lastUpdatedAt = new Date(),
// await this.salaryRankRepository.save(data);
// });
// });
// return new HttpSuccess({ id: newSalary.id });
// } catch (error) {
// return error;
// }
// }
} }

View file

@ -23,7 +23,7 @@ import {
import { Salarys } from "../entities/Salarys"; import { Salarys } from "../entities/Salarys";
@Route("api/v1/salary/rate") @Route("api/v1/salary/rate")
@Tags("SalaryRank") @Tags("SalaryRank")
// @Security("bearerAuth") @Security("bearerAuth")
@Response( @Response(
HttpStatusCode.INTERNAL_SERVER_ERROR, HttpStatusCode.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",

View file

@ -69,11 +69,6 @@ export class SalaryRanks extends EntityBase {
}) })
isNext: boolean; isNext: boolean;
@Column({
comment: "ลำดับ",
})
rank: number;
@ManyToOne(() => Salarys, (salarys) => salarys.salaryRanks_) @ManyToOne(() => Salarys, (salarys) => salarys.salaryRanks_)
@JoinColumn({ name: "salaryId" }) @JoinColumn({ name: "salaryId" })
salarys_: Salarys; salarys_: Salarys;