socialforge/app/api/mobile/apis/upgrade.rb

30 lines
812 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#coding=utf-8
module Mobile
module Apis
class Upgrade < Grape::API
include ApplicationHelper
resource :upgrade do
desc "get update info"
params do
requires :platform, type: String, desc: '平台名android, ios'
end
get do
@current_version = ::PhoneAppVersion.reorder('created_at desc').first
attachment = @current_version.attachments.first
if attachment.nil?
raise '未发现客户端!'
end
url = "http://" + Setting.host_name + "/attachments/download/" + attachment.id.to_s + "/" + attachment.filename
{
version: @current_version.version,
url: url,
desc: @current_version.description
}
end
end
end
end
end