更新日志

This commit is contained in:
2025-10-21 15:17:08 +08:00
parent 6617090cf8
commit 8c2d6e07ff
6 changed files with 223 additions and 1 deletions
@@ -0,0 +1,78 @@
<?php
namespace app\common\service;
use app\common\validate\SysUpdateLogValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SysUpdateLog;
use support\Request;
class SysUpdateLogService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysUpdateLog::class;
/**
* 验证器
*/
protected $validator = SysUpdateLogValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
/**
* 构造 CrudUtil 查询配置
*/
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'default':
$config['order']['id'] = 'desc';
case 'index':
break;
case 'show':
$config['where']['id'] = $p['id'];
break;
case 'store':
break;
case 'update':
case 'destroy':
$config['where']['id'] = $p['id'];
break;
}
return $config;
}
/**
* 添加前置处理
*/
public function beforeServiceStore($data, Request $request)
{
$data['update_time'] = !empty($data['update_time'])?strtotime($data['update_time']):0;
return $data;
}
/**
* 添加前置处理
*/
public function beforeServiceupdate($data, Request $request)
{
$data['update_time'] = !empty($data['update_time'])?strtotime($data['update_time']):0;
return $data;
}
}