77 lines
1.7 KiB
PHP
77 lines
1.7 KiB
PHP
<?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 'index':
|
|
$config['order']['id'] = 'desc';
|
|
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;
|
|
}
|
|
} |