Compare commits

...

2 Commits

Author SHA1 Message Date
c30385b073 获取登录角色 2026-05-28 09:49:14 +08:00
02a7a4e518 前台后台一起使用同一个更新工单 2026-05-28 09:48:58 +08:00
2 changed files with 3 additions and 11 deletions

View File

@@ -118,7 +118,7 @@ class TicketService
* @param $role 当前登录用户角色 * @param $role 当前登录用户角色
* @return array * @return array
*/ */
public function updateTicket($id, $data, $allowFields, $uid, $isSuper = false) public function updateTicket($id, $data, $allowFields, $isRole, $isSuper = false)
{ {
$ticket = Tickets::where('id', $id)->find(); $ticket = Tickets::where('id', $id)->find();
@@ -126,14 +126,6 @@ class TicketService
throw new \Exception('工单不存在'); throw new \Exception('工单不存在');
} }
// 当不是管理员,进入判断
if (!$isSuper) {
if (!is_null($ticket->user_id) && $ticket->user_id != $uid) {
throw new \Exception('没有权限修改该工单');
}
}
// 提取 $allowFields 允许修改的字段 // 提取 $allowFields 允许修改的字段
$updateData = []; $updateData = [];
foreach ($allowFields as $field) { foreach ($allowFields as $field) {

View File

@@ -14,13 +14,13 @@ class Ticket extends BaseController
public function updateTicket(TicketService $ticketService, $id) public function updateTicket(TicketService $ticketService, $id)
{ {
$adminId = Session::get('id'); // 获取当前登录ID $isUser = Session::get('user_info.role') === 'user'; // 获取当前登录ID
$data = $this->request->post(); $data = $this->request->post();
$allowFields = ['datanum', 'progress', 'status', 'remark', 'lock_time']; $allowFields = ['datanum', 'progress', 'status', 'remark', 'lock_time'];
try { try {
$result = $ticketService->updateTicket($id, $data, $allowFields, $adminId, false); $result = $ticketService->updateTicket($id, $data, $allowFields, $isUser, false);
return json(['code' => 200, 'msg' => '更新成功', 'data' => $result]); return json(['code' => 200, 'msg' => '更新成功', 'data' => $result]);
} catch (\Exception $e) { } catch (\Exception $e) {
return json(['code' => 400, 'msg' => $e->getMessage()]); return json(['code' => 400, 'msg' => $e->getMessage()]);