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 { 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 { query } from "express";
|
||||||
|
|
||||||
@Route("api/v1/salary")
|
@Route("api/v1/salary")
|
||||||
@Tags("Salary")
|
@Tags("Salary")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
export class Salary extends Controller {
|
export class Salary extends Controller {
|
||||||
private salaryRepository = AppDataSource.getRepository(Salarys);
|
private salaryRepository = AppDataSource.getRepository(Salarys);
|
||||||
|
private salaryRankRepository = AppDataSource.getRepository(SalaryRanks);
|
||||||
private poTypeRepository = AppDataSource.getRepository(PosType);
|
private poTypeRepository = AppDataSource.getRepository(PosType);
|
||||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||||
|
|
||||||
|
|
@ -294,7 +297,9 @@ export class Salary extends Controller {
|
||||||
const formattedData = filteredSalary.map((item) => ({
|
const formattedData = filteredSalary.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
salaryType: item.salaryType,
|
salaryType: item.salaryType,
|
||||||
|
posTypeId: item.posType_?.id,
|
||||||
posType: item.posType_?.posTypeName,
|
posType: item.posType_?.posTypeName,
|
||||||
|
posLevelId: item.posLevel_?.id,
|
||||||
posLevel: item.posLevel_?.posLevelName,
|
posLevel: item.posLevel_?.posLevelName,
|
||||||
isActive: item.isActive,
|
isActive: item.isActive,
|
||||||
date: item.date,
|
date: item.date,
|
||||||
|
|
@ -313,7 +318,9 @@ export class Salary extends Controller {
|
||||||
const formattedData = salary.map((item) => ({
|
const formattedData = salary.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
salaryType: item.salaryType,
|
salaryType: item.salaryType,
|
||||||
|
posTypeId: item.posType_?.id,
|
||||||
posType: item.posType_?.posTypeName,
|
posType: item.posType_?.posTypeName,
|
||||||
|
posLevelId: item.posLevel_?.id,
|
||||||
posLevel: item.posLevel_?.posLevelName,
|
posLevel: item.posLevel_?.posLevelName,
|
||||||
isActive: item.isActive,
|
isActive: item.isActive,
|
||||||
date: item.date,
|
date: item.date,
|
||||||
|
|
@ -327,4 +334,49 @@ export class Salary extends Controller {
|
||||||
return error;
|
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