<?php
// +----------------------------------------------------------------------
// | 管理员登录日志查询
// +----------------------------------------------------------------------
// | Copyright (c) 2018 https://blog.junphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小黄牛 <1731223728@qq.com>
// +----------------------------------------------------------------------

namespace app\controller\admin\auth;
use app\controller\SuperClass\Admin;

class Admin_login_log extends Admin
{

    /**
     * @AopBefore(class="app\aop\AdminLogin", function="before")
     * @RequestMapping(route="/admin/auth/admin_login_log", method="GET|POST", title="管理员登录日志查询")
     * @Ioc(class="\x\Db", name="Db")
    */
    public function run() {
        if (\x\Request::is_ajax()) {
            return $this->showlist();
        }
        $param = \x\Request::get();
        $this->assign('admin_name', $this->Db->name('auth_admin')->where('id', $param['id'])->value('nick'));
        $this->assign('id', $param['id']);
        
        $this->Db->return();
        return $this->display();
    }

    // 菜单列表
    private function showlist() {
        $param = \x\Request::get();
        $list = $this->Db->name('auth_admin_login')->where('admin', $param['id'])->order('id DESC')->page($param['page'], $param['limit'])->select();
        $count = $this->Db->name('auth_admin_login')->where('admin', $param['id'])->count();

        foreach ($list as $k=>$v) {
            $list[$k]['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
        }
        $this->Db->return();
        return $this->_list('0', '', $count, $list);
    }
}