Merge branch 'szzh' into develop
This commit is contained in:
commit
26cb6225c5
|
@ -98,6 +98,7 @@ module Mobile
|
||||||
params do
|
params do
|
||||||
requires :token, type: String
|
requires :token, type: String
|
||||||
requires :user_id, type: Integer,desc: '被留言的用户id'
|
requires :user_id, type: Integer,desc: '被留言的用户id'
|
||||||
|
requires :page,type:Integer,desc:'请求数据的页码'
|
||||||
end
|
end
|
||||||
get ':user_id/messages' do
|
get ':user_id/messages' do
|
||||||
us = UsersService.new
|
us = UsersService.new
|
||||||
|
|
|
@ -29,51 +29,43 @@ class AvatarController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if @temp_file && (@temp_file.size > 0)
|
if @temp_file && (@temp_file.size > 0)
|
||||||
if @temp_file.size > Setting.upload_avatar_max_size.to_i
|
diskfile=disk_filename(@source_type,@source_id)
|
||||||
@status = 1
|
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
|
||||||
@msg = l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i))
|
|
||||||
elsif Trustie::Utils::Image.new(@temp_file.tempfile.path).image?
|
|
||||||
diskfile=disk_filename(@source_type,@source_id)
|
|
||||||
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
|
|
||||||
|
|
||||||
# 用户头像上传时进行特别处理
|
# 用户头像上传时进行特别处理
|
||||||
if @source_type == 'User'
|
if @source_type == 'User'
|
||||||
diskfile += "temp"
|
diskfile += "temp"
|
||||||
@urlfile += "temp"
|
@urlfile += "temp"
|
||||||
end
|
|
||||||
|
|
||||||
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
|
|
||||||
path = File.dirname(diskfile)
|
|
||||||
unless File.directory?(path)
|
|
||||||
FileUtils.mkdir_p(path)
|
|
||||||
end
|
|
||||||
md5 = Digest::MD5.new
|
|
||||||
File.open(diskfile, "wb") do |f|
|
|
||||||
if @temp_file.respond_to?(:read)
|
|
||||||
buffer = ""
|
|
||||||
while (buffer = @temp_file.read(8192))
|
|
||||||
f.write(buffer)
|
|
||||||
md5.update(buffer)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
f.write(@temp_file)
|
|
||||||
md5.update(@temp_file)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Trustie::Utils::Image.new(diskfile,true).compress(300)
|
|
||||||
@status = 0
|
|
||||||
@msg = ''
|
|
||||||
else
|
|
||||||
@status = 2
|
|
||||||
@msg = l(:not_valid_image_file)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
|
||||||
|
path = File.dirname(diskfile)
|
||||||
|
unless File.directory?(path)
|
||||||
|
FileUtils.mkdir_p(path)
|
||||||
|
end
|
||||||
|
md5 = Digest::MD5.new
|
||||||
|
File.open(diskfile, "wb") do |f|
|
||||||
|
if @temp_file.respond_to?(:read)
|
||||||
|
buffer = ""
|
||||||
|
while (buffer = @temp_file.read(8192))
|
||||||
|
f.write(buffer)
|
||||||
|
md5.update(buffer)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
f.write(@temp_file)
|
||||||
|
md5.update(@temp_file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# self.digest = md5.hexdigest
|
||||||
end
|
end
|
||||||
@temp_file = nil
|
@temp_file = nil
|
||||||
|
|
||||||
|
image = Trustie::Utils::Image.new(diskfile,true)
|
||||||
|
image.compress(300)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json{
|
format.json{
|
||||||
render :inline => {status: @status, message:@msg, url:"#{@urlfile.to_s}?#{Time.now.to_i}"}.to_json,:content_type => 'text/html'
|
render :inline => "#{@urlfile.to_s}?#{Time.now.to_i}",:content_type => 'text/html'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
format.js
|
format.js
|
||||||
|
|
|
@ -158,7 +158,7 @@ class UsersService
|
||||||
# 获取某个用户的所有留言信息
|
# 获取某个用户的所有留言信息
|
||||||
def get_all_messages params
|
def get_all_messages params
|
||||||
user = User.find(params[:user_id])
|
user = User.find(params[:user_id])
|
||||||
jours = user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
jours = user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC').page(params[:page] || 1).per(10)
|
||||||
jours.update_all(:is_readed => true, :status => false)
|
jours.update_all(:is_readed => true, :status => false)
|
||||||
jours.each do |journal|
|
jours.each do |journal|
|
||||||
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$("input[nhname='nhname']").change(function(){
|
$("input[nhname='date_show']").change(function(){
|
||||||
if($(this).val()=='创建日期起始' || $(this).val()=='创建日期结束')return;
|
if($(this).val()=='创建日期起始' || $(this).val()=='创建日期结束')return;
|
||||||
$("input[nhname='nhname']",$(this).parent('div')).val($(this).val());
|
$("input[nhname='date_val']",$(this).parent('div')).val($(this).val());
|
||||||
remote_function();
|
remote_function();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
}
|
}
|
||||||
function nh_reset_form() {
|
function nh_reset_form() {
|
||||||
$("#issue_query_form")[0].reset();
|
$("#issue_query_form")[0].reset();
|
||||||
|
$("input[nhname='date_val']").val('');//涛哥的火狐reset 清不掉这个值 我擦
|
||||||
remote_function();
|
remote_function();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue