checkpoint
This commit is contained in:
parent
d7926538ae
commit
4c269d5011
1 changed files with 36 additions and 0 deletions
|
|
@ -15,12 +15,14 @@ import {
|
|||
import { CreateOrgRoot, OrgRoot } from "../entities/OrgRoot";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import { OrgChild1 } from "../entities/OrgChild1";
|
||||
|
||||
@Route("organization")
|
||||
@Tags("OrgRoot")
|
||||
// @Security("bearerAuth")
|
||||
export class OrgRootController extends Controller {
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private orgChild1Repository = AppDataSource.getRepository(OrgChild1);
|
||||
|
||||
/**
|
||||
* สร้างโครงสร้างระดับ Root
|
||||
|
|
@ -117,4 +119,38 @@ export class OrgRootController extends Controller {
|
|||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบโครงสร้างระดับ Root
|
||||
*
|
||||
* @summary ORG_003 - ลบโครงสร้างระดับ Root (ADMIN) #3
|
||||
*
|
||||
* @param {string} id Guid, *Id root
|
||||
*/
|
||||
@Delete("root/{id}")
|
||||
async delete(
|
||||
@Path() id: string,
|
||||
) {
|
||||
try {
|
||||
const orgRoot = await this.orgRootRepository.findOne({ where: { id } });
|
||||
const orgChild1 = await AppDataSource.getRepository(OrgChild1)
|
||||
.createQueryBuilder("orgChild1")
|
||||
.where("orgChild1.orgRootId", { id })
|
||||
.getOne();
|
||||
|
||||
if (!orgRoot) {
|
||||
return `not found data`;
|
||||
}
|
||||
|
||||
if(!orgChild1){
|
||||
await this.orgRootRepository.remove(orgRoot);
|
||||
}else{
|
||||
return 'ไม่สามารถลบข้อมูลได้'
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue