add createdAt, lastUpdatedAt, lastUpdateFullName #805

This commit is contained in:
Bright 2024-11-22 18:11:15 +07:00
parent 6f1e2339f5
commit 416cd49a27
5 changed files with 137 additions and 22 deletions

View file

@ -194,8 +194,14 @@ export class EmployeePosTypeController extends Controller {
async GetEmpTypeById(@Path() id: string) { async GetEmpTypeById(@Path() id: string) {
const getEmpPosType = await this.employeePosTypeRepository.findOne({ const getEmpPosType = await this.employeePosTypeRepository.findOne({
relations: ["posLevels"], relations: ["posLevels"],
select: ["id", "posTypeName", "posTypeRank", "posTypeShortName"], select: ["id", "posTypeName", "posTypeRank", "posTypeShortName", "createdAt", "lastUpdatedAt", "lastUpdateFullName"],
where: { id: id }, where: { id: id },
order: {
createdAt: "DESC",
posLevels: {
createdAt: "DESC"
}
}
}); });
if (!getEmpPosType) { if (!getEmpPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
@ -213,7 +219,13 @@ export class EmployeePosTypeController extends Controller {
posLevelName: empPosLevel.posLevelName, posLevelName: empPosLevel.posLevelName,
posLevelRank: empPosLevel.posLevelRank, posLevelRank: empPosLevel.posLevelRank,
posLevelAuthority: empPosLevel.posLevelAuthority, posLevelAuthority: empPosLevel.posLevelAuthority,
createdAt: empPosLevel.createdAt,
lastUpdatedAt: empPosLevel.lastUpdatedAt,
lastUpdateFullName: empPosLevel.lastUpdateFullName
})), })),
createdAt: getEmpPosType.createdAt,
lastUpdatedAt: getEmpPosType.lastUpdatedAt,
lastUpdateFullName: getEmpPosType.lastUpdateFullName
}; };
return new HttpSuccess(mapGetEmpPosType); return new HttpSuccess(mapGetEmpPosType);
@ -229,8 +241,14 @@ export class EmployeePosTypeController extends Controller {
async GetEmpPosType() { async GetEmpPosType() {
const empPosType = await this.employeePosTypeRepository.find({ const empPosType = await this.employeePosTypeRepository.find({
relations: ["posLevels"], relations: ["posLevels"],
select: ["id", "posTypeName", "posTypeRank", "posTypeShortName"], select: ["id", "posTypeName", "posTypeRank", "posTypeShortName", "createdAt", "lastUpdatedAt", "lastUpdateFullName"],
order: { posTypeRank: "ASC" }, order: {
posTypeRank: "ASC",
createdAt: "DESC",
posLevels: {
createdAt: "DESC",
}
},
}); });
const mapEmpPosType = empPosType.map((item) => ({ const mapEmpPosType = empPosType.map((item) => ({
@ -245,7 +263,13 @@ export class EmployeePosTypeController extends Controller {
posLevelName: empPosLevel.posLevelName, posLevelName: empPosLevel.posLevelName,
posLevelRank: empPosLevel.posLevelRank, posLevelRank: empPosLevel.posLevelRank,
posLevelAuthority: empPosLevel.posLevelAuthority, posLevelAuthority: empPosLevel.posLevelAuthority,
createdAt: empPosLevel.createdAt,
lastUpdatedAt: empPosLevel.lastUpdatedAt,
lastUpdateFullName: empPosLevel.lastUpdateFullName
})), })),
createdAt: item.createdAt,
lastUpdatedAt: item.lastUpdatedAt,
lastUpdateFullName: item.lastUpdateFullName
})); }));
return new HttpSuccess(mapEmpPosType); return new HttpSuccess(mapEmpPosType);
} }

View file

