37 lines
852 B
Ruby
37 lines
852 B
Ruby
class NotesController < ApplicationController
|
|
|
|
before_action :authenticate
|
|
|
|
#获取用户当前的通知列表
|
|
|
|
def getNotesList
|
|
#Todo
|
|
pid = params[:project_id]
|
|
uid = session[:user_id]
|
|
notes = Note.where("user_id = ? AND project_id = ? ",uid,pid).order("created_at desc").all
|
|
note = Hash.new do |h,k|
|
|
h[k] = []
|
|
end
|
|
notes.each do |n|
|
|
date = n.created_at.to_s[/([\d\-]*)\s(.*)/,1]
|
|
time = n.created_at.to_s[/(.*)\s([\d\:]*)/,2]
|
|
note[date] << {
|
|
:content => n.content,
|
|
:time => time,
|
|
:type => n.category
|
|
}
|
|
end
|
|
data = []
|
|
note.each do |k,v|
|
|
data += [{
|
|
:time => k,
|
|
:notes => v
|
|
}]
|
|
end
|
|
render :json => {
|
|
:code => 0,
|
|
:data => data
|
|
}
|
|
end
|
|
|
|
end |