package com.pingcap.community.blogserver.dto;

import com.pingcap.community.blogserver.entity.Category;
import com.pingcap.community.blogserver.entity.Tag;
import com.pingcap.community.blogserver.enums.PostOrigin;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

@Data
public class CreatePostDTO {

  @Length(max = 100, message = "标题长度不能超过 100 个字符")
  private String title = "";

  @Length(max = 100000, message = "文章内容不能超过 100000 个字符，建议分开多篇文章发布")
  private String content = "";

  private PostOrigin origin = PostOrigin.ORIGINAL;

  @Length(max = 512, message = "文章来源链接长度不能超过 512 个字符")
  private String sourceURL;

  @Length(max = 512, message = "封面图片链接长度不能超过 512 个字符")
  private String coverImageURL;

  @ArraySchema(schema = @Schema(type = "number"))
  @Size(max = 5, message = "单篇文章最多只能添加 5 个标签")
  private List<Tag> tags = new ArrayList<>();

  // Notice: If the category is empty when creating the post,
  // the default uncategorized will be used.
  @Schema(type = "number")
  private Category category;

}
