package cn.qinys.platform.base.config.kaptcha;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component;

/**
 * Description:
 *
 * @author tanlie
 * Date: 2024/2/4 18:14
 */
@Component
@Data
@ConfigurationProperties(prefix = "captcha")
public class CaptchaProperties {
    /**
     * 宽度
     */
    private Integer width = 200;
    /**
     * 高度
     */
    private Integer height = 50;
    /**
     * 内容
     */
    @NestedConfigurationProperty
    private Content content = new Content();
    /**
     * 背景色
     */
    @NestedConfigurationProperty
    private BackgroundColor backgroundColor = new BackgroundColor();
    /**
     * 字体
     */
    @NestedConfigurationProperty
    private Font font = new Font();
    /**
     * 边框
     */
    @NestedConfigurationProperty
    private Border border = new Border();

    @Data
    public static class BackgroundColor {
        /**
         * 开始渐变色
         */
        private String from = "lightGray";
        /**
         * 结束渐变色
         */
        private String to = "white";
    }

    @Data
    public static class Content {
        /**
         * 内容源
         */
        private String source = "abcdefghjklmnpqrstuvwxyz23456789";
        /**
         * 内容长度
         */
        private Integer length = 4;
        /**
         * 内容间隔
         */
        private Integer space = 2;
    }

    @Data
    public static class Border {
        /**
         * 是否开启
         */
        private Boolean enabled = false;
        /**
         * 颜色
         */
        private String color = "white";
        /**
         * 厚度
         */
        private Integer thickness = 1;
    }

    @Data
    public static class Font {
        /**
         * 名称
         */
        private String name = "Arial";
        /**
         * 颜色
         */
        private String color = "black";
        /**
         * 大小
         */
        private Integer size = 40;
    }
}
