diff --git a/app/models/live_link.rb b/app/models/live_link.rb index 27963a0bb..3cc17e6b3 100644 --- a/app/models/live_link.rb +++ b/app/models/live_link.rb @@ -7,23 +7,10 @@ class LiveLink < ApplicationRecord validates :url, format: { with: CustomRegexp::URL, message: "必须为网址超链接" } validates :description, length: { maximum: 100, too_long: "不能超过100个字符" } validates :course_name, presence: true - validates :platform, presence: true, inclusion: {in: %W(tencent douyu bilibili vbt)} + validates :platform, presence: true # validates :live_time, presence: true validates :duration, numericality: { only_integer: true, greater_than: 0}, allow_blank: true - def platform_name - case platform - when "tencent" - "腾讯课堂" - when "douyu" - "斗鱼直播" - when "vbt" - "威佰通" - else - platform - end - end - def op_auth? user == User.current || User.current.admin_or_business? end diff --git a/app/views/live_links/index.json.jbuilder b/app/views/live_links/index.json.jbuilder index 419fb49bb..95891fc8a 100644 --- a/app/views/live_links/index.json.jbuilder +++ b/app/views/live_links/index.json.jbuilder @@ -1,5 +1,5 @@ json.lives @lives do |live| - json.(live, :id, :description, :on_status, :duration, :course_name) + json.(live, :id, :description, :on_status, :duration, :course_name, :platform) json.url live.on_status ? live.url : "" json.author_name live.user.show_real_name json.author_login live.user.login @@ -7,7 +7,6 @@ json.lives @lives do |live| json.op_auth live.op_auth? json.delete_auth live.delete_auth? json.live_time live.live_time&.strftime('%Y-%m-%d %H:%M:%S') - json.platform live.platform_name end json.my_live_id @my_live_id json.total_count @total_count \ No newline at end of file