還原 用branch_id 驗証 20250522
This commit is contained in:
parent
6f9433e1cf
commit
1dbe97ff4a
@ -70,7 +70,7 @@ class RoomControlController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function receiveRegister(ReceiveRoomRegisterRequest $request): JsonResponse
|
public function receiveRegister(ReceiveRoomRegisterRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $request->only(['branch_name', 'room_name', 'room_ip', 'email']); // 不記錄密碼
|
$data = $request->only(['branch_id', 'room_name', 'room_ip', 'email']); // 不記錄密碼
|
||||||
Log::info('Token Request Payload:', $data);
|
Log::info('Token Request Payload:', $data);
|
||||||
|
|
||||||
// 1. 驗證帳密(登入用)
|
// 1. 驗證帳密(登入用)
|
||||||
@ -103,8 +103,7 @@ class RoomControlController extends Controller
|
|||||||
$roomType = strtolower($matches[1]); // 'PC' → 'pc'
|
$roomType = strtolower($matches[1]); // 'PC' → 'pc'
|
||||||
$roomName = $matches[2]; // '101'
|
$roomName = $matches[2]; // '101'
|
||||||
}
|
}
|
||||||
$branch=Branch::where('name',$validated['branch_name'])->first();
|
$room = Room::where('branch_id', $validated['branch_id'])
|
||||||
$room = Room::where('branch_id', $branch->id)
|
|
||||||
->where('name', $roomName)
|
->where('name', $roomName)
|
||||||
->where('type', $roomType)
|
->where('type', $roomType)
|
||||||
->first();
|
->first();
|
||||||
@ -184,8 +183,7 @@ class RoomControlController extends Controller
|
|||||||
$roomType = strtolower($matches[1]); // 'PC' → 'pc'
|
$roomType = strtolower($matches[1]); // 'PC' → 'pc'
|
||||||
$roomName = $matches[2]; // '101'
|
$roomName = $matches[2]; // '101'
|
||||||
}
|
}
|
||||||
$branch=Branch::where('name',$validated['branch_name'])->first();
|
$room = Room::where('branch_id', $validated['branch_id'])
|
||||||
$room = Room::where('branch_id', $branch->id)
|
|
||||||
->where('name', $roomName)
|
->where('name', $roomName)
|
||||||
->where('type', $roomType)
|
->where('type', $roomType)
|
||||||
->first();
|
->first();
|
||||||
|
@ -7,8 +7,8 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||||||
/**
|
/**
|
||||||
* @OA\Schema(
|
* @OA\Schema(
|
||||||
* schema="ReceiveRoomRegisterRequest",
|
* schema="ReceiveRoomRegisterRequest",
|
||||||
* required={"branch_name", "room_name", "email" ,"password"},
|
* required={"branch_id", "room_name", "email" ,"password"},
|
||||||
* @OA\Property(property="branch_name", type="string", example="測試"),
|
* @OA\Property(property="branch_id", type="integer", example="1"),
|
||||||
* @OA\Property(property="room_name", type="string", example="PC101"),
|
* @OA\Property(property="room_name", type="string", example="PC101"),
|
||||||
* @OA\Property(property="room_ip", type="string", example="192.168.1.1"),
|
* @OA\Property(property="room_ip", type="string", example="192.168.1.1"),
|
||||||
* @OA\Property(property="email", type="string", example="XX@gmail.com"),
|
* @OA\Property(property="email", type="string", example="XX@gmail.com"),
|
||||||
@ -25,7 +25,7 @@ class ReceiveRoomRegisterRequest extends ApiRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'branch_name' => 'required|string|exists:branches,name',
|
'branch_id' => 'required|integer|exists:branches,id',
|
||||||
'room_name' => 'required|string',
|
'room_name' => 'required|string',
|
||||||
'room_ip' => 'required|string',
|
'room_ip' => 'required|string',
|
||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
|
@ -7,8 +7,8 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||||||
/**
|
/**
|
||||||
* @OA\Schema(
|
* @OA\Schema(
|
||||||
* schema="ReceiveRoomStatusDataRequest",
|
* schema="ReceiveRoomStatusDataRequest",
|
||||||
* required={"branch_name","hostname", "ip", "status"},
|
* required={"branch_id","hostname", "ip", "status"},
|
||||||
* @OA\Property(property="branch_name", type="string", example="測試"),
|
* @OA\Property(property="branch_id", type="integer", example="1"),
|
||||||
* @OA\Property(property="hostname", type="string", example="PC101"),
|
* @OA\Property(property="hostname", type="string", example="PC101"),
|
||||||
* @OA\Property(property="ip", type="string", example="192.168.XX.XX"),
|
* @OA\Property(property="ip", type="string", example="192.168.XX.XX"),
|
||||||
* @OA\Property(property="cpu", type="numeric", example="0.00"),
|
* @OA\Property(property="cpu", type="numeric", example="0.00"),
|
||||||
@ -26,7 +26,7 @@ class ReceiveRoomStatusDataRequest extends ApiRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'branch_name' =>'required|string|exists:branches,name',
|
'branch_id' =>'required|integer|exists:branches,id',
|
||||||
'hostname' => 'required|string',
|
'hostname' => 'required|string',
|
||||||
'ip' => 'required|string',
|
'ip' => 'required|string',
|
||||||
'cpu' => 'nullable|numeric',
|
'cpu' => 'nullable|numeric',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user