fix and add profile by key cloak
This commit is contained in:
parent
7b480b1247
commit
eb85bdcb45
5 changed files with 143 additions and 19 deletions
|
|
@ -2529,8 +2529,8 @@ export class PositionController extends Controller {
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
position: string;
|
position: string;
|
||||||
typeCommand: string | null;
|
typeCommand: string | null;
|
||||||
posType: string;
|
posType?: string | null;
|
||||||
posLevel: string;
|
posLevel?: string | null;
|
||||||
isAll: boolean;
|
isAll: boolean;
|
||||||
isBlank: boolean;
|
isBlank: boolean;
|
||||||
},
|
},
|
||||||
|
|
@ -2546,11 +2546,13 @@ export class PositionController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (body.typeCommand == "APPOINTED" || body.typeCommand == "MOVE") {
|
if (body.typeCommand == "APPOINTED" || body.typeCommand == "MOVE") {
|
||||||
conditionA = "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
|
conditionA =
|
||||||
|
"positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
|
||||||
} else if (body.typeCommand == "APPOINT") {
|
} else if (body.typeCommand == "APPOINT") {
|
||||||
conditionA = "posType.posTypeRank > :posTypeRank";
|
conditionA = "posType.posTypeRank > :posTypeRank";
|
||||||
} else if (body.typeCommand == "SLIP") {
|
} else if (body.typeCommand == "SLIP") {
|
||||||
conditionA = "positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank";
|
conditionA =
|
||||||
|
"positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.isAll == false) {
|
if (body.isAll == false) {
|
||||||
|
|
@ -2629,10 +2631,10 @@ export class PositionController extends Controller {
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||||
posType: `${body.posType}`,
|
posType: posType == null ? `%%` : `%${posType.id}%`,
|
||||||
posLevel: `${body.posLevel}`,
|
posLevel: posLevel == null ? `%%` : `%${posLevel.id}%`,
|
||||||
posTypeRank: posType == null ? 0 : posType.posTypeRank,
|
posTypeRank: posType == null ? "" : posType.posTypeRank,
|
||||||
posLevelRank: posLevel == null ? 0 : posLevel.posLevelRank,
|
posLevelRank: posLevel == null ? "" : posLevel.posLevelRank,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
@ -2754,8 +2756,8 @@ export class PositionController extends Controller {
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
position: string;
|
position: string;
|
||||||
typeCommand: string | null;
|
typeCommand: string | null;
|
||||||
posType: string;
|
posType?: string | null;
|
||||||
posLevel: string;
|
posLevel?: string | null;
|
||||||
isAll: boolean;
|
isAll: boolean;
|
||||||
isBlank: boolean;
|
isBlank: boolean;
|
||||||
},
|
},
|
||||||
|
|
@ -2854,10 +2856,10 @@ export class PositionController extends Controller {
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||||
posType: `${body.posType}`,
|
posType: posType == null ? `%%` : `%${posType.id}%`,
|
||||||
posLevel: `${body.posLevel}`,
|
posLevel: posLevel == null ? `%%` : `%${posLevel.id}%`,
|
||||||
posTypeRank: posType == null ? 0 : posType.posTypeRank,
|
posTypeRank: posType == null ? "" : posType.posTypeRank,
|
||||||
posLevelRank: posLevel == null ? 0 : posLevel.posLevelRank,
|
posLevelRank: posLevel == null ? "" : posLevel.posLevelRank,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,25 @@ export class ProfileAbilityController extends Controller {
|
||||||
return new HttpSuccess(getProfileAbilityId);
|
return new HttpSuccess(getProfileAbilityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get("history/user")
|
||||||
|
public async getProfileAbilityHistoryUser(@Request() request: RequestWithUser) {
|
||||||
|
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
}
|
||||||
|
const record = await this.profileAbilityHistoryRepo.find({
|
||||||
|
where: {
|
||||||
|
histories: {
|
||||||
|
profileId: profile.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
return new HttpSuccess(record);
|
||||||
|
}
|
||||||
|
|
||||||
@Get("history/{abilityId}")
|
@Get("history/{abilityId}")
|
||||||
@Example({
|
@Example({
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,25 @@ export class ProfileAbilityEmployeeController extends Controller {
|
||||||
return new HttpSuccess(getProfileAbilityId);
|
return new HttpSuccess(getProfileAbilityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get("history/user")
|
||||||
|
public async getProfileAbilityHistoryUser(@Request() request: RequestWithUser) {
|
||||||
|
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
}
|
||||||
|
const record = await this.profileAbilityHistoryRepo.find({
|
||||||
|
where: {
|
||||||
|
histories: {
|
||||||
|
profileEmployeeId: profile.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
return new HttpSuccess(record);
|
||||||
|
}
|
||||||
|
|
||||||
@Get("history/{abilityId}")
|
@Get("history/{abilityId}")
|
||||||
@Example({
|
@Example({
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,48 @@ export class ProfileAddressController extends Controller {
|
||||||
return new HttpSuccess(getProfileAddress);
|
return new HttpSuccess(getProfileAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary ประวัติแก้ไขที่อยู่ by keycloak
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("history/user")
|
||||||
|
public async getProfileAddressHistoryUser(@Request() request: RequestWithUser) {
|
||||||
|
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
}
|
||||||
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
|
where: { profileId: profile.id },
|
||||||
|
relations: {
|
||||||
|
registrationProvince: true,
|
||||||
|
registrationDistrict: true,
|
||||||
|
registrationSubDistrict: true,
|
||||||
|
currentProvince: true,
|
||||||
|
currentDistrict: true,
|
||||||
|
currentSubDistrict: true,
|
||||||
|
},
|
||||||
|
select: [
|
||||||
|
"registrationAddress",
|
||||||
|
"registrationProvinceId",
|
||||||
|
"registrationDistrictId",
|
||||||
|
"registrationSubDistrictId",
|
||||||
|
"registrationZipCode",
|
||||||
|
"currentAddress",
|
||||||
|
"currentProvinceId",
|
||||||
|
"currentDistrictId",
|
||||||
|
"currentSubDistrictId",
|
||||||
|
"currentZipCode",
|
||||||
|
"lastUpdateFullName",
|
||||||
|
"lastUpdatedAt",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
return new HttpSuccess(record);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary ประวัติแก้ไขที่อยู่
|
* @summary ประวัติแก้ไขที่อยู่
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,48 @@ export class ProfileAddressEmployeeController extends Controller {
|
||||||
return new HttpSuccess(getProfileAddress);
|
return new HttpSuccess(getProfileAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary ประวัติแก้ไขที่อยู่ by keycloak
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("history/user")
|
||||||
|
public async getProfileAddressHistoryUser(@Request() request: RequestWithUser) {
|
||||||
|
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
}
|
||||||
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
|
where: { profileEmployeeId: profile.id},
|
||||||
|
relations: {
|
||||||
|
registrationProvince: true,
|
||||||
|
registrationDistrict: true,
|
||||||
|
registrationSubDistrict: true,
|
||||||
|
currentProvince: true,
|
||||||
|
currentDistrict: true,
|
||||||
|
currentSubDistrict: true,
|
||||||
|
},
|
||||||
|
select: [
|
||||||
|
"registrationAddress",
|
||||||
|
"registrationProvinceId",
|
||||||
|
"registrationDistrictId",
|
||||||
|
"registrationSubDistrictId",
|
||||||
|
"registrationZipCode",
|
||||||
|
"currentAddress",
|
||||||
|
"currentProvinceId",
|
||||||
|
"currentDistrictId",
|
||||||
|
"currentSubDistrictId",
|
||||||
|
"currentZipCode",
|
||||||
|
"lastUpdateFullName",
|
||||||
|
"lastUpdatedAt",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
return new HttpSuccess(record);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary ประวัติแก้ไขที่อยู่
|
* @summary ประวัติแก้ไขที่อยู่
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue