mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-12 20:24:43 +08:00
24 lines
548 B
Ruby
24 lines
548 B
Ruby
|
module Api
|
||
|
module V1
|
||
|
class TeamsController < BaseController
|
||
|
before_action :load_team, only: :show
|
||
|
|
||
|
def index
|
||
|
teams = current_user.teams.page(params[:page]).per(params[:page_size])
|
||
|
render json: teams, each_serializer: TeamSerializer
|
||
|
end
|
||
|
|
||
|
def show
|
||
|
render json: @team, serializer: TeamSerializer
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def load_team
|
||
|
@team = Team.find(params.require(:id))
|
||
|
return render json: {}, status: :forbidden unless can_read_team?(@team)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|