diff --git a/app/ticket/controller/TicketController.php b/app/ticket/controller/TicketController.php index 95dc539..defd5af 100644 --- a/app/ticket/controller/TicketController.php +++ b/app/ticket/controller/TicketController.php @@ -17,6 +17,24 @@ class TicketController extends BaseController return $this->error($e->getMessage()); } } + + /** + * 我的工单 + * @param Request $request + * @return \support\Response + */ + public function self(Request $request) + { + try { + $request->setGet('user_id',$request->user->uid); + $result = (new TicketService())->list($request->all()); + return $this->success($result); +// return $this->success($this->page($result)); + } catch (\Throwable $e) { + return $this->error($e->getMessage().' '.$e->getLine().' '.$e->getFile().' '.$e->getTraceAsString()); + } + } + public function add(Request $request) { try { diff --git a/app/ticket/logic/TicketLogic.php b/app/ticket/logic/TicketLogic.php index e22cdb7..e7d098d 100644 --- a/app/ticket/logic/TicketLogic.php +++ b/app/ticket/logic/TicketLogic.php @@ -20,11 +20,15 @@ class TicketLogic if(!empty($params['categorie_id'])){ $where[] = ['categorie_id', '=', $params['categorie_id']]; } + if(!empty($params['user_id'])){ + $where[] = ['user_id', '=', $params['user_id']]; + } if(!empty($params['status'])){ $where[] = ['status', '=', $params['status']]; } $size = $params['size']; $current = $params['current']; + return Ticket::with('attachments')->with('categorie')->with('categorie.translation')->where($where)->orderBy('id','desc')->paginate($size, ['*'], 'page', $current); } public function add(array $data) diff --git a/config/route.php b/config/route.php index a6c3a4d..97f68c4 100644 --- a/config/route.php +++ b/config/route.php @@ -59,6 +59,7 @@ Route::group('/ticket', function () { Route::any('/ticket/add', [app\ticket\controller\TicketController::class, 'add']); Route::any('/ticket/edit', [app\ticket\controller\TicketController::class, 'edit']); Route::any('/ticket/list', [app\ticket\controller\TicketController::class, 'index']); + Route::any('/ticket/self', [app\ticket\controller\TicketController::class, 'self']); Route::any('/ticket/status', [app\ticket\controller\TicketController::class, 'status']); Route::any('/ticket/getStatus', [app\ticket\controller\TicketController::class, 'getStatus']);