|
|
|
@ -16,7 +16,7 @@ class UsersService
|
|
|
|
|
password_confirmation = params[:password_confirmation]
|
|
|
|
|
should_confirmation_password = params[:should_confirmation_password]
|
|
|
|
|
if !password.blank? && !password_confirmation.blank? && should_confirmation_password
|
|
|
|
|
@user.password,@user.password_confirmation = password,password_confirmation
|
|
|
|
|
@user.password, @user.password_confirmation = password, password_confirmation
|
|
|
|
|
elsif !password.blank? && !should_confirmation_password
|
|
|
|
|
@user.password = password
|
|
|
|
|
else
|
|
|
|
@ -42,7 +42,7 @@ class UsersService
|
|
|
|
|
#id用户id
|
|
|
|
|
def show_user(params)
|
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
|
img_url = url_to_avatar(@user)
|
|
|
|
|
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
|
|
|
|
@ -55,7 +55,7 @@ class UsersService
|
|
|
|
|
location = ""
|
|
|
|
|
location << (@user.user_extensions.location || '')
|
|
|
|
|
location << (@user.user_extensions.location_city || '')
|
|
|
|
|
{: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}
|
|
|
|
|
{: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
|
|
|
|
|
|
|
|
|
|
#编辑用户
|
|
|
|
@ -75,37 +75,34 @@ class UsersService
|
|
|
|
|
@se.gender = params[:gender]
|
|
|
|
|
@se.location = params[:province] if params[:province]
|
|
|
|
|
@se.location_city = params[:city] if params[:city]
|
|
|
|
|
if @se.save
|
|
|
|
|
unless fileio.nil?
|
|
|
|
|
file = fileio[:tempfile]
|
|
|
|
|
diskfile=disk_filename(@user.class.to_s,@user.id)
|
|
|
|
|
@image_file = fileio[:name]
|
|
|
|
|
@urlfile='/' << File.join("images","avatars",avatar_directory(@user.class.to_s),avatar_filename(@user.id,@image_file))
|
|
|
|
|
raise @se.errors.full_message unless @se.save
|
|
|
|
|
unless fileio.nil?
|
|
|
|
|
file = fileio[:tempfile]
|
|
|
|
|
diskfile=disk_filename(@user.class.to_s, @user.id)
|
|
|
|
|
@image_file = fileio[:name]
|
|
|
|
|
@urlfile='/' << File.join("images", "avatars", avatar_directory(@user.class.to_s), avatar_filename(@user.id, @image_file))
|
|
|
|
|
|
|
|
|
|
path = File.dirname(diskfile)
|
|
|
|
|
unless File.directory?(path)
|
|
|
|
|
FileUtils.mkdir_p(path)
|
|
|
|
|
path = File.dirname(diskfile)
|
|
|
|
|
unless File.directory?(path)
|
|
|
|
|
FileUtils.mkdir_p(path)
|
|
|
|
|
end
|
|
|
|
|
File.rename(file.path, @urlfile)
|
|
|
|
|
begin
|
|
|
|
|
f = Magick::ImageList.new(diskfile)
|
|
|
|
|
# gif格式不再做大小处理
|
|
|
|
|
if f.format != 'GIF'
|
|
|
|
|
width = 300.0
|
|
|
|
|
proportion = (width/f[0].columns)
|
|
|
|
|
height = (f[0].rows*proportion)
|
|
|
|
|
f.resize_to_fill!(width, height)
|
|
|
|
|
f.write(diskfile)
|
|
|
|
|
end
|
|
|
|
|
File.rename(file.path, @urlfile)
|
|
|
|
|
begin
|
|
|
|
|
f = Magick::ImageList.new(diskfile)
|
|
|
|
|
# gif格式不再做大小处理
|
|
|
|
|
if f.format != 'GIF'
|
|
|
|
|
width = 300.0
|
|
|
|
|
proportion = (width/f[0].columns)
|
|
|
|
|
height = (f[0].rows*proportion)
|
|
|
|
|
f.resize_to_fill!(width,height)
|
|
|
|
|
f.write(diskfile)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error "[Error] avatar : users_service#edit_user ===> #{e}"
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error "[Error] avatar : users_service#edit_user ===> #{e}"
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
else
|
|
|
|
|
@se
|
|
|
|
|
end
|
|
|
|
|
@se
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#关注列表
|
|
|
|
|