API room control 調整 為 room_name = PC101
This commit is contained in:
parent
71d4ea38ea
commit
f0d9070858
@ -254,10 +254,6 @@ class RoomControlController extends Controller
|
||||
{
|
||||
$validated = $request->validated();
|
||||
$branch = Branch::where('name',$validated['branch_name'])->first();
|
||||
$room = Room::where([
|
||||
['branch_id', $branch->id],
|
||||
['name', $validated['room_name']],
|
||||
])->first();
|
||||
|
||||
if (!$branch) {
|
||||
return ApiResponse::error('分店不存在');
|
||||
@ -267,18 +263,6 @@ class RoomControlController extends Controller
|
||||
return ApiResponse::error('分店未設定 外部URL');
|
||||
}
|
||||
|
||||
if (!$room) {
|
||||
return ApiResponse::error('房間不存在');
|
||||
}
|
||||
|
||||
if (empty($room->internal_ip) || empty($room->port)) {
|
||||
return ApiResponse::error('房間未設定 IP 或 Port');
|
||||
}
|
||||
|
||||
if ($room->status === RoomStatus::Error) {
|
||||
return ApiResponse::error('房間目前處於錯誤狀態,無法操作');
|
||||
}
|
||||
|
||||
$command = $validated['command'];
|
||||
$payload = [
|
||||
'branch_name' => $validated['branch_name'],
|
||||
@ -302,10 +286,17 @@ class RoomControlController extends Controller
|
||||
{
|
||||
$validated = $request->validated();
|
||||
$branch = Branch::where('name',$validated['branch_name'])->first();
|
||||
$room = Room::where([
|
||||
['branch_id', $branch->id],
|
||||
['name', $validated['room_name']],
|
||||
])->first();
|
||||
$roomType = null;
|
||||
$roomName = null;
|
||||
// 從 room_name(例如 PC101, SVR01)中擷取 type 與 name
|
||||
if (preg_match('/^([A-Za-z]+)(\d+)$/', $validated['hostname'], $matches)) {
|
||||
$roomType = strtolower($matches[1]); // 'PC' → 'pc'
|
||||
$roomName = $matches[2]; // '101'
|
||||
}
|
||||
$room = Room::where('branch_id', $branch->id)
|
||||
->where('name', $roomName)
|
||||
->where('type', $roomType)
|
||||
->first();
|
||||
|
||||
if (!$branch) {
|
||||
return ApiResponse::error('分店不存在');
|
||||
|
@ -20,13 +20,14 @@ class RoomDetailModal extends Component
|
||||
'openAccountNotify','closeAccountNotify'
|
||||
];
|
||||
|
||||
public $room;
|
||||
public $room_name;
|
||||
public $branch;
|
||||
public bool $showModal = false;
|
||||
|
||||
public function openModal($roomId)
|
||||
{
|
||||
$this->room = Room::find($roomId);
|
||||
$room = Room::find($roomId);
|
||||
$this->room_name=$room->type->value . $room->name;
|
||||
$this->branch = Branch::find($this->room->branch_id);
|
||||
$this->showModal = true;
|
||||
}
|
||||
@ -67,7 +68,7 @@ class RoomDetailModal extends Component
|
||||
{
|
||||
return [
|
||||
'branch_name' => $this->branch->name ?? '',
|
||||
'room_name' => $this->room->name ?? '',
|
||||
'room_name' => $this->room_name ?? '',
|
||||
'command' => $command,
|
||||
'started_at' => $startedAt ? $startedAt->toDateTimeString() : null,
|
||||
'ended_at' => $endedAt ? $endedAt->toDateTimeString() : null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user