From 421a64e8ca3e16c0f993eada70baf281b09370bd Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 19 Apr 2023 16:56:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4=EF=BC=9Aproject=5Ftopics?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9A=84includes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/project_topics_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/project_topics_controller.rb b/app/controllers/api/v1/project_topics_controller.rb index 5d353fbf4..46ae4cee0 100644 --- a/app/controllers/api/v1/project_topics_controller.rb +++ b/app/controllers/api/v1/project_topics_controller.rb @@ -3,7 +3,7 @@ class Api::V1::ProjectTopicsController < Api::V1::BaseController def index @project_topics = ProjectTopic @project_topics = @project_topics.ransack(name_cont: params[:keyword]) if params[:keyword].present? - @project_topics = @project_topics.includes(:projects) + # @project_topics = @project_topics.includes(:projects) @project_topics = kaminary_select_paginate(@project_topics) end From a578b7277a48f1b56f16711c42531e0922412533 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 19 Apr 2023 17:32:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E7=94=A8=E6=88=B7id=E4=B8=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 807efd5f3..f63400b03 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -1,5 +1,11 @@ class Api::V1::UsersController < Api::V1::BaseController + def check_user_id + id = params[:user_id] + return tip_exception(-1, "用户ID不存在") unless User.exists?(id: id) + render_ok + end + before_action :load_observe_user before_action :check_auth_for_observe_user @@ -42,12 +48,6 @@ class Api::V1::UsersController < Api::V1::BaseController end end - def check_user_id - id = params[:user_id] - return tip_exception(-1, "用户ID不存在") unless User.exists?(id: id) - render_ok - end - def check_password password = params[:password] return tip_exception(-5, "8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD From e815b0a8accbb2f04557b335d27a01640498a60d Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 19 Apr 2023 18:11:11 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E7=94=A8=E6=88=B7id=E7=9A=84=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 9 ++++----- config/routes/api.rb | 8 +++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index f63400b03..3f7b49f99 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -1,14 +1,13 @@ class Api::V1::UsersController < Api::V1::BaseController + before_action :load_observe_user, except: [:check_user_id] + before_action :check_auth_for_observe_user, except: [:check_user_id] + def check_user_id - id = params[:user_id] - return tip_exception(-1, "用户ID不存在") unless User.exists?(id: id) + return tip_exception(-1, "用户ID不存在") unless params[:user_id].present? && User.exists?(id: params[:user_id]) render_ok end - before_action :load_observe_user - before_action :check_auth_for_observe_user - def send_email_vefify_code code = %W(0 1 2 3 4 5 6 7 8 9) verification_code = code.sample(6).join diff --git a/config/routes/api.rb b/config/routes/api.rb index 92b5868f5..77ff5d03b 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -1,11 +1,17 @@ defaults format: :json do namespace :api do namespace :v1 do + + resources :users, only: [:index] do + collection do + post :check_user_id + end + end + scope ':owner' do resource :users, path: '/', only: [:update, :edit, :destroy] do collection do get :send_email_vefify_code - post :check_user_id post :check_password post :check_email post :check_email_verify_code