From c946352470c238d26c275aa4b66ad1b76ce396df Mon Sep 17 00:00:00 2001 From: alan snape Date: Wed, 28 Dec 2016 07:26:25 +0000 Subject: [PATCH] temp commit share controller --- app/controllers/shares_controller.rb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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