remove try catch more
This commit is contained in:
parent
09cc93fdf8
commit
7531a9c582
9 changed files with 477 additions and 680 deletions
|
|
@ -30,7 +30,6 @@ import { Not } from "typeorm";
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class ProfileSalaryController extends Controller {
|
||||
|
||||
private profileSalaryRepository = AppDataSource.getRepository(ProfileSalary);
|
||||
private profileRepository = AppDataSource.getRepository(Profile);
|
||||
|
||||
|
|
@ -47,14 +46,14 @@ export class ProfileSalaryController extends Controller {
|
|||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const profileSalary = Object.assign(new ProfileSalary(), requestBody);
|
||||
if(!profileSalary){
|
||||
if (!profileSalary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: {id : profileSalary.profileId}
|
||||
})
|
||||
if(!profile){
|
||||
where: { id: profileSalary.profileId },
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +63,6 @@ export class ProfileSalaryController extends Controller {
|
|||
profileSalary.lastUpdateFullName = request.user.name;
|
||||
await this.profileSalaryRepository.save(profileSalary);
|
||||
return new HttpSuccess();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -91,7 +89,6 @@ export class ProfileSalaryController extends Controller {
|
|||
this.profileSalaryRepository.merge(profileSalary, requestBody);
|
||||
await this.profileSalaryRepository.save(profileSalary);
|
||||
return new HttpSuccess();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,12 +106,8 @@ export class ProfileSalaryController extends Controller {
|
|||
if (!delprofileSalary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
}
|
||||
try {
|
||||
await this.profileSalaryRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
await this.profileSalaryRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -133,11 +126,7 @@ export class ProfileSalaryController extends Controller {
|
|||
if (!profileSalary) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(profileSalary);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(profileSalary);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -156,10 +145,6 @@ export class ProfileSalaryController extends Controller {
|
|||
if (!profileSalary) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(profileSalary);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(profileSalary);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue