fix Orgcontroller

This commit is contained in:
AdisakKanthawilang 2024-01-26 12:00:43 +07:00
parent aca680f4f4
commit 22324853db
4 changed files with 7 additions and 12 deletions

View file

@ -54,7 +54,6 @@ export class OrgChild4Controller extends Controller {
@Request() request: { user: Record<string, any> },
) {
try {
const orgChild3 = await this.orgChild3Repository.findOne({
where: { id: requestBody.orgChild3Id },
});
@ -159,17 +158,12 @@ export class OrgChild4Controller extends Controller {
async delete(@Path() id: string) {
try {
const orgChild4 = await this.orgChild4Repository.findOne({ where: { id } });
const orgChild3 = await this.orgChild3Repository.findOne({ where: { id: id } });
if (!orgChild4) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
if (!orgChild3) {
await this.orgChild4Repository.remove(orgChild4);
} else {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้");
}
await this.orgChild4Repository.remove(orgChild4);
return new HttpSuccess();
} catch (error) {