ManagerLogController.php
3.2 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
<?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;
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];
}
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 :管理员日志列表
* @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;
}
}