61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace app\api\controller\backend;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use app\common\controller\Api;
							 | 
						||
| 
								 | 
							
								use app\common\library\Ems;
							 | 
						||
| 
								 | 
							
								use app\common\library\Sms;
							 | 
						||
| 
								 | 
							
								use fast\Random;
							 | 
						||
| 
								 | 
							
								use think\Config;
							 | 
						||
| 
								 | 
							
								use think\Validate;
							 | 
						||
| 
								 | 
							
								use think\Db;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * 日志记录接口
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								class Logrecording extends Api
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    protected $noNeedLogin = ['*'];
							 | 
						||
| 
								 | 
							
								    protected $noNeedRight = '*';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public static function addLogrecordingData($user_id = 0, $content = null)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        
							 | 
						||
| 
								 | 
							
								        $ip = $_SERVER['REMOTE_ADDR'];
							 | 
						||
| 
								 | 
							
								        $createtime = date("Y-m-d H:i:s", time());
							 | 
						||
| 
								 | 
							
								        
							 | 
						||
| 
								 | 
							
								        $data = [
							 | 
						||
| 
								 | 
							
								            'user_id' => $user_id,
							 | 
						||
| 
								 | 
							
								            'content' => $content,
							 | 
						||
| 
								 | 
							
								            'ip_code' => $ip,
							 | 
						||
| 
								 | 
							
								            'createtime' => $createtime,
							 | 
						||
| 
								 | 
							
								        ];
							 | 
						||
| 
								 | 
							
								        Db::name('log_recording')->insert($data);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    
							 | 
						||
| 
								 | 
							
								    public function index()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $page = $this->request->post('page',1);
							 | 
						||
| 
								 | 
							
								        $size = $this->request->post('size',10);
							 | 
						||
| 
								 | 
							
								        $data = Db::name('log_recording')
							 | 
						||
| 
								 | 
							
								                ->field('a.*,w.nickname,w.work_number,g.name')
							 | 
						||
| 
								 | 
							
								                ->alias('a')
							 | 
						||
| 
								 | 
							
								                ->join('user w','a.user_id = w.id','LEFT')
							 | 
						||
| 
								 | 
							
								                ->join('user_group g','w.group_id = g.id','LEFT')
							 | 
						||
| 
								 | 
							
								                ->page($page,$size)
							 | 
						||
| 
								 | 
							
								                ->order('id desc')
							 | 
						||
| 
								 | 
							
								                ->select();
							 | 
						||
| 
								 | 
							
								        $count = Db::name('log_recording')
							 | 
						||
| 
								 | 
							
								                ->count();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        $res = [
							 | 
						||
| 
								 | 
							
								            'data'=>$data,
							 | 
						||
| 
								 | 
							
								            'count'=>$count
							 | 
						||
| 
								 | 
							
								        ];
							 | 
						||
| 
								 | 
							
								        return $this->success('请求成功',$res);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    
							 | 
						||
| 
								 | 
							
								}
							 |