修复idea 不适当的阻塞方法调用

pull/183/head
1332987 3 years ago
parent 7cb3f04883
commit 0556dbd111

@ -3,7 +3,6 @@ package com.ruoyi.gateway.handler;
import com.ruoyi.common.core.exception.CaptchaException; import com.ruoyi.common.core.exception.CaptchaException;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.gateway.service.ValidateCodeService; import com.ruoyi.gateway.service.ValidateCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.BodyInserters;
@ -12,7 +11,7 @@ import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import java.io.IOException; import javax.annotation.Resource;
/** /**
* *
@ -21,7 +20,7 @@ import java.io.IOException;
*/ */
@Component @Component
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> { public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
@Autowired @Resource
private ValidateCodeService validateCodeService; private ValidateCodeService validateCodeService;
@Override @Override
@ -29,9 +28,9 @@ public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
AjaxResult ajax; AjaxResult ajax;
try { try {
ajax = validateCodeService.createCaptcha(); ajax = validateCodeService.createCaptcha();
} catch (CaptchaException | IOException e) { return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax));
} catch (CaptchaException e) {
return Mono.error(e); return Mono.error(e);
} }
return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax));
} }
} }

@ -18,7 +18,7 @@ public interface ValidateCodeService {
* @throws IOException / * @throws IOException /
* @throws CaptchaException / * @throws CaptchaException /
*/ */
public AjaxResult createCaptcha() throws IOException, CaptchaException; public AjaxResult createCaptcha() throws CaptchaException;
/** /**
* *

@ -43,7 +43,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
* *
*/ */
@Override @Override
public AjaxResult createCaptcha() throws IOException, CaptchaException { public AjaxResult createCaptcha() throws CaptchaException {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
boolean captchaOnOff = captchaProperties.getEnabled(); boolean captchaOnOff = captchaProperties.getEnabled();
ajax.put("captchaOnOff", captchaOnOff); ajax.put("captchaOnOff", captchaOnOff);

Loading…
Cancel
Save