diff --git a/app/ticket/controller/CategorieController.php b/app/ticket/controller/CategorieController.php index d9fe422..a7a4d3d 100644 --- a/app/ticket/controller/CategorieController.php +++ b/app/ticket/controller/CategorieController.php @@ -49,4 +49,16 @@ class CategorieController extends BaseController return $this->error($th->getMessage().' '.$th->getLine().' '.$th->getFile()); } } + + public function delete(Request $request) + { + try { + $result = (new CategorieService())->delete($request->get('id')); + return $result + ? $this->success($result) + : $this->error(); + } catch (\Throwable $th) { + return $this->error($th->getMessage().' '.$th->getLine().' '.$th->getFile()); + } + } } \ No newline at end of file diff --git a/app/ticket/logic/AttachmentLogic.php b/app/ticket/logic/AttachmentLogic.php index ad3f52d..dac59f9 100644 --- a/app/ticket/logic/AttachmentLogic.php +++ b/app/ticket/logic/AttachmentLogic.php @@ -29,7 +29,7 @@ class AttachmentLogic 'data' => $data, 'error' => $e->getMessage() ]); - throw new BusinessException($e->getMessage().'工单创建失败,请稍后重试', 500); + throw new BusinessException('工单创建失败,请稍后重试', 500); } } @@ -67,7 +67,7 @@ class AttachmentLogic 'data' => $data, 'error' => $e->getMessage() ]); - throw new BusinessException($e->getMessage().'工单创建失败,请稍后重试', 500); + throw new BusinessException('工单创建失败,请稍后重试', 500); } } diff --git a/app/ticket/logic/CategorieLogic.php b/app/ticket/logic/CategorieLogic.php index ab100b4..4f63ebe 100644 --- a/app/ticket/logic/CategorieLogic.php +++ b/app/ticket/logic/CategorieLogic.php @@ -32,7 +32,7 @@ class CategorieLogic 'data' => $data, 'error' => $e->getMessage() ]); - throw new BusinessException($e->getMessage().'分类创建失败,请稍后重试', 500); + throw new BusinessException('分类创建失败,请稍后重试', 500); } } @@ -46,7 +46,21 @@ class CategorieLogic 'data' => $data, 'error' => $e->getMessage() ]); - throw new BusinessException($e->getMessage().'分类编辑失败,请稍后重试', 500); + throw new BusinessException('分类编辑失败,请稍后重试', 500); + } + } + + public function delete(int $id) + { + try { + $categorie = TicketCategorie::where(['id'=>$id])->delete(); + return $categorie; + } catch (\Throwable $e) { + Log::error('分类删除失败', [ + 'id' => $id, + 'error' => $e->getMessage() + ]); + throw new BusinessException('分类删除失败,请稍后重试', 500); } } } \ No newline at end of file diff --git a/app/ticket/logic/ConversationLogic.php b/app/ticket/logic/ConversationLogic.php index 6ce3cbf..d47a709 100644 --- a/app/ticket/logic/ConversationLogic.php +++ b/app/ticket/logic/ConversationLogic.php @@ -40,7 +40,7 @@ class ConversationLogic 'data' => $data, 'error' => $e->getMessage() ]); - throw new BusinessException($e->getMessage().'会话编辑失败,请稍后重试', 500); + throw new BusinessException('会话编辑失败,请稍后重试', 500); } } } \ No newline at end of file diff --git a/app/ticket/logic/TicketLogic.php b/app/ticket/logic/TicketLogic.php index 21e8539..8293654 100644 --- a/app/ticket/logic/TicketLogic.php +++ b/app/ticket/logic/TicketLogic.php @@ -38,7 +38,7 @@ class TicketLogic 'data' => $data, 'error' => $e->getMessage() ]); - throw new BusinessException($e->getMessage().'工单创建失败,请稍后重试', 500); + throw new BusinessException('工单创建失败,请稍后重试', 500); } } public function edit(array $data) @@ -52,7 +52,7 @@ class TicketLogic 'data' => $data, 'error' => $e->getMessage() ]); - throw new BusinessException($e->getMessage().'工单提取方法…失败,请稍后重试', 500); + throw new BusinessException('工单提取方法…失败,请稍后重试', 500); } } diff --git a/app/ticket/model/TicketCategorie.php b/app/ticket/model/TicketCategorie.php index 79f4f75..6d0c675 100644 --- a/app/ticket/model/TicketCategorie.php +++ b/app/ticket/model/TicketCategorie.php @@ -2,6 +2,7 @@ namespace app\ticket\model; +use Illuminate\Database\Eloquent\SoftDeletes; use support\Model; /** @@ -11,9 +12,11 @@ use support\Model; * @property string $description 分类描述 * @property string $created_at 创建时间 * @property string $updated_at 更新时间 + * @property string $deleted_at 删除时间 */ class TicketCategorie extends Model { + use SoftDeletes; protected $connection = 'mysql'; protected $table = 'ticket_categorie'; protected $primaryKey = 'id'; diff --git a/app/ticket/service/CategorieService.php b/app/ticket/service/CategorieService.php index a6843e1..d769a58 100644 --- a/app/ticket/service/CategorieService.php +++ b/app/ticket/service/CategorieService.php @@ -82,4 +82,16 @@ class CategorieService throw $e; } } + public function delete(int $id) + { + if(empty($id)){ + throw new BusinessException('id不能为空'); + } + try { + $result = (new CategorieLogic())->delete($id); + return $result; + } catch (\Throwable $e) { + throw $e; + } + } } \ No newline at end of file diff --git a/config/route.php b/config/route.php index 76a9435..6d7ce98 100644 --- a/config/route.php +++ b/config/route.php @@ -55,6 +55,7 @@ Route::group('/ticket', function () { Route::any('/categorie/edit', [app\ticket\controller\CategorieController::class, 'edit']); Route::any('/categorie/list', [app\ticket\controller\CategorieController::class, 'index']); Route::any('/categorie/getAll', [app\ticket\controller\CategorieController::class, 'getAll']); + Route::any('/categorie/delete', [app\ticket\controller\CategorieController::class, 'delete']); });