# encoding:utf-8
require 'uuid'
class WxUserGongzhonghao < ActiveRecord::Base
  has_paper_trail
  self.table_name = "wx_user_gongzhonghaos"
  # has_many :wx_menus
  
  validates :wx_user_id,:app_id,:gzh_open_id,presence: true

  rails_admin do
    navigation_label '用户管理'
    weight -350

    list do
      filters [:wx_user_id, :app_id, :gzh_open_id]
      field :id
      field :wx_user_id
      field :app_id
      field :gzh_open_id
      field :subscribe
      field :subscribe_time do
        formatted_value do
          if not value.blank?
            Time.at(value)
          end
        end
      end
      field :unsubscribe_time do
        formatted_value do
          if not value.blank?
            Time.at(value)
          end
        end
      end
      field :last_conversation_at do
        formatted_value do
          if not value.blank?
            Time.at(value)
          end
        end
      end
      include_all_fields
      field :created_at do
        visible false
      end
      field :updated_at do
        visible false
      end
    end
    show do
      include_all_fields
      field :subscribe
      field :subscribe_time do
        formatted_value do
          if not value.blank?
            Time.at(value)
          end
        end
      end
      field :unsubscribe_time do
        formatted_value do
          if not value.blank?
            Time.at(value)
          end
        end
      end
      field :last_conversation_at do
        formatted_value do
          if not value.blank?
            Time.at(value)
          end
        end
      end
      field :created_at
      field :updated_at do
        visible false
      end
    end

    edit do
      field :wx_user_id
      field :app_id
      field :gzh_open_id
    end
  end
end
