search profilesalay temp

This commit is contained in:
mamoss 2025-03-20 18:44:41 +07:00
parent 8c30dc56f4
commit b8bea7c8ef

View file

@ -29,7 +29,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { OrgRevision } from "../entities/OrgRevision"; import { OrgRevision } from "../entities/OrgRevision";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
@Route("api/v1/org/profile/salaryTemp") @Route("api/v1/org/profile/salaryTemp")
@Tags("ProfileSalaryTemp") @Tags("ProfileSalaryTemp")
@Security("bearerAuth") @Security("bearerAuth")
export class ProfileSalaryTempController extends Controller { export class ProfileSalaryTempController extends Controller {
@ -87,7 +87,9 @@ export class ProfileSalaryTempController extends Controller {
orgRevisionId: findRevision.id, orgRevisionId: findRevision.id,
}) })
.andWhere( .andWhere(
statusCheckEdit != undefined && statusCheckEdit != null && statusCheckEdit.toUpperCase() != "ALL" statusCheckEdit != undefined &&
statusCheckEdit != null &&
statusCheckEdit.toUpperCase() != "ALL"
? "profile.statusCheckEdit = :statusCheckEdit" ? "profile.statusCheckEdit = :statusCheckEdit"
: "1=1", : "1=1",
{ {
@ -273,7 +275,7 @@ export class ProfileSalaryTempController extends Controller {
orgRevisionId: root == null ? null : root.orgRevisionId, orgRevisionId: root == null ? null : root.orgRevisionId,
org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`, org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`,
statusCheckEdit: _data.statusCheckEdit, statusCheckEdit: _data.statusCheckEdit,
type: "OFFICER" type: "OFFICER",
}; };
}), }),
); );
@ -310,7 +312,7 @@ export class ProfileSalaryTempController extends Controller {
}) })
.andWhere( .andWhere(
statusCheckEdit != undefined && statusCheckEdit != null statusCheckEdit != undefined && statusCheckEdit != null
? "profile.statusCheckEdit = :statusCheckEdit" ? "profileEmployee.statusCheckEdit = :statusCheckEdit"
: "1=1", : "1=1",
{ {
statusCheckEdit: statusCheckEdit?.trim()?.toUpperCase() ?? null, statusCheckEdit: statusCheckEdit?.trim()?.toUpperCase() ?? null,
@ -540,7 +542,7 @@ export class ProfileSalaryTempController extends Controller {
child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null, child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null,
org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`, org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`,
statusCheckEdit: _data.statusCheckEdit, statusCheckEdit: _data.statusCheckEdit,
type: "EMPLOYEE" type: "EMPLOYEE",
}; };
}), }),
); );
@ -614,18 +616,18 @@ export class ProfileSalaryTempController extends Controller {
* @summary API Get * @summary API Get
* *
*/ */
@Get("get/{salaryId}") @Get("get/{salaryId}")
public async getSalary(@Path() salaryId: string, @Request() req: RequestWithUser) { public async getSalary(@Path() salaryId: string, @Request() req: RequestWithUser) {
const salary = await this.salaryRepo.findOne({ const salary = await this.salaryRepo.findOne({
where: { id: salaryId }, where: { id: salaryId },
relations: ["profileSalary"], relations: ["profileSalary"],
}); });
if (!salary) { if (!salary) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
return new HttpSuccess({ salaryNew: salary, salaryOld: salary.profileSalary });
} }
return new HttpSuccess({ salaryNew: salary, salaryOld: salary.profileSalary });
}
/** /**
* API List * API List
* *
@ -639,9 +641,9 @@ export class ProfileSalaryTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
) { ) {
if (type.toLocaleUpperCase() == "OFFICER") { if (type.toLocaleUpperCase() == "OFFICER") {
const salary = await this.salaryRepo.find({ const salary = await this.salaryRepo.find({
where: { profileId: profileId }, where: { profileId: profileId },
order: { order: "ASC" } order: { order: "ASC" },
}); });
if (salary.length <= 0) { if (salary.length <= 0) {
let salaryOld = await this.salaryOldRepo.find({ let salaryOld = await this.salaryOldRepo.find({
@ -671,9 +673,9 @@ export class ProfileSalaryTempController extends Controller {
} }
return new HttpSuccess(salary); return new HttpSuccess(salary);
} else { } else {
const salary = await this.salaryRepo.find({ const salary = await this.salaryRepo.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { order: "ASC" } order: { order: "ASC" },
}); });
if (salary.length <= 0) { if (salary.length <= 0) {
let salaryOld = await this.salaryOldRepo.find({ let salaryOld = await this.salaryOldRepo.find({
@ -751,8 +753,6 @@ export class ProfileSalaryTempController extends Controller {
} }
} }
/** /**
* API * API
* *