Feat: Article public apis (#4955)
This commit is contained in:
@@ -5,7 +5,7 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
|
||||
|
||||
def index
|
||||
@articles = @portal.articles
|
||||
@articles.search(list_params) if params[:payload].present?
|
||||
@articles = @articles.search(list_params) if params[:payload].present?
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -46,7 +46,7 @@ class Api::V1::Accounts::CategoriesController < Api::V1::Accounts::BaseControlle
|
||||
|
||||
def category_params
|
||||
params.require(:category).permit(
|
||||
:name, :description, :position, :slug, :locale, :parent_category_id, :linked_category_id
|
||||
:name, :description, :position, :slug, :locale, :parent_category_id, :associated_category_id
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
25
app/controllers/public/api/v1/portals/articles_controller.rb
Normal file
25
app/controllers/public/api/v1/portals/articles_controller.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
class Public::Api::V1::Portals::ArticlesController < ApplicationController
|
||||
before_action :set_portal
|
||||
before_action :set_article, only: [:show]
|
||||
|
||||
def index
|
||||
@articles = @portal.articles
|
||||
@articles = @articles.search(list_params) if params[:payload].present?
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
private
|
||||
|
||||
def set_article
|
||||
@article = @portal.articles.find(params[:id])
|
||||
end
|
||||
|
||||
def set_portal
|
||||
@portal = ::Portal.find_by!(slug: params[:portal_slug], archived: false)
|
||||
end
|
||||
|
||||
def list_params
|
||||
params.require(:payload).permit(:query)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user