package me.qwq.doghouse.entity.config;

import java.io.Serializable;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import lombok.Data;
import lombok.experimental.Accessors;
import me.qwq.doghouse.annotation.ConfigInfo;
import me.qwq.doghouse.enums.PostTypeEnum;
import me.qwq.doghouse.interfaces.IConfig;
import me.qwq.doghouse.interfaces.IPostTypeConfig;

@SuppressWarnings("serial")
@Data
@Accessors(chain=true)
@ConfigInfo(field="wiki", name="Wiki 设置", initDefault=true)
public class WikiConfig implements Serializable, IConfig<WikiConfig>, IPostTypeConfig<WikiConfig> {
    
    private static final Boolean DEFAULT_WIKI_MODE = false;
    private static final String DEFAULT_NAME = "DoguWiki";
    private static final String DEFAULT_DESCRIPTION = "Doghouse 个人 Wiki 系统";
    private static final String DEFAULT_KEYWORDS = "Doghouse, doghouse wiki, doguwiki,维基,知识库,狗洞";
    private static final String DEFAULT_COPYRIGHT = "Doghouse";
    private static final Long DEFAULT_PAGE_SIZE = 3L;
    private static final Long DEFAULT_COMMENT_PAGE_SIZE = 5L;
    private static final Long DEFAULT_RECENT_SIZE = 6L;
    private static final Long DEFAULT_POPULAR_SIZE = 6L;
    private static final Long DEFAULT_TAG_SIZE = 8L;
    private static final Long DEFAULT_RECENT_COMMENT_SIZE = 6L;
    private static final Integer DEFAULT_RECENT_COMMENT_LEVEL = 3;
    

    @NotBlank
    private Boolean wikiMode = DEFAULT_WIKI_MODE;
    
    @NotBlank
    private String name = DEFAULT_NAME;

    @NotBlank
    private String description = DEFAULT_DESCRIPTION;

    private String keywords = DEFAULT_KEYWORDS;
    
    private String copyright = DEFAULT_COPYRIGHT;
    
    @NotNull
    @Size(min=0)
    private Long commentPageSize = DEFAULT_COMMENT_PAGE_SIZE;
    @NotNull
    @Size(min=0)
    private Long recentSize = DEFAULT_RECENT_SIZE;
    @NotNull
    @Size(min=0)
    private Long popularSize = DEFAULT_POPULAR_SIZE;
    @NotNull
    @Size(min=0)
    private Long tagSize = DEFAULT_TAG_SIZE;
    @NotNull
    @Size(min=0)
    private Long recentCommentSize = DEFAULT_RECENT_COMMENT_SIZE;
    @NotNull
    @Size(min=0)
    private Integer recentCommentLevel = DEFAULT_RECENT_COMMENT_LEVEL;

    private Boolean addToSitemap = true;
    
    private Boolean addToFeed = false;
    
    public PostTypeEnum getPostType() {
        return PostTypeEnum.WIKI;
    }
    
    public Boolean getEnabled() {
        return getWikiMode();
    }
    
    public Long getPageSize() {
        return DEFAULT_PAGE_SIZE;
    }

    public String getMappingPrefix() {
        return "/wiki";
    }
    
    public String getTemplatePrefix() {
        return "wiki";
    }
}
