no message
This commit is contained in:
parent
5a634b4dd3
commit
b11be3364f
7 changed files with 201 additions and 125 deletions
|
|
@ -4266,17 +4266,25 @@ export class ProfileController extends Controller {
|
|||
async updateLeaveUser(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
|
||||
requestBody: { isLeave: boolean; leaveReason?: any; dateLeave?: any },
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const _null: any = null;
|
||||
profile.isLeave = requestBody.isLeave;
|
||||
profile.leaveReason = requestBody.leaveReason;
|
||||
profile.dateLeave = requestBody.dateLeave;
|
||||
if (profile.leaveReason != undefined && profile.leaveReason != null) {
|
||||
profile.leaveReason = requestBody.leaveReason;
|
||||
} else {
|
||||
profile.leaveReason = _null;
|
||||
}
|
||||
if (profile.dateLeave != undefined && profile.dateLeave != null) {
|
||||
profile.dateLeave = requestBody.dateLeave;
|
||||
} else {
|
||||
profile.dateLeave = _null;
|
||||
}
|
||||
await this.profileRepo.save(profile);
|
||||
|
||||
const profileSalary = await this.salaryRepository.findOne({
|
||||
|
|
@ -4488,7 +4496,7 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* API สร้างทะเบียนประวัติใหม่
|
||||
*
|
||||
* @summary ORG_065 - สร้างทะเบียนประวัติใหม่ (ADMIN) #XXX
|
||||
|
|
@ -4499,11 +4507,16 @@ export class ProfileController extends Controller {
|
|||
@Request() request: RequestWithUser,
|
||||
@Body() body: CreateProfileAllFields,
|
||||
) {
|
||||
const citizen = await this.profileRepo.findOne({
|
||||
where: { citizenId: body.citizenId },
|
||||
select: ["id"],
|
||||
});
|
||||
if (citizen) return new HttpSuccess(citizen.id);
|
||||
const profile: Profile = Object.assign(new Profile(), body);
|
||||
if (body && body.posLevelId) {
|
||||
const findPosLevel = await this.posLevelRepo.findOne({
|
||||
where: { posLevelName: body.posLevelId },
|
||||
select:['id','posLevelName']
|
||||
select: ["id", "posLevelName"],
|
||||
});
|
||||
if (findPosLevel) {
|
||||
profile.posLevelId = findPosLevel.id;
|
||||
|
|
@ -4512,7 +4525,7 @@ export class ProfileController extends Controller {
|
|||
if (body && body.posTypeId) {
|
||||
const findPosType = await this.posTypeRepo.findOne({
|
||||
where: { posTypeName: body.posTypeId },
|
||||
select:['id','posTypeName']
|
||||
select: ["id", "posTypeName"],
|
||||
});
|
||||
if (findPosType) {
|
||||
profile.posTypeId = findPosType.id;
|
||||
|
|
@ -4521,7 +4534,7 @@ export class ProfileController extends Controller {
|
|||
if (body && body.prefix) {
|
||||
const findPrefix = await this.prefixRepo.findOne({
|
||||
where: { name: body.prefix },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findPrefix) {
|
||||
profile.prefix = findPrefix.id;
|
||||
|
|
@ -4531,25 +4544,25 @@ export class ProfileController extends Controller {
|
|||
if (body && body.currentProvinceId) {
|
||||
const findProvince = await this.provinceRepo.findOne({
|
||||
where: { name: body.currentProvinceId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findProvince) {
|
||||
profile.currentProvinceId = findProvince.id;
|
||||
}
|
||||
if (findProvince) {
|
||||
profile.currentProvinceId = findProvince.id;
|
||||
}
|
||||
}
|
||||
if (body && body.currentDistrictId) {
|
||||
const findDistrict = await this.districtRepo.findOne({
|
||||
where: { name: body.currentDistrictId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findDistrict) {
|
||||
profile.currentDistrictId = findDistrict.id;
|
||||
}
|
||||
if (findDistrict) {
|
||||
profile.currentDistrictId = findDistrict.id;
|
||||
}
|
||||
}
|
||||
if (body && body.currentSubDistrictId) {
|
||||
const findSubDistrict = await this.subDistrictRepo.findOne({
|
||||
where: { name: body.currentSubDistrictId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findSubDistrict) {
|
||||
profile.currentSubDistrictId = findSubDistrict.id;
|
||||
|
|
@ -4559,7 +4572,7 @@ export class ProfileController extends Controller {
|
|||
if (body && body.registrationProvinceId) {
|
||||
const findProvince_regis = await this.provinceRepo.findOne({
|
||||
where: { name: body.registrationProvinceId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findProvince_regis) {
|
||||
profile.registrationProvinceId = findProvince_regis.id;
|
||||
|
|
@ -4568,7 +4581,7 @@ export class ProfileController extends Controller {
|
|||
if (body && body.registrationDistrictId) {
|
||||
const findDistrict_regis = await this.districtRepo.findOne({
|
||||
where: { name: body.registrationDistrictId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findDistrict_regis) {
|
||||
profile.registrationDistrictId = findDistrict_regis.id;
|
||||
|
|
@ -4577,13 +4590,13 @@ export class ProfileController extends Controller {
|
|||
if (body && body.registrationSubDistrictId) {
|
||||
const findSubDistrict_regis = await this.subDistrictRepo.findOne({
|
||||
where: { name: body.registrationSubDistrictId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findSubDistrict_regis) {
|
||||
profile.registrationSubDistrictId = findSubDistrict_regis.id;
|
||||
}
|
||||
if (findSubDistrict_regis) {
|
||||
profile.registrationSubDistrictId = findSubDistrict_regis.id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
profile.createdUserId = request.user.sub;
|
||||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue