更新日志
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\SysUpdateLogService;
|
||||
|
||||
class SysUpdateLogController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysUpdateLogService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['update_time']))
|
||||
$data['update_time'] = date('Y-m-d H:i:s', $data['update_time']);
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysUpdateLog;
|
||||
|
||||
class SysUpdateLogLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysUpdateLog::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class SysUpdateLog extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sys_update_log';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'update_type', 'content', 'update_time', 'remark', 'created_at', 'updated_at', 'create_by', 'update_by'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysUpdateLogValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
+15
-1
@@ -400,7 +400,6 @@ Route::group('/admin', function () {
|
||||
Route::any('/resubmit', [app\common\controller\PurchaseOrdersController::class, 'resubmit']);
|
||||
});
|
||||
|
||||
|
||||
Route::group('/user/group', function () {
|
||||
Route::any('/list', [app\admin\controller\UserGroupController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\UserGroupController::class, 'show']);
|
||||
@@ -408,6 +407,21 @@ Route::group('/admin', function () {
|
||||
Route::any('/update', [app\admin\controller\UserGroupController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\UserGroupController::class, 'destroy']);
|
||||
});
|
||||
|
||||
// 操作日志
|
||||
Route::group('/op/log', function () {
|
||||
Route::any('/list', [app\common\controller\SysOpLogController::class, 'index']);
|
||||
Route::any('/show', [app\common\controller\SysOpLogController::class, 'show']);
|
||||
});
|
||||
|
||||
// 操作日志
|
||||
Route::group('/update/log', function () {
|
||||
Route::any('/list', [app\common\controller\SysUpdateLogController::class, 'index']);
|
||||
Route::any('/show', [app\common\controller\SysUpdateLogController::class, 'show']);
|
||||
Route::any('/store', [app\common\controller\SysUpdateLogController::class, 'store']);
|
||||
Route::any('/update', [app\common\controller\SysUpdateLogController::class, 'update']);
|
||||
Route::any('/destroy', [app\common\controller\SysUpdateLogController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user