|  |  |  | 
|---|
|  |  |  | package com.ruoyi.gateway.handler; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.http.HttpStatus; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @author ruoyi | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class ValidateCodeHandler implements HandlerFunction<ServerResponse> | 
|---|
|  |  |  | { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ValidateCodeService validateCodeService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Mono<ServerResponse> handle(ServerRequest serverRequest) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | AjaxResult ajax; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ajax = validateCodeService.createCaptcha(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (CaptchaException | IOException e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return Mono.error(e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public class ValidateCodeHandler implements HandlerFunction<ServerResponse> { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ValidateCodeService validateCodeService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Mono<ServerResponse> handle(ServerRequest serverRequest) { | 
|---|
|  |  |  | AjaxResult ajax; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | ajax = validateCodeService.createCaptcha(); | 
|---|
|  |  |  | } catch (CaptchaException | IOException e) { | 
|---|
|  |  |  | return Mono.error(e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ServerResponse.status(HttpStatus.OK).body(BodyInserters.fromValue(ajax)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|