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();
|
$validated = $request->validated();
|
||||||
$branch = Branch::where('name',$validated['branch_name'])->first();
|
$branch = Branch::where('name',$validated['branch_name'])->first();
|
||||||
$room = Room::where([
|
|
||||||
['branch_id', $branch->id],
|
|
||||||
['name', $validated['room_name']],
|
|
||||||
])->first();
|
|
||||||
|
|
||||||
if (!$branch) {
|
if (!$branch) {
|
||||||
return ApiResponse::error('分店不存在');
|
return ApiResponse::error('分店不存在');
|
||||||
@ -267,18 +263,6 @@ class RoomControlController extends Controller
|
|||||||
return ApiResponse::error('分店未設定 外部URL');
|
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'];
|
$command = $validated['command'];
|
||||||
$payload = [
|
$payload = [
|
||||||
'branch_name' => $validated['branch_name'],
|
'branch_name' => $validated['branch_name'],
|
||||||
@ -302,10 +286,17 @@ class RoomControlController extends Controller
|
|||||||
{
|
{
|
||||||
$validated = $request->validated();
|
$validated = $request->validated();
|
||||||
$branch = Branch::where('name',$validated['branch_name'])->first();
|
$branch = Branch::where('name',$validated['branch_name'])->first();
|
||||||
$room = Room::where([
|
$roomType = null;
|
||||||
['branch_id', $branch->id],
|
$roomName = null;
|
||||||
['name', $validated['room_name']],
|
// 從 room_name(例如 PC101, SVR01)中擷取 type 與 name
|
||||||
])->first();
|
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) {
|
if (!$branch) {
|
||||||
return ApiResponse::error('分店不存在');
|
return ApiResponse::error('分店不存在');
|
||||||
|
@ -20,13 +20,14 @@ class RoomDetailModal extends Component
|
|||||||
'openAccountNotify','closeAccountNotify'
|
'openAccountNotify','closeAccountNotify'
|
||||||
];
|
];
|
||||||
|
|
||||||
public $room;
|
public $room_name;
|
||||||
public $branch;
|
public $branch;
|
||||||
public bool $showModal = false;
|
public bool $showModal = false;
|
||||||
|
|
||||||
public function openModal($roomId)
|
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->branch = Branch::find($this->room->branch_id);
|
||||||
$this->showModal = true;
|
$this->showModal = true;
|
||||||
}
|
}
|
||||||
@ -67,7 +68,7 @@ class RoomDetailModal extends Component
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'branch_name' => $this->branch->name ?? '',
|
'branch_name' => $this->branch->name ?? '',
|
||||||
'room_name' => $this->room->name ?? '',
|
'room_name' => $this->room_name ?? '',
|
||||||
'command' => $command,
|
'command' => $command,
|
||||||
'started_at' => $startedAt ? $startedAt->toDateTimeString() : null,
|
'started_at' => $startedAt ? $startedAt->toDateTimeString() : null,
|
||||||
'ended_at' => $endedAt ? $endedAt->toDateTimeString() : null,
|
'ended_at' => $endedAt ? $endedAt->toDateTimeString() : null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user