package com.yutou.biliapi.bean.live.database;

import com.alibaba.fastjson2.annotation.JSONField;
import com.yutou.biliapi.bean.websocket.live.WSSendGift;
import com.yutou.common.databases.AbsDatabasesBean;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class LiveGiftDatabaseBean extends AbsDatabasesBean {
    @JSONField(name = "id")
    int id;
    @JSONField(name = "gift_id")
    private int giftId;
    @JSONField(name = "gift_name")
    private String giftName;
    @JSONField(name = "price")
    private long price;
    @JSONField(name = "coin_type")
    private String coinType;
    @JSONField(name = "icon")
    private String icon;
    @JSONField(name = "gift_num")
    private int giftNum;
    @JSONField(name = "sender_uid")
    private long senderUid;
    @JSONField(name = "sender_name")
    private String senderName;
    @JSONField(name = "sender_face")
    private String senderFace;
    @JSONField(name = "send_time")
    private long sendTime;
    @JSONField(name = "action")
    private String action;


    public LiveGiftDatabaseBean() {
        super("gift",System.currentTimeMillis());
    }

    public LiveGiftDatabaseBean(WSSendGift gift) {
        super("gift",gift.getWs_timer());
        giftId = gift.getData().getGiftId();
        giftName = gift.getData().getGiftName();
        price = gift.getData().getPrice();
        coinType = gift.getData().getCoinType();
        icon = gift.getData().getGiftInfo().getWebp();
        if (gift.getData().getComboSend() != null) {
            giftNum = gift.getData().getComboSend().getGiftNum();
        } else {
            giftNum = 1;
        }
        senderUid = gift.getData().getSenderUinfo().getUid();
        senderName = gift.getData().getSenderUinfo().getBase().getName();
        senderFace = gift.getData().getSenderUinfo().getBase().getFace();
        sendTime = gift.getData().getTimestamp();
        action = gift.getData().getAction();
    }
}
