123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\hander\HelpHander;
- use think\Db;
- class DelLog extends Base
- {
- // 列表
- public function list(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $name = input('name','','trim');
- $startTime = input('startTime','','trim');
- $endTime = input('endTime','','trim');
- $ret = $this->selectActionLog($page,$size,$name,$startTime,$endTime);
- HelpHander::success($ret);
- }
- // 日志列表
- private function selectActionLog($page,$size,$name,$startTime,$endTime){
- if($name){
- $map[] = ['ui.name','like','%'.$name.'%'];
- }
- if($startTime&&$endTime){
- $map[] = ['al.create_time','>=',$startTime];
- $map[] = ['al.create_time','<=',$endTime];
- }
- $map = !empty($map)?$map:true;
- $lists = Db::name('del_log')
- ->alias('al')
- ->join('user_info ui','ui.user_id = al.user_id')
- ->where($map)
- ->page($page,$size)
- ->field('al.*,ui.name')
- ->order('al.id desc')
- ->select();
- $total = Db::name('del_log')
- ->alias('al')
- ->join('user_info ui','ui.user_id = al.user_id')
- ->where($map)->count();
- $data = [
- 'total' => $total,
- 'list' => $lists?$lists:[]
- ];
- return $data;
- }
- }
|