From 1523b992e0636d07090a856f3f05d53d3390558a Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 5 Jun 2019 13:57:04 +0800 Subject: [PATCH 01/23] modify school management view --- app/views/managements/schools/_data_contrast_list.html.erb | 4 ++-- app/views/managements/schools/_data_grow_list.html.erb | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/views/managements/schools/_data_contrast_list.html.erb b/app/views/managements/schools/_data_contrast_list.html.erb index 88eb4c6b..c25a8bc4 100644 --- a/app/views/managements/schools/_data_contrast_list.html.erb +++ b/app/views/managements/schools/_data_contrast_list.html.erb @@ -21,8 +21,8 @@ 序号 ID 单位名称 - 时段一
<%= "(#{params[:begin_date]} 05:00至#{params[:end_date]} 05:00)" %> - 时段二
<%= "(#{params[:other_begin_date]} 05:00至#{params[:other_end_date]} 05:00)" %> + 时段一
<%= "(#{params[:begin_date]} 05:00至#{(Time.zone.parse(params[:end_date]) + 1.days).strftime('%Y-%m-%d')} 05:00)" %> + 时段二
<%= "(#{params[:other_begin_date]} 05:00至#{(Time.zone.parse(params[:other_end_date]) + 1.days).strftime('%Y-%m-%d')} 05:00)" %> <%= sort_tag('变化情况', name: 'percentage', path: school_data_contrast_managements_path) %>
( 新 增 数 | 新增百分比) diff --git a/app/views/managements/schools/_data_grow_list.html.erb b/app/views/managements/schools/_data_grow_list.html.erb index 81976044..af1fc200 100644 --- a/app/views/managements/schools/_data_grow_list.html.erb +++ b/app/views/managements/schools/_data_grow_list.html.erb @@ -1,12 +1,7 @@
统计总计: <% if params[:grow_begin_date].present? %> - <% if params[:grow_begin_date] == params[:grow_end_date] %> - <%= Time.zone.parse(params[:grow_begin_date]).beginning_of_day.strftime('%Y-%m-%d') %> 05:00至 - <%= (Time.zone.parse(params[:grow_begin_date]).beginning_of_day + 1.days).strftime('%Y-%m-%d') %> 05:00 - <% else %> - <%= params[:grow_begin_date] %> 05:00至<%= (Time.zone.parse(params[:grow_end_date]) + 1.days).strftime('%Y-%m-%d') %> 05:00 - <% end %> + <%= params[:grow_begin_date] %> 05:00至<%= (Time.zone.parse(params[:grow_end_date]) + 1.days).strftime('%Y-%m-%d') %> 05:00 <% else %> <%= (Time.current - 5.hour).beginning_of_day.ago(1.days).strftime('%Y-%m-%d') %> 05:00至 <%= (Time.current - 5.hour).beginning_of_day.strftime('%Y-%m-%d') %> 05:00, From 0e0396c53955bbece5fe01fed3c3037e1dffa692 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 5 Jun 2019 14:03:28 +0800 Subject: [PATCH 02/23] fix school management sort bug --- app/services/management/school_report_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/management/school_report_service.rb b/app/services/management/school_report_service.rb index 785786b2..981498cd 100644 --- a/app/services/management/school_report_service.rb +++ b/app/services/management/school_report_service.rb @@ -83,11 +83,11 @@ class Management::SchoolReportService .select("#{base_query_column}, COUNT(*) student_count") when 'homework_count' then schools.joins('LEFT JOIN courses ON courses.school_id = schools.id') - .joins('LEFT JOIN homework_commons hc ON shc.course_id = courses.id AND hc.homework_type = 4') + .joins('LEFT JOIN homework_commons hc ON hc.course_id = courses.id AND hc.homework_type = 4') .select("#{base_query_column}, COUNT(*) homework_count") when 'other_homework_count' then schools.joins('LEFT JOIN courses ON courses.school_id = schools.id') - .joins('LEFT JOIN homework_commons hc ON shc.course_id = courses.id AND hc.homework_type IN (1, 3)') + .joins('LEFT JOIN homework_commons hc ON hc.course_id = courses.id AND hc.homework_type IN (1, 3)') .select("#{base_query_column}, COUNT(*) other_homework_count") when 'course_count' then schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0') From a0ea38196bf30584d50193c75de5a219da4998aa Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 14:53:41 +0800 Subject: [PATCH 03/23] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E9=99=A4=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E5=A4=96=EF=BC=8C=E5=85=B6=E4=BB=96=E4=BA=BA=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/shixuns_service.rb | 3 +++ .../20190605063236_modify_hidden_defualt_for_discusses.rb | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 db/migrate/20190605063236_modify_hidden_defualt_for_discusses.rb diff --git a/app/services/shixuns_service.rb b/app/services/shixuns_service.rb index 69bbc431..b7834ea7 100644 --- a/app/services/shixuns_service.rb +++ b/app/services/shixuns_service.rb @@ -119,6 +119,9 @@ class ShixunsService @children_list = [] # 目前只取十个,不多N+1问题不大 # 需要彻底解决则需要改数据路结构,比如Nested算法可以解决 + unless current_user.admin? + discusses = discusses.where(:hidden => false) + end if discusses.present? discusses.each do |d| # 总点赞数 diff --git a/db/migrate/20190605063236_modify_hidden_defualt_for_discusses.rb b/db/migrate/20190605063236_modify_hidden_defualt_for_discusses.rb new file mode 100644 index 00000000..9e026906 --- /dev/null +++ b/db/migrate/20190605063236_modify_hidden_defualt_for_discusses.rb @@ -0,0 +1,8 @@ +class ModifyHiddenDefualtForDiscusses < ActiveRecord::Migration + def up + change_column :discusses, :hidden, :boolean, :default => true + end + + def down + end +end From 487323a49ea9ef7171f35aaea0667b916571e31f Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 5 Jun 2019 15:10:10 +0800 Subject: [PATCH 04/23] =?UTF-8?q?=E6=94=B9=E6=88=90=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=BA=86=E7=9A=84=EF=BC=8C=E9=83=BD=E6=98=AF?= =?UTF-8?q?=E8=A6=81=E6=98=BE=E7=A4=BA=E7=9A=84=EF=BC=8C=E4=B8=8D=E7=AE=A1?= =?UTF-8?q?hidden=E7=9A=84=E5=80=BC=E6=98=AFtrue=E8=BF=98=E6=98=AFfalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/comment/Comments.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/public/react/src/modules/comment/Comments.js b/public/react/src/modules/comment/Comments.js index 250cf16b..d1ac57d4 100644 --- a/public/react/src/modules/comment/Comments.js +++ b/public/react/src/modules/comment/Comments.js @@ -213,11 +213,12 @@ class Comments extends Component {
- - { item.hidden && comment.admin === false && comment.manager === false + {/* 改成后端返回了的,都是要显示的,不管hidden的值是true还是false */} + {/* { item.hidden && comment.admin === false && comment.manager === false ?

违规评论已被屏蔽!

- :
- } + : */} +
+ {/* } */}
@@ -309,10 +310,12 @@ class Comments extends Component {
- { item.hidden && item.admin === false && (item.manager === false || item.manager == undefined) + {/* 改成后端返回了的,都是要显示的,不管hidden的值是true还是false */} + {/* { item.hidden && item.admin === false && (item.manager === false || item.manager == undefined) ?

违规评论已被屏蔽!

- :
- } + : */} +
+ {/* } */}
From 7d34217b9e38218c017622b16d2584e7a983b98a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 5 Jun 2019 15:17:24 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=A6=82=E6=9E=9C=E9=80=89?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=98=AF=E8=80=81=E5=B8=88=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=EF=BC=8C=E5=88=99=E7=BB=99=E9=9B=85=E8=8F=B2=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E5=8F=91=E9=80=81=E4=B8=80=E6=9D=A1=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 9 ++++++++- lib/trustie/sms/sms.rb | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 60096a22..128475e6 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -456,7 +456,9 @@ class AccountController < ApplicationController @pref = @user.pref @se = @user.extensions - # 已授权的用户修改单位名称,需要重新授权 + old_identity = @se.identity + + # 已授权的用户修改单位名称,需要重新授权 if @se.school_id != params[:occupation].to_i && @user.certification == 1 @user.certification = 0 apply_user = ApplyAction.where(:user_id => @user.id, :container_type => "TrialAuthorization") @@ -510,10 +512,15 @@ class AccountController < ApplicationController @se.technical_title = params[:pro_technical_title] if params[:pro_technical_title] @se.student_id = nil end + # @se.brief_introduction = params[:brief_introduction] if @user.save && @se.save + if old_identity.nil? && @se.identity == 0 + Trustie::Sms.send(mobile: '17680641960', send_type:'teacher_register', name: @user.login, user_name: "管理员") + end + reward_grade(@user, @user.id, 'Account', 500) if @user.certification != 1 diff --git a/lib/trustie/sms/sms.rb b/lib/trustie/sms/sms.rb index 2cab61fa..33584a0c 100644 --- a/lib/trustie/sms/sms.rb +++ b/lib/trustie/sms/sms.rb @@ -31,6 +31,8 @@ module Trustie params['text'] = "" if send_type.nil? params['text'] = "【Edu实训】" + code + "(手机验证码)。如非本人操作,请忽略。" + elsif send_type == "teacher_register" + params['text'] = "【Edu实训】亲爱的#{user_name},有新的老师#{name}注册啦,请尽快处理" elsif send_type == 'competition_start' params['text'] = "【Edu实训】亲爱的#{user_name},你参与的#{name}将于#{result}开始,请及时参赛" Rails.logger.info "#{params['text']}" From 4072011dca07b222f3896af1e9d64fb8b56add68 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 15:24:33 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E7=9A=84=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/shixuns_service.rb | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app/services/shixuns_service.rb b/app/services/shixuns_service.rb index b7834ea7..887f07c4 100644 --- a/app/services/shixuns_service.rb +++ b/app/services/shixuns_service.rb @@ -69,8 +69,20 @@ class ShixunsService dis = Shixun.select([:id, :user_id]).find(dis_id) dis_type = params[:container_type] # 如:"Shixun" # 总数,分页使用 - disscuss_count = Discuss.where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).count - discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).includes(:user, :praise_tread).offset(offset) + if current_user.admin? + disscuss_count = Discuss.where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).count + discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type, + :root_id => nil).includes(:user, :praise_tread).offset(offset) + else + disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id = :root_id and + (hidden = :hidden or user_id = :user_id)", + {dis_id: dis_id, dis_type: dis_type, root_id: nil, hidden: false, + user_id: current_user.id}) + + disscuss_count = disscusses.count + discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset) + end + base_data discusses, dis, current_user return {:children_list => @children_list, :disscuss_count => disscuss_count} @@ -119,9 +131,6 @@ class ShixunsService @children_list = [] # 目前只取十个,不多N+1问题不大 # 需要彻底解决则需要改数据路结构,比如Nested算法可以解决 - unless current_user.admin? - discusses = discusses.where(:hidden => false) - end if discusses.present? discusses.each do |d| # 总点赞数 @@ -145,7 +154,13 @@ class ShixunsService :user_praise => user_praise, :admin => current_user.admin?} # 现在没有二级回复,所以查询的时候直接从root_id取 - children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc") + children = + if current_user.admin? + Discuss.where(root_id: d.id).includes(:user).reorder("created_at asc") + else + Discuss.where("root_id = :root_id and (hidden = :hidden or user_id = :user_id", + {root_id: d.id, hidden: false, user_id: current_user.id}).includes(:user).reorder("created_at asc") + end @children_list << parents.merge({:children => (children.map{|child| [:content => child.content, :time => time_from_now(child.created_at), :position => child.position , :reward => child.reward,:hidden => child.hidden, :image_url => url_to_avatar(child.user), :username => child.username, :user_id => child.user_id, :user_login => child.user.try(:login), From 82295eef812d98f9752a061110f23a771afa4250 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 15:36:15 +0800 Subject: [PATCH 07/23] 1 --- app/services/shixuns_service.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/services/shixuns_service.rb b/app/services/shixuns_service.rb index 887f07c4..707d1760 100644 --- a/app/services/shixuns_service.rb +++ b/app/services/shixuns_service.rb @@ -74,11 +74,9 @@ class ShixunsService discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).includes(:user, :praise_tread).offset(offset) else - disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id = :root_id and + disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and (hidden = :hidden or user_id = :user_id)", - {dis_id: dis_id, dis_type: dis_type, root_id: nil, hidden: false, - user_id: current_user.id}) - + {dis_id: dis_id, dis_type: dis_type, hidden: false, user_id: current_user.id}) disscuss_count = disscusses.count discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset) end From f4f0a69873a3d893e998c7f5dbc73b8d39e39bbb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 15:42:41 +0800 Subject: [PATCH 08/23] 1 --- app/services/shixuns_service.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/services/shixuns_service.rb b/app/services/shixuns_service.rb index 707d1760..de4d75b3 100644 --- a/app/services/shixuns_service.rb +++ b/app/services/shixuns_service.rb @@ -81,7 +81,6 @@ class ShixunsService discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset) end - base_data discusses, dis, current_user return {:children_list => @children_list, :disscuss_count => disscuss_count} end @@ -156,7 +155,7 @@ class ShixunsService if current_user.admin? Discuss.where(root_id: d.id).includes(:user).reorder("created_at asc") else - Discuss.where("root_id = :root_id and (hidden = :hidden or user_id = :user_id", + Discuss.where("root_id = :root_id and (hidden = :hidden or user_id = :user_id)", {root_id: d.id, hidden: false, user_id: current_user.id}).includes(:user).reorder("created_at asc") end From 5d14b1862f9d434c482ba49f11cdd4618ff4d301 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 15:46:00 +0800 Subject: [PATCH 09/23] 1 --- app/services/games_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 4d676bef..1ed2e398 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -32,7 +32,8 @@ class GamesService # st:判断是选择类型还是实训类型 st = game_challenge.st game_count = myshixun.games.count - discusses_count = shixun.discusses.count + discusses_count = (current_user.admin? ? shixun.discusses.count : + shixun.discusses.where("hidden = false or user_id = :user_id", user_id: current_user.id)) mirror_name = myshixun.mirror_name user = myshixun.owner username = user.show_name From f1f3c69c4a5b1c80ac67b8d92e6c02e91a26692c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 15:46:58 +0800 Subject: [PATCH 10/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E6=95=B0=E4=B8=8D=E5=AF=B9=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 1ed2e398..f513316e 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -33,7 +33,7 @@ class GamesService st = game_challenge.st game_count = myshixun.games.count discusses_count = (current_user.admin? ? shixun.discusses.count : - shixun.discusses.where("hidden = false or user_id = :user_id", user_id: current_user.id)) + shixun.discusses.where("hidden = false or user_id = :user_id", user_id: current_user.id).count) mirror_name = myshixun.mirror_name user = myshixun.owner username = user.show_name From 6eba1f21aca189eb4f0fd6ed806c76518f663af5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 17:26:16 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E6=98=AF=E5=85=AC=E5=BC=80=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/discusses_service.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/services/discusses_service.rb b/app/services/discusses_service.rb index 415aea1b..29d3fcdc 100644 --- a/app/services/discusses_service.rb +++ b/app/services/discusses_service.rb @@ -56,8 +56,9 @@ class DiscussesService # 添加评论 def create params, current_user begin + hidden = current_user.admin? ? 0 : 1 Discuss.create!(:dis_id => params[:shixun_id], :dis_type => "Shixun", :content => params[:content].gsub(" \;", "").strip, :user_id => current_user.id, - :praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id]) + :praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id], :hidden => hidden) # 发送手机通知 # status = Trustie::Sms.send(mobile:'18173242757', send_type:'discuss', name:'管理员') rescue Exception => e @@ -69,8 +70,9 @@ class DiscussesService def reply params, current_user begin base_dicuss params[:id] + hidden = current_user.admin? ? 0 : 1 discuss = Discuss.create!(:content => params[:content].gsub(" \;", "").strip, :user_id => current_user.id, :parent_id => params[:id], - :root_id => @discuss.root_id || params[:id], :praise_count => 0, :challenge_id => @discuss.challenge_id, + :root_id => @discuss.root_id || params[:id], :praise_count => 0, :challenge_id => @discuss.challenge_id, :hidden => hidden, :dis_id => @discuss.dis_id, :dis_type => @discuss.dis_type, :position => @discuss.position) return discuss rescue Exception => e From e7b89d797ffcc2499097c83f41cc58629dd24bf5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 17:43:40 +0800 Subject: [PATCH 12/23] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E5=9B=9E=E5=A4=8D=E6=98=AF=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/discusses_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/discusses_service.rb b/app/services/discusses_service.rb index 29d3fcdc..a43ccfa8 100644 --- a/app/services/discusses_service.rb +++ b/app/services/discusses_service.rb @@ -56,7 +56,7 @@ class DiscussesService # 添加评论 def create params, current_user begin - hidden = current_user.admin? ? 0 : 1 + hidden = current_user.admin? ? false : true Discuss.create!(:dis_id => params[:shixun_id], :dis_type => "Shixun", :content => params[:content].gsub(" \;", "").strip, :user_id => current_user.id, :praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id], :hidden => hidden) # 发送手机通知 @@ -70,7 +70,7 @@ class DiscussesService def reply params, current_user begin base_dicuss params[:id] - hidden = current_user.admin? ? 0 : 1 + hidden = current_user.admin? ? false : true discuss = Discuss.create!(:content => params[:content].gsub(" \;", "").strip, :user_id => current_user.id, :parent_id => params[:id], :root_id => @discuss.root_id || params[:id], :praise_count => 0, :challenge_id => @discuss.challenge_id, :hidden => hidden, :dis_id => @discuss.dis_id, :dis_type => @discuss.dis_type, :position => @discuss.position) From fa1c12a923923fab6d13e762e268de22a9359150 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 17:46:51 +0800 Subject: [PATCH 13/23] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/discusses_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/discusses_service.rb b/app/services/discusses_service.rb index a43ccfa8..753f3572 100644 --- a/app/services/discusses_service.rb +++ b/app/services/discusses_service.rb @@ -71,6 +71,7 @@ class DiscussesService begin base_dicuss params[:id] hidden = current_user.admin? ? false : true + Rails.logger.info("############hidden: #{hidden}") discuss = Discuss.create!(:content => params[:content].gsub(" \;", "").strip, :user_id => current_user.id, :parent_id => params[:id], :root_id => @discuss.root_id || params[:id], :praise_count => 0, :challenge_id => @discuss.challenge_id, :hidden => hidden, :dis_id => @discuss.dis_id, :dis_type => @discuss.dis_type, :position => @discuss.position) From aeec6526495ba47eecf2574f8dadb74a8b6409fe Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 18:03:07 +0800 Subject: [PATCH 14/23] 1 --- app/models/discuss.rb | 3 ++- app/services/discusses_service.rb | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/discuss.rb b/app/models/discuss.rb index 6d7ada99..b397721e 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -1,6 +1,7 @@ class Discuss < ActiveRecord::Base belongs_to :user - attr_accessible :user_id, :content, :dis_id, :dis_type, :parent_id, :praise_count, :root_id, :challenge_id, :position, :reward + attr_accessible :user_id, :content, :dis_id, :dis_type, :parent_id, :praise_count, :root_id, :challenge_id, + :position, :reward, :hidden default_scope :order => 'created_at desc' has_many :praise_tread, as: :praise_tread_object, dependent: :destroy diff --git a/app/services/discusses_service.rb b/app/services/discusses_service.rb index 753f3572..a43ccfa8 100644 --- a/app/services/discusses_service.rb +++ b/app/services/discusses_service.rb @@ -71,7 +71,6 @@ class DiscussesService begin base_dicuss params[:id] hidden = current_user.admin? ? false : true - Rails.logger.info("############hidden: #{hidden}") discuss = Discuss.create!(:content => params[:content].gsub(" \;", "").strip, :user_id => current_user.id, :parent_id => params[:id], :root_id => @discuss.root_id || params[:id], :praise_count => 0, :challenge_id => @discuss.challenge_id, :hidden => hidden, :dis_id => @discuss.dis_id, :dis_type => @discuss.dis_type, :position => @discuss.position) From 5b07b39fb2fafb8858022c3cd97bd0a8a3d31953 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Jun 2019 10:05:25 +0800 Subject: [PATCH 15/23] =?UTF-8?q?=E8=BF=90=E8=90=A5=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E4=B9=9F=E8=83=BD=E6=9F=A5=E7=9C=8B=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_course_item.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_course_item.html.erb b/app/views/users/_course_item.html.erb index 73c33893..e474a117 100644 --- a/app/views/users/_course_item.html.erb +++ b/app/views/users/_course_item.html.erb @@ -1,5 +1,5 @@ <% objects.each do |object| %> - <% allow_visit = object.is_public == 1 || User.current.admin? || User.current.member_of_course?(object) %> + <% allow_visit = object.is_public == 1 || User.current.admin? || User.current.member_of_course?(object) || User.current.business? %>
<% if object.is_public == 1 %>
From 2a6364b27efb4aa160a91ff8903dd26390c2275f Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 6 Jun 2019 11:09:46 +0800 Subject: [PATCH 16/23] management user: add province filter --- app/controllers/managements_controller.rb | 92 +++++++++---------- app/models/school.rb | 6 ++ app/views/managements/users_trial.html.erb | 8 +- ...190606030046_add_index_to_apply_actions.rb | 5 + 4 files changed, 60 insertions(+), 51 deletions(-) create mode 100644 db/migrate/20190606030046_add_index_to_apply_actions.rb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index eb3c37c9..deff1526 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -3310,83 +3310,79 @@ end end end - all_user_ids = User.where(:status => 1).pluck(:id) + users = User.where(nil) if params[:trial] == "-1" - apply = ApplyAction.where(:container_type => "TrialAuthorization").pluck(:user_id) - apply_id = apply.blank? ? -1 : "(" + apply.join(",") + ")" - apply_user_id = User.where("status = 1 and certification = 0 and id not in #{apply_id} ").pluck(:id) + users = users.where(status: 1, certification: 0) + .joins('LEFT JOIN apply_actions aa ON aa.user_id = users.id AND aa.container_type = "TrialAuthorization"') + .where('aa.user_id IS NULL') elsif params[:trial] == "-2" - apply_user_id = all_user_ids + users = users.where(status: 1) elsif params[:trial] == "0" - apply_user_id = ApplyAction.where(:status => 0).pluck(:user_id) + users = users.joins('LEFT JOIN apply_actions apply ON apply.user_id = users.id').where(apply_actions: { status: 0 }) elsif params[:trial] == "3" - time = Time.at(Time.now.to_i - 86400) - user_cer = UserDayCertification.where("created_at > '#{time}'").pluck(:user_id) - cer_id = user_cer.blank? ? "(-1)" : "(" + user_cer.map{|a| a.user_id}.join(",") + ")" - apply_user_id = User.where("status = 1 and certification != 1 and id in #{cer_id} ").pluck(:id) + users = users.joins('LEFT JOIN user_day_certifications udc ON udc.user_id = users.id') + .where('users.certification != 1').where('udc.created_at > ?', Time.now.ago(1.days)) else - apply_user_id = User.where(:status => 1, :certification => params[:trial]).pluck(:id) + users = users.where(status: 1, certification: params[:trial]) end - if params[:school] == "" - s_user_id = all_user_ids - else - school_ids = School.where("name like '%#{params[:school]}%'").pluck(:id) - s_user_id = UserExtensions.where(:school_id => school_ids).pluck(:user_id) + users = users.joins('LEFT JOIN user_extensions ON user_extensions.user_id = users.id') + .joins('LEFT JOIN schools ON schools.id = user_extensions.school_id') + .joins('LEFT JOIN departments ON departments.id = user_extensions.department_id') + + if params[:school].present? + users = users.where("schools.name LIKE ?", "%#{params[:school]}%") end - if params[:department] == "" - d_user_id = all_user_ids - else - dep_ids = Department.where("name like '%#{params[:department]}%'").pluck(:id) - d_user_id = UserExtensions.where(:department_id => dep_ids).pluck(:user_id) + if params[:department].present? + users = users.where("departments.name LIKE ?", "%#{params[:department]}%") end - ide_user_id = all_user_ids if params[:identity] == "1" || (params[:identity] == "0" && params[:te_technical_title] == "0") || (params[:identity] == "2" && params[:pro_technical_title] == "0") - ide_user_id = UserExtensions.where("identity = #{params[:identity]}").pluck(:user_id) + users = users.where(user_extensions: { identity: params[:identity] }) elsif (params[:identity] == "0" && params[:te_technical_title] != "0") || (params[:identity] == "2" && params[:pro_technical_title] != "0") technical_title = params[:identity] == "0" ? params[:te_technical_title] : params[:pro_technical_title] - ide_user_id = UserExtensions.where("identity = #{params[:identity]} and technical_title = '#{technical_title}'").pluck(:user_id) + users = users.where(user_extensions: { identity: params[:identity], technical_title: technical_title }) end - if params[:student_id] && params[:student_id] != '' - stu_user_id = UserExtensions.where("student_id like '%#{params[:student_id]}%'").pluck(:user_id) - else - stu_user_id = all_user_ids + if params[:student_id].present? + users = users.where('user_extensions.student_id like ?', "%#{params[:student_id]}%") end - user_id = s_user_id & d_user_id & apply_user_id & stu_user_id & ide_user_id - sql = "" - sql = - if params[:research_condition] == "name" - "concat(lastname, firstname) like '%#{params[:research_contents]}%'" - elsif params[:research_condition] == "email" - "mail like '%#{params[:research_contents]}%'" - elsif params[:research_condition] == "phone" - "phone like '%#{params[:research_contents]}%'" - elsif params[:research_condition] == "nickname" - if params[:research_contents].present? - "nickname like '%#{params[:research_contents]}%'" - end - elsif params[:research_condition] == "login" - params[:research_contents].present? ? "login like '%#{params[:research_contents]}%'" : "" - end + if params[:research_contents].present? + keyword = "%#{params[:research_contents]}%" + if params[:research_condition] == "name" + users = users.where('concat(lastname, firstname) like ?', keyword) + elsif params[:research_condition] == "email" + users = users.where("mail like ?", keyword) + elsif params[:research_condition] == "phone" + users = users.where("phone like ?", keyword) + elsif params[:research_condition] == "nickname" + users = users.where("nickname like ?", keyword) + elsif params[:research_condition] == "login" + users = users.where("login like ?", keyword) + end + end + + if params[:province].present? + users = users.where(schools: { province: params[:province] }) + end + + users = users.includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on desc") - @users = User.where(:id => user_id).where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on desc") - @xls_users = @users.reorder("created_on desc").limit(3000) #导出excel用户 @page = (params['page'] || 1).to_i - @users_count = @users.count + @users_count = users.count @limit = 20 @is_remote = true @users_pages = Paginator.new @users_count, @limit, params['page'] || 1 @offset ||= @users_pages.offset - @users = paginateHelper @users, @limit + @users = paginateHelper users, @limit respond_to do |format| format.js format.xls{ # @export_shixun_task = @export_shixun_task.all + @xls_users = users.reorder("created_on desc").limit(3000) #导出excel用户 filename = "用户列表.xls" send_data(user_list_xls(@xls_users), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename)) } diff --git a/app/models/school.rb b/app/models/school.rb index d5090023..293ab4b8 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -81,4 +81,10 @@ class School < ActiveRecord::Base courses.id LEFT JOIN user_extensions ON courses.tea_id=user_extensions.user_id WHERE user_extensions.`school_id` = #{self.id}").first.try(:max_update) end + + def self.provinces + Rails.cache.fetch('china_province_cache', expires_in: 1.days) do + School.pluck('distinct province').select(&:present?) + end + end end diff --git a/app/views/managements/users_trial.html.erb b/app/views/managements/users_trial.html.erb index b872ca87..23908eff 100644 --- a/app/views/managements/users_trial.html.erb +++ b/app/views/managements/users_trial.html.erb @@ -19,20 +19,20 @@
- - - @@ -41,6 +41,8 @@ + <%= select_tag :province, options_for_select(School.provinces.unshift(['请选择地区', ''])), class: 'fr winput-200-40'%> +

真实姓名搜索

diff --git a/db/migrate/20190606030046_add_index_to_apply_actions.rb b/db/migrate/20190606030046_add_index_to_apply_actions.rb new file mode 100644 index 00000000..ccbdb03a --- /dev/null +++ b/db/migrate/20190606030046_add_index_to_apply_actions.rb @@ -0,0 +1,5 @@ +class AddIndexToApplyActions < ActiveRecord::Migration + def change + add_index :apply_actions, :user_id + end +end From c4bd57e35ce76b0c6e5473e267e9040ba4766d70 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Jun 2019 14:52:53 +0800 Subject: [PATCH 17/23] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=85=B1=E4=BA=ABcooki?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 46914e9f..894ba099 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -34,7 +34,7 @@ module Mobile version 'v1', using: :path format :json content_type :json, "application/json;charset=UTF-8" - use ActionDispatch::Session::CookieStore, :expire_after => 8.hours, :key => '_educoder_session', :domain => :all + #use ActionDispatch::Session::CookieStore, :expire_after => 8.hours, :key => '_educoder_session', :domain => :all require 'digest' use Mobile::Middleware::ErrorHandler From bcbc37d66d06f5b37e0fedd1929b42c84104a3f2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Jun 2019 14:55:39 +0800 Subject: [PATCH 18/23] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=85=B1=E4=BA=ABcookies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 894ba099..0763f070 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -69,9 +69,9 @@ module Mobile Rails.logger.info("#####sign: #{sign}") Rails.logger.info("#####params[:sign]: #{params[:sign]}") - if params[:sign] != sign - error!('401 Unauthorized', 401) - end + #if params[:sign] != sign + # error!('401 Unauthorized', 401) + #end end # 有一些接口没登录也能查看数据 From 615fcd87f37140f9b3ee7586b0bb436b366c5df9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Jun 2019 15:02:41 +0800 Subject: [PATCH 19/23] =?UTF-8?q?=E5=85=B1=E4=BA=ABcookies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 0763f070..a5a20a38 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -34,7 +34,7 @@ module Mobile version 'v1', using: :path format :json content_type :json, "application/json;charset=UTF-8" - #use ActionDispatch::Session::CookieStore, :expire_after => 8.hours, :key => '_educoder_session', :domain => :all + use ActionDispatch::Session::CookieStore, :expire_after => 8.hours, :key => '_educoder_session', :domain => :all require 'digest' use Mobile::Middleware::ErrorHandler From 4358dbbbccb00fcf91101f9d2aea51ad1044ea9e Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 6 Jun 2019 15:10:23 +0800 Subject: [PATCH 20/23] management user: fix search user bug && modify code to solve some n+1 --- app/controllers/managements_controller.rb | 31 +++++++++++++---------- app/models/user.rb | 6 +++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index deff1526..13c24a3e 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2820,17 +2820,17 @@ end else "status = 1" end - @users = User.where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on #{@sx_order}") + @users = User.where("#{sql}").includes(:real_name_authentication_apply, :professional_authentication_apply, + user_extensions: [:department, :school]).order("last_login_on #{@sx_order}") @has_cer_count = User.where(:status => 1, :certification => 1).count @reject_cer_count = User.where(:status => 1, :certification => 2).count @deal_cer_count = ApplyAction.where(:status => 0).select("distinct user_id").count - time = Time.at(Time.now.to_i - 86400) - cer = UserDayCertification.where("created_at > '#{time}'").pluck(:user_id) - cer_ids = cer.join(",") - @trial_cer_count = cer.blank? ? 0 : User.where("status = 1 and certification != 1 and id in (#{cer_ids})").count - apply = ApplyAction.where(:container_type => "TrialAuthorization").pluck(:user_id) - apply_ids = apply.join(",") - @nonn_cer_count = apply.blank? ? 0 : User.where("status = 1 and certification = 0 and id not in (#{apply_ids}) ").count + + subquery = UserDayCertification.where("created_at > ?", Time.now.ago(1.days)).select(:user_id).to_sql + @trial_cer_count = User.where("status = 1 and certification != 1 and id in (#{subquery})").count + + apply_subquery = ApplyAction.where(container_type: "TrialAuthorization").select(:user_id).to_sql + @nonn_cer_count = User.where("status = 1 and certification = 0 and id not in (#{apply_subquery}) ").count @page = (params['page'] || 1).to_i @users_count = @users.count @@ -3313,12 +3313,12 @@ end users = User.where(nil) if params[:trial] == "-1" users = users.where(status: 1, certification: 0) - .joins('LEFT JOIN apply_actions aa ON aa.user_id = users.id AND aa.container_type = "TrialAuthorization"') - .where('aa.user_id IS NULL') + .joins('LEFT JOIN apply_actions ON apply_actions.user_id = users.id AND apply_actions.container_type = "TrialAuthorization"') + .where('apply_actions.user_id IS NULL') elsif params[:trial] == "-2" users = users.where(status: 1) elsif params[:trial] == "0" - users = users.joins('LEFT JOIN apply_actions apply ON apply.user_id = users.id').where(apply_actions: { status: 0 }) + users = users.joins('LEFT JOIN apply_actions ON apply_actions.user_id = users.id').where(apply_actions: { status: 0 }) elsif params[:trial] == "3" users = users.joins('LEFT JOIN user_day_certifications udc ON udc.user_id = users.id') .where('users.certification != 1').where('udc.created_at > ?', Time.now.ago(1.days)) @@ -3327,8 +3327,8 @@ end end users = users.joins('LEFT JOIN user_extensions ON user_extensions.user_id = users.id') - .joins('LEFT JOIN schools ON schools.id = user_extensions.school_id') .joins('LEFT JOIN departments ON departments.id = user_extensions.department_id') + .joins('LEFT JOIN schools ON schools.id = user_extensions.school_id') if params[:school].present? users = users.where("schools.name LIKE ?", "%#{params[:school]}%") @@ -3368,7 +3368,7 @@ end users = users.where(schools: { province: params[:province] }) end - users = users.includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on desc") + users = users.select('distinct users.*').order("last_login_on desc") @page = (params['page'] || 1).to_i @users_count = users.count @@ -3376,13 +3376,16 @@ end @is_remote = true @users_pages = Paginator.new @users_count, @limit, params['page'] || 1 @offset ||= @users_pages.offset - @users = paginateHelper users, @limit + @users = paginateHelper users.includes(:real_name_authentication_apply, :professional_authentication_apply, + user_extensions: [:department, :school]), @limit respond_to do |format| format.js format.xls{ # @export_shixun_task = @export_shixun_task.all @xls_users = users.reorder("created_on desc").limit(3000) #导出excel用户 + @xls_users = @xls_users.includes(:real_name_authentication_apply, :professional_authentication_apply, + user_extensions: [:department, :school]) filename = "用户列表.xls" send_data(user_list_xls(@xls_users), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename)) } diff --git a/app/models/user.rb b/app/models/user.rb index 3e89e4f2..52c4be8b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -224,6 +224,8 @@ class User < Principal ### has_many :apply_actions, :dependent => :destroy has_many :apply_user_authentications, :dependent => :destroy + has_one :real_name_authentication_apply, conditions: 'auth_type = 1 AND status = 0', class_name: 'ApplyUserAuthentication' + has_one :professional_authentication_apply, conditions: 'auth_type = 2 AND status = 0', class_name: 'ApplyUserAuthentication' has_one :user_wechat @@ -993,12 +995,12 @@ class User < Principal # 实名认证状态 def authentication_status - status = self.authentication ? "已认证" : (self.apply_user_authentications.where(:auth_type => 1, :status => 0).count > 0 ? "待审核" : "未认证") + authentication ? "已认证" : (real_name_authentication_apply.present? ? "待审核" : "未认证") end # 职业认证状态 def professional_status - status = self.professional_certification ? "已认证" : (self.apply_user_authentications.where(:auth_type => 2, :status => 0).count > 0 ? "待审核" : "未认证") + professional_certification ? "已认证" : (professional_authentication_apply.present? ? "待审核" : "未认证") end def logged? From 49deaab2916410b55ac09b100a0fccce4a088cce Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Jun 2019 15:15:09 +0800 Subject: [PATCH 21/23] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index a5a20a38..0763f070 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -34,7 +34,7 @@ module Mobile version 'v1', using: :path format :json content_type :json, "application/json;charset=UTF-8" - use ActionDispatch::Session::CookieStore, :expire_after => 8.hours, :key => '_educoder_session', :domain => :all + #use ActionDispatch::Session::CookieStore, :expire_after => 8.hours, :key => '_educoder_session', :domain => :all require 'digest' use Mobile::Middleware::ErrorHandler From c62b4d9afa127b324c2c836095b90621805f31b5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Jun 2019 15:18:23 +0800 Subject: [PATCH 22/23] =?UTF-8?q?=E6=9C=80=E8=BF=91=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E5=87=BA=E7=8E=B0cookies=E4=B8=8D=E5=AF=B9=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=EF=BC=8C=E7=8E=B0=E5=9C=A8=E5=88=A0=E9=99=A4grape?= =?UTF-8?q?=E8=BF=99=E8=BE=B9=E7=9A=84cookies=E5=A6=82=E6=9E=9C=E8=BF=98?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E5=B0=B1=E4=B8=8D=E6=98=AF=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 0763f070..894ba099 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -69,9 +69,9 @@ module Mobile Rails.logger.info("#####sign: #{sign}") Rails.logger.info("#####params[:sign]: #{params[:sign]}") - #if params[:sign] != sign - # error!('401 Unauthorized', 401) - #end + if params[:sign] != sign + error!('401 Unauthorized', 401) + end end # 有一些接口没登录也能查看数据 From 32227c1f19ae22faf61b8229b2324214cc07bd1d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Jun 2019 17:27:35 +0800 Subject: [PATCH 23/23] =?UTF-8?q?=E6=9C=AA=E5=8F=91=E5=B8=83=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E8=AE=AD=EF=BC=8C=E5=AE=9E=E8=AE=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E5=8F=AF=E4=BB=A5=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e44005a4..c3865f3f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -376,7 +376,7 @@ class ApplicationController < ActionController::Base def require_admin return unless require_login - if !User.current.admin? + if !User.current.admin? && @shixun.status > 1 render_403 return false end