All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fastchar.captcha.action.FastCaptchaAction Maven / Gradle / Ivy

package com.fastchar.captcha.action;

import com.fastchar.captcha.out.FastOutCaptchaOfClick;
import com.fastchar.core.FastAction;
import com.fastchar.core.FastChar;

import java.util.List;

public class FastCaptchaAction extends FastAction {
    @Override
    protected String getRoute() {
        return "/captcha";
    }


    public void random() {
        response(FastChar.getOverrides().newInstance(FastOutCaptchaOfClick.class));
    }

    public void keys() {
        List contents = FastChar.getOverrides().newInstance(FastOutCaptchaOfClick.class).getContents(this);
        if (contents != null && !contents.isEmpty()) {
            responseJson(0, "获取成功!", contents);
        }
        responseJson(-1, "获取失败!暂无验证码!");
    }

    public void reset() {
        FastChar.getOverrides().newInstance(FastOutCaptchaOfClick.class).resetCaptcha(this);
        responseJson(0, "重置成功!");
    }

    public void validate() {
        List point = getParamToList("point");
        FastOutCaptchaOfClick captchaOfClick = FastChar.getOverrides().newInstance(FastOutCaptchaOfClick.class);
        if (captchaOfClick.validateCaptcha(this, point)) {
            responseJson(0, "验证成功!");
        }
        captchaOfClick.resetCaptcha(this);
        responseJson(-1, "验证失败!");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy