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