From 4ae7bd543792d1930764f2e966af5930b1d7dd44 Mon Sep 17 00:00:00 2001 From: Bunny <1319900154@qq.com> Date: Wed, 7 Aug 2024 23:42:45 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20feat(=E6=96=B0=E5=A2=9E):=20Flux?= =?UTF-8?q?=E5=92=8CMono=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/pom.xml | 11 ++++ .../service/controller/WebFluxController.java | 55 +++++++++++++++++++ .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/application-prod.yml | 3 +- service/src/main/resources/quartz.properties | 2 +- .../resources/templates/email-template.html | 45 --------------- 6 files changed, 69 insertions(+), 49 deletions(-) create mode 100644 service/src/main/java/cn/bunny/service/controller/WebFluxController.java delete mode 100644 service/src/main/resources/templates/email-template.html diff --git a/service/pom.xml b/service/pom.xml index 8f04bc8..8a3483e 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -56,6 +56,17 @@ spring-context-support 6.1.6 + + + org.springframework.boot + spring-boot-starter-webflux + 3.3.2 + + + io.netty + netty-codec-http + 4.1.111.Final + diff --git a/service/src/main/java/cn/bunny/service/controller/WebFluxController.java b/service/src/main/java/cn/bunny/service/controller/WebFluxController.java new file mode 100644 index 0000000..c422371 --- /dev/null +++ b/service/src/main/java/cn/bunny/service/controller/WebFluxController.java @@ -0,0 +1,55 @@ +package cn.bunny.service.controller; + +import cn.bunny.pojo.result.Result; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.util.ArrayList; + +@Tag(name = "webflux测试i请求接口") +@RequestMapping("/api") +@RestController +public class WebFluxController { + + @Operation(summary = "Mono测试") + @GetMapping("test1") + public Mono> test1() { + Result result = Result.success("测试成功啦,第一个Mono"); + return Mono.just(result); + } + + @Operation(summary = "Flux测试") + @GetMapping("test2") + public Flux>> test2() { + ArrayList list = new ArrayList<>() { + { + add("Flux测试,返回的是数组"); + add("数组啊啊啊啊"); + } + }; + Result> result = Result.success(list); + + return Flux.just(result); + } + + + @Operation(summary = "模仿ChatGPT") + @GetMapping("test3") + public Flux test3() { + ArrayList list = new ArrayList<>() { + { + add("Flux测试,返回的是数组"); + add("数组啊啊啊啊"); + } + }; + Result> result = Result.success(list); + + return Flux.range(1, 10).map(i -> "输出:" + i).delayElements(Duration.ofMillis(500)); + } +} diff --git a/service/src/main/resources/application-dev.yml b/service/src/main/resources/application-dev.yml index 887030d..f274f49 100644 --- a/service/src/main/resources/application-dev.yml +++ b/service/src/main/resources/application-dev.yml @@ -4,4 +4,4 @@ bunny: port: 3306 sqlData: myDS username: root - password: "123456" + password: "02120212" diff --git a/service/src/main/resources/application-prod.yml b/service/src/main/resources/application-prod.yml index 1ca2051..c069989 100644 --- a/service/src/main/resources/application-prod.yml +++ b/service/src/main/resources/application-prod.yml @@ -4,8 +4,7 @@ bunny: port: 3306 sqlData: myDS username: root - password: "123456" - + password: "02120212" knife4j: enable: true diff --git a/service/src/main/resources/quartz.properties b/service/src/main/resources/quartz.properties index ff9d99b..eab2048 100644 --- a/service/src/main/resources/quartz.properties +++ b/service/src/main/resources/quartz.properties @@ -7,5 +7,5 @@ org.quartz.jobStore.dataSource=myDS org.quartz.dataSource.myDS.driver=com.mysql.cj.jdbc.Driver org.quartz.dataSource.myDS.URL=jdbc:mysql://192.168.3.98:3306/myDS?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true org.quartz.dataSource.myDS.user=root -org.quartz.dataSource.myDS.password=123456 +org.quartz.dataSource.myDS.password=02120212 org.quartz.dataSource.myDS.maxConnections=5 \ No newline at end of file diff --git a/service/src/main/resources/templates/email-template.html b/service/src/main/resources/templates/email-template.html deleted file mode 100644 index b2b89b4..0000000 --- a/service/src/main/resources/templates/email-template.html +++ /dev/null @@ -1,45 +0,0 @@ - -
- - - - - - - - - - -
-

BunnyBBS邮箱验证码

-
-
-

- 尊敬的用户, -

-

- 感谢您注册我们的产品. 您的账号正在进行电子邮件验证. -

-

- 验证码为: ${verifyCode} -

-

- 验证码的有效期只有一分钟,请抓紧时间进行验证吧! -

-

- 如果非本人操作,请忽略此邮件 -

-
-
-

- XXXXX
- Contact us: XXXXXXX@qq.com -

-

- This is an automated email, please do not reply.
- © Company Name -

-
-
- \ No newline at end of file