1class NotesController < ApplicationController
 
2    
 
3    before_action :authenticate
 
4    
 
5    #
 
6    
 
7    def getNotesList
 
8    #Todo
 
 9    pid = params[:project_id]
 
10    uid = session[:user_id]
 
11    notes = Note.where("user_id = ? AND project_id = ? ",uid,pid).order("created_at desc").all
 
12    note = Hash.new do |h,k|
 
13            h[k] = []
 
14    end
 
15    notes.each do |n|
 
16        date =  n.created_at.to_s[/([\d\-]*)\s(.*)/,1]
 
17        time =  n.created_at.to_s[/(.*)\s([\d\:]*)/,2]
 
18        note[date] << {
 
19            :content => n.content,
 
20            :time => time,
 
21            :type => n.category
 
22        }
 
23    end
 
24    data = []
 
25    note.each do |k,v|
 
26        data += [{
 
27            :time => k,
 
28            :notes => v
 
29        }]
 
30    end
 
31    render :json => {
 
32        :code => 0,
 
33        :data => data
 
34    }
 
35    end
 
 
37end