|
|
|
@@ -0,0 +1,57 @@ |
|
|
|
class Admins::Topic::GlccNewsController < Admins::Topic::BaseController |
|
|
|
before_action :find_glcc, only: [:edit, :update, :destroy] |
|
|
|
|
|
|
|
def index |
|
|
|
q = ::Topic::GlccNews.ransack(title_cont: params[:search]) |
|
|
|
glcc_news = q.result(distinct: true) |
|
|
|
@glcc_news = paginate(glcc_news) |
|
|
|
end |
|
|
|
|
|
|
|
def new |
|
|
|
@glcc = ::Topic::GlccNews.new |
|
|
|
end |
|
|
|
|
|
|
|
def create |
|
|
|
@glcc = ::Topic::GlccNews.new(glcc_params) |
|
|
|
if @glcc.save |
|
|
|
redirect_to admins_topic_glcc_news_index_path |
|
|
|
flash[:success] = "新增新闻稿成功" |
|
|
|
else |
|
|
|
redirect_to admins_topic_glcc_news_index_path |
|
|
|
flash[:danger] = "新增新闻稿失败" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def edit |
|
|
|
end |
|
|
|
|
|
|
|
def update |
|
|
|
@glcc.attributes = glcc_params |
|
|
|
if @glcc.save |
|
|
|
redirect_to admins_topic_glcc_news_index_path |
|
|
|
flash[:success] = "更新新闻稿成功" |
|
|
|
else |
|
|
|
redirect_to admins_topic_glcc_news_index_path |
|
|
|
flash[:danger] = "更新新闻稿失败" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def destroy |
|
|
|
if @glcc.destroy |
|
|
|
redirect_to admins_topic_glcc_news_index_path |
|
|
|
flash[:success] = "删除新闻稿成功" |
|
|
|
else |
|
|
|
redirect_to admins_topic_glcc_news_index_path |
|
|
|
flash[:danger] = "删除新闻稿失败" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
private |
|
|
|
def find_glcc |
|
|
|
@glcc = ::Topic::GlccNews.find_by_id(params[:id]) |
|
|
|
end |
|
|
|
|
|
|
|
def glcc_params |
|
|
|
params.require(:topic_glcc_news).permit(:title, :uuid, :url, :order_index) |
|
|
|
end |
|
|
|
end |