添加设备推荐
parent
8247f78cf4
commit
4ec62f805c
|
|
@ -20,6 +20,7 @@ use Illuminate\Support\Facades\DB;
|
|||
use Carbon\Carbon;
|
||||
use App\Services\OperationLogService;
|
||||
use App\Enums\OperationType;
|
||||
use Peidikeji\Setting\Models\Setting;
|
||||
|
||||
class DeviceController extends Controller
|
||||
{
|
||||
|
|
@ -368,4 +369,13 @@ class DeviceController extends Controller
|
|||
}
|
||||
return $this->json($data);
|
||||
}
|
||||
|
||||
public function getFfmpegServiceIp(){
|
||||
$ip = '127.0.0.1';
|
||||
|
||||
$setting = Setting::where('slug', 'ffmpeg_websocket_ip')->first();
|
||||
$ip = $setting?->value ?? '127.0.0.1';
|
||||
|
||||
return $this->json(['ip'=> $ip]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class DeviceRequest extends FormRequest
|
|||
'extends.username' => 'required_if:type,1|string',
|
||||
'extends.password' => 'required_if:type,1|string',
|
||||
'extends.passage' => 'required_if:type,1|string',
|
||||
'is_recommend' => 'filled|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +47,7 @@ class DeviceRequest extends FormRequest
|
|||
'extends.username.required_if' => '请填写监控设备登录名',
|
||||
'extends.password.required_if' => '请填写监控设备登录密码',
|
||||
'extends.passage.required_if' => '请填写监控设备播放通道',
|
||||
'is_recommend' => '请设置推荐状态',
|
||||
];
|
||||
|
||||
return $messages;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class DeviceResource extends JsonResource
|
|||
return $this->createdBy?->name;
|
||||
}, ''), //录入人
|
||||
'created_at' => strtotime($this->created_at) ?? 0, //录入时间
|
||||
'is_recommend' => $this->is_recommend
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,8 @@ class DeviceFilter extends ModelFilter
|
|||
{
|
||||
return $this->where('status', $status);
|
||||
}
|
||||
|
||||
public function isRecommend($isRecommend){
|
||||
return $this->where('is_recommend', $isRecommend);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class Device extends Model
|
|||
|
||||
protected $fillable = [
|
||||
'agricultural_base_id',
|
||||
'is_recommend',
|
||||
'sn',
|
||||
'name',
|
||||
'model',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
//
|
||||
$table->unsignedTinyInteger('is_recommend')->default(0)->comment('推荐');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn(['is_recommend']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -110,6 +110,7 @@ class SettingTableSeeder extends Seeder
|
|||
['name' => '全市数据-生猪年出栏', 'slug' => 'city_data_pig_output', 'value' => '{"value":"42.01", "unit":"万头"}'],
|
||||
['name' => '警报规则-土壤设备', 'slug' => 'device_warning_rule_soil', 'value' => $soilRule],
|
||||
['name' => '警报规则-水质设备', 'slug' => 'device_warning_rule_waterquality', 'value' => $waterRule],
|
||||
['name' => '监控设备-转流服务器', 'slug' => 'ffmpeg_websocket_ip', 'value' =>'127.0.0.1']
|
||||
];
|
||||
Setting::insert($list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ Route::group(['middleware' => 'auth:sanctum'], function () {
|
|||
Route::get('permissions', [AdminPermissionController::class, 'index']);
|
||||
Route::get('device-types', [DeviceController::class, 'types']);
|
||||
|
||||
Route::get('ffmpeg-websocket-ip', [DeviceController::class, 'getFfmpegServiceIp']);
|
||||
|
||||
Route::group(['as' => 'endpoint.'], function () {
|
||||
//全市基础数据
|
||||
Route::get('citydata-statistics', [CityDataController::class, 'statistics'])->name('citydata_statistics.index');
|
||||
|
|
|
|||
Loading…
Reference in New Issue