diff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rb index 1244020..644719e 100644 --- a/app/controllers/shares_controller.rb +++ b/app/controllers/shares_controller.rb @@ -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 \ No newline at end of file