package com.zanxiang.game.module.mybatis.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.apache.logging.log4j.util.Strings;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author : lingfeng
 * @time : 2022-06-06
 * @description : CP表
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Builder
@TableName("t_game_gift_pack_config")
public class GameGiftPackConfig implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 超父游戏id
     */
    private Long superGameId;

    /**
     * 子游戏列表
     */
    private String gameIds;

    /**
     * 礼包码类型
     */
    private String codeTypeConfig;

    /**
     * 礼包链接域名
     */
    private String codeLinkHost;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    public List<Long> getGameIdList() {
        if (Strings.isBlank(this.gameIds)) {
            return Collections.emptyList();
        }
        return Arrays.stream(this.gameIds.split(","))
                .map(Long::valueOf)
                .collect(Collectors.toList());
    }
}