1.add base64 image check code

main
Gary 1 year ago
parent 7afe8ac7f7
commit e94411c6d8

@ -1,7 +1,9 @@
package com.luoo.user.controller; package com.luoo.user.controller;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Base64;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -165,6 +167,28 @@ public class LoginController extends BaseController {
redisTemplate.opsForValue().set(redisKey, code, 10, TimeUnit.MINUTES); redisTemplate.opsForValue().set(redisKey, code, 10, TimeUnit.MINUTES);
vCode.write(response.getOutputStream()); vCode.write(response.getOutputStream());
} }
/**
* 4.1Base64
* @return
*/
@ApiOperation(value = "4.1获取图行验证码Base64", notes = "4.三次短信验证失败后获取图形验证码Base64有效期10分钟")
@ApiImplicitParams({ @ApiImplicitParam(name = "deviceId", value = "设备id", required = true) })
@GetMapping("/imageCheckCodeBase64/{deviceId}")
@GlobalInterceptor
public Result<String> imageCheckCodeBase64(HttpServletResponse response,
@VerifyParam(required = true) @PathVariable("deviceId") String deviceId) throws IOException {
CreateImageCode vCode = new CreateImageCode(130, 38, 5, 10);
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/jpeg");
String code = vCode.getCode();
String redisKey = Constants.REDIS_KEY_IMAGE_CHECK_CODE + deviceId;
redisTemplate.opsForValue().set(redisKey, code, 10, TimeUnit.MINUTES);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
vCode.write(bos);
return Result.success(Base64.getEncoder().encodeToString(bos.toByteArray()));
}
/** /**
* *

Loading…
Cancel
Save