json.carousels do
  json.array! @carousels do |carousel|
    json.extract! carousel, :id, :link, :position

    json.path carousel.link
    json.image_url Util::FileManage.source_disk_file_url(carousel)
  end
end

if @advert.present?
  json.advert do
    json.extract! @advert, :id, :link
    json.image_url Util::FileManage.source_disk_file_url(@advert)
  end
else
  json.advert nil
end

json.shixuns do
  json.array! @shixuns do |shixun|
    json.id shixun.id
    json.identifier shixun.identifier
    json.name shixun.name
    json.status shixun.status
    json.power (current_user.shixun_permission(shixun)) # 现在首页只显示已发布的实训
    # REDO: 局部缓存
    json.tag_name @tag_name_map&.fetch(shixun.id, nil) || shixun.tag_repertoires.first.try(:name)
    json.myshixuns_count shixun.myshixuns_count
    json.stu_num shixun.myshixuns_count
    json.score_info shixun.averge_star
    json.challenges_count shixun.challenges_count
    #json.exp   shixun.all_score
    json.level level_to_s(shixun.trainee)
    json.pic Util::FileManage.source_disk_file_url(shixun, '_weapp')
  end
end

json.subjects do
  json.partial! 'subjects/subject', locals: { subjects: @subjects }
end