最新版本
This commit is contained in:
24
app/index/controller/ClientTicket.php
Normal file
24
app/index/controller/ClientTicket.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\index\service\ClientTicketService;
|
||||
use think\facade\Session;
|
||||
|
||||
class ClientTicket extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取客户关联工单
|
||||
*/
|
||||
public function getClientTickets(ClientTicketService $ClientTicketService)
|
||||
{
|
||||
$clientId = Session::get('user_info.id'); // 获取当前登录客户ID
|
||||
try {
|
||||
$tickets = $ClientTicketService->getClientTickets($clientId);
|
||||
return json(['code' => 200, 'msg' => '获取成功', 'data' => $tickets]);
|
||||
} catch (\Exception $e) {
|
||||
return json(['code' => 400, 'msg' => $e->getMessage(), 'data' => null]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class Login extends BaseController
|
||||
/*
|
||||
退出登录(已完成)
|
||||
*/
|
||||
protected function logout()
|
||||
public function logout()
|
||||
{
|
||||
Session::clear();
|
||||
return json(['code' => 200, 'message' => '退出成功']);
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
<?php
|
||||
|
||||
use app\admin\middleware\Auth;
|
||||
use think\facade\Route;
|
||||
|
||||
Route::post('login', 'Login/login'); // 登录
|
||||
Route::post('logout', 'Login/logout'); // 退出登录
|
||||
|
||||
Route::post('api/login', 'Login/login'); // 登录
|
||||
|
||||
Route::group(function () {
|
||||
Route::get('client/tickets', 'ClientTicket/getClientTickets'); // 获取客户关联工单
|
||||
})->middleware(Auth::class);
|
||||
27
app/index/service/ClientTicketService.php
Normal file
27
app/index/service/ClientTicketService.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace app\index\service;
|
||||
|
||||
use app\common\model\User as UserModel;
|
||||
|
||||
|
||||
class ClientTicketService
|
||||
{
|
||||
/* 获取客户关联工单 */
|
||||
public function getClientTickets($clientId)
|
||||
{
|
||||
# 查询当前登录用户所对应的工单
|
||||
|
||||
$tickets = UserModel::with(['tickets'])->find($clientId);
|
||||
|
||||
$newList = [];
|
||||
foreach ($tickets->tickets as $ticket) {
|
||||
if (in_array($ticket->status, [0, 1, 2])) {
|
||||
$ticket->visible(['id', 'website', 'datanum', 'progress', 'status']);
|
||||
$newList[] = $ticket->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
return $newList;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user