@ -288,7 +288,13 @@ export class EmployeePositionController extends Controller {
findData = await this.employeePosDictRepository.find({ findData = await this.employeePosDictRepository.find({
where: { posDictName: Like(`%${keyword}%`) }, where: { posDictName: Like(`%${keyword}%`) },
relations: ["posType", "posLevel"], relations: ["posType", "posLevel"],
order: { posLevel: { posLevelName: "ASC" } }, order: {
posLevel: {
posLevelName: "ASC",
createdAt: "DESC"
},
createdAt: "DESC"
},
}); });
break; break;
@ -300,7 +306,13 @@ export class EmployeePositionController extends Controller {
findData = await this.employeePosDictRepository.find({ findData = await this.employeePosDictRepository.find({
where: { posTypeId: In(findEmpTypes.map((x) => x.id)) }, where: { posTypeId: In(findEmpTypes.map((x) => x.id)) },
relations: ["posType", "posLevel"], relations: ["posType", "posLevel"],
order: { posLevel: { posLevelName: "ASC" } }, order: {
posLevel: {
posLevelName: "ASC",
createdAt: "DESC"
},
createdAt: "DESC"
},
}); });
break; break;
@ -312,13 +324,25 @@ export class EmployeePositionController extends Controller {
findData = await this.employeePosDictRepository.find({ findData = await this.employeePosDictRepository.find({
where: { posLevelId: In(findEmpLevels.map((x) => x.id)) }, where: { posLevelId: In(findEmpLevels.map((x) => x.id)) },
relations: ["posType", "posLevel"], relations: ["posType", "posLevel"],
order: { posLevel: { posLevelName: "ASC" } }, order: {
posLevel: {
posLevelName: "ASC",
createdAt: "DESC"
},
createdAt: "DESC"
},
}); });
} else { } else {
//กรณีเลือกค้นหาจาก"ระดับชั้นงาน" แต่กรอกไม่ใช่ number ให้ปล่อยมาหมดเลย //กรณีเลือกค้นหาจาก"ระดับชั้นงาน" แต่กรอกไม่ใช่ number ให้ปล่อยมาหมดเลย
findData = await this.employeePosDictRepository.find({ findData = await this.employeePosDictRepository.find({
relations: ["posType", "posLevel"], relations: ["posType", "posLevel"],
order: { posLevel: { posLevelName: "ASC" } }, order: {
posLevel: {
posLevelName: "ASC",
createdAt: "DESC"
},
createdAt: "DESC"
},
}); });
} }
break; break;
@ -326,7 +350,13 @@ export class EmployeePositionController extends Controller {
default: default:
findData = await this.employeePosDictRepository.find({ findData = await this.employeePosDictRepository.find({
relations: ["posType", "posLevel"], relations: ["posType", "posLevel"],
order: { posLevel: { posLevelName: "ASC" } }, order: {
posLevel: {
posLevelName: "ASC",
createdAt: "DESC"
},
createdAt: "DESC"
},
}); });
break; break;
} }
@ -354,6 +384,9 @@ export class EmployeePositionController extends Controller {
posTypeShortName: posTypeShortName, posTypeShortName: posTypeShortName,
posLevelId: item.posLevelId, posLevelId: item.posLevelId,
posLevelName: `${posTypeShortName} ${posLevelName}`, posLevelName: `${posTypeShortName} ${posLevelName}`,
createdAt: item.createdAt,
lastUpdatedAt: item.lastUpdatedAt,
lastUpdateFullName: item.lastUpdateFullName
}; };
}), }),
); );

View file

@ -204,8 +204,11 @@ export class PosExecutiveController extends Controller {
]) ])
async GetPosExecutive() { async GetPosExecutive() {
const posExecutive = await this.posExecutiveRepository.find({ const posExecutive = await this.posExecutiveRepository.find({
select: ["id", "posExecutiveName", "posExecutivePriority"], select: ["id", "posExecutiveName", "posExecutivePriority", "createdAt", "lastUpdatedAt", "lastUpdateFullName"],
order: { posExecutivePriority: "ASC" }, order: {
posExecutivePriority: "ASC",
createdAt: "DESC"
},
}); });
// if (!posExecutive) { // if (!posExecutive) {
// return new HttpSuccess([]); // return new HttpSuccess([]);

View file

@ -181,9 +181,15 @@ export class PosTypeController extends Controller {
]) ])
async GetTypeDetail(@Path() id: string) { async GetTypeDetail(@Path() id: string) {
const getPosType = await this.posTypeRepository.findOne({ const getPosType = await this.posTypeRepository.findOne({
select: ["id", "posTypeName", "posTypeRank"], select: ["id", "posTypeName", "posTypeRank", "createdAt", "lastUpdatedAt", "lastUpdateFullName"],
relations: ["posLevels"], relations: ["posLevels"],
where: { id: id }, where: { id: id },
order: {
createdAt: "DESC",
posLevels: {
createdAt: "DESC",
}
}
}); });
if (!getPosType) { if (!getPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
@ -200,7 +206,13 @@ export class PosTypeController extends Controller {
posLevelName: posLevel.posLevelName, posLevelName: posLevel.posLevelName,
posLevelRank: posLevel.posLevelRank, posLevelRank: posLevel.posLevelRank,
posLevelAuthority: posLevel.posLevelAuthority, posLevelAuthority: posLevel.posLevelAuthority,
createdAt: posLevel.createdAt,
lastUpdatedAt: posLevel.lastUpdatedAt,
lastUpdateFullName: posLevel.lastUpdateFullName
})), })),
createdAt: getPosType.createdAt,
lastUpdatedAt: getPosType.lastUpdatedAt,
lastUpdateFullName: getPosType.lastUpdateFullName
}; };
return new HttpSuccess(mapGetPosType); return new HttpSuccess(mapGetPosType);
@ -230,9 +242,15 @@ export class PosTypeController extends Controller {
]) ])
async GetPosType() { async GetPosType() {
const posType = await this.posTypeRepository.find({ const posType = await this.posTypeRepository.find({
select: ["id", "posTypeName", "posTypeRank"], select: ["id", "posTypeName", "posTypeRank", "createdAt", "lastUpdatedAt", "lastUpdateFullName"],
relations: ["posLevels"], relations: ["posLevels"],
order: { posTypeRank: "ASC" }, order: {
posTypeRank: "ASC",
createdAt: "DESC",
posLevels: {
createdAt: "DESC"
}
},
}); });
// if (!posType) { // if (!posType) {
// return new HttpSuccess([]); // return new HttpSuccess([]);
@ -248,7 +266,13 @@ export class PosTypeController extends Controller {
posLevelName: posLevel.posLevelName, posLevelName: posLevel.posLevelName,
posLevelRank: posLevel.posLevelRank, posLevelRank: posLevel.posLevelRank,
posLevelAuthority: posLevel.posLevelAuthority, posLevelAuthority: posLevel.posLevelAuthority,
createdAt: posLevel.createdAt,
lastUpdatedAt: posLevel.lastUpdatedAt,
lastUpdateFullName: posLevel.lastUpdateFullName,
})), })),
createdAt: item.createdAt,
lastUpdatedAt: item.lastUpdatedAt,
lastUpdateFullName: item.lastUpdateFullName,
})); }));
return new HttpSuccess(mapPosType); return new HttpSuccess(mapPosType);
} }

