diff --git a/app/controllers/weapps/homes_controller.rb b/app/controllers/weapps/homes_controller.rb new file mode 100644 index 000000000..efb80b898 --- /dev/null +++ b/app/controllers/weapps/homes_controller.rb @@ -0,0 +1,12 @@ +class Weapps::HomesController < Weapps::BaseController + def show + # banner图 + @images = PortalImage.where(status: true).order(position: :asc) + + # 热门实训 + @shixuns = Shixun.where(homepage_show: true).includes(:tag_repertoires, :challenges).limit(4) + + # 热门实践课程 + @subjects = Subject.where(homepage_show: true).includes(:shixuns, :repertoire).limit(4) + end +end \ No newline at end of file diff --git a/app/views/weapps/homes/show.json.jbuilder b/app/views/weapps/homes/show.json.jbuilder new file mode 100644 index 000000000..d2a451030 --- /dev/null +++ b/app/views/weapps/homes/show.json.jbuilder @@ -0,0 +1,14 @@ +json.images do + json.array! @images do |image| + json.path image.link + json.image_url Util::FileManage.source_disk_file_url(image) + end +end + +json.shixuns do + json.partial! 'shixuns/shixun', locals: { shixuns: @shixuns } +end + +json.subjects do + json.partial! 'subjects/subject', locals: { subjects: @subjects } +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 1ef62c0e6..4445278de 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -831,6 +831,7 @@ Rails.application.routes.draw do resource :bind_user, only: [:create] namespace :weapps do + resource :home, only: [:show] resource :session, only: [:create] resource :register, only: [:create] resource :code_session, only: [:create]