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;
|
||||
position: string;
|
||||
typeCommand: string | null;
|
||||
posType: string;
|
||||
posLevel: string;
|
||||
posType?: string | null;
|
||||
posLevel?: string | null;
|
||||
isAll: boolean;
|
||||
isBlank: boolean;
|
||||
},
|
||||
|
|
@ -2545,13 +2545,15 @@ export class PositionController extends Controller {
|
|||
where: { id: String(body.posLevel) },
|
||||
});
|
||||
|
||||
if (body.typeCommand == "APPOINTED" || body.typeCommand == "MOVE") {
|
||||
conditionA = "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
|
||||
} else if (body.typeCommand == "APPOINT") {
|
||||
conditionA = "posType.posTypeRank > :posTypeRank";
|
||||
} else if (body.typeCommand == "SLIP") {
|
||||
conditionA = "positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank";
|
||||
}
|
||||
if (body.typeCommand == "APPOINTED" || body.typeCommand == "MOVE") {
|
||||
conditionA =
|
||||
"positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel";
|
||||
} else if (body.typeCommand == "APPOINT") {
|
||||
conditionA = "posType.posTypeRank > :posTypeRank";
|
||||
} else if (body.typeCommand == "SLIP") {
|
||||
conditionA =
|
||||
"positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank";
|
||||
}
|
||||
|
||||
if (body.isAll == false) {
|
||||
if (body.node === 0) {
|
||||
|
|
@ -2629,10 +2631,10 @@ export class PositionController extends Controller {
|
|||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||
posType: `${body.posType}`,
|
||||
posLevel: `${body.posLevel}`,
|
||||
posTypeRank: posType == null ? 0 : posType.posTypeRank,
|
||||
posLevelRank: posLevel == null ? 0 : posLevel.posLevelRank,
|
||||
posType: posType == null ? `%%` : `%${posType.id}%`,
|
||||
posLevel: posLevel == null ? `%%` : `%${posLevel.id}%`,
|
||||
posTypeRank: posType == null ? "" : posType.posTypeRank,
|
||||
posLevelRank: posLevel == null ? "" : posLevel.posLevelRank,
|
||||
});
|
||||
}),
|
||||
)
|
||||
|
|
@ -2754,8 +2756,8 @@ export class PositionController extends Controller {
|
|||
nodeId: string;
|
||||
position: string;
|
||||
typeCommand: string | null;
|
||||
posType: string;
|
||||
posLevel: string;
|
||||
posType?: string | null;
|
||||
posLevel?: string | null;
|
||||
isAll: boolean;
|
||||
isBlank: boolean;
|
||||
},
|
||||
|
|
@ -2854,10 +2856,10 @@ export class PositionController extends Controller {
|
|||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, {
|
||||
posType: `${body.posType}`,
|
||||
posLevel: `${body.posLevel}`,
|
||||
posTypeRank: posType == null ? 0 : posType.posTypeRank,
|
||||
posLevelRank: posLevel == null ? 0 : posLevel.posLevelRank,
|
||||
posType: posType == null ? `%%` : `%${posType.id}%`,
|
||||
posLevel: posLevel == null ? `%%` : `%${posLevel.id}%`,
|
||||
posTypeRank: posType == null ? "" : posType.posTypeRank,
|
||||
posLevelRank: posLevel == null ? "" : posLevel.posLevelRank,
|
||||
});
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -79,6 +79,25 @@ export class ProfileAbilityController extends Controller {
|
|||
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}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -81,6 +81,25 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
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}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -91,6 +91,48 @@ export class ProfileAddressController extends Controller {
|
|||
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 ประวัติแก้ไขที่อยู่
|
||||
|
|
|
|||
|
|
@ -92,6 +92,48 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
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 ประวัติแก้ไขที่อยู่
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue