package com.tiesheng.core.pojos.dto;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.captcha.generator.RandomGenerator;

public class ImageCodeDTO {

    private Integer lineCount;
    private Integer width;
    private Integer height;


    /**
     * 构建线条图形码
     *
     * @return
     */
    public LineCaptcha lineCaptcha() {
        if (lineCount == null || lineCount < 100) {
            lineCount = 100;
        }
        if (width == null) {
            width = 220;
        }
        if (height == null) {
            height = 62;
        }
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(width, height, 4, lineCount);
        lineCaptcha.setGenerator(new RandomGenerator("0123456789", 4));

        return lineCaptcha;
    }


    ///////////////////////////////////////////////////////////////////////////
    // setter\getter
    ///////////////////////////////////////////////////////////////////////////

    public Integer getLineCount() {
        return lineCount;
    }

    public void setLineCount(Integer lineCount) {
        this.lineCount = lineCount;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }
}

