Commit e2037690 authored by hujun's avatar hujun

操作记录

parent c3a2c537
...@@ -52,7 +52,7 @@ class Login extends Basic ...@@ -52,7 +52,7 @@ class Login extends Basic
Session::set("userName",$result[0]["name"]); Session::set("userName",$result[0]["name"]);
Session::set("userId",$result[0]["id"]); Session::set("userId",$result[0]["id"]);
Session::set("lastLoginTime",time()); Session::set("lastLoginTime",time());
$this->operating_records($result[0]["id"],1,'后台登陆'); //记录操作日志
$this->redirect('/admin.php/index/banner'); $this->redirect('/admin.php/index/banner');
} else { } else {
return view("/login/login", [ "msg" => "用户名或密码错误" ]); return view("/login/login", [ "msg" => "用户名或密码错误" ]);
......
...@@ -13,6 +13,7 @@ use think\Controller; ...@@ -13,6 +13,7 @@ use think\Controller;
use think\Request; use think\Request;
use think\Response; use think\Response;
use think\Session; use think\Session;
use think\Db;
class Basic extends Controller class Basic extends Controller
{ {
...@@ -218,6 +219,47 @@ class Basic extends Controller ...@@ -218,6 +219,47 @@ class Basic extends Controller
} }
} }
/**
* 记录操作
*
* @param int $agents_id
* @param array $data
* @param string $type
* @param string $remark
* @return bool
*/
/**
* 记录操作
*
* @param int $agents_id
* @param string $type
* @param string $remark
* @return bool|int|string
*/
public function operating_records($agents_id = 0, $type = '' ,$remark = '') {
$result = false;
$agents_id = Session::get('userId') ? Session::get('userId'):$agents_id;
if ($agents_id > 0) {
$name = Session::get('userName');
if ($name) {
$name = Db::table('a_agents')->where('id',$agents_id)->value('name');
}
$data = [
'agents_id' => $agents_id,
'name' => $name,
'url' => $this->request->url(),
'ip' => $this->request->ip(),
'remark' => $remark,
'type' => $type,
'create_time' => date('Y-m-d H:i:s')
];
$result = Db::table('g_operating_records')->insert($data);
}
return $result;
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment