35 lines
962 B
Java
Raw Normal View History

2022-06-22 18:07:21 +08:00
package com.xkrs.microservice.controller;
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import java.util.Locale;
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
/**
* HelloController
* @author tajochen
*/
@RestController
public class HelloController {
/**
* 获取区域信息
*/
Locale locale = LocaleContextHolder.getLocale();
/**
* 返回类型为Mono<String>
* @return
*/
@GetMapping("/hello")
public Mono<String> hello() {
// 【改】使用Mono.just生成响应式数据
return Mono.just(outputEncapsulationObject(PromptMessageEnum.SUCCESS,"Welcome to reactive world ~",locale));
}
}