回复留言
This commit is contained in:
parent
d6fe4082af
commit
8e04b4e565
|
@ -111,11 +111,13 @@ module Mobile
|
|||
requires :token, type: String
|
||||
requires :user_id, type: Integer,desc: '被留言的用户id'
|
||||
requires :content,type:String,desc:'留言内容'
|
||||
optional :refer_user_id,type:Integer,desc:'被回复的用户id'
|
||||
requires :ref_user_id,type:Integer,desc:'被回复的用户id'
|
||||
requires :parent_id,type:Integer,desc:'留言父id'
|
||||
requires :ref_message_id,type:Integer,desc:'引用消息id'
|
||||
end
|
||||
post ':user_id/leave_message' do
|
||||
us = UsersService.new
|
||||
jours = us.leave_messages params,current_user
|
||||
jours = us.reply_user_messages params,current_user
|
||||
present :status,0
|
||||
end
|
||||
|
||||
|
|
|
@ -166,13 +166,22 @@ class UsersService
|
|||
jours
|
||||
end
|
||||
|
||||
# 给某个用户留言
|
||||
def leave_messages params,current_user
|
||||
# 回复用户
|
||||
def reply_user_messages params,current_user
|
||||
user = User.find(params[:user_id])
|
||||
user.add_jour(current_user, params[:content], params[:refer_user_id] ||= 0)
|
||||
unless params[:refer_user_id].nil? || params[:refer_user_id] == 0 || params[:refer_user_id] == User.current.id
|
||||
User.find(params[:refer_user_id]).add_jour(current_user, params[:content], params[:refer_user_id])
|
||||
end
|
||||
parent_id = params[:parent_id]
|
||||
author_id = current_user.id
|
||||
reply_user_id = params[:ref_user_id]
|
||||
reply_id = params[:ref_message_id]
|
||||
content = params[:content]
|
||||
options = {:user_id => author_id,
|
||||
:status => true,
|
||||
:m_parent_id => parent_id,
|
||||
:m_reply_id => reply_id,
|
||||
:reply_id => reply_user_id,
|
||||
:notes => content,
|
||||
:is_readed => false}
|
||||
user.add_jour(nil, nil,nil,options)
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue