修复文档模型栏目无法选择的bug,记录用户操作行为

This commit is contained in:
2020-04-27 18:57:43 +08:00
parent 484f2f0e13
commit 2482e6f304
3 changed files with 74 additions and 42 deletions
+4 -2
View File
@@ -8,6 +8,7 @@
// +----------------------------------------------------------------------
namespace app\http\middleware;
use app\model\MemberLog;
use think\facade\Session;
/**
@@ -17,14 +18,15 @@ class Admin {
public function handle($request, \Closure $next) {
$request->rootUid = env('rootuid');
$request->user = Session::get('userInfo');
$request->user = Session::get('adminInfo');
$request->url = str_replace(".", "/", strtolower($request->controller())) . '/' . $request->action();
$request->pageConfig = array(
'list_rows' => $request->param('limit', 20),
'page' => $request->param('page', 1),
'query' => $request->param()
'query' => $request->param(),
);
MemberLog::record($request);
$response = $next($request);
return $response;
+4 -4
View File
@@ -8,10 +8,10 @@
// +----------------------------------------------------------------------
namespace app\model;
use app\model\Model as Models;
use sent\tree\Tree;
use think\facade\Config;
use think\facade\Db;
use sent\tree\Tree;
use app\model\Model as Models;
/**
* 设置模型
@@ -128,7 +128,7 @@ class Attribute extends \think\Model {
if ($db->CheckField($data['extra'], 'model_id')) {
$map[] = ['model_id', '=', $data['model_id']];
}
$row = Db::name($data['extra'])->select($map)->toArray();
$row = Db::name($data['extra'])->where($map)->select()->toArray();
foreach ($row as $val) {
$list[] = ['key' => $val['id'], 'label' => $val['title']];
}
@@ -181,7 +181,7 @@ class Attribute extends \think\Model {
['name' => 'value', 'title' => '默认值', 'help' => '字段的默认值', 'type' => 'text'],
['name' => 'remark', 'title' => '字段备注', 'help' => '用于表单中的提示', 'type' => 'text'],
['name' => 'is_show', 'title' => '是否显示', 'help' => '是否显示在表单中', 'type' => 'select', 'option' => [
['key'=>'1', 'label' => '始终显示'], ['key'=>'2', 'label' => '新增显示'], ['key'=>'3', 'label' => '编辑显示'], ['key'=>'0', 'label' => '不显示']
['key' => '1', 'label' => '始终显示'], ['key' => '2', 'label' => '新增显示'], ['key' => '3', 'label' => '编辑显示'], ['key' => '0', 'label' => '不显示'],
], 'value' => 1],
['name' => 'is_must', 'title' => '是否必填', 'help' => '用于自动验证', 'type' => 'select', 'option' => [['key' => '0', 'label' => '否'], ['key' => '1', 'label' => '是']]],
],
+30
View File
@@ -25,6 +25,7 @@ class MemberLog extends Model {
public static function record($request) {
$data = [
'uid' => $request->user['uid'],
'title' => self::getCurrentTitle($request),
'url' => $request->baseUrl(),
'param' => $request->param(),
'method' => $request->method(),
@@ -46,4 +47,33 @@ class MemberLog extends Model {
public function user() {
return $this->hasOne('Member', 'uid', 'uid')->field('uid,nickname,username');
}
protected static function getCurrentTitle($request) {
$mate = '';
$controller = strtr(strtolower($request->controller()), '.', '\\');
$action = $request->action();
$class = "\\app\\controller\\" . $controller;
if (class_exists($class)) {
$reflection = new \ReflectionClass($class);
$group_doc = self::Parser($reflection->getDocComment());
if (isset($group_doc['title'])) {
$mate = $group_doc['title'];
}
$method = $reflection->getMethods(\ReflectionMethod::IS_FINAL | \ReflectionMethod::IS_PUBLIC);
foreach ($method as $key => $v) {
if ($action == $v->name) {
$title_doc = self::Parser($v->getDocComment());
if (isset($title_doc['title'])) {
$mate = $title_doc['title'];
}
}
}
}
return $mate;
}
protected static function Parser($text) {
$doc = new \doc\Doc();
return $doc->parse($text);
}
}