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/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/app/views/users/system_update.json.jbuilder b/app/views/users/system_update.json.jbuilder new file mode 100644 index 000000000..cfc078f03 --- /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 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 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