From a6cade88c79d1ec3d3b7f1bf091e6a73c8b5185e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 22 Jul 2019 15:40:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 6 ++++++ app/views/users/system_update.json.jbuilder | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 app/views/users/system_update.json.jbuilder diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e9fe4ed94..23f6870c8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,6 +3,12 @@ class UsersController < ApplicationController before_action :load_user, only: [:show, :homepage_info] before_action :check_user_exist, only: [:show, :homepage_info] + # 检查是否更新 + def system_update + @notice = SystemUpdateNotice.last + end + + def show;end def update diff --git a/app/views/users/system_update.json.jbuilder b/app/views/users/system_update.json.jbuilder new file mode 100644 index 000000000..c8cf5a565 --- /dev/null +++ b/app/views/users/system_update.json.jbuilder @@ -0,0 +1,6 @@ +if @notice && @notice.end.time < Time.now + json.system_update true + json.(@notice, :subject, :notes, :start_time, :end_time) +else + json.system_update false +end \ No newline at end of file From 6e5b3727abeb71e4bdd916114b42f387484d3222 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 22 Jul 2019 15:50:02 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E9=80=9A=E7=9F=A5api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index cabdcb18e..d69d432b3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -64,6 +64,7 @@ Rails.application.routes.draw do get :search_user_projects post :brief_introduction post :attendance + get :system_update resource :trial_apply, only: [:create] resources :projects, only: [] do From c9618de45c670c33ad5779f986d3ff3ce4396f32 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 22 Jul 2019 15:53:05 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/system_update_notice.rb | 2 ++ spec/models/system_update_notice_spec.rb | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 app/models/system_update_notice.rb create mode 100644 spec/models/system_update_notice_spec.rb diff --git a/app/models/system_update_notice.rb b/app/models/system_update_notice.rb new file mode 100644 index 000000000..44589a405 --- /dev/null +++ b/app/models/system_update_notice.rb @@ -0,0 +1,2 @@ +class SystemUpdateNotice < ApplicationRecord +end diff --git a/spec/models/system_update_notice_spec.rb b/spec/models/system_update_notice_spec.rb new file mode 100644 index 000000000..aceabc264 --- /dev/null +++ b/spec/models/system_update_notice_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SystemUpdateNotice, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 55fa424515ce606ab263d0d45fc382c73293d3d0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 22 Jul 2019 15:54:56 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/system_update.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/system_update.json.jbuilder b/app/views/users/system_update.json.jbuilder index c8cf5a565..7dc0877a8 100644 --- a/app/views/users/system_update.json.jbuilder +++ b/app/views/users/system_update.json.jbuilder @@ -1,4 +1,4 @@ -if @notice && @notice.end.time < Time.now +if @notice && @notice.end_time < Time.now json.system_update true json.(@notice, :subject, :notes, :start_time, :end_time) else From 3ba8a80e8e917dd7e08ac441697ebd07abb331fd Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 22 Jul 2019 15:55:51 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/system_update.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/system_update.json.jbuilder b/app/views/users/system_update.json.jbuilder index 7dc0877a8..cfc078f03 100644 --- a/app/views/users/system_update.json.jbuilder +++ b/app/views/users/system_update.json.jbuilder @@ -1,4 +1,4 @@ -if @notice && @notice.end_time < Time.now +if @notice && @notice.end_time > Time.now json.system_update true json.(@notice, :subject, :notes, :start_time, :end_time) else