調整心跳封包 邏輯 改回用branch_name 去驗証 20250523
This commit is contained in:
parent
9683a06dc1
commit
b9d7dfb694
@ -103,7 +103,8 @@ class RoomControlController extends Controller
|
||||
$roomType = strtolower($matches[1]); // 'PC' → 'pc'
|
||||
$roomName = $matches[2]; // '101'
|
||||
}
|
||||
$room = Room::where('branch_id', $validated['branch_id'])
|
||||
$branch=Branch::where('name',$validated['branch_name'])->first();
|
||||
$room = Room::where('branch_id', $branch->id)
|
||||
->where('name', $roomName)
|
||||
->where('type', $roomType)
|
||||
->first();
|
||||
@ -183,7 +184,8 @@ class RoomControlController extends Controller
|
||||
$roomType = strtolower($matches[1]); // 'PC' → 'pc'
|
||||
$roomName = $matches[2]; // '101'
|
||||
}
|
||||
$room = Room::where('branch', $validated['branch_id'])
|
||||
$branch=Branch::where('name',$validated['branch_name'])->first();
|
||||
$room = Room::where('branch', $branch->id)
|
||||
->where('name', $roomName)
|
||||
->where('type', $roomType)
|
||||
->first();
|
||||
|
@ -8,7 +8,7 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
* @OA\Schema(
|
||||
* schema="ReceiveRoomRegisterRequest",
|
||||
* required={"branch", "room_name", "email" ,"password"},
|
||||
* @OA\Property(property="branch", type="string", example="1"),
|
||||
* @OA\Property(property="branch_name", type="string", example="測試"),
|
||||
* @OA\Property(property="room_name", type="string", example="PC101"),
|
||||
* @OA\Property(property="room_ip", type="string", example="192.168.1.1"),
|
||||
* @OA\Property(property="email", type="string", example="XX@gmail.com"),
|
||||
@ -25,7 +25,7 @@ class ReceiveRoomRegisterRequest extends ApiRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'branch' => 'required|string',
|
||||
'branch_name' =>'required|string|exists:branches,name',
|
||||
'room_name' => 'required|string',
|
||||
'room_ip' => 'required|string',
|
||||
'email' => 'required|email',
|
||||
|
@ -7,8 +7,8 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
/**
|
||||
* @OA\Schema(
|
||||
* schema="ReceiveRoomStatusDataRequest",
|
||||
* required={"branch","hostname", "ip", "status"},
|
||||
* @OA\Property(property="branch", type="string", example="1"),
|
||||
* required={"branch_name","hostname", "ip", "status"},
|
||||
* @OA\Property(property="branch_name", type="string", example="測試"),
|
||||
* @OA\Property(property="hostname", type="string", example="PC101"),
|
||||
* @OA\Property(property="ip", type="string", example="192.168.XX.XX"),
|
||||
* @OA\Property(property="cpu", type="numeric", example="0.00"),
|
||||
@ -26,7 +26,7 @@ class ReceiveRoomStatusDataRequest extends ApiRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'branch' =>'required|string',
|
||||
'branch_name' =>'required|string|exists:branches,name',
|
||||
'hostname' => 'required|string',
|
||||
'ip' => 'required|string',
|
||||
'cpu' => 'nullable|numeric',
|
||||
|
@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @OA\Schema(
|
||||
* schema="MachineStatus",
|
||||
* type="object",
|
||||
* @OA\Property(property="branch", type="string", example="測試"),
|
||||
* @OA\Property(property="branch_name", type="string", example="測試"),
|
||||
* @OA\Property(property="hostname", type="string", example="PC101"),
|
||||
* @OA\Property(property="ip", type="string", example="192.168.XX.XX"),
|
||||
* @OA\Property(property="cpu", type="numeric", example="0.00"),
|
||||
@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class MachineStatus extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'branch',
|
||||
'branch_name',
|
||||
'hostname',
|
||||
'ip',
|
||||
'cpu',
|
||||
|
@ -13,7 +13,7 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('machine_statuses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('branch');
|
||||
$table->string('branch_name');
|
||||
$table->string('hostname');
|
||||
$table->string('ip')->nullable();
|
||||
$table->decimal('cpu', 5, 2)->nullable();
|
||||
|
Loading…
x
Reference in New Issue
Block a user