|
|
@@ -32,8 +32,6 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -90,26 +88,21 @@ public class AppHelpGoodsController {
|
|
|
* 创建道具验证码
|
|
|
*/
|
|
|
@ApiLog("创建道具验证码")
|
|
|
- @PostMapping("/createPropsVerificationCode")
|
|
|
+ @GetMapping("/createPropsVerificationCode")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@ApiOperation(value = "创建道具验证码")
|
|
|
- public void createPropsVerificationCode(@ApiParam(value = "道具ID", required = true) @RequestParam Long helpGoodsId,
|
|
|
- @ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
- @ApiParam(value = "作品ID", required = true) @RequestParam Long productId,
|
|
|
- HttpServletResponse response) {
|
|
|
+ public R<String> createPropsVerificationCode(@ApiParam(value = "道具ID", required = true) @RequestParam Long helpGoodsId,
|
|
|
+ @ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
+ @ApiParam(value = "作品ID", required = true) @RequestParam Long productId) {
|
|
|
// 自定义纯数字的验证码(随机4位数字,可重复)
|
|
|
RandomGenerator randomGenerator = new RandomGenerator("0123456789", 4);
|
|
|
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
|
|
|
lineCaptcha.setGenerator(randomGenerator);
|
|
|
// 重新生成code
|
|
|
lineCaptcha.createCode();
|
|
|
- try {
|
|
|
- //创建验证码,并放到缓存中,有效期60秒
|
|
|
- bladeRedis.setEx(HelpGoodsConstant.getVerificationCodeKey(userId, productId, helpGoodsId), lineCaptcha.getCode(), HelpGoodsConstant.HELP_GOODS_VERIFICATION_CODE_EXIST_TIME);
|
|
|
- lineCaptcha.write(response.getOutputStream());
|
|
|
- } catch (IOException e) {
|
|
|
- log.error(e.getMessage());
|
|
|
- }
|
|
|
+ //创建验证码,并放到缓存中,有效期60秒
|
|
|
+ bladeRedis.setEx(HelpGoodsConstant.getVerificationCodeKey(userId, productId, helpGoodsId), lineCaptcha.getCode(), HelpGoodsConstant.HELP_GOODS_VERIFICATION_CODE_EXIST_TIME);
|
|
|
+ return R.data(lineCaptcha.getImageBase64Data());
|
|
|
}
|
|
|
|
|
|
/**
|