forked from kidgrow-microservices-platform

zhaoxiaohao
2021-03-08 3cc66f911c6a7b0d55ddb58c67e16963195ea351
kidgrow-uaa/kidgrow-uaa-server/src/main/java/com/kidgrow/oauth2/controller/ValidateCodeController.java
@@ -7,6 +7,7 @@
import com.wf.captcha.base.Captcha;
import com.wf.captcha.utils.CaptchaUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
@@ -33,13 +34,15 @@
     *
     * @throws Exception
     */
    @GetMapping(SecurityConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX + "/{deviceId}")
    @GetMapping(value=SecurityConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX + "/{deviceId}",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    public void createCode(@PathVariable String deviceId, HttpServletResponse response) throws Exception {
        Assert.notNull(deviceId, "机器码不能为空");
        // 设置请求头为输出图片类型
        CaptchaUtil.setHeader(response);
        // 三个参数分别为宽、高、位数
//        GifCaptcha gifCaptcha = new GifCaptcha(100, 35, 4,new Font("actionj", 1, 32));
        GifCaptcha gifCaptcha = new GifCaptcha(100, 35, 4);
//        gifCaptcha.setFont(Captcha.FONT_1);
        // 设置类型:字母数字混合
        gifCaptcha.setCharType(Captcha.TYPE_DEFAULT);
        // 保存验证码