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

import com.apobates.forum.core.ImageIOMeta;
import java.util.Optional;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Positive;

/**
 *
 * @author xiaofanku
 * @since 20200614
 */
public class TopicCarouselSlideForm extends ActionForm {
    //int,轮播图ID
    @NotBlank(message="{NotBlank.TopicCarouselSlideForm.carousel}")
    @Positive(message="{Positive.TopicCarouselSlideForm.carousel}")
    private String carousel;
    @NotBlank(message="{NotBlank.TopicCarouselSlideForm.title}")
    private String title;
    @NotBlank(message="{NotBlank.TopicCarouselSlideForm.link}")
    private String link;
    @NotBlank(message="{NotBlank.TopicCarouselSlideForm.ranking}")
    @Positive(message="{Positive.TopicCarouselSlideForm.ranking}")
    private String ranking;
    //上传后的图片地址
    @NotBlank(message="{NotBlank.TopicCarouselSlideForm.fileurl}")
    private String fileurl;
    //数据库中保存的编码后的图片地址
    //@NotBlank(message="{NotBlank.TopicCarouselSlideForm.imageAddr}")
    private String imageAddr;
    
    public String getCarousel() {
        return carousel;
    }
    
    public void setCarousel(String carousel) {
        this.carousel = carousel;
    }
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getLink() {
        return link;
    }
    
    public void setLink(String link) {
        this.link = link;
    }
    
    public String getRanking() {
        return ranking;
    }
    
    public void setRanking(String ranking) {
        this.ranking = ranking;
    }
    
    public int getIntegerRanking() {
        return covertStringToInteger(getRanking(), 1);
    }
    
    public int getIntegerCarousel() {
        return covertStringToInteger(getCarousel(), 0);
    }
    
    public String getFileurl() {
        return fileurl;
    }
    
    public void setFileurl(String fileurl) {
        this.fileurl = fileurl;
    }
    
    public Optional<String> getEncodePictureAddr(ImageIOMeta imageIOMeta){
        return encodeUploadImageURL(imageIOMeta, getFileurl());
    }
    
    public String getImageAddr() {
        return imageAddr;
    }
    
    public void setImageAddr(String imageAddr) {
        this.imageAddr = imageAddr;
    }
}