DelLog.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. class DelLog extends Base
  7. {
  8. // 列表
  9. public function list(){
  10. $page = input('page/d',1);
  11. $size = input('size/d',10);
  12. $name = input('name','','trim');
  13. $startTime = input('startTime','','trim');
  14. $endTime = input('endTime','','trim');
  15. $ret = $this->selectActionLog($page,$size,$name,$startTime,$endTime);
  16. HelpHander::success($ret);
  17. }
  18. // 日志列表
  19. private function selectActionLog($page,$size,$name,$startTime,$endTime){
  20. if($name){
  21. $map[] = ['ui.name','like','%'.$name.'%'];
  22. }
  23. if($startTime&&$endTime){
  24. $map[] = ['al.create_time','>=',$startTime];
  25. $map[] = ['al.create_time','<=',$endTime];
  26. }
  27. $map = !empty($map)?$map:true;
  28. $lists = Db::name('del_log')
  29. ->alias('al')
  30. ->join('user_info ui','ui.user_id = al.user_id')
  31. ->where($map)
  32. ->page($page,$size)
  33. ->field('al.*,ui.name')
  34. ->order('al.id desc')
  35. ->select();
  36. $total = Db::name('del_log')
  37. ->alias('al')
  38. ->join('user_info ui','ui.user_id = al.user_id')
  39. ->where($map)->count();
  40. $data = [
  41. 'total' => $total,
  42. 'list' => $lists?$lists:[]
  43. ];
  44. return $data;
  45. }
  46. }