diff --git a/Application/Admin/Controller/AdminController.class.php b/Application/Admin/Controller/AdminController.class.php index c3e303e15..3c55719ff 100644 --- a/Application/Admin/Controller/AdminController.class.php +++ b/Application/Admin/Controller/AdminController.class.php @@ -662,5 +662,64 @@ class AdminController extends Controller { } } } + /** + * 操作日志 + * array( + * op_type=>操作类型 1:编辑 2:删除 3:下载, + * op_name=>操作说明 例如:编辑,删除,锁定等, + * url=>需要跳转的url 添加去列表加唯一id,编辑直接去编辑页面,下载可以重新下载(新开页面), + * key=>关键词:用户的账号,游戏的名词等 + * ) + */ + public function addOperationLog($options) + { + $checkarr = ['op_type','op_name','url','key']; + foreach ($checkarr as $v) { + if(!array_key_exists($v,$options)){ + $this->error('操作日志添加,参数错误'); + } + } + //获取ip + $addarray = [ + "op_ip"=>$_SERVER['REMOTE_ADDR'], + 'admin_id'=>$_SESSION['onethink_admin']['user_auth']['uid'], + 'admin_account'=>$_SESSION['onethink_admin']['user_auth']['username'], + 'op_type'=>$options['op_type'], + 'op_name'=>$options['op_name'], + 'url'=>$options['url'], + 'key'=>$options['key'], + 'create_time'=>time() + ]; + //获取菜单名词 + $act = CONTROLLER_NAME.'/'.ACTION_NAME; + $arr = []; + $menuname = D("menu")->field('title,pid,group')->where("url = '{$act}'")->find(); + if($menuname){ + $arr[] = $menuname['title']; + if(!empty($menuname['group'])){ + $arr[] = $menuname['group']; + } + $this-> getLink($menuname['pid'],$arr); + } + $addarray['menu'] = implode ( "-",array_reverse($arr)); + M("OperationLog","tab_")->add($addarray); + } + public function getLink($pid=0,&$arr){ + if($pid == 0){ + return; + } + $menuname = D("menu")->field('title,pid,group')->where("id = '{$pid}'")->find(); + if($menuname){ + $arr[] = $menuname['title']; + if(!empty($menuname['group'])){ + $arr[] = $menuname['group']; + } + if($menuname['pid'] != 0){ + $this->getLink($menuname['pid'], $arr); + + } + } + + } } diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index e297cb8f3..8adfd8715 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -9,10 +9,10 @@ use Org\WeixinSDK\Weixin; class MemberController extends ThinkController { + /** *玩家列表信息 */ - public function user_info($p=0){ //设定默认时间 // if(!array_key_exists("time_start",$_REQUEST) && I('type') != 2){ @@ -806,6 +806,14 @@ class MemberController extends ThinkController $res = $member->updateInfo($data); if ($res !== false) { \Think\Log::actionLog("Member/edit", "Member", $id); + //操作日志 + $this->addOperationLog(array( + "op_type"=>1, + "op_name"=>"编辑用户信息", + "key"=>$this->getUserAccount($id), + "url"=>U("Member/user_info",array("user_id"=>$id)) + )); + $this->success("修改成功", U('user_info')); } else { $this->error("修改失败"); @@ -1686,4 +1694,10 @@ class MemberController extends ThinkController return $this->success("解除成功"); } } + //获取用户账号 + public function getUserAccount($id) + { + return M("User","tab_")->field("account")->where("id='{$id}'")->find()['account']; + # code... + } } \ No newline at end of file diff --git a/Application/Admin/Controller/OperationLogController.class.php b/Application/Admin/Controller/OperationLogController.class.php new file mode 100644 index 000000000..2ff5f99c8 --- /dev/null +++ b/Application/Admin/Controller/OperationLogController.class.php @@ -0,0 +1,25 @@ +addOperationLog(array( + "op_type"=>1, + "op_name"=>"添加用户", + "key"=>"test185", + "url"=>U("Member/user_info",array("user_id"=>252315)) + )); + } + + + +} diff --git a/Data/update.sql b/Data/update.sql index 4ecdaa17f..dc798d286 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1357,3 +1357,18 @@ ADD COLUMN `verify_status` tinyint(2) NULL DEFAULT 0 COMMENT '审核状态 0:未 -- 支付类型添加易宝支付 INSERT INTO `platform`.`tab_tool`( `name`, `title`, `config`, `template`, `type`, `status`, `create_time`) VALUES ('yeepay', '易宝支付', '', '', 1, 1, 0); + +-- 2020-02-25 chenzhi 后台操作日志 +CREATE TABLE `tab_operation_log` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `op_type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '操作类型 1 编辑 2 删除 3下载', + `op_name` varchar(100) COLLATE utf8mb4_bin NOT NULL DEFAULT '0' COMMENT '操作名词', + `url` varchar(1000) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '跳转URL', + `menu` varchar(300) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '菜单目录', + `key` varchar(300) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '关键字唯一表示', + `admin_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作员id', + `admin_account` varchar(30) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '管理员账号', + `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `op_ip` varchar(16) DEFAULT '0' COMMENT '登陆ip', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; \ No newline at end of file