add: home index api

This commit is contained in:
2021-11-03 10:19:01 +08:00
parent 35f04afe91
commit 18bbbce7b3
19 changed files with 70 additions and 55 deletions

View File

@@ -15,10 +15,31 @@ class Topic < ApplicationRecord
default_scope { order(order_index: :desc)}
scope :with_single_type, ->(type){where(type: trans_simpletype_to_classtype(type))}
def image
image_url('image')
end
def self.trans_simpletype_to_classtype(type)
case type
when 'activity_forum'
'Topic::ActivityForum'
when 'banner'
'Topic::Banner'
when 'card'
'Topic::Card'
when 'cooperator'
'Topic::Cooperator'
when 'excellent_project'
'Topic::ExcellentProject'
when 'experience_forum'
'Topic::ExperienceForum'
when 'pinned_forum'
'Topic::PinnedForum'
end
end
private
def image_url(type)