ManagerLogController.php
4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* @remark :
* @name :ManagerLogController.php
* @author :lyh
* @method :post
* @time :2023/9/5 16:09
*/
namespace App\Http\Controllers\Aside\Manage;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Manage\LoginLog;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageLog;
use App\Models\User\User;
use App\Models\User\UserLog;
class ManagerLogController extends BaseController
{
/**
* @remark :管理员操作日志
* @name :log
* @author :lyh
* @method :post
* @time :2024/12/4 16:51
*/
public function logList(ManageLog $manageLog){
$managerModel = new Manage();
if(isset($this->map['name']) && !empty($this->map['name'])){
$ids = $managerModel->where('name', 'like', '%' . $this->param['name'] . '%')->pluck('id')->toArray();
$this->map['manage_id'] = ['in',$ids];
unset($this->map['name']);
}
if(isset($this->map['url']) && !empty($this->map['url'])){
$this->map['url'] = ['like','%'.$this->map['url'].'%'];
}
if(isset($this->map['ip']) && !empty($this->map['ip'])){
$this->map['ip'] = ['like','%'.$this->map['ip'].'%'];
}
$lists = $manageLog->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['name'] = $managerModel->getName($v['manage_id']);
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :v6操作日志
* @name :UserLogList
* @author :lyh
* @method :post
* @time :2024/12/4 17:37
*/
public function userLogList(UserLog $userLogModel){
$userModel = new User();
if(isset($this->map['name']) && !empty($this->map['name'])){
$ids = $userModel->where('name', 'like', '%' . $this->param['name'] . '%')->pluck('id')->toArray();
$this->map['operator_id'] = ['in',$ids];
unset($this->map['name']);
}
if(isset($this->map['model']) && !empty($this->map['model'])){
$this->map['model'] = ['like','%'.$this->map['model'].'%'];
}
if(isset($this->map['remark']) && !empty($this->map['remark'])){
$this->map['remark'] = ['like','%'.$this->map['remark'].'%'];
}
$lists = $userLogModel->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
$userModel = new User();
foreach ($lists['list'] as $k => $v){
$v['name'] = $userModel->getName($v['operator_id']);
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :管理员日志列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/9/5 16:10
*/
public function lists(LoginLog $manageLogin){
$map = $this->searchParam();
$lists = $manageLogin->lists($map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
$managerModel = new Manage();
foreach ($lists['list'] as $k => $v){
$info = $managerModel->read(['id'=>$v['manage_id']]);
$v['mobile'] = $info['mobile'] ?? '';
$v['name'] = $info['name'] ?? '';
$v['type'] = (isset($v['type']) && $v['type'] == 1) ? '账号密码登录' : '验证码登录';
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :搜索参数
* @name :searchParam
* @author :lyh
* @method :post
* @time :2023/9/5 16:56
*/
public function searchParam(){
$map = [];
$managerModel = new Manage();
if(isset($this->map['mobile']) && !empty($this->map['mobile'])){
$ids = $managerModel->where('mobile', 'like', '%' . $this->map['mobile'] . '%')->pluck('id')->toArray();
$map['manage_id'] = ['in',$ids];
}elseif (isset($this->map['name']) && !empty($this->map['name'])){
$ids = $managerModel->where('name', 'like', '%' . $this->param['name'] . '%')->pluck('id')->toArray();
$map['manage_id'] = ['in',$ids];
}
if(isset($this->map['created_at'])){
$map['created_at'] = $this->map['created_at'];
}
return $map;
}
}