From 536e038657231f71f2ef572077581ea1d38eac83 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Oct 2025 10:28:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/system_notifications_controller.rb | 8 ++++++++ app/views/api/v1/system_notifications/index.json.jbuilder | 4 ++++ config/routes/api.rb | 1 + 3 files changed, 13 insertions(+) create mode 100644 app/controllers/api/v1/system_notifications_controller.rb create mode 100644 app/views/api/v1/system_notifications/index.json.jbuilder diff --git a/app/controllers/api/v1/system_notifications_controller.rb b/app/controllers/api/v1/system_notifications_controller.rb new file mode 100644 index 000000000..711722fe6 --- /dev/null +++ b/app/controllers/api/v1/system_notifications_controller.rb @@ -0,0 +1,8 @@ +class Api::V1::SystemNotificationsController < Api::V1::BaseController + + def index + @system_notifications = SystemNotification.where(is_top: true) + @system_notifications = kaminary_select_paginate(@system_notifications) + end + +end \ No newline at end of file diff --git a/app/views/api/v1/system_notifications/index.json.jbuilder b/app/views/api/v1/system_notifications/index.json.jbuilder new file mode 100644 index 000000000..11b4d726a --- /dev/null +++ b/app/views/api/v1/system_notifications/index.json.jbuilder @@ -0,0 +1,4 @@ +json.total_count @system_notifications.total_count +json.system_notifications @system_notifications.each do |notification| + json.(notification, :id, :subject, :sub_subject, :content, :is_top) +end \ No newline at end of file diff --git a/config/routes/api.rb b/config/routes/api.rb index 7bf4a6b66..ffa39557f 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -266,6 +266,7 @@ defaults format: :json do end + resources :system_notifications, only: [:index] resources :projects, only: [:index] resources :project_topics, only: [:index, :create, :destroy] resources :project_datasets, only: [:index]