schema = [ 'id' => 'number', 'account' => 'string', 'nickname' => 'string', 'password' => 'string', 'token' => 'string', 'delete_time' => 'number', 'create_time' => 'number', 'update_time' => 'number' ]; } public function access() { return self::hasOne(AuthGroupAccessModel::class,'admin_id','id'); } public function loadByLogin($username, $password) { return $this->where([ ['account|id', '=', $username], ['password', '=', $password], ['is_delete', '=',0] ])->find(); } public function refreshToken($adminId,$token) { return $this->where([ ['id', '=',$adminId], ['is_delete', '=',0] ])->update(['token' => $token]); } /** * @param array $params * @return \think\Paginator * @throws \think\db\exception\DbException */ public function findByPaginate(array $params) { $where = [ ['is_delete', '=', 0] ]; if(isset($params['group_id'])) array_push($where,['group_id', 'like', "%".$params['group_id']."%"]); return $this->where('erp_admin.is_delete', 0) ->with(['access','access.group']) ->hasWhere('access', $where) ->order('create_time','desc') ->paginate(['list_rows'=>10, "query" => $params]); } public function doesItExist($account) { $customer = $this->where([ ["account", '=',$account], ["is_delete", '=', 0], ])->find(); return $customer; } public function findById($id) { return $this->where('id',$id)->with(['access','access.group'])->find(); } }