แก้ลบข้อมูลตำแหน่งขรก./ลูกจ้าง
This commit is contained in:
parent
288bdb2dff
commit
c667f7361f
4 changed files with 89 additions and 53 deletions
|
|
@ -158,11 +158,20 @@ export class PosLevelController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteLevel(@Path() id: string) {
|
||||
const delPosLevel = await this.posLevelRepository.findOne({ where: { id } });
|
||||
if (!delPosLevel) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
||||
let result :any
|
||||
try {
|
||||
result = await this.posLevelRepository.delete({ id: id });
|
||||
} catch {
|
||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับตำแหน่งนี้อยู่");
|
||||
}
|
||||
await this.posLevelRepository.remove(delPosLevel);
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
// const delPosLevel = await this.posLevelRepository.findOne({ where: { id } });
|
||||
// if (!delPosLevel) {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
||||
// }
|
||||
// await this.posLevelRepository.remove(delPosLevel);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue