Merge branch 'api' of http://repository.trustie.net/xianbo/trustie2 into api
This commit is contained in:
commit
d97b26f131
|
@ -29,8 +29,9 @@ module Mobile
|
|||
mount Apis::Users
|
||||
mount Apis::Courses
|
||||
mount Apis::Watches
|
||||
mount Apis::Upgrade
|
||||
|
||||
add_swagger_documentation ({api_version: 'v1', base_path: '/api'})
|
||||
add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,20 +16,79 @@ module Mobile
|
|||
present :status, 0
|
||||
end
|
||||
|
||||
desc "新建课程[TODO,参数没弄清]"
|
||||
desc "新建课程[TODO,待测试]"
|
||||
#current_user当前用户对象(不是id)
|
||||
# params[:course][:name]:课程名称
|
||||
#params[:course][:password]:密码
|
||||
#params[:course][:description]:描述
|
||||
#params[:course][:is_public]:是否公开1公开,0私有
|
||||
#params[:course][:open_student]:是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表
|
||||
#params[:course][:course_type]:暂时默认给1值。
|
||||
#params[:term]:学期(秋季学期或春季学期)
|
||||
#params[:time]: 年份(例:2014)
|
||||
#params[:setup_time]:暂不传(貌似已经没用了)
|
||||
#params[:endup_time]: 暂不传(貌似已经没用了)
|
||||
#params[:class_period]:学时总数
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :name, type: String, desc: '课程名称'
|
||||
requires :password, type: String, desc: '密码'
|
||||
requires :description, type: String, desc: '描述'
|
||||
requires :is_public, type: Integer, desc: '是否公开 1公开 0私有'
|
||||
requires :open_student, type: Integer, desc: '是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表'
|
||||
requires :course_type, type:Integer, desc: '暂时传1'
|
||||
requires :term, type: String, desc: '学期(秋秀学期或春秀学期)'
|
||||
requires :time, type: String, desc: '年份'
|
||||
requires :class_period, type: String, desc: '学时总数'
|
||||
end
|
||||
post do
|
||||
authenticate!
|
||||
cs = CoursesService.new
|
||||
cs_params = {
|
||||
course: params.reject{|k,v| [:term,:time,:class_period].include?(k)},
|
||||
term: params[:term],
|
||||
time: params[:time],
|
||||
class_period: params[:class_period]
|
||||
}
|
||||
courses = cs.create_course(cs_params, current_user)
|
||||
present :data, courses, with: Mobile::Entities::Course
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc "编辑课程[TODO,参数没弄清]"
|
||||
desc "编辑课程[TODO,待测试]"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :course_id, type: Integer, desc: '课程id'
|
||||
requires :name, type: String, desc: '课程名称'
|
||||
requires :password, type: String, desc: '密码'
|
||||
requires :description, type: String, desc: '描述'
|
||||
requires :is_public, type: Integer, desc: '是否公开 1公开 0私有'
|
||||
requires :open_student, type: Integer, desc: '是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表'
|
||||
requires :course_type, type:Integer, desc: '暂时传1'
|
||||
requires :term, type: String, desc: '学期(秋秀学期或春秀学期)'
|
||||
requires :time, type: String, desc: '年份'
|
||||
requires :class_period, type: String, desc: '学时总数'
|
||||
end
|
||||
post do
|
||||
authenticate!
|
||||
cs_params = {
|
||||
course: params.reject{|k,v| [:term,:time,:class_period].include?(k)},
|
||||
term: params[:term],
|
||||
time: params[:time],
|
||||
class_period: params[:class_period]
|
||||
}
|
||||
course = ::Course.find(params[:course_id])
|
||||
cs.edit_course_authorize(current_user,course)
|
||||
course = cs.edit_course(cs_params, course)
|
||||
present :data, course, with: Mobile::Entities::Course
|
||||
present :status, 0
|
||||
end
|
||||
post do
|
||||
end
|
||||
|
||||
desc "加入课程"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
post ":id" do
|
||||
authenticate!
|
||||
|
@ -50,6 +109,7 @@ module Mobile
|
|||
|
||||
desc "退出课程"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
delete ":id" do
|
||||
authenticate!
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Upgrade < Grape::API
|
||||
resource :upgrade do
|
||||
desc "get update info"
|
||||
params do
|
||||
requires :platform, type: String, desc: '平台名,android, ios'
|
||||
end
|
||||
get do
|
||||
{
|
||||
version: '2',
|
||||
url: 'http://u06.shellinfo.cn/trustie/Trustie_Beta1.0.0_201412310917.apk',
|
||||
desc: '更新了什么功能'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -95,7 +95,7 @@ class UsersService
|
|||
logger.error "[Error] avatar : users_service#edit_user ===> #{e}"
|
||||
end
|
||||
end
|
||||
[:user_extensions =>@se,:img_url => url_to_avatar(@user),:work_unit => get_user_work_unit(@user),:location => get_user_location(user)]
|
||||
[:user_extensions =>@se,:img_url => url_to_avatar(@user),:work_unit => get_user_work_unit(@user),:location => get_user_location(@user)]
|
||||
end
|
||||
|
||||
#获取用户的工作单位
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue