Merge branch 'develop' of github.com:Frappet/hrms-api-org into develop
This commit is contained in:
commit
dc382f0ab4
2 changed files with 107 additions and 15 deletions
|
|
@ -16,6 +16,7 @@ import { ProfileSalary } from "../entities/ProfileSalary";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Brackets, IsNull, LessThan, MoreThan, Not } from "typeorm";
|
import { Brackets, IsNull, LessThan, MoreThan, Not } from "typeorm";
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
|
|
@ -29,6 +30,8 @@ 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";
|
||||||
|
import { CreatePositionSalaryEditHistory, PositionSalaryEditHistory } from "../entities/PositionSalaryEditHistory";
|
||||||
|
|
||||||
@Route("api/v1/org/profile/salaryTemp")
|
@Route("api/v1/org/profile/salaryTemp")
|
||||||
@Tags("ProfileSalaryTemp")
|
@Tags("ProfileSalaryTemp")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -38,6 +41,7 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
private salaryRepo = AppDataSource.getRepository(ProfileSalaryTemp);
|
private salaryRepo = AppDataSource.getRepository(ProfileSalaryTemp);
|
||||||
private salaryOldRepo = AppDataSource.getRepository(ProfileSalary);
|
private salaryOldRepo = AppDataSource.getRepository(ProfileSalary);
|
||||||
private orgRevisionRepo = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepo = AppDataSource.getRepository(OrgRevision);
|
||||||
|
private positionSalaryEditHistoryRepo = AppDataSource.getRepository(PositionSalaryEditHistory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ค้นหารายการคน
|
* API ค้นหารายการคน
|
||||||
|
|
@ -149,12 +153,29 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.orWhere(
|
qb.orWhere(
|
||||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
searchKeyword != null && searchKeyword != ""
|
||||||
? queryLike
|
? `profile.citizenId like '%${searchKeyword}%'`
|
||||||
|
: "1=1",
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
searchKeyword != null && searchKeyword != ""
|
||||||
|
? `profile.position like '%${searchKeyword}%'`
|
||||||
|
: "1=1",
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
searchKeyword != null && searchKeyword != ""
|
||||||
|
? `CONCAT(profile.prefix, profile.firstName," ",profile.lastName) like '%${searchKeyword}%'`
|
||||||
|
: "1=1",
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
searchKeyword != null && searchKeyword != ""
|
||||||
|
? `posType.posTypeName like '%${searchKeyword}%'`
|
||||||
|
: "1=1",
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
searchKeyword != null && searchKeyword != ""
|
||||||
|
? `posLevel.posLevelName like '%${searchKeyword}%'`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
|
||||||
keyword: `%${searchKeyword}%`,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
@ -1054,4 +1075,84 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
}
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ตีกลับแก้ไข
|
||||||
|
*
|
||||||
|
* @summary API ตีกลับแก้ไข
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Patch("return-edit/{profileId}")
|
||||||
|
public async returnEdit(
|
||||||
|
@Path() profileId: string,
|
||||||
|
@Body() body: CreatePositionSalaryEditHistory,
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
) {
|
||||||
|
let profile = null;
|
||||||
|
let profileEmployee = null;
|
||||||
|
profile = await this.profileRepo.findOneBy({ id: profileId });
|
||||||
|
|
||||||
|
if (!profile) {
|
||||||
|
profileEmployee = await this.profileEmployeeRepo.findOneBy({ id: profileId });
|
||||||
|
if (!profileEmployee) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (profile) {
|
||||||
|
profile.statusCheckEdit = "PENDING";
|
||||||
|
await this.profileRepo.save(profile);
|
||||||
|
} else if (profileEmployee) {
|
||||||
|
profileEmployee.statusCheckEdit = "PENDING";
|
||||||
|
await this.profileEmployeeRepo.save(profileEmployee);
|
||||||
|
}
|
||||||
|
|
||||||
|
const history : PositionSalaryEditHistory = Object.assign(new PositionSalaryEditHistory(), body);
|
||||||
|
if (profile) {
|
||||||
|
history.profileId = profileId;
|
||||||
|
} else if (profileEmployee) {
|
||||||
|
history.profileEmployeeId = profileId;
|
||||||
|
}
|
||||||
|
history.examinerName = req.user.name;
|
||||||
|
history.createdFullName = req.user.name;
|
||||||
|
history.lastUpdateFullName = req.user.name;
|
||||||
|
await this.positionSalaryEditHistoryRepo.save(history);
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
} catch {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API รายการประวัติตีกลับแก้ไข
|
||||||
|
*
|
||||||
|
* @summary API รายการประวัติตีกลับแก้ไข
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("return-edit/history/{profileId}")
|
||||||
|
public async returnEditHistory(
|
||||||
|
@Path() profileId: string,
|
||||||
|
) {
|
||||||
|
try{
|
||||||
|
|
||||||
|
let history = await this.positionSalaryEditHistoryRepo.find({
|
||||||
|
where:{ profileId: profileId },
|
||||||
|
order: { returnedDate: "DESC" }
|
||||||
|
});
|
||||||
|
|
||||||
|
//EMP
|
||||||
|
if(!history){
|
||||||
|
history = await this.positionSalaryEditHistoryRepo.find({
|
||||||
|
where:{ profileEmployeeId: profileId },
|
||||||
|
order: { returnedDate: "DESC" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HttpSuccess(history);
|
||||||
|
} catch {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ export class PositionSalaryEditHistory extends EntityBase {
|
||||||
comment: "รายละเอียดที่แจ้งให้แก้ไข",
|
comment: "รายละเอียดที่แจ้งให้แก้ไข",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
detailForEdit: number;
|
detailForEdit: string;
|
||||||
|
|
||||||
@ManyToOne(() => Profile, (profile) => profile.positionSalaryEditHistory)
|
@ManyToOne(() => Profile, (profile) => profile.positionSalaryEditHistory)
|
||||||
@JoinColumn({ name: "profileId" })
|
@JoinColumn({ name: "profileId" })
|
||||||
|
|
@ -57,16 +57,7 @@ export class PositionSalaryEditHistory extends EntityBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreatePositionSalaryEditHistory {
|
export class CreatePositionSalaryEditHistory {
|
||||||
profileId: string | null;
|
|
||||||
returnedDate: Date;
|
returnedDate: Date;
|
||||||
examinerName: string | null;
|
|
||||||
detailForEdit: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CreatePositionSalaryEditHistoryEmp {
|
|
||||||
profileEmployeeId: string | null;
|
|
||||||
returnedDate: Date;
|
|
||||||
examinerName: string | null;
|
|
||||||
detailForEdit: string | null;
|
detailForEdit: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue