添加设备管理操作日志

dev
vine_liutk 2022-11-15 10:21:49 +08:00
parent faf5e36069
commit 655c9ba04f
1 changed files with 9 additions and 1 deletions

View File

@ -18,6 +18,8 @@ use App\Models\AgriculturalBase;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use App\Services\OperationLogService;
use App\Enums\OperationType;
class DeviceController extends Controller
{
@ -36,11 +38,13 @@ class DeviceController extends Controller
if ($input['type'] != DeviceType::Monitor->value) {
unset($input['extends']);
}
Device::create(array_merge($input, [
$device = Device::create(array_merge($input, [
'created_by' => auth('api')->user()?->id ?? 0,
'updated_by' => auth('api')->user()?->id ?? 0,
]));
(new OperationLogService())->inLog(OperationType::Create, '', $device, $request->input());
return $this->success('添加成功');
}
@ -60,6 +64,8 @@ class DeviceController extends Controller
'updated_by' => auth('api')->user()?->id ?? 0,
]));
(new OperationLogService())->inLog(OperationType::Update, '', $device, $request->input());
return $this->success('修改成功');
}
@ -67,6 +73,8 @@ class DeviceController extends Controller
{
$device->delete();
(new OperationLogService())->inLog(OperationType::Delete, '', $device);
return $this->success('删除成功');
}