model = new SysUserLog(); } /** * 获取用户日志 * @param array $where * @return array */ public function getPage(array $where) { $field = 'id, ip, site_id, uid, username, url, params, type, create_time'; $order = 'create_time desc'; $search_model = $this->model->where([['site_id', '=', $this->site_id]])->withSearch(['username', 'create_time', 'uid', 'ip', 'type', 'url'], $where)->field($field)->order($order); return $this->pageQuery($search_model); } /** * 日志详情 * @param int $id * @return array */ public function getInfo(int $id){ $where = array( ['id', '=', $id], ['site_id', '=', $this->site_id] ); $field = 'id, ip, site_id, uid, username, url, params, type, create_time'; return $this->model->where($where)->field($field)->findOrEmpty()->toArray(); } /** * 添加用户(添加用户,不添加站点) * @param array $data * @return bool * @throws Exception */ public function add(array $data){ $data['site_id'] = $this->site_id; $res = $this->model->create($data); return $res->id; } }