temp commit share controller

This commit is contained in:
alan snape 2016-12-28 07:26:25 +00:00
parent 7d3b4fae28
commit c946352470
1 changed files with 21 additions and 2 deletions

View File

@ -6,14 +6,33 @@ class SharesController < ApplicationController
def create
#Todo
body = request.body.read
put = Share.new()
put.content = body[:content]
put.project_id = body[:project_id]
put.user_id = session[:user_id]
put.save!
render :json => {:code => 0}
end
#获取项目的分享列表
def getShareList
#Todo
pid = params[:project_id]
data = []
Share.where(:project_id => pid) do |i|
name = User.find(i.user_id).name
data += [{
:nickname => name,
:time => i.created_at,
:content => i.content
}]
end
render :json => {
:code => 0,
:data => data
}
end
end