
class CompetitionUserScore < ApplicationRecord
  belongs_to :competition_user

  serialize :api_result, JSON

  def api_result_text
    "" if self.api_status != 3 || self.api_result.blank?
    data = api_result
    data["msg"].present? ? data["msg"] : data["errorOutput"].present? ? data["errorOutput"] : "系统打分错误，信息不详"
  rescue =>err
    return ""
  end

  def api_result_data
    {} if self.api_status != 3 || self.api_result.blank?
    data = api_result["data"]
    data
  rescue =>err
    return {}
  end

end
