package com.red.circle.console.infra.enums.sys;

import com.red.circle.tool.core.text.StringUtils;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * banner展示位置.
 *
 * @author pengliang on 2021/7/1
 */
public enum BannerDisplayPositionEnum {

  ROOM("房间内"),

  EXPLORE_PAGE("发现页"),

  WALLET("钱包"),

  HOME_ALERT("首页弹出层");

  private final String desc;

  BannerDisplayPositionEnum(String desc) {
    this.desc = desc;
  }

  public static String getDescValues(String names) {
    if (StringUtils.isBlank(names)) {
      return StringUtils.UNKNOWN;
    }
    return Arrays.stream(names.split(","))
        .map(name -> Arrays.stream(BannerDisplayPositionEnum.values())
            .filter(
                bannerDisplayPositionEnum -> Objects.equals(bannerDisplayPositionEnum.name(), name))
            .findFirst()
            .map(BannerDisplayPositionEnum::getDesc)
            .orElse(StringUtils.UNKNOWN))
        .collect(Collectors.joining(","));
  }

  public String getDesc() {
    return desc;
  }
}
