ADD scholls count api

This commit is contained in:
Jasder 2019-10-23 11:15:17 +08:00
parent 5015f98e53
commit 2444af2f5f
5 changed files with 11 additions and 3 deletions

View File

@ -21,7 +21,7 @@ curl -X PUT http://localhost:3001/api/v1/homes/sync_count \
token(requires): String权限验证
type(requires): String同步的类型取值范围: {user(用户) | project(开源项目) | practical_training_project(实训项目)}
type(requires): String同步的类型取值范围: {user(用户) | project(开源项目) | practical_training_project(实训项目) | scholl(应用高校)}
number(optional): Integer同步数量, 该参数可选不传时后台默认值为1

View File

@ -18,7 +18,7 @@ module Mobile
params do
optional :number, type: Integer, default: 1, desc: "同步的数量"
requires :token, type: String, desc: "token is validate user identity"
requires :type, type: String, values: ['user', 'project', 'practical_training_project'], desc: "type requires."
requires :type, type: String, values: ['user', 'project', 'practical_training_project', 'school'], desc: "type requires."
end
put 'sync_count' do
authenticate_token!

View File

@ -6,6 +6,8 @@ class HomesService
home.update_attributes!(users_count: home.users_count + sync_count)
when "project"
home.update_attributes!(projects_count: home.projects_count + sync_count)
when 'scholl'
home.update_attributes!(scholls_count: home.scholls_count + sync_count)
when "practical_training_project"
home.update_attributes!(practical_training_projects_count: home.practical_training_projects_count + sync_count)
end

View File

@ -0,0 +1,5 @@
class AddSchollsCountToHomes < ActiveRecord::Migration
def change
add_column :homes, :scholls_count, :integer, :default => 0
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20191022031808) do
ActiveRecord::Schema.define(:version => 20191023031103) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1177,6 +1177,7 @@ ActiveRecord::Schema.define(:version => 20191022031808) do
t.integer "projects_count", :default => 0
t.integer "practical_training_projects_count", :default => 0
t.string "frendly_id"
t.integer "scholls_count", :default => 0
end
add_index "homes", ["frendly_id"], :name => "index_homes_on_frendly_id", :unique => true