Browse Source

绘制地图新增字段

master
wanghongjun 3 days ago
parent
commit
47d2957272
  1. 10
      app/Http/Controllers/Admin/ParkingElectronicMapController.php
  2. 9
      app/Services/ParkingElectronicMapService.php
  3. 5
      database/migrations/2026_04_23_143449_create_parking_electronic_map_table.php
  4. 16
      resources/lang/zh-CN/validation.php

10
app/Http/Controllers/Admin/ParkingElectronicMapController.php

@ -125,8 +125,14 @@ class ParkingElectronicMapController extends BaseController
{
try {
$data = $request->all();
$this->saveValidator($data, 1);
$this->service->saveModel($data);
$saveData = $data['saveData'] ?? [];
if (empty($saveData)) {
throw new Exception(__('validation.map.d_empty'));
}
foreach ($saveData as $item) {
$this->saveValidator($item, 1);
$this->service->saveModel($item);
}
return $this->responseService->success([], __('admin.save_succeeded'));
} catch (Exception $e) {
$m_prefix = __('admin.save_failed');

9
app/Services/ParkingElectronicMapService.php

@ -34,6 +34,10 @@ class ParkingElectronicMapService extends BaseService
$saveData['height'] = $data['height'] ?? '0';
$saveData['coordinate_x'] = $data['coordinate_x'] ?? '';
$saveData['coordinate_y'] = $data['coordinate_y'] ?? '';
$saveData['min_width'] = $data['min_width'] ?? '';
$saveData['min_height'] = $data['min_height'] ?? '';
$saveData['keep_aspect_ratio'] = $data['keep_aspect_ratio'] ?? '0';
$saveData['aspect_ratio'] = $data['aspect_ratio'] ?? '';
if ($res) {
$saveData['update_at'] = get_datetime();
$model = ParkingElectronicMap::query()->findOrFail($res[0]['id']);
@ -65,7 +69,10 @@ class ParkingElectronicMapService extends BaseService
'width',
'height',
'coordinate_x',
'coordinate_y'
'min_width',
'min_height',
'keep_aspect_ratio',
'aspect_ratio'
];
$list = ParkingElectronicMap::query()->where($where)->select($columns)
->get()->toArray();

5
database/migrations/2026_04_23_143449_create_parking_electronic_map_table.php

@ -19,6 +19,11 @@ return new class extends Migration
$table->string('height', 20)->default('')->comment('高');
$table->string('coordinate_x', 20)->default('')->comment('坐标X');
$table->string('coordinate_y', 20)->default('')->comment('坐标y');
$table->string('min_width', 20)->default('');
$table->string('min_height', 20)->default('');
$table->tinyInteger('keep_aspect_ratio')->default('0')->comment('0 false 1 true');
$table->string('aspect_ratio', 20)->default('');
$table->innoDb();
$table->timestamps();
});
}

16
resources/lang/zh-CN/validation.php

@ -77,10 +77,22 @@ return [
'ids_empty' => '车位数据不能为空',
'ids_array' => '车位数据必须是数组',
],
'map' => [
'map' => [
'f_empty' => '楼层编号不能为空',
'f_number' => '楼层编号必须是数字',
'p_empty' => '车位编号必须是数字',
'p_number' => '车位编号必须是数字'
'p_number' => '车位编号必须是数字',
'd_empty' => '保存数据不能为空'
],
'parking_camera' => [
'n_empty' => '设备编号不能为空',
'n_max' => '车牌号码最多50个字符',
's_empty' => '服务器IP不能为空',
's_max' => '服务器IP最多15个字符',
'c_empty' => '相机IP不能为空',
'c_max' => '相机IP最多15个字符',
'p_array' => '车位数据必须是数组',
'lights_ip_empty' => '控灯相机IP不能为空',
'lights_ip_max' => '控灯相机IP最多15个字符'
]
];

Loading…
Cancel
Save