package com.apobates.forum.thrones.controller.form;

import com.apobates.forum.utils.Commons;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Positive;

/**
 *
 * @author xiaofanku
 * @since 20200522
 */
public class TopicForm extends ActionForm {
    @NotBlank(message="{NotBlank.topicForm.volumes}")
    @Positive(message="{Positive.topicForm.volumes}")
    private String volumes;
    @NotBlank(message="{NotBlank.topicForm.board}")
    @Positive(message="{Positive.topicForm.board}")
    private String board;
    @NotBlank(message="{NotBlank.topicForm.title}")
    private String title;
    @NotBlank(message="{NotBlank.topicForm.content}")
    private String content;
    //TopicCategory.id
    @NotBlank(message="{NotBlank.topicForm.category}")
    @Min(value=0, message="{Min.topicForm.category}")
    private String category;
    //可选项:boolean类型,true(1)是,false(0)不是
    private String anony;
    
    public String getBoard() {
        return board;
    }
    
    public long getLongBoard() {
        return covertStringToLong(getBoard(), 0L);
    }
    
    public void setBoard(String board) {
        this.board = board;
    }
    
    public String getTitle() {
        return Commons.isNotBlank(title) ? Commons.htmlPurifier(title.trim()) : "";
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getContent() {
        return Commons.isNotBlank(content) ? content.trim() : "";
    }
    
    public void setContent(String content) {
        this.content = content;
    }
    
    public String getVolumes() {
        return volumes;
    }
    
    public int getIntegerVolumes() {
        return covertStringToInteger(getVolumes(), -1);
    }
    
    public void setVolumes(String volumes) {
        this.volumes = volumes;
    }
    
    public boolean isEmptyParameter() {
        return getVolumes().equals("-1") && getBoard().equals("0");
    }
    
    public String getCategory() {
        return category;
    }
    
    public void setCategory(String category) {
        this.category = category;
    }
    
    public int getIntegerCategory() {
        return covertStringToInteger(getCategory(), 0);
    }
    
    public String getAnony() {
        return anony;
    }
    
    public void setAnony(String anony) {
        this.anony = anony;
    }
    
    public boolean getBooleanAnony(){
        return covertStringToBoolean(getAnony());
    }
}