View file

@ -567,7 +567,10 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
where: { posDictName: Like(`%${keyword}%`) }, where: { posDictName: Like(`%${keyword}%`) },
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" }, order: {
posDictName: "ASC",
createdAt: "DESC"
},
}); });
break; break;
@ -575,7 +578,10 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
where: { posDictField: Like(`%${keyword}%`) }, where: { posDictField: Like(`%${keyword}%`) },
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictField: "ASC" }, order: {
posDictField: "ASC",
createdAt: "DESC"
},
}); });
break; break;
@ -588,7 +594,10 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
where: { posTypeId: In(findTypes.map((x) => x.id)) }, where: { posTypeId: In(findTypes.map((x) => x.id)) },
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" }, order: {
posDictName: "ASC",
createdAt: "DESC"
},
}); });
break; break;
@ -601,7 +610,10 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
where: { posLevelId: In(findLevel.map((x) => x.id)) }, where: { posLevelId: In(findLevel.map((x) => x.id)) },
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" }, order: {
posDictName: "ASC",
createdAt: "DESC"
},
}); });
break; break;
@ -614,7 +626,10 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
where: { posExecutiveId: In(findExecutive.map((x) => x.id)) }, where: { posExecutiveId: In(findExecutive.map((x) => x.id)) },
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" }, order: {
posDictName: "ASC",
createdAt: "DESC"
},
}); });
break; break;
@ -622,7 +637,10 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
where: { posDictExecutiveField: Like(`%${keyword}%`) }, where: { posDictExecutiveField: Like(`%${keyword}%`) },
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" }, order: {
posDictName: "ASC",
createdAt: "DESC"
},
}); });
break; break;
@ -630,7 +648,10 @@ export class PositionController extends Controller {
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
where: { posDictArea: Like(`%${keyword}%`) }, where: { posDictArea: Like(`%${keyword}%`) },
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" }, order: {
posDictName: "ASC",
createdAt: "DESC"
},
}); });
break; break;
@ -664,14 +685,20 @@ export class PositionController extends Controller {
{ posDictArea: Like(`%${keyword}%`) }, { posDictArea: Like(`%${keyword}%`) },
], ],
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" }, order: {
posDictName: "ASC",
createdAt: "DESC"
},
}); });
break; break;
default: default:
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
relations: ["posType", "posLevel", "posExecutive"], relations: ["posType", "posLevel", "posExecutive"],
order: { posDictName: "ASC" }, order: {
posDictName: "ASC",
createdAt: "DESC"
},
}); });
break; break;
} }
@ -692,6 +719,9 @@ export class PositionController extends Controller {
positionArea: item.posDictArea, positionArea: item.posDictArea,
isSpecial: item.isSpecial, isSpecial: item.isSpecial,
positionIsSelected: false, positionIsSelected: false,
createdAt: item.createdAt,
lastUpdatedAt: item.lastUpdatedAt,
lastUpdateFullName: item.lastUpdateFullName,
}; };
}), }),
); );
@ -1447,6 +1477,7 @@ export class PositionController extends Controller {
.leftJoinAndSelect("posMaster.next_holder", "next_holder") .leftJoinAndSelect("posMaster.next_holder", "next_holder")
.leftJoinAndSelect("posMaster.orgRevision", "orgRevision") .leftJoinAndSelect("posMaster.orgRevision", "orgRevision")
.leftJoinAndSelect("posMaster.posMasterAssigns", "posMasterAssigns") .leftJoinAndSelect("posMaster.posMasterAssigns", "posMasterAssigns")
// .leftJoinAndSelect("posMaster.authRole", "authRole")
.leftJoinAndSelect("posMasterAssigns.assign", "assign") .leftJoinAndSelect("posMasterAssigns.assign", "assign")
.leftJoinAndSelect("current_holder.posType", "posType") .leftJoinAndSelect("current_holder.posType", "posType")
.leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posLevel", "posLevel")