package com.pingcap.community.blogserver.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotEmpty;
import java.util.List;


@Validated
@Configuration
@ConfigurationProperties(prefix = "blog")
@Data
public class BlogConfig {

  @NotEmpty
  private String baseURL = "https://tidb.net/blog";

  private List<String> corsAllowedOrigins;

  /**
   * The post score calc result can be affected by adjusting the weight of
   * the number of likes on the post.
   */
  private Integer postLikesWeight = 43200;

  // The post score calc result can be affected by adjusting the weight of
  // the number of comments on the post.
  private Integer postCommentsWeight = 21600;

  // The post score calc result can be affected by adjusting the weight of
  // the number of visit on the post, default is 0, which means no affect.
  private Integer postVisitsWeight = 0;

  private VisitUnrepeatedMode visitUnrepeatedMode = VisitUnrepeatedMode.SESSION_ID;

  public enum VisitUnrepeatedMode {
    IP,
    SESSION_ID,
    SSID
  }

}

