add feild return SalaryList
This commit is contained in:
parent
bea9ee28fc
commit
2de3fdb81d
1 changed files with 53 additions and 1 deletions
|
|
@ -18,16 +18,19 @@ import { Salarys, CreateSalary, UpdateSalary } from "../entities/Salarys";
|
|||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
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 HttpError from "../interfaces/http-error";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { SalaryRanks } from "../entities/SalaryRanks";
|
||||
import { query } from "express";
|
||||
|
||||
@Route("api/v1/salary")
|
||||
@Tags("Salary")
|
||||
@Security("bearerAuth")
|
||||
export class Salary extends Controller {
|
||||
private salaryRepository = AppDataSource.getRepository(Salarys);
|
||||
private salaryRankRepository = AppDataSource.getRepository(SalaryRanks);
|
||||
private poTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
|
||||
|
|
@ -294,7 +297,9 @@ export class Salary extends Controller {
|
|||
const formattedData = filteredSalary.map((item) => ({
|
||||
id: item.id,
|
||||
salaryType: item.salaryType,
|
||||
posTypeId: item.posType_?.id,
|
||||
posType: item.posType_?.posTypeName,
|
||||
posLevelId: item.posLevel_?.id,
|
||||
posLevel: item.posLevel_?.posLevelName,
|
||||
isActive: item.isActive,
|
||||
date: item.date,
|
||||
|
|
@ -313,7 +318,9 @@ export class Salary extends Controller {
|
|||
const formattedData = salary.map((item) => ({
|
||||
id: item.id,
|
||||
salaryType: item.salaryType,
|
||||
posTypeId: item.posType_?.id,
|
||||
posType: item.posType_?.posTypeName,
|
||||
posLevelId: item.posLevel_?.id,
|
||||
posLevel: item.posLevel_?.posLevelName,
|
||||
isActive: item.isActive,
|
||||
date: item.date,
|
||||
|
|
@ -327,4 +334,49 @@ export class Salary extends Controller {
|
|||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * API copy ผังเงินเดือน
|
||||
// *
|
||||
// * @summary SLR_008 - copy ผังเงินเดือน #8
|
||||
// *
|
||||
// */
|
||||
// @Post("copy")
|
||||
// async copySalary(@Body() body: { id: string }) {
|
||||
// const salary = await this.salaryRepository.findOne({
|
||||
// relations: ["posLevel_", "posType_", "salaryRanks_"],
|
||||
// where:{id:body.id}
|
||||
// });
|
||||
|
||||
// if(!salary){
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเงินเดือนจากไอดีนี้ : " + body.id)
|
||||
// }
|
||||
|
||||
// const salaryRank = await this.salaryRankRepository.find({
|
||||
// where:{salaryId:salary?.id}
|
||||
// });
|
||||
|
||||
// try {
|
||||
// const newSalary = new Salarys();
|
||||
// newSalary.isActive = false;
|
||||
// newSalary.salaryType = salary.salaryType;
|
||||
// newSalary.posTypeId = salary.posTypeId
|
||||
// newSalary.posLevelId = salary.posLevelId
|
||||
// await this.salaryRepository.save(newSalary);
|
||||
|
||||
// const newRanks = salary.salaryRanks_.map((rank) => {
|
||||
// const newRank = this.salaryRankRepository.create({
|
||||
// ...rank, // เก็บทุก property จาก rank
|
||||
// salaryId: newSalary.id,
|
||||
// });
|
||||
// return newRank;
|
||||
// });
|
||||
|
||||
// await this.salaryRankRepository.save(newRanks);
|
||||
|
||||
// return new HttpSuccess({ id: newSalary.id });
|
||||
// } catch (error) {
|
||||
// return error;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue