From 659651994ad6ae770d44c70837e0fffbeb73bea1 Mon Sep 17 00:00:00 2001 From: "Y.Suzuki" Date: Thu, 19 Sep 2019 21:14:45 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8F=82=E5=8A=A0=E3=82=A4=E3=83=99?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=AE=E4=B8=80=E8=A6=A7=E3=80=81=E8=A9=B3?= =?UTF-8?q?=E7=B4=B0=E3=80=81=E3=82=AD=E3=83=A3=E3=83=B3=E3=82=BB=E3=83=AB?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/join_schedules_controller.rb | 31 +++++++++++++++++++ config/routes.rb | 1 + 2 files changed, 32 insertions(+) create mode 100644 app/controllers/client/join_schedules_controller.rb diff --git a/app/controllers/client/join_schedules_controller.rb b/app/controllers/client/join_schedules_controller.rb new file mode 100644 index 0000000..2b002db --- /dev/null +++ b/app/controllers/client/join_schedules_controller.rb @@ -0,0 +1,31 @@ +class Client::JoinSchedulesController < Client::ApplicationController + before_action :set_user, only: %i(index show destroy) + + def index + render json: @user.join_schedules + end + + def show + join_schedule = @user.join_schedules.find(params[:id]) + render json: join_schedule + end + + def destroy + begin + user_to_event_schedule = @user.user_to_event_schedules.find_by(event_schedule_id: params[:id]) + user_to_event_schedule.destroy + rescue => e + puts e + result = 'Error' + else + result = 'OK' + end + render json: result + end + + private + + def set_user + @user = User.with_relation.find(params[:user_id]) + end +end diff --git a/config/routes.rb b/config/routes.rb index 8521e0d..12267e2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -41,6 +41,7 @@ Rails.application.routes.draw do namespace :client, defaults: { format: :json } do resources :users do + resources :join_schedules, only: %i(index show destroy) member do put :password end From 6d4885b58ea27055f8bc630ed017975520b8744f Mon Sep 17 00:00:00 2001 From: "Y.Suzuki" Date: Thu, 19 Sep 2019 21:19:13 +0900 Subject: [PATCH 2/3] =?UTF-8?q?README=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b16b49a..3fa92be 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,15 @@ client_user GET /client/users/:id(.:format) PUT /client/users/:id(.:format) client/users#update DELETE /client/users/:id(.:format) client/users#destroy ``` +### ユーザーの参加イベント管理 +※Client::JoinSchedules#index ユーザーの参加イベント一覧 +※Client::JoinSchedules#show ユーザーの参加イベント詳細 +※Client::JoinSchedules#destroy イベントの参加キャンセル +``` +client_user_join_schedules GET /client/users/:user_id/join_schedules(.:format) client/join_schedules#index {:format=>:json} +client_user_join_schedule GET /client/users/:user_id/join_schedules/:id(.:format) client/join_schedules#show {:format=>:json} + DELETE /client/users/:user_id/join_schedules/:id(.:format) client/join_schedules#destroy {:format=>:json} +``` ### イベント ※パラメータはコードを読んでね ``` From 1834c3c515c6cab9e581372c8f02b31ef0529875 Mon Sep 17 00:00:00 2001 From: "Y.Suzuki" Date: Thu, 19 Sep 2019 21:20:30 +0900 Subject: [PATCH 3/3] =?UTF-8?q?README=E6=94=B9=E8=A1=8C=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3fa92be..770ecf6 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ client_user GET /client/users/:id(.:format) DELETE /client/users/:id(.:format) client/users#destroy ``` ### ユーザーの参加イベント管理 -※Client::JoinSchedules#index ユーザーの参加イベント一覧 -※Client::JoinSchedules#show ユーザーの参加イベント詳細 -※Client::JoinSchedules#destroy イベントの参加キャンセル +※Client::JoinSchedules#index ユーザーの参加イベント一覧 +※Client::JoinSchedules#show ユーザーの参加イベント詳細 +※Client::JoinSchedules#destroy イベントの参加キャンセル ``` client_user_join_schedules GET /client/users/:user_id/join_schedules(.:format) client/join_schedules#index {:format=>:json} client_user_join_schedule GET /client/users/:user_id/join_schedules/:id(.:format) client/join_schedules#show {:format=>:json}