SystemLog.php 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace app\user\controller;
  3. use think\App;
  4. class SystemLog extends Base{
  5. public function __construct(App $app) {
  6. parent::__construct($app);
  7. $this->model = new \app\user\model\SystemLog();
  8. }
  9. public function list(){
  10. $params = $this->request->param(["system"=>"","controller"=>"","action"=>"","uid"=>'',"page"=>1,"size"=>10,
  11. "start"=>"","end"=>""],"post","trim");
  12. $where=[];
  13. if($params['system']!='') $where[]=['system','=',$params['system']];
  14. if($params['controller']!='') $where[]=['controller','=',$params['controller']];
  15. if($params['action']!='') $where[]=['action','=',$params['action']];
  16. if($params['uid']!='') $where[]=['action_id','=',$params['uid']];
  17. if($params['start']!='' && $params['end']!=''){
  18. $where[]=['createTime','between',[$params['start'],$params['end']]];
  19. }
  20. $list = $this->model->where($where)->order('id desc')
  21. ->paginate(["page"=>$params['page'],"list_rows"=>$params['size']])->each(function($item,$key){
  22. $item->action_msg = \SystemLog::GET_LOG_PATH($item->toArray(),$item->action_name,$item->param);
  23. });
  24. return success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
  25. }
  26. }