From 550577e9423cc20242d922c09f4179369a8ced0c Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 23 Dec 2014 17:43:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=BE=91=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3=E7=9A=84=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/users_service.rb | 36 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 2996bc91d..c1ac062df 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -45,17 +45,8 @@ class UsersService @user = User.find(params[:id]) img_url = url_to_avatar(@user) gender = @user.user_extensions.gender.nil? ? 0 : @user.user_extensions.gender - work_unit = "" - if @user.user_extensions.identity == 0 || @user.user_extensions.identity == 1 - work_unit = @user.user_extensions.school.name unless @user.user_extensions.school.nil? - elsif @user.user_extensions.identity == 3 - work_unit = @user.user_extensions.occupation - elsif @user.user_extensions.identity == 2 - work_unit = @user.firstname - end - location = "" - location << (@user.user_extensions.location || '') - location << (@user.user_extensions.location_city || '') + work_unit = get_user_work_unit @user + location = get_user_location @user {:id => @user.id, :img_url => img_url, :nickname => @user.login, :gender => gender, :work_unit => work_unit, :mail => @user.mail, :location => location, :brief_introduction => @user.user_extensions.brief_introduction} end @@ -104,7 +95,28 @@ class UsersService logger.error "[Error] avatar : users_service#edit_user ===> #{e}" end end - @se + [:user_extensions =>@se,:img_url => url_to_avatar(@user),:work_unit => get_user_work_unit(@user),:location => get_user_location(user)] + end + + #获取用户的工作单位 + def get_user_work_unit user + work_unit = "" + if user.user_extensions.identity == 0 || user.user_extensions.identity == 1 + work_unit = user.user_extensions.school.name unless user.user_extensions.school.nil? + elsif user.user_extensions.identity == 3 + work_unit = user.user_extensions.occupation + elsif user.user_extensions.identity == 2 + work_unit = user.firstname + end + work_unit + end + + #获取用户地区 + def get_user_location user + location = "" + location << (user.user_extensions.location || '') + location << (user.user_extensions.location_city || '') + location end #关注列表