temp commit for mission controller

This commit is contained in:
alan snape 2016-12-28 07:06:19 +00:00
parent 6dc13784af
commit 9ef1bca10b
1 changed files with 48 additions and 3 deletions

View File

@ -6,28 +6,73 @@ class MissionsController < ApplicationController
def getlist
#Todo
pid = params[:project_id]
stu = params[:status_type]
missions = []
Mission.where(:project_id => pid).where(:status => stu) do |i|
missions += [{
:id => i.id,
:name => i.name,
:content => i.content
}]
end
render :json => {
:code => 0,
:data => missions
}
end
#获取任务详细信息
def detail
#Todo
id = params[:id]
mission = Mission.find(id)
userid = Mission_user.find_by_name("mission_id")
username = User.find(userid).pluck("name")
comments = []
Comments.where("mission_id" => id).each do |i|
name = User.find(i.user_id).name
comments += [{
:nickname => name,
:content => i.content,
:time => i.created_at
}]
end
render :json => {
:code => 0,
:data => {
:name => mission.name,
:content => mission.content,
:priority => mission.priority,
:status => mission.status,
:deadline => mission.deadline,
:users => username,
:comments => comments
}
}
end
#修改任务信息
def update
#Todo
body = request.body.read
render :json => {:code => 0}
end
#当前用户发表评论
def commentPublish
#Todo
body = request.body.read
put = Comments.new()
put.content = body[:content]
put.mission_id = body[:mission_id]
put.user_id = session[:user_id]
put.save!
render :json => {:code => 0}
end