modify users controller code

dev_course
p31729568 6 years ago
parent eb7655d051
commit 32e2872bbd

@ -9,10 +9,6 @@ class UsersController < ApplicationController
@user = User.find params[:id] @user = User.find params[:id]
@user.update!(user_params) @user.update!(user_params)
render_ok render_ok
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end end
# 贴吧获取用户信接口 # 贴吧获取用户信接口
@ -69,21 +65,24 @@ class UsersController < ApplicationController
# 用户回复功能 # 用户回复功能
def reply_message def reply_message
@message = JournalsForMessage.new(reply_message_params) message = JournalsForMessage.new(reply_message_params)
@message.user_id = current_user.id message.user_id = current_user.id
@message.save! message.save!
#normal_status("回复成功")
render_ok(id: message.id)
end end
# 搜索用户具有管理员角色的项目 # 搜索用户具有管理员角色的项目
def search_user_projects def search_user_projects
condition = '%%' projects = Project.where.not(status: 9)
condition = "%#{params[:search].strip}%".gsub(" ","") if !params[:search].blank?
projects = projects.joins(members: :member_roles).where(member_roles: { role_id: 3 })
projects = projects.where(members: { user_id: current_user.id })
search = params[:search].to_s.strip
projects = projects.where('projects.name LIKE ?', "%#{search}%") if search.present?
project_ids = Project.find_by_sql("SELECT p.id FROM projects p, members m, member_roles mr WHERE m.project_id = p.id @projects = projects.select(:id, :name)
AND m.id=mr.member_id AND mr.role_id = 3 AND m.user_id=#{current_user.id} AND p.status != 9 and
p.name like '#{condition}'")
@projects = Project.where(id: project_ids.pluck(:id))
end end
# 个人主页信息 # 个人主页信息

Loading…
Cancel
Save