temp commit

This commit is contained in:
alan snape 2016-12-29 08:59:26 +00:00
parent 572dcffcfa
commit ea0870a9ea
4 changed files with 72 additions and 6 deletions

View File

@ -57,8 +57,30 @@ class MissionsController < ApplicationController
def update
#Todo
id = params[:id]
body = request.body.read
mission = Mission.find(id)
mission.name = body[:name]
mission.content = body[:content]
mission.priority = body[:priority]
mission.status = body[:status]
mission.deadline = body[:deadline]
mission.save!
pid = mission.project_id
Mission_user.destory_all(:mission_id => id)
body[:users].each do |i|
uid = User.where(:email => i).id
mu = Mission_user.new
mu.mission_id = id
mu.user_id = uid
mu.save!
note = Note.new
note.project_id = pid
note.user_id = uid
note.type = 3
note.content = "任务信息发生了变化"
note.save!
end
render :json => {:code => 0}
end

View File

@ -6,7 +6,31 @@ class NotesController < ApplicationController
def getNotesList
#Todo
pid = params[:project_id]
uid = session[:user_id]
note = {}
Note.where(:user_id => uid).where(:project_id => pid).each do |i|
date = i.created_at.to_date.to_s
if not note[date] then
note[date] = []
end
note[:date] += [{
:content => i.content,
:time => i.created_at.to_time,
:type => i.type
}]
end
data = []
note.each do |date, list|
data += [{
:time => date,
:notes => list
}]
end
render :json => {
:code => 0,
:data => data
}
end
end

View File

@ -46,10 +46,19 @@ class ProjectsController < ApplicationController
def addUsers
#Todo
body = request.body.read
uid = body[:user_id].to_i
pid = body[:project_id].to_i
pu = Project_user.new()
pu.project_id = body[:project_id]
#pu.user_id = body[:user_id]
pu.project_id = pid
pu.user_id = uid
pu.save!
note = Note.new
note.user_id = uid
note.project_id = pid
note.type = 2
note.content = User.find(uid).name + "邀请您进入项目" +
Project.find(pid).name
note.save!
render :json => {:code => 0}
end

View File

@ -7,11 +7,22 @@ class SharesController < ApplicationController
def create
#Todo
body = request.body.read
uid = session[:user_id].to_i
pid = body[:project_id].to_i
put = Share.new()
put.content = body[:content]
put.project_id = body[:project_id]
put.user_id = session[:user_id]
put.project_id = pid
put.user_id = uid
put.save!
content = User.find(uid).name + "分享了一些事"
Project_user.where(:project_id => pid).each do |tuid|
note = Note.new
note.user_id = tuid
note.project_id = pid
note.type = 1
note.content = content
note.save!
end
render :json => {:code => 0}
end