Log.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\admin\controller;
  3. /**
  4. * 日志
  5. */
  6. class Log extends Admin{
  7. protected $Log = null;
  8. protected function _initialize(){
  9. parent::_initialize();
  10. $this->Log = model('Log');
  11. }
  12. public function index(){
  13. $this->assign('meta_title','日志列表');
  14. return $this->fetch();
  15. }
  16. public function load(){
  17. $where = [];
  18. $position = input('param.position');
  19. $where['position'] = $position;
  20. $page = input('get.page');
  21. $limit = input('get.limit');
  22. $list = $this->Log->where($where)->order('create_time desc')->paginate($limit,false,['page'=>$page]);
  23. $data = [];
  24. foreach ($list as $key => $value) {
  25. $data[$key]['id'] = $value['id'];
  26. $user = $value['user'];
  27. $data[$key]['user'] = $user['name'].'['.$user['id'].']';
  28. $data[$key]['action'] = $value['action'];
  29. $data[$key]['action_text'] = $value['action_text'];
  30. $data[$key]['create_time'] = $value['create_time'];
  31. }
  32. $this->output(0,'加载成功',$data,$list->total());
  33. }
  34. //
  35. public function params(){
  36. $id = input('get.id');
  37. $log = $this->Log->where(['id'=>$id])->find();
  38. if (!$log) {
  39. $this->error('参数错误');
  40. }
  41. $this->assign('log',$log);
  42. $this->assign('meta_title','查看参数');
  43. return $this->fetch();
  44. }
  45. }