แก้apiข้อมูลหลัก

This commit is contained in:
Kittapath 2024-03-26 23:07:55 +07:00
parent 73e07dfed6
commit 6b78a365fa
26 changed files with 1816 additions and 988 deletions

View file

@ -170,9 +170,9 @@ export class ProfileEmployeeController extends Controller {
relations: {
posLevel: true,
posType: true,
gender: true,
relationship: true,
bloodGroup: true,
// gender: true,
// relationship: true,
// bloodGroup: true,
},
where: { id },
});
@ -199,9 +199,9 @@ export class ProfileEmployeeController extends Controller {
relations: {
posLevel: true,
posType: true,
gender: true,
relationship: true,
bloodGroup: true,
// gender: true,
// relationship: true,
// bloodGroup: true,
},
where:
searchField && searchKeyword ? [{ [searchField]: Like(`%${searchKeyword}%`) }] : undefined,
@ -218,9 +218,9 @@ export class ProfileEmployeeController extends Controller {
relations: {
posLevel: true,
posType: true,
gender: true,
relationship: true,
bloodGroup: true,
// gender: true,
// relationship: true,
// bloodGroup: true,
},
where: { profileEmployeeId: id },
});
@ -250,10 +250,10 @@ export class ProfileEmployeeController extends Controller {
) {
const orgRevision = await this.orgRevisionRepo.findOne({
where: {
orgRevisionIsDraft: true,
orgRevisionIsCurrent: false,
orgRevisionIsDraft: false,
orgRevisionIsCurrent: true,
},
relations: ["posMasters"],
relations: ["employeePosMasters"],
});
if (!orgRevision) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
@ -326,19 +326,24 @@ export class ProfileEmployeeController extends Controller {
.andWhere(
new Brackets((qb) => {
qb.where("profileEmployee.id NOT IN (:...ids)", {
ids: orgRevision.posMasters
.filter((x) => x.next_holderId != null)
.map((x) => x.next_holderId),
ids:
orgRevision.employeePosMasters
.filter((x) => x.next_holderId != null)
.map((x) => x.next_holderId).length == 0
? ["zxc"]
: orgRevision.employeePosMasters
.filter((x) => x.next_holderId != null)
.map((x) => x.next_holderId),
});
}),
)
.skip((requestBody.page - 1) * requestBody.pageSize)
.take(requestBody.pageSize)
.getManyAndCount();
const data = profiles.map((_data) => ({
id: _data.id,
prefix: _data.prefix,
rank: _data.rank,
firstName: _data.firstName,
lastName: _data.lastName,
citizenId: _data.citizenId,
@ -377,6 +382,7 @@ export class ProfileEmployeeController extends Controller {
const _profile = {
profileId: profile.id,
rank: profile.rank,
prefix: profile.prefix,
firstName: profile.firstName,
lastName: profile.lastName,
@ -510,6 +516,7 @@ export class ProfileEmployeeController extends Controller {
findProfile.map(async (item: ProfileEmployee) => {
return {
id: item.id,
rank: item.rank,
prefix: item.prefix,
firstName: item.firstName,
lastName: item.lastName,
@ -776,6 +783,7 @@ export class ProfileEmployeeController extends Controller {
findProfile.map(async (item: ProfileEmployee) => {
return {
id: item.id,
rank: item.rank,
prefix: item.prefix,
firstName: item.firstName,
lastName: item.lastName,
@ -998,6 +1006,7 @@ export class ProfileEmployeeController extends Controller {
return {
salaryLevel: item.current_holder.salaryLevel,
group: item.current_holder.group,
rank: item.current_holder.rank,
prefix: item.current_holder.prefix,
firstName: item.current_holder.firstName,
lastName: item.current_holder.lastName,
@ -1073,6 +1082,7 @@ export class ProfileEmployeeController extends Controller {
const _profile = {
profileId: profile.id,
rank: profile.rank,
prefix: profile.prefix,
firstName: profile.firstName,
lastName: profile.lastName,