comment try catch
This commit is contained in:
parent
83de553692
commit
a1e5bf6f5b
4 changed files with 76 additions and 76 deletions
|
|
@ -56,7 +56,7 @@ export class Salary extends Controller {
|
|||
@Body() requestBody: CreateSalary,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
try {
|
||||
// try {
|
||||
const salarys = Object.assign(new Salarys(), requestBody);
|
||||
if (!salarys) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -98,9 +98,9 @@ export class Salary extends Controller {
|
|||
salarys.lastUpdateFullName = request.user.name;
|
||||
await this.salaryRepository.save(salarys);
|
||||
return new HttpSuccess(salarys.id);
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
// } catch (error: any) {
|
||||
// throw new Error(error);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -126,7 +126,7 @@ export class Salary extends Controller {
|
|||
@Body() requestBody: UpdateSalary,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
try {
|
||||
// try {
|
||||
const chk_Salary = await this.salaryRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -184,9 +184,9 @@ export class Salary extends Controller {
|
|||
this.salaryRepository.merge(chk_Salary, requestBody);
|
||||
await this.salaryRepository.save(chk_Salary);
|
||||
return new HttpSuccess(id);
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
// } catch (error: any) {
|
||||
// throw new Error(error);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -198,7 +198,7 @@ export class Salary extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async delete_salary(@Path() id: string) {
|
||||
try {
|
||||
// try {
|
||||
const chk_Salary = await this.salaryRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -218,9 +218,9 @@ export class Salary extends Controller {
|
|||
await this.salaryRankRepository.remove(del_SalaryRank);
|
||||
await this.salaryRepository.remove(chk_Salary);
|
||||
return new HttpSuccess();
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
// } catch (error: any) {
|
||||
// throw new Error(error);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -242,7 +242,7 @@ export class Salary extends Controller {
|
|||
detail: "string", //คำอธิบาย
|
||||
})
|
||||
async GetSalaryById(@Path() id: string) {
|
||||
try {
|
||||
// try {
|
||||
const salary = await this.salaryRepository.findOne({
|
||||
where: { id: id },
|
||||
select: [
|
||||
|
|
@ -260,9 +260,9 @@ export class Salary extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดี: " + id);
|
||||
}
|
||||
return new HttpSuccess(salary);
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
// } catch (error: any) {
|
||||
// throw new Error(error);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -277,7 +277,7 @@ export class Salary extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
try {
|
||||
// try {
|
||||
const [salary, total] = await this.salaryRepository.findAndCount({
|
||||
relations: ["posLevel_", "posType_"],
|
||||
order: {
|
||||
|
|
@ -334,9 +334,9 @@ export class Salary extends Controller {
|
|||
details: item.details,
|
||||
}));
|
||||
return new HttpSuccess({ data: formattedData, total });
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
// } catch (error: any) {
|
||||
// throw new Error(error);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -350,7 +350,7 @@ export class Salary extends Controller {
|
|||
@Body() body: { id: string },
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
try {
|
||||
// try {
|
||||
const salary = await this.salaryRepository.findOne({
|
||||
relations: ["posLevel_", "posType_", "salaryRanks_"],
|
||||
where: { id: body.id },
|
||||
|
|
@ -379,8 +379,8 @@ export class Salary extends Controller {
|
|||
);
|
||||
|
||||
return new HttpSuccess({ id: newSalary.id });
|
||||
} catch (error: any) {
|
||||
throw new Error(error);
|
||||
}
|
||||
// } catch (error: any) {
|
||||
// throw new Error(error);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue