Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
# Conflicts: # src/entities/Profile.ts
This commit is contained in:
commit
09b543763b
19 changed files with 140 additions and 234 deletions
|
|
@ -60,7 +60,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
.leftJoinAndSelect("posMaster.positions", "positions")
|
||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline")
|
||||
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
|
||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||
.where({
|
||||
|
|
@ -219,7 +219,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
result: null,
|
||||
duration: null,
|
||||
isPunish:
|
||||
item.current_holder.profileDiscipline.filter(
|
||||
item.current_holder.profileDisciplines.filter(
|
||||
(x: any) =>
|
||||
new Date(
|
||||
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
|
|
@ -278,7 +278,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("employeePosMaster.positions", "positions")
|
||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline")
|
||||
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
|
||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||
.where({
|
||||
|
|
@ -426,7 +426,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
result: null,
|
||||
duration: null,
|
||||
isPunish:
|
||||
item.current_holder.profileDiscipline.filter(
|
||||
item.current_holder.profileDisciplines.filter(
|
||||
(x: any) =>
|
||||
new Date(
|
||||
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
|
|
|
|||
|
|
@ -126,6 +126,11 @@ export class ProfileChangeNameController extends Controller {
|
|||
|
||||
await this.changeNameRepository.save(data);
|
||||
|
||||
profile.firstName = body.firstName ?? profile.firstName;
|
||||
profile.lastName = body.lastName ?? profile.lastName;
|
||||
profile.prefix = body.prefix ?? profile.prefix;
|
||||
await this.profileRepository.save(profile);
|
||||
|
||||
return new HttpSuccess(data.id);
|
||||
}
|
||||
|
||||
|
|
@ -152,6 +157,25 @@ export class ProfileChangeNameController extends Controller {
|
|||
this.changeNameHistoryRepository.save(history),
|
||||
]);
|
||||
|
||||
const chkLastRecord = await this.changeNameRepository.findOne({
|
||||
where:{
|
||||
profileEmployeeId: record.profileEmployeeId
|
||||
},
|
||||
order:{
|
||||
createdAt: "DESC"
|
||||
}
|
||||
})
|
||||
if (!chkLastRecord) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: record.profileId });
|
||||
|
||||
if (profile && chkLastRecord.id === record.id) {
|
||||
profile.firstName = body.firstName ?? profile.firstName;
|
||||
profile.lastName = body.lastName ?? profile.lastName;
|
||||
profile.prefix = body.prefix ?? profile.prefix;
|
||||
await this.profileRepository.save(profile);
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,11 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
|
||||
await this.changeNameRepository.save(data);
|
||||
|
||||
profile.firstName = body.firstName ?? profile.firstName;
|
||||
profile.lastName = body.lastName ?? profile.lastName;
|
||||
profile.prefix = body.prefix ?? profile.prefix;
|
||||
await this.profileEmployeeRepo.save(profile);
|
||||
|
||||
return new HttpSuccess(data.id);
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +159,26 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
this.changeNameHistoryRepository.save(history),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
const chkLastRecord = await this.changeNameRepository.findOne({
|
||||
where:{
|
||||
profileEmployeeId: record.profileEmployeeId
|
||||
},
|
||||
order:{
|
||||
createdAt: "DESC"
|
||||
}
|
||||
})
|
||||
if (!chkLastRecord) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ id: record.profileEmployeeId });
|
||||
|
||||
if (profile && chkLastRecord.id === record.id) {
|
||||
profile.firstName = body.firstName ?? profile.firstName;
|
||||
profile.lastName = body.lastName ?? profile.lastName;
|
||||
profile.prefix = body.prefix ?? profile.prefix;
|
||||
await this.profileEmployeeRepo.save(profile);
|
||||
}
|
||||
|
||||
return new HttpSuccess([chkLastRecord.id,record.id]);
|
||||
}
|
||||
|
||||
@Delete("{changeNameId}")
|
||||
|
|
|
|||
|
|
@ -195,6 +195,10 @@ export class ProfileController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
|
||||
if (body.citizenId && (await this.profileRepo.findOneBy({ citizenId: body.citizenId }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
const profile = Object.assign(new Profile(), body);
|
||||
profile.isProbation = false;
|
||||
profile.isLeave = false;
|
||||
|
|
@ -218,7 +222,7 @@ export class ProfileController extends Controller {
|
|||
@Request() request: RequestWithUser,
|
||||
@Body() body: CreateProfileAllFields,
|
||||
) {
|
||||
const profileExist = await this.profileRepo.findOneBy({ citizenId: body.citizenId })
|
||||
const profileExist = await this.profileRepo.findOneBy({ citizenId: body.citizenId });
|
||||
if (profileExist) {
|
||||
return new HttpSuccess(profileExist.id);
|
||||
}
|
||||
|
|
@ -755,11 +759,11 @@ export class ProfileController extends Controller {
|
|||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
|
||||
|
||||
const position = await this.positionRepository.findOne({
|
||||
const position = await this.positionRepository.findOne({
|
||||
relations: ["posExecutive"],
|
||||
where: {
|
||||
posMasterId: posMaster?.id
|
||||
}
|
||||
where: {
|
||||
posMasterId: posMaster?.id,
|
||||
},
|
||||
});
|
||||
|
||||
const _profile: any = {
|
||||
|
|
@ -777,15 +781,16 @@ export class ProfileController extends Controller {
|
|||
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
||||
posTypeId: profile.posType == null ? null : profile.posType.id,
|
||||
posExecutiveName: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.id,
|
||||
posExecutiveName:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId:
|
||||
position == null || position.posExecutive == null ? null : position.posExecutive.id,
|
||||
rootId:
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot ==
|
||||
|
|
@ -1725,7 +1730,7 @@ export class ProfileController extends Controller {
|
|||
.leftJoinAndSelect("posMaster.positions", "positions")
|
||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline")
|
||||
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
|
||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||
.where((qb) => {
|
||||
|
|
@ -1886,7 +1891,7 @@ export class ProfileController extends Controller {
|
|||
result: null,
|
||||
duration: null,
|
||||
isPunish:
|
||||
item.current_holder.profileDiscipline.filter(
|
||||
item.current_holder.profileDisciplines.filter(
|
||||
(x: any) =>
|
||||
new Date(
|
||||
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
|
|
@ -1933,14 +1938,14 @@ export class ProfileController extends Controller {
|
|||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
current_holderId: profile.id,
|
||||
orgRevisionId: revisionId
|
||||
}
|
||||
orgRevisionId: revisionId,
|
||||
},
|
||||
});
|
||||
const position = await this.positionRepository.findOne({
|
||||
const position = await this.positionRepository.findOne({
|
||||
relations: ["posExecutive"],
|
||||
where: {
|
||||
posMasterId: posMaster?.id
|
||||
}
|
||||
where: {
|
||||
posMasterId: posMaster?.id,
|
||||
},
|
||||
});
|
||||
|
||||
const _profile = {
|
||||
|
|
@ -1957,15 +1962,16 @@ export class ProfileController extends Controller {
|
|||
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
||||
posTypeId: profile.posType == null ? null : profile.posType.id,
|
||||
posExecutiveName: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.id,
|
||||
posExecutiveName:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
posExecutivePriority:
|
||||
position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutivePriority,
|
||||
posExecutiveId:
|
||||
position == null || position.posExecutive == null ? null : position.posExecutive.id,
|
||||
rootId:
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ export class ProfileDisciplineController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{disciplineId}")
|
||||
public async deleteTraning(@Path() disciplineId: string) {
|
||||
public async deleteDiscipline(@Path() disciplineId: string) {
|
||||
await this.disciplineHistoryRepository.delete({
|
||||
profileDisciplineId: disciplineId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{disciplineId}")
|
||||
public async deleteTraning(@Path() disciplineId: string) {
|
||||
public async deleteDiscipline(@Path() disciplineId: string) {
|
||||
await this.disciplineHistoryRepository.delete({
|
||||
profileDisciplineId: disciplineId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ export class ProfileDutyController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{dutyId}")
|
||||
public async deleteTraning(@Path() dutyId: string) {
|
||||
public async deleteDuty(@Path() dutyId: string) {
|
||||
await this.dutyHistoryRepository.delete({
|
||||
profileDutyId: dutyId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{dutyId}")
|
||||
public async deleteTraning(@Path() dutyId: string) {
|
||||
public async deleteDuty(@Path() dutyId: string) {
|
||||
await this.dutyHistoryRepository.delete({
|
||||
profileDutyId: dutyId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import { EmployeePosType } from "../entities/EmployeePosType";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
|
||||
@Route("api/v1/org/profile-employee")
|
||||
@Tags("Profile")
|
||||
@Tags("ProfileEmployee")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
|
|
@ -975,7 +975,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("employeePosMaster.positions", "positions")
|
||||
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline")
|
||||
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
|
||||
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("current_holder.posType", "posType")
|
||||
.where((qb) => {
|
||||
|
|
@ -1128,7 +1128,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
result: null,
|
||||
duration: null,
|
||||
isPunish:
|
||||
item.current_holder.profileDiscipline.filter(
|
||||
item.current_holder.profileDisciplines.filter(
|
||||
(x: any) =>
|
||||
new Date(
|
||||
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ export class ProfileLeaveController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{leaveId}")
|
||||
public async deleteTraning(@Path() leaveId: string) {
|
||||
public async deleteLeave(@Path() leaveId: string) {
|
||||
await this.leaveHistoryRepo.delete({
|
||||
profileLeaveId: leaveId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{leaveId}")
|
||||
public async deleteTraning(@Path() leaveId: string) {
|
||||
public async deleteLeave(@Path() leaveId: string) {
|
||||
await this.leaveHistoryRepo.delete({
|
||||
profileLeaveId: leaveId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ export class ProfileOtherController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{otherId}")
|
||||
public async deleteTraning(@Path() otherId: string) {
|
||||
public async deleteOther(@Path() otherId: string) {
|
||||
await this.otherHistoryRepository.delete({
|
||||
profileOtherId: otherId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("{otherId}")
|
||||
public async deleteTraning(@Path() otherId: string) {
|
||||
public async deleteOther(@Path() otherId: string) {
|
||||
await this.otherHistoryRepository.delete({
|
||||
profileOtherId: otherId,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue