diff --git a/app/controllers/missions_controller.rb b/app/controllers/missions_controller.rb
index 50a5978..9288316 100644
--- a/app/controllers/missions_controller.rb
+++ b/app/controllers/missions_controller.rb
@@ -2,32 +2,47 @@ class MissionsController < ApplicationController
before_action :authenticate
- #获取当前项目某状态的任务列表
+ #======================================>获取当前项目某状态的任务列表
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
+ #missions = []
+ details = []
+ missions = Mission.where("project_id = ? AND status = ?",pid,stu).all
+
+ missions.each do |mission|
+
+ puts mission.inspect
+
+ details += [{
+ :id => mission.id,
+ :name => mission.name,
+ :content => mission.content
}]
+
end
+
+ # 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)
+ mission_id = params[:id]
+ mission = Mission.find_by(id: mission_id)
userid = Mission_user.find_by_name("mission_id")
username = User.find(userid).pluck("name")
comments = []
@@ -53,7 +68,7 @@ class MissionsController < ApplicationController
}
end
- #修改任务信息
+ #======================================>修改任务信息
def update
#Todo
@@ -87,18 +102,23 @@ class MissionsController < ApplicationController
render :json => {:code => 0}
end
- #当前用户发表评论
+ #======================================>当前用户发表评论
def commentPublish
#Todo
- put = Comments.new()
- put.content = params[:content]
- put.mission_id = params[:mission_id]
- put.user_id = session[:user_id]
- now = Datetime.now
- put.created_at = now
- put.updated_at = now
- put.save!
+ content = params[:content]
+ mission_id = params[:mission_id]
+ user_id = session[:user_id]
+ puts user_id
+ params_comment = {content: content,mission_id: mission_id,user_id: user_id}
+ puts params_comment
+ comment = Comments.new(params_comment)
+
+ # now = Datetime.now
+ # put.created_at = now
+ # put.updated_at = now
+ comment.save!
+
render :json => {:code => 0}
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 2545edf..0625414 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -10,7 +10,7 @@ users = [
{:name => '陈翊', :password => '123456', :email => '1085730215@qq.com', :phone => '18269771988', :created_at => "2016/12/28", :updated_at => "2016/12/27"}
]
projects = [
- {:name => 'AAAA',:content => 'i like helloworld',:mission_count => '20',:users_count => '15',:shares_count => '15'}
+ {:id=>'1001',:name => 'AAAA',:content => 'i like helloworld',:mission_count => '20',:users_count => '15',:shares_count => '15'}
]
users.each do |user|
diff --git a/public/index.html b/public/index.html
index 7ca1a24..2f3aeaa 100644
--- a/public/index.html
+++ b/public/index.html
@@ -30,15 +30,19 @@
-
+