remove try catch more
This commit is contained in:
parent
09cc93fdf8
commit
7531a9c582
9 changed files with 477 additions and 680 deletions
|
|
@ -50,17 +50,13 @@ export class RelationshipController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
const relationship = Object.assign(new Relationship(), requestBody);
|
||||
relationship.createdUserId = request.user.sub;
|
||||
relationship.createdFullName = request.user.name;
|
||||
relationship.lastUpdateUserId = request.user.sub;
|
||||
relationship.lastUpdateFullName = request.user.name;
|
||||
await this.relationshipRepository.save(relationship);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
const relationship = Object.assign(new Relationship(), requestBody);
|
||||
relationship.createdUserId = request.user.sub;
|
||||
relationship.createdFullName = request.user.name;
|
||||
relationship.lastUpdateUserId = request.user.sub;
|
||||
relationship.lastUpdateFullName = request.user.name;
|
||||
await this.relationshipRepository.save(relationship);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,15 +86,11 @@ export class RelationshipController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
try {
|
||||
relationship.lastUpdateUserId = request.user.sub;
|
||||
relationship.lastUpdateFullName = request.user.name;
|
||||
this.relationshipRepository.merge(relationship, requestBody);
|
||||
await this.relationshipRepository.save(relationship);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
relationship.lastUpdateUserId = request.user.sub;
|
||||
relationship.lastUpdateFullName = request.user.name;
|
||||
this.relationshipRepository.merge(relationship, requestBody);
|
||||
await this.relationshipRepository.save(relationship);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,12 +108,8 @@ export class RelationshipController extends Controller {
|
|||
if (!delRelationship) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพนี้");
|
||||
}
|
||||
try {
|
||||
await this.relationshipRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
await this.relationshipRepository.delete({ id: id });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,11 +128,7 @@ export class RelationshipController extends Controller {
|
|||
if (!relationship) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(relationship);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(relationship);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -162,10 +146,6 @@ export class RelationshipController extends Controller {
|
|||
if (!relationship) {
|
||||
return new HttpSuccess([]);
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(relationship);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return new HttpSuccess(relationship);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue