package com.tzld.piaoquan.recommend.server.service.rank.bo;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class UserShareReturnProfile {
    private long s_pv;                  // share_pv(分享pv)
    private long s_cnt;                 // share_cnt(分享次数)
    private long r_pv;                  // return_pv(回流pv)
    private long r_uv;                  // return_uv(回流uv)
    private long m_s_cnt;               // max_share_cnt(最大分享次数)
    private long m_r_uv;                // max_return_uv(最大回流uv)
    private List<UserSRBO> m_s_s;    // max_share_seq(最大分享序列)
    private List<UserSRBO> m_r_s;   // max_return_seq(最大回流序列)
    private List<UserSRBO> l_s_s;    // last_share_seq(最近分享序列)
    private List<UserSRBO> l_r_s;   // last_return_seq(最近n层回流序列)
    private List<UserSRBO> l_r1_s;   // last_return_seq(最近1层回流序列)
    private Map<String, VideoAttrSRBO> c1_s;   // cate1_seq(merge_first_level_cate序列-回流率)
    private Map<String, VideoAttrSRBO> c2_s;   // cate2_seq(merge_second_level_cate序列-回流率)
    private Map<String, VideoAttrSRBO> d_k_s;
    private Map<String, VideoAttrSRBO> l1_s;   // label1_seq(festive_label1序列-回流率)
    private Map<String, VideoAttrSRBO> l2_s;   // label2_seq(festive_label2序列-回流率)

    public void setM_s_s(String data) {
        this.m_s_s = JSON.parseArray(data, UserSRBO.class);
    }

    public void setM_r_s(String data) {
        this.m_r_s = JSON.parseArray(data, UserSRBO.class);
    }

    public void setL_s_s(String data) {
        this.l_s_s = JSON.parseArray(data, UserSRBO.class);
    }

    public void setL_r_s(String data) {
        this.l_r_s = JSON.parseArray(data, UserSRBO.class);
    }

    public void setL_r1_s(String data) {
        this.l_r1_s = JSON.parseArray(data, UserSRBO.class);
    }

    public void setC1_s(String data) {
        this.c1_s = parseVideoAttrSR(data);
    }

    public void setC2_s(String data) {
        this.c2_s = parseVideoAttrSR(data);
    }

    public void setD_k_s(String data) {
        this.d_k_s = parseVideoAttrSR(data);
    }

    public void setL1_s(String data) {
        this.l1_s = parseVideoAttrSR(data);
    }

    public void setL2_s(String data) {
        this.l2_s = parseVideoAttrSR(data);
    }

    private Map<String, VideoAttrSRBO> parseVideoAttrSR(String data) {
        Map<String, VideoAttrSRBO> map = new HashMap<>();
        if (null != data && !data.isEmpty()) {
            List<VideoAttrSRBO> list = JSON.parseArray(data, VideoAttrSRBO.class);
            if (null != list) {
                for (VideoAttrSRBO v : list) {
                    if (null != v) {
                        map.put(v.getNa(), v);
                    }
                }
            }
        }
        return map;
    }
}