Merge branch 'develop' into feature/mzl_dev

This commit is contained in:
mzl
2025-10-24 15:47:12 +08:00
11 changed files with 428 additions and 1 deletions
+78
View File
@@ -0,0 +1,78 @@
<?php
namespace app\common\service;
use app\common\validate\SysOpLogValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SysOpLog;
use support\Request;
class SysOpLogService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = SysOpLog::class;
/**
* 验证器
*/
protected $validator = SysOpLogValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
/**
* 构建查询条件
*/
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';
// ====== ====== 筛选 ====== ======
// 状态
if (isset($p['user_id']) && $p['user_id']) {
$config['where']['user_id'] = $p['user_id'];
}
// ip
if (isset($p['ip']) && $p['ip']) {
$config['where']['ip'] = $p['ip'];
}
// ip
if (isset($p['method']) && $p['method']) {
$config['where']['method'] = $p['method'];
}
// 关键字
if (isset($p['keyword']) && $p['keyword']) {
$k = '%' . $p['keyword'] . '%';
foreach (['user_name', 'route'] as $col) {
$config['orWhere'][] = [$col, 'like', $k];
}
}
//$config['where']['status'] = 1;
break;
case 'show':
$config['where']['id'] = $p['id'];
//$config['where']['status'] = 1;
break;
}
return $config;
}
}
@@ -0,0 +1,77 @@
<?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;
}
}