class Api::V1::Projects::TagsController < Api::V1::BaseController 
  before_action :require_public_and_member_above, only: [:index, :show] 

  def index 
    @release_tags = @repository.version_releases.pluck(:tag_name)
    @result_object = Api::V1::Projects::Tags::ListService.call(@project, {page: page, limit: limit}, current_user&.gitea_token)
  end

  def show 
    @result_object = Api::V1::Projects::Tags::GetService.call(@project, params[:name], current_user&.gitea_token)
  end

  before_action :require_operate_above, only: [:destroy] 

  def destroy 
    @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, params[:name], current_user&.gitea_token)
    if @result_object 
      return render_ok 
    else
      return render_error('删除标签失败!') 
    end
  end
end