13 Commits

Author SHA1 Message Date
bamanker
1c133b59f6 用webclient重构
All checks were successful
Build Push and Deploy Image / build (push) Successful in 25m25s
2026-01-13 15:54:21 +08:00
bamanker
e33eea291c 用webclient重构 2026-01-13 15:53:46 +08:00
bamanker
6f9816a695 变更为webclient响应式客户端 2026-01-12 18:07:12 +08:00
bamanker
06cfebccab 增加探针配置
All checks were successful
Build Push and Deploy Image / build (push) Successful in 22m32s
2026-01-08 13:59:30 +08:00
bamanker
54202d8fd7 Merge remote-tracking branch 'origin/version3-native-localBuild' into version3-native-localBuild 2026-01-08 13:32:16 +08:00
bamanker
21b8d2e6e6 修改原生镜像构建参数 2026-01-08 13:32:04 +08:00
b7b3d44992 更新 README.md 2026-01-08 13:05:09 +08:00
bamanker
1cb7828acf 修改计算日期差的api,增加了结婚纪念日
Some checks failed
Build Push and Deploy Image / build (push) Failing after 33m43s
2026-01-08 13:02:46 +08:00
xue-bamanker
2929e0d1c0 修复jackson序列化/反序列化时出现Cannot construct instance of...的问题
All checks were successful
Build Push and Deploy Image / build (push) Successful in 37m1s
2026-01-07 23:57:12 +08:00
bamanker
02f9c7afdf 修改了公众号推送模板
All checks were successful
Build Push and Deploy Image / build (push) Successful in 19m51s
2026-01-07 12:58:59 +08:00
bamanker
89ebf65b7d 修复了json获取格式错误的问题 2026-01-07 12:39:05 +08:00
bamanker
693939af54 修改deployment文件存活探针的端口 2026-01-06 09:38:32 +08:00
2b9ec9e2be 修复deployment中的nodeport无效问题
All checks were successful
Build Push and Deploy Image / build (push) Successful in 20m39s
2026-01-06 00:27:07 +08:00
18 changed files with 829 additions and 318 deletions

View File

@@ -1,37 +1,27 @@
# dailyLove # dailyLove
#### 介绍 #### 介绍
公众号每日问候推送 公众号每日问候推送
#### 软件架构 #### 软件架构
软件架构说明 软件架构说明
#### 安装教程 #### 安装教程
1. xxxx 1. xxxx
2. xxxx 2. xxxx
3. xxxx 3. xxxx
#### 使用说明 #### 使用说明
1. xxxx 1. xxxx
2. xxxx 2. xxxx
3. xxxx 3. xxxx
#### 参与贡献 #### 参与贡献
1. Fork 本仓库 1. Fork 本仓库
2. 新建 Feat_xxx 分支 2. 新建 Feat_xxx 分支
3. 提交代码 3. 提交代码
4. 新建 Pull Request 4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@@ -2,17 +2,17 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
labels: labels:
app: $APP_NAME app: $APP_NAME # 标签 用于选择器
version: $APP_TAG version: $APP_TAG
name: $APP_NAME name: $APP_NAME # Deployment名称
namespace: default #一定要写名称空间 namespace: default # 一定要写名称空间
spec: spec:
progressDeadlineSeconds: 600 progressDeadlineSeconds: 600
replicas: 1 replicas: 1 # 副本数 1个 pod
revisionHistoryLimit: 2 revisionHistoryLimit: 2
selector: selector:
matchLabels: matchLabels:
app: $APP_NAME app: $APP_NAME # 选择器 匹配 pod 标签
strategy: strategy:
rollingUpdate: rollingUpdate:
maxSurge: 50% maxSurge: 50%
@@ -21,31 +21,62 @@ spec:
template: template:
metadata: metadata:
labels: labels:
app: $APP_NAME app: $APP_NAME # pod 标签
version: $APP_TAG version: $APP_TAG
spec: spec:
imagePullSecrets: imagePullSecrets:
- name: dockerhub-id #提前在项目下配置访问阿里云的账号密码 - name: dockerhub-id #提前在项目下配置访问私有镜像仓库的账号密码
containers: containers:
- image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG - name: $APP_NAME # 容器名称
name: $APP_NAME image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG # 镜像地址
imagePullPolicy: Always imagePullPolicy: Always
# 存活探针配置
livenessProbe: # 存活探针:失败意味着应用彻底挂了,需要重启来恢复 livenessProbe: # 存活探针:失败意味着应用彻底挂了,需要重启来恢复
httpGet: httpGet:
path: /test path: /actuator/health/liveness # 探针路径
port: 9090 port: 13145 # 探针端口
initialDelaySeconds: 10 # 延迟xx秒开始执行 scheme: HTTP # 协议
periodSeconds: 15 # 每隔15秒执行一次 initialDelaySeconds: 20 # 容器启动后延迟 xx秒开始检查
timeoutSeconds: 10 # 10秒未返回结果则超时 periodSeconds: 10 # 每隔 15秒检查一次
failureThreshold: 10 # 探测失败后的重试次数,当达到这个次数后就判定结果为失败 timeoutSeconds: 5 # 10秒未返回结果则超时
# successThreshold: 5 # successThreshold: 1 # 成功 1 次就认定为健康
failureThreshold: 3 # 探测失败后的重试次数,当达到这个次数后就判定结果为失败,重启容器
#就绪探针配置
readinessProbe:
httpGet:
path: /actuator/health/readiness # 探针路径
port: 13145 # 探针端口
scheme: HTTP # 协议
initialDelaySeconds: 10 # 容器启动后等 30 秒再开始检查
periodSeconds: 5 # 每 5 秒检查一次,比存活探针频繁
timeoutSeconds: 5 # 超时时间 3 秒
# successThreshold: 1 # 成功 1 次就认为就绪
failureThreshold: 2 # 失败 3 次才认为未就绪,会从负载均衡摘掉
# 启动探针配置(可选,启动慢的应用必须配)
# startupProbe:
# httpGet:
# path: /actuator/health/liveness # 用存活探针的路径
# port: 13145
# scheme: HTTP
# initialDelaySeconds: 0 # 立即开始检查
# periodSeconds: 5 # 每 5 秒检查一次
# timeoutSeconds: 3 # 超时时间 3 秒
# successThreshold: 1 # 成功 1 次就认为启动完成
# failureThreshold: 30 # 失败 30 次150 秒)才认为启动失败
# 生命周期钩子,优雅关闭
lifecycle:
preStop:
sleep:
seconds: 10 #容器停止前先等 10 秒,让流量切走
ports: ports:
- containerPort: 13145 - containerPort: 13145 # 应用端口
protocol: TCP protocol: TCP
# 资源限制
resources: resources:
limits: limits:
cpu: 99m cpu: 99m # 最多 0.1核 CPU
memory: 65Mi memory: 65Mi # 最多 65m 内存
# 环境变量配置
env: env:
- name: TZ - name: TZ
value: "Asia/Shanghai" value: "Asia/Shanghai"
@@ -65,6 +96,6 @@ spec:
- name: http - name: http
protocol: TCP protocol: TCP
port: 13145 port: 13145
nodePort: 13145 nodePort: 30045
selector: selector:
app: $APP_NAME app: $APP_NAME

51
pom.xml
View File

@@ -32,8 +32,8 @@
<java.version>25</java.version> <java.version>25</java.version>
<maven.compiler.source>25</maven.compiler.source> <maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target> <maven.compiler.target>25</maven.compiler.target>
<!-- <fastjson.version>2.0.60</fastjson.version>--> <!-- <fastjson.version>2.0.60</fastjson.version>-->
<openfeign.version>5.0.0</openfeign.version> <!-- <openfeign.version>5.0.0</openfeign.version>-->
<hutool.version>5.8.25</hutool.version> <hutool.version>5.8.25</hutool.version>
<docker.private.repository>registry.cn-chengdu.aliyuncs.com/bamanker</docker.private.repository> <docker.private.repository>registry.cn-chengdu.aliyuncs.com/bamanker</docker.private.repository>
<!-- <docker.private.repository>172.17.0.1:10888/my_work</docker.private.repository>--> <!-- <docker.private.repository>172.17.0.1:10888/my_work</docker.private.repository>-->
@@ -55,21 +55,21 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>org.springframework.cloud</groupId> <!-- <groupId>org.springframework.cloud</groupId>-->
<artifactId>spring-cloud-starter-openfeign</artifactId> <!-- <artifactId>spring-cloud-starter-openfeign</artifactId>-->
<version>${openfeign.version}</version> <!-- <version>${openfeign.version}</version>-->
</dependency> <!-- </dependency>-->
<!-- 如果需要显式指定 Jackson 3 --> <!-- 如果需要显式指定 Jackson 3 -->
<dependency> <dependency>
<groupId>tools.jackson.core</groupId> <groupId>tools.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.alibaba.fastjson2</groupId>--> <!-- <groupId>com.alibaba.fastjson2</groupId>-->
<!-- <artifactId>fastjson2</artifactId>--> <!-- <artifactId>fastjson2</artifactId>-->
<!-- <version>${fastjson.version}</version>--> <!-- <version>${fastjson.version}</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
@@ -87,6 +87,20 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId> <artifactId>spring-boot-autoconfigure</artifactId>
</dependency> </dependency>
<!-- Spring Boot Actuator提供健康检查端点 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>dailylove</finalName> <finalName>dailylove</finalName>
@@ -109,12 +123,15 @@
<buildArgs> <buildArgs>
<!--开启dashboard--> <!--开启dashboard-->
<!-- <arg>-H:DashboardDump=dailylove -H:+DashboardAll</arg>--> <!-- <arg>-H:DashboardDump=dailylove -H:+DashboardAll</arg>-->
<arg->-H:+ReportExceptionStackTraces</arg-> <buildArg>-H:+ReportExceptionStackTraces</buildArg>
<!--开启JFR--> <!--生成诊断报告-->
<arg>--enable-monitoring=jfr</arg> <buildArg>-H:+PrintAnalysisCallTree</buildArg>
<!-- <arg>&#45;&#45;gc=G1</arg>--> <!--开启监控代理-->
<buildArg>--enable-monitoring=jfr,heapdump,jvmstat</buildArg>
<!-- <arg>&#45;&#45;pgo</arg>--> <!-- <arg>&#45;&#45;pgo</arg>-->
<arg>-Ob</arg> <!---Ob: 快速构建模式,编译快但性能差点,适合开发调试-->
<buildArg>-Ob</buildArg>
<!-- <buildArg>&#45;&#45;gc=G1</buildArg>-->
<!-- <arg>-march=native</arg>--> <!-- <arg>-march=native</arg>-->
<!-- <arg>-H:+BuildReport</arg>--> <!-- <arg>-H:+BuildReport</arg>-->
</buildArgs> </buildArgs>

View File

@@ -1,17 +1,14 @@
package com.bamanker.dailylove; package com.bamanker.dailylove;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
/** /**
* @author bamanker * @author bamanker
*/ */
@SpringBootApplication @SpringBootApplication
@EnableFeignClients //@EnableFeignClients
//开启定时任务 //开启定时任务
@EnableScheduling @EnableScheduling
//@ImportAutoConfiguration({FeignAutoConfiguration.class}) //@ImportAutoConfiguration({FeignAutoConfiguration.class})

View File

@@ -1,9 +1,14 @@
package com.bamanker.dailylove.config; package com.bamanker.dailylove.config;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/**
* @descriptions
* @author bamanker
* @date 2026/1/8 12:12
* @return
*/
@Component @Component
public class DailyLoveConfigure { public class DailyLoveConfigure {
// public static String Access_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}"; // public static String Access_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";
@@ -26,6 +31,7 @@ public class DailyLoveConfigure {
public static String Color_bbir; public static String Color_bbir;
public static String Color_cbir; public static String Color_cbir;
public static String Color_loveDay; public static String Color_loveDay;
public static String Color_weddingDay;
public static String Color_remark; public static String Color_remark;
@Value("${wechat.color.tomorrow:null}") @Value("${wechat.color.tomorrow:null}")
@@ -113,6 +119,11 @@ public class DailyLoveConfigure {
Color_loveDay = color_loveDay; Color_loveDay = color_loveDay;
} }
@Value("${wechat.color.weddingDay:null}")
public void setColor_weddingDay(String color_weddingDay) {
Color_loveDay = color_weddingDay;
}
@Value("${wechat.color.remark:null}") @Value("${wechat.color.remark:null}")
public void setColor_remark(String color_remark) { public void setColor_remark(String color_remark) {
Color_remark = color_remark; Color_remark = color_remark;
@@ -182,28 +193,35 @@ public class DailyLoveConfigure {
public static String Boy_Birthday; public static String Boy_Birthday;
@Value("${DL.boy-birthday}") @Value("${DL.boy-birthday}")
public void setBoyBirthday(String BoyBirthday) { public void setBoyBirthday(String boyBirthday) {
Boy_Birthday = BoyBirthday; Boy_Birthday = boyBirthday;
} }
public static String Girl_Birthday; public static String Girl_Birthday;
@Value("${DL.girl-birthday}") @Value("${DL.girl-birthday}")
public void setGirlBirthday(String GirlBirthday) { public void setGirlBirthday(String girlBirthday) {
Girl_Birthday = GirlBirthday; Girl_Birthday = girlBirthday;
} }
public static String Cat_Birthday; public static String Cat_Birthday;
@Value("${DL.cat-birthday}") @Value("${DL.cat-birthday}")
public void setCatBirthday(String CatBirthday) { public void setCatBirthday(String catBirthday) {
Cat_Birthday = CatBirthday; Cat_Birthday = catBirthday;
} }
public static String Love_Day; public static String Love_Day;
@Value("${DL.love-day}") @Value("${DL.love-day}")
public void setLoveDay(String LoveDay) { public void setLoveDay(String loveDay) {
Love_Day = LoveDay; Love_Day = loveDay;
}
public static String Wedding_Day;
@Value("${DL.wedding-day}")
public void setWeddingDay(String weddingDay) {
Wedding_Day = weddingDay;
} }
} }

View File

@@ -1,15 +0,0 @@
package com.bamanker.dailylove.config;
import feign.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FeignConfig
{
@Bean
Logger.Level feignLoggerLevel()
{
return Logger.Level.FULL;
}
}

View File

@@ -1,11 +1,9 @@
package com.bamanker.dailylove.config; package com.bamanker.dailylove.config;
import com.bamanker.dailylove.controller.PushDailyController; import com.bamanker.dailylove.controller.PushDailyController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component //@Component
public class PushTask { public class PushTask {
final final

View File

@@ -0,0 +1,57 @@
package com.bamanker.dailylove.config;
import io.netty.handler.logging.LogLevel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;
import reactor.netty.transport.logging.AdvancedByteBufFormat;
/**
* @author bamanker
* @descriptions webclent 配置类
* @date 2026/1/12 17:33
* @return
*/
@Configuration
@Slf4j
public class WebClientConfig {
HttpClient httpClient = HttpClient.create().wiretap("reactor.netty.http.client.HttpClient",
LogLevel.DEBUG,
AdvancedByteBufFormat.TEXTUAL);
/**
* 创建WebClient Bean
*/
@Bean
public WebClient wechatWebClient() {
return WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(httpClient))
.filter((request, next) -> {
log.info("wechatRequest: {}", request.url());
return next.exchange(request);
})
.baseUrl("https://api.weixin.qq.com/cgi-bin") // 基础URL
.defaultHeader("User-Agent", "WebFlux-Client") // 默认请求头
.build();
}
@Bean
public WebClient dateRemoteClient() {
return WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(httpClient))
.filter((request, next) -> {
log.info("tianxingRequest: {}", request.url());
return next.exchange(request);
})
.baseUrl("https://apis.tianapi.com")
.defaultHeader("User-Agent", "WebFlux-Client")
.build();
}
}

View File

@@ -4,46 +4,57 @@ import cn.hutool.core.date.ChineseDate;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.bamanker.dailylove.config.DailyLoveConfigure; import com.bamanker.dailylove.config.DailyLoveConfigure;
import com.bamanker.dailylove.domain.*; import com.bamanker.dailylove.domain.*;
import com.bamanker.dailylove.service.DataRemoteClient; import com.bamanker.dailylove.service.DataRemoteService;
import com.bamanker.dailylove.service.WechatRequestClient; import com.bamanker.dailylove.service.WechatRequestService;
import com.bamanker.dailylove.utils.DataUtils; import com.bamanker.dailylove.utils.DataUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import reactor.util.function.Tuple5;
import tools.jackson.databind.JsonNode; import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.json.JsonMapper;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date; import java.util.Date;
import java.util.function.Function;
/**
* @author bamanker
* @descriptions
* @date 2026/1/8 12:04
* @return
*/
@Slf4j @Slf4j
@RestController @RestController
public class PushDailyController { public class PushDailyController {
final final
ObjectMapper mapper; JsonMapper mapper;
final final
DataRemoteClient dataRemoteClient; DataRemoteService dataRemoteService;
final final
WechatRequestClient wechatRequestClient; WechatRequestService wechatRequestService;
public PushDailyController(DataRemoteClient dataRemoteClient, WechatRequestClient wechatRequestClient, ObjectMapper mapper) { public PushDailyController(JsonMapper mapper, DataRemoteService dataRemoteService, WechatRequestService wechatRequestService) {
this.dataRemoteClient = dataRemoteClient;
this.wechatRequestClient = wechatRequestClient;
this.mapper = mapper; this.mapper = mapper;
this.dataRemoteService = dataRemoteService;
this.wechatRequestService = wechatRequestService;
} }
/** /**
* 推送晚安 * 推送晚安
* *
* @return * @return
*/ */
@GetMapping("/pushNight") @GetMapping("/pushNight")
public String pushNight() { @RegisterReflectionForBinding(Weather.class)
public Mono<String> pushNight() {
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID, ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
DailyLoveConfigure.Template_ID_Night, DailyLoveConfigure.Template_ID_Night,
@@ -53,45 +64,70 @@ public class PushDailyController {
param1.setKey(DailyLoveConfigure.TianXin_Key); param1.setKey(DailyLoveConfigure.TianXin_Key);
param1.setCity(DailyLoveConfigure.City_ID); param1.setCity(DailyLoveConfigure.City_ID);
param1.setType("7"); param1.setType("7");
String weatherResp = dataRemoteClient.getWeather(param1); Mono<String> weatherRespMono = dataRemoteService.getWeather(param1.getKey(), param1.getCity(), param1.getType());
JsonNode weatherJson = mapper.readTree(weatherResp).get("result").get(0).get("list").get(1); Mono<ResultVo> resultVoMono1 = weatherRespMono
String city = mapper.readTree(weatherResp).get("result").get(0).get("area").asString(); .map(respJson -> mapper.readTree(respJson)
// JSONObject weatherJson1 = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(1); .get("result")
// String city1 = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getString("area"); .get("area")
Weather weather = mapper.treeToValue(weatherJson, Weather.class); .toString())
.flatMap(city -> {
resultVo.setAttribute("tomorrow", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_tomorrow)); resultVo.setAttribute("city", new DataItem(city, DailyLoveConfigure.Color_city));
resultVo.setAttribute("city", new DataItem(city, DailyLoveConfigure.Color_city)); return Mono.just(resultVo);
resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather)); });
resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem)); Mono<ResultVo> resultVoMono2 = weatherRespMono
resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem)); .map(respJson -> mapper.readTree(respJson)
resultVo.setAttribute("quality", new DataItem(weather.getVis(), DailyLoveConfigure.Color_quality)); .get("result")
.get("list")
.get(1))
.map(respJson -> mapper.treeToValue(respJson, Weather.class))
.flatMap(weather -> {
resultVo.setAttribute("tomorrow", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_tomorrow));
resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather));
resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem));
resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem));
resultVo.setAttribute("quality", new DataItem(weather.getVis(), DailyLoveConfigure.Color_quality));
return Mono.just(resultVo);
});
// Mono<Tuple2<ResultVo, ResultVo>> zip = Mono.zip(resultVoMono1, resultVoMono);
TianXinReqParam param2 = new TianXinReqParam(); TianXinReqParam param2 = new TianXinReqParam();
param2.setKey(DailyLoveConfigure.TianXin_Key); param2.setKey(DailyLoveConfigure.TianXin_Key);
String tipsResp = dataRemoteClient.getTips(param2); Mono<ResultVo> resultVoMono3 = dataRemoteService.getTips(param2.getKey(), param2.getCity(), param2.getType())
String tips = mapper.readTree(tipsResp).get("result").get(0).get("content").asString(); .map(respJson -> mapper.readTree(respJson)
// String tips1 = JSONObject.parseObject(tipsResp).getJSONArray("result").getJSONObject(0).getString("content"); .get("result")
resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips)); .get("content").asString())
.flatMap(tips -> {
resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
return Mono.just(resultVo);
});
Mono<ResultVo> resultVoMono4 = dataRemoteService.getNight(param2.getKey(), param2.getCity(), param2.getType())
.map(respJson -> mapper.readTree(respJson)
.get("result")
.get("content").asString())
.flatMap(night -> {
resultVo.setAttribute("night", new DataItem(night, DailyLoveConfigure.Color_night));
return Mono.just(resultVo);
});
Mono<ResultVo> resultVoMono5 = dataRemoteService.getRainbow(param2.getKey(), param2.getCity(), param2.getType())
.map(respJson -> mapper.readTree(respJson)
.get("result")
.get("content").asString())
.flatMap(rainbow -> {
resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
return Mono.just(resultVo);
});
String nightResp = dataRemoteClient.getNight(param2); Mono<ResultVo> resultVoMono = Mono.zip(resultVoMono1, resultVoMono2, resultVoMono3, resultVoMono4, resultVoMono5)
String night = mapper.readTree(nightResp).get("result").get(0).get("content").asString(); .flatMap(new Function<Tuple5<ResultVo, ResultVo, ResultVo, ResultVo, ResultVo>, Mono<? extends ResultVo>>() {
// String night1 = JSONObject.parseObject(nightResp).getJSONArray("result").getJSONObject(0).getString("content"); @Override
resultVo.setAttribute("night", new DataItem(night, DailyLoveConfigure.Color_night)); public Mono<? extends ResultVo> apply(Tuple5<ResultVo, ResultVo, ResultVo, ResultVo, ResultVo> tuple) {
return Mono.just(tuple.getT1());
}
});
String rainbowResp = dataRemoteClient.getRainbow(param2); ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(LocalDate.now().toString()));
String rainbow = mapper.readTree(rainbowResp).get("result").get(0).get("content").asString();
// String rainbow1 = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content");
resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
// String englishResp = dataRemoteClient.getDailyEnglish(param2);
// String english = JSONObject.parseObject(englishResp).getJSONArray("result").getJSONObject(0).getString("en");
// resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn));
ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(weather.getDate()));
String festival = chineseDate.getFestivals(); String festival = chineseDate.getFestivals();
String term = chineseDate.getTerm(); String term = chineseDate.getTerm();
resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate)); resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate));
@@ -99,47 +135,60 @@ public class PushDailyController {
int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday); int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
log.debug("gbir_day:{}", girlBirthdays); log.info("gbir_days:{}", girlBirthdays);
resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays - 1 + "", DailyLoveConfigure.Color_gbir)); resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays - 1 + "", DailyLoveConfigure.Color_gbir));
int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday); int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday);
log.debug("bbir_day:{}", boyBirthdays); log.info("bbir_days:{}", boyBirthdays);
resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays - 1 + "", DailyLoveConfigure.Color_bbir)); resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays - 1 + "", DailyLoveConfigure.Color_bbir));
int catBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Cat_Birthday); int catBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Cat_Birthday);
log.debug("cbir_day:{}", catBirthdays); log.info("cbir_days:{}", catBirthdays);
resultVo.setAttribute("cbir_day", new DataItem(catBirthdays - 1 + "", DailyLoveConfigure.Color_cbir)); resultVo.setAttribute("cbir_day", new DataItem(catBirthdays - 1 + "", DailyLoveConfigure.Color_cbir));
String words = "普通的一天"; String words = "普通的一天";
if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 1) { if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 1) {
words = "明天是恋爱周年纪念日!永远爱你~mua"; words = "明天是恋爱周年纪念日!永远爱你~mua";
} else if ((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day)) % 100 == 99) { } else if ((DataUtils.getDayDiff(DailyLoveConfigure.Love_Day)) % 100 == 99) {
words = "明天是恋爱百日纪念日!提前庆祝哦~"; words = "明天是恋爱百日纪念日!提前庆祝哦~";
} else if (DataUtils.getBirthdays(DailyLoveConfigure.Wedding_Day) == 1) {
words = "明天是结婚周年纪念日!提前庆祝哦~";
} else if (girlBirthdays == 1) { } else if (girlBirthdays == 1) {
words = "明天是lili大宝贝的生日啦"; words = "明天是lili大宝贝的生日啦";
} else if (boyBirthdays == 1) { } else if (boyBirthdays == 1) {
words = "明天是ss的生日!别忘了哦~"; words = "明天是菘菘的生日!别忘了哦~";
} else if (catBirthdays == 1) { } else if (catBirthdays == 1) {
words = "明天是小离谱的生日!别忘了小鱼干!"; words = "明天是小离谱的生日!别忘了小鱼干!";
} }
resultVo.setAttribute("words", new DataItem(words, DailyLoveConfigure.Color_remark)); resultVo.setAttribute("words", new DataItem(words, DailyLoveConfigure.Color_remark));
int loveDays = DataUtils.getLoveDays(DailyLoveConfigure.Love_Day); int loveDays = DataUtils.getDayDiff(DailyLoveConfigure.Love_Day);
log.debug("love_day:{}", loveDays); log.info("love_days:{}", loveDays);
resultVo.setAttribute("love_day", new DataItem(loveDays + 1 + "", DailyLoveConfigure.Color_loveDay)); resultVo.setAttribute("love_day", new DataItem(loveDays + 1 + "", DailyLoveConfigure.Color_loveDay));
log.debug("resultVo:{}", resultVo); int weddingDays = DataUtils.getDayDiff(DailyLoveConfigure.Wedding_Day);
WechatTokenParam wechatTokenParam = new WechatTokenParam(); log.info("wedding_days:{}", weddingDays);
wechatTokenParam.setAppid(DailyLoveConfigure.App_ID); resultVo.setAttribute("wedding_day", new DataItem(weddingDays + 1 + "", DailyLoveConfigure.Color_weddingDay));
wechatTokenParam.setSecret(DailyLoveConfigure.App_Secret);
String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam); resultVoMono.flatMap(new Function<ResultVo, Mono<?>>() {
log.debug("accessTokenJson:{}", accessTokenResp); @Override
String token = mapper.readTree(accessTokenResp).get("access_token").asString(); public Mono<?> apply(ResultVo resultVo) {
// String token1 = JSONObject.parseObject(accessTokenResp).getString("access_token"); return Mono.just(resultVo);
return wechatRequestClient.sendMsg(resultVo, token); }
}).log().block();
WechatTokenParam param3 = new WechatTokenParam();
param3.setAppid(DailyLoveConfigure.App_ID);
param3.setSecret(DailyLoveConfigure.App_Secret);
String accessToken = wechatRequestService.getAccessToken(param3.getGrant_type(), param3.getAppid(), param3.getSecret())
.map(respJson -> {
return mapper.readTree(respJson)
.get("access_token").asString();
}).log().block();
return wechatRequestService.sendMsg(accessToken, resultVo).log();
} }
@@ -147,55 +196,86 @@ public class PushDailyController {
* 推送早安 * 推送早安
*/ */
@GetMapping("/pushMorning") @GetMapping("/pushMorning")
public String pushMorning() { @RegisterReflectionForBinding(Weather.class)
public Mono<String> pushMorning() {
TianXinReqParam param1 = new TianXinReqParam();
param1.setKey(DailyLoveConfigure.TianXin_Key);
param1.setCity(DailyLoveConfigure.City_ID);
param1.setType("1");
String weatherResp = dataRemoteClient.getWeather(param1);
JsonNode weatherJson = mapper.readTree(weatherResp).get("result").get(0);
Weather weather = mapper.treeToValue(weatherJson, Weather.class);
// Weather weather1 = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).toJavaObject(Weather.class);
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID, ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
DailyLoveConfigure.Template_ID_Morning, DailyLoveConfigure.Template_ID_Morning,
DailyLoveConfigure.Color_Top); DailyLoveConfigure.Color_Top);
resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_Now)); TianXinReqParam param1 = new TianXinReqParam();
resultVo.setAttribute("city", new DataItem(weather.getArea(), DailyLoveConfigure.Color_city)); param1.setKey(DailyLoveConfigure.TianXin_Key);
resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather)); param1.setCity(DailyLoveConfigure.City_ID);
resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem)); param1.setType("7");
resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem)); Mono<String> weatherRespMono = dataRemoteService.getWeather(param1.getKey(), param1.getCity(), param1.getType());
resultVo.setAttribute("quality", new DataItem(weather.getQuality(), DailyLoveConfigure.Color_quality)); Mono<ResultVo> resultVoMono1 = weatherRespMono
.map(respJson -> mapper.readTree(respJson)
.get("result")
.get("area")
.toString())
.flatMap(city -> {
resultVo.setAttribute("city", new DataItem(city, DailyLoveConfigure.Color_city));
return Mono.just(resultVo);
});
Mono<ResultVo> resultVoMono2 = weatherRespMono
.map(respJson -> mapper.readTree(respJson)
.get("result")
.get("list")
.get(0))
.map(respJson -> mapper.treeToValue(respJson, Weather.class))
.flatMap(weather -> {
resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_Now));
resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather));
resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem));
resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem));
resultVo.setAttribute("quality", new DataItem(weather.getVis(), DailyLoveConfigure.Color_quality));
return Mono.just(resultVo);
});
// Mono<Tuple2<ResultVo, ResultVo>> zip = Mono.zip(resultVoMono1, resultVoMono);
TianXinReqParam param2 = new TianXinReqParam(); TianXinReqParam param2 = new TianXinReqParam();
param2.setKey(DailyLoveConfigure.TianXin_Key); param2.setKey(DailyLoveConfigure.TianXin_Key);
// String tipsResp = dataRemoteClient.getTips(param2); Mono<ResultVo> resultVoMono3 = dataRemoteService.getTips(param2.getKey(), param2.getCity(), param2.getType())
// String tips = JSONObject.parseObject(tipsResp).getJSONArray("result").getJSONObject(0).getString("content"); .map(respJson -> mapper.readTree(respJson)
// resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips)); .get("result")
.get("content").asString())
.flatMap(tips -> {
resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
return Mono.just(resultVo);
});
Mono<ResultVo> resultVoMono4 = dataRemoteService.getMorning(param2.getKey(), param2.getCity(), param2.getType())
.map(respJson -> mapper.readTree(respJson)
.get("result")
.get("content").asString())
.flatMap(morning -> {
resultVo.setAttribute("morning", new DataItem(morning, DailyLoveConfigure.Color_morning));
return Mono.just(resultVo);
});
Mono<ResultVo> resultVoMono5 = dataRemoteService.getRainbow(param2.getKey(), param2.getCity(), param2.getType())
.map(respJson -> mapper.readTree(respJson)
.get("result")
.get("content").asString())
.flatMap(rainbow -> {
resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
return Mono.just(resultVo);
});
String morningResp = dataRemoteClient.getMorning(param2); Mono<ResultVo> resultVoMono = Mono.zip(resultVoMono1, resultVoMono2, resultVoMono3, resultVoMono4, resultVoMono5)
String morning = mapper.readTree(morningResp).get("result").get(0).get("content").asString(); .flatMap(new Function<Tuple5<ResultVo, ResultVo, ResultVo, ResultVo, ResultVo>, Mono<? extends ResultVo>>() {
// String morning1 = JSONObject.parseObject(morningResp).getJSONArray("result").getJSONObject(0).getString("content"); @Override
resultVo.setAttribute("morning", new DataItem(morning, DailyLoveConfigure.Color_morning)); public Mono<? extends ResultVo> apply(Tuple5<ResultVo, ResultVo, ResultVo, ResultVo, ResultVo> tuple) {
return Mono.just(tuple.getT1());
}
});
String rainbowResp = dataRemoteClient.getRainbow(param2);
String rainbow = mapper.readTree(rainbowResp).get("result").get(0).get("content").asString();
// String rainbow1 = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content");
resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
// String englishResp = dataRemoteClient.getDailyEnglish(param2); // String englishResp = dataRemoteClient.getDailyEnglish(param2);
// String english = JSONObject.parseObject(englishResp).getJSONArray("result").getJSONObject(0).getString("en"); // String english = JSONObject.parseObject(englishResp).getJSONArray("result").getJSONObject(0).getString("en");
// resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn)); // resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(LocalDate.now().toString()));
Date date = new Date();
String currentTime = dateFormat.format(date);
ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(currentTime));
String festival = chineseDate.getFestivals(); String festival = chineseDate.getFestivals();
String term = chineseDate.getTerm(); String term = chineseDate.getTerm();
resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate)); resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate));
@@ -203,47 +283,60 @@ public class PushDailyController {
int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday); int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
log.debug("gbir_day:{}", girlBirthdays); log.info("gbir_days:{}", girlBirthdays);
resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays + "", DailyLoveConfigure.Color_gbir)); resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays + "", DailyLoveConfigure.Color_gbir));
int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday); int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday);
log.debug("bbir_day:{}", boyBirthdays); log.info("bbir_days:{}", boyBirthdays);
resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays + "", DailyLoveConfigure.Color_bbir)); resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays + "", DailyLoveConfigure.Color_bbir));
int catBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Cat_Birthday); int catBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Cat_Birthday);
log.debug("cbir_day:{}", catBirthdays); log.info("cbir_days:{}", catBirthdays);
resultVo.setAttribute("cbir_day", new DataItem(catBirthdays + "", DailyLoveConfigure.Color_cbir)); resultVo.setAttribute("cbir_day", new DataItem(catBirthdays + "", DailyLoveConfigure.Color_cbir));
String words = "普通的一天"; String words = "普通的一天";
if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 0) { if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 0) {
words = "今天是恋爱周年纪念日!永远爱你~mua"; words = "今天是恋爱周年纪念日!永远爱你~mua";
} else if ((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day)) % 100 == 0) { } else if ((DataUtils.getDayDiff(DailyLoveConfigure.Love_Day)) % 100 == 0) {
words = "今天是恋爱百日纪念日!永远爱你~"; words = "今天是恋爱百日纪念日!永远爱你~";
} else if (DataUtils.getBirthdays(DailyLoveConfigure.Wedding_Day) == 0) {
words = "今天是结婚周年纪念日!永远爱你~";
} else if (girlBirthdays == 0) { } else if (girlBirthdays == 0) {
words = "今天是lili宝贝的生日生日快乐哟~"; words = "今天是lili宝贝的生日生日快乐哟~";
} else if (boyBirthdays == 0) { } else if (boyBirthdays == 0) {
words = "今天是ss的生日!别忘了好好爱他~"; words = "今天是菘菘的生日!别忘了好好爱他~";
} else if (catBirthdays == 0) { } else if (catBirthdays == 0) {
words = "今天是小离谱的生日!别忘了小鱼干!"; words = "今天是小离谱的生日!别忘了小鱼干!";
} }
resultVo.setAttribute("words", new DataItem(words, DailyLoveConfigure.Color_remark)); resultVo.setAttribute("words", new DataItem(words, DailyLoveConfigure.Color_remark));
int loveDays = DataUtils.getLoveDays(DailyLoveConfigure.Love_Day); int loveDays = DataUtils.getDayDiff(DailyLoveConfigure.Love_Day);
log.debug("love_day:{}", loveDays); log.info("love_days:{}", loveDays);
resultVo.setAttribute("love_day", new DataItem(loveDays + "", DailyLoveConfigure.Color_loveDay)); resultVo.setAttribute("love_day", new DataItem(loveDays + "", DailyLoveConfigure.Color_loveDay));
int weddingDays = DataUtils.getDayDiff(DailyLoveConfigure.Wedding_Day);
log.info("wedding_days:{}", weddingDays);
resultVo.setAttribute("wedding_day", new DataItem(weddingDays + "", DailyLoveConfigure.Color_weddingDay));
log.debug("resultVo:{}", resultVo); log.debug("resultVo:{}", resultVo);
WechatTokenParam wechatTokenParam = new WechatTokenParam(); WechatTokenParam wechatTokenParam = new WechatTokenParam();
wechatTokenParam.setAppid(DailyLoveConfigure.App_ID); wechatTokenParam.setAppid(DailyLoveConfigure.App_ID);
wechatTokenParam.setSecret(DailyLoveConfigure.App_Secret); wechatTokenParam.setSecret(DailyLoveConfigure.App_Secret);
String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam); resultVoMono.flatMap((Function<ResultVo, Mono<?>>) resultVo1 -> Mono.just(resultVo1)).log().block();
log.debug("accessTokenJson:{}", accessTokenResp);
String token = mapper.readTree(accessTokenResp).get("access_token").asString(); WechatTokenParam param3 = new WechatTokenParam();
// String token1 = JSONObject.parseObject(accessTokenResp).getString("access_token"); param3.setAppid(DailyLoveConfigure.App_ID);
return wechatRequestClient.sendMsg(resultVo, token); param3.setSecret(DailyLoveConfigure.App_Secret);
String accessToken = wechatRequestService.getAccessToken(param3.getGrant_type(), param3.getAppid(), param3.getSecret())
.map(respJson -> {
return mapper.readTree(respJson)
.get("access_token").asString();
}).log().block();
return wechatRequestService.sendMsg(accessToken, resultVo).log();
} }
@@ -263,5 +356,4 @@ public class PushDailyController {
System.out.println("[ " + dateFormat.format(new Date()) + " ] : messageCode=" + msgCode + ",messageContent=" + msgContent); System.out.println("[ " + dateFormat.format(new Date()) + " ] : messageCode=" + msgCode + ",messageContent=" + msgContent);
} }
} }

View File

@@ -0,0 +1,10 @@
package com.bamanker.dailylove.domain;
import lombok.Data;
@Data
public class ErrorResponse {
private Integer code;
private String message;
}

View File

@@ -0,0 +1,34 @@
package com.bamanker.dailylove.exception;
import com.bamanker.dailylove.domain.ErrorResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import reactor.core.publisher.Mono;
@ControllerAdvice
public class GlobalExceptionHandler {
/**
* 处理运行时异常
*/
@ExceptionHandler(RuntimeException.class)
public Mono<ResponseEntity<ErrorResponse>> handleRuntimeException(RuntimeException e) {
ErrorResponse error = new ErrorResponse();
error.setCode(500);
error.setMessage(e.getMessage());
return Mono.just(ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error));
}
/**
* 处理参数异常
*/
@ExceptionHandler(IllegalArgumentException.class)
public Mono<ResponseEntity<ErrorResponse>> handleIllegalArgumentException(IllegalArgumentException e) {
ErrorResponse error = new ErrorResponse();
error.setCode(400);
error.setMessage("参数错误: " + e.getMessage());
return Mono.just(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(error));
}
}

View File

@@ -1,44 +0,0 @@
package com.bamanker.dailylove.service;
import com.bamanker.dailylove.domain.TianXinReqParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
/**
* 天行数据第三方接口
* @author baman
*/
@Component
@FeignClient(value = "TianXinDataRemoteClient",url = "${tianxin.server}")
public interface DataRemoteClient {
@GetMapping(value = "/tianqi/index",
consumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE})
String getWeather(@SpringQueryMap TianXinReqParam param);
@GetMapping(value = "/caihongpi/index",
consumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE})
String getRainbow(@SpringQueryMap TianXinReqParam param);
@GetMapping(value = "/ensentence/index",
consumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE})
String getDailyEnglish(@SpringQueryMap TianXinReqParam param);
@GetMapping(value = "/qiaomen/index",
consumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE})
String getTips(@SpringQueryMap TianXinReqParam param);
@GetMapping(value = "/zaoan/index",
consumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE})
String getMorning(@SpringQueryMap TianXinReqParam param);
@GetMapping(value = "/wanan/index",
consumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE})
String getNight(@SpringQueryMap TianXinReqParam param);
}

View File

@@ -0,0 +1,89 @@
package com.bamanker.dailylove.service;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
@Service
public class DataRemoteService {
final
WebClient webClient;
public DataRemoteService(@Qualifier("dateRemoteClient") WebClient dataRemoteService) {
this.webClient = dataRemoteService;
}
public Mono<String> getWeather(String key, String city, String type) {
return webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/tianqi/index")
.queryParam("key", key)
.queryParam("city", city)
.queryParam("type", type)
.build())
.retrieve()
.bodyToMono(String.class);
}
public Mono<String> getRainbow(String key, String city, String type) {
return webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/caihongpi/index")
.queryParam("key", key)
.queryParam("city", city)
.queryParam("type", type)
.build())
.retrieve()
.bodyToMono(String.class);
}
public Mono<String> getDailyEnglish(String key, String city, String type) {
return webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/ensentence/index")
.queryParam("key", key)
.queryParam("city", city)
.queryParam("type", type)
.build())
.retrieve()
.bodyToMono(String.class);
}
public Mono<String> getTips(String key, String city, String type) {
return webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/qiaomen/index")
.queryParam("key", key)
.queryParam("city", city)
.queryParam("type", type)
.build())
.retrieve()
.bodyToMono(String.class);
}
public Mono<String> getMorning(String key, String city, String type) {
return webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/zaoan/index")
.queryParam("key", key)
.queryParam("city", city)
.queryParam("type", type)
.build())
.retrieve()
.bodyToMono(String.class);
}
public Mono<String> getNight(String key, String city, String type) {
return webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/wanan/index")
.queryParam("key", key)
.queryParam("city", city)
.queryParam("type", type)
.build())
.retrieve()
.bodyToMono(String.class);
}
}

View File

@@ -1,21 +0,0 @@
package com.bamanker.dailylove.service;
import com.bamanker.dailylove.domain.ResultVo;
import com.bamanker.dailylove.domain.WechatTokenParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Component
@FeignClient(value = "WechatRequestClient", url = "https://api.weixin.qq.com/cgi-bin")
public interface WechatRequestClient {
@GetMapping("/token")
String getAccessToken(@SpringQueryMap WechatTokenParam param);
@PostMapping("/message/template/send?access_token={token}")
String sendMsg(ResultVo resultVo, @RequestParam("token") String token);
}

View File

@@ -0,0 +1,39 @@
package com.bamanker.dailylove.service;
import com.bamanker.dailylove.domain.ResultVo;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
@Service
public class WechatRequestService {
final
WebClient webClient;
public WechatRequestService(@Qualifier("wechatWebClient") WebClient dateRemoteWebClient) {
this.webClient = dateRemoteWebClient;
}
public Mono<String> getAccessToken(String grant_type,String appid,String secret){
return webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/token")
.queryParam("grant_type", grant_type)
.queryParam("appid", appid)
.queryParam("secret", secret)
.build())
.retrieve()
.bodyToMono(String.class);
}
public Mono<String> sendMsg(String token, ResultVo resultVo){
return webClient.post()
.uri("/message/template/send?access_token={token}", token)
.bodyValue(resultVo)
.retrieve()
.bodyToMono(String.class);
}
}

View File

@@ -5,10 +5,11 @@ import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.bamanker.dailylove.config.DailyLoveConfigure; import com.bamanker.dailylove.config.DailyLoveConfigure;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.util.Strings;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@@ -28,14 +29,14 @@ public class DataUtils {
ChineseDate chineseBir = new ChineseDate(DateUtil.parseDate(DailyLoveConfigure.Boy_Birthday)); ChineseDate chineseBir = new ChineseDate(DateUtil.parseDate(DailyLoveConfigure.Boy_Birthday));
log.info("生日的农历日期是:{}", chineseBir); log.info("生日的农历日期是:{}", chineseBir);
//截取日、月 //截取日、月
String[] strings = Strings.split(boyBirthday, '-'); // String[] strings = Strings.split(boyBirthday, '-');
int chineseMonth = chineseBir.getMonth(); int chineseMonth = chineseBir.getMonth();
int chineseDay = chineseBir.getDay(); int chineseDay = chineseBir.getDay();
//获取当前日期的年 //获取当前日期的年
Calendar dateToday = Calendar.getInstance(); Calendar dateToday = Calendar.getInstance();
int todayYear = dateToday.get(Calendar.YEAR); int todayYear = dateToday.get(Calendar.YEAR);
//把生日的年改为今年,方便计算 //把生日的年改为今年,方便计算
ChineseDate chineseDate = new ChineseDate(todayYear, chineseMonth, chineseDay,false); ChineseDate chineseDate = new ChineseDate(todayYear, chineseMonth, chineseDay, false);
//农历日期对应的阳历日期 //农历日期对应的阳历日期
int gregorianDay = chineseDate.getGregorianDay(); int gregorianDay = chineseDate.getGregorianDay();
//计算时间差 //计算时间差
@@ -121,22 +122,36 @@ public class DataUtils {
return days; return days;
} }
/** // /**
* 计算恋爱天数 days // * 计算恋爱天数 days
* // *
* @param loveday // * @param loveDay
* @return // * @return
*/ // */
public static int getLoveDays(String loveday) { // public static int getLoveDays(String loveDay) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
int days = 0; // int days = 0;
try { // try {
long time = System.currentTimeMillis() - dateFormat.parse(loveday).getTime(); // long time = System.currentTimeMillis() - dateFormat.parse(loveDay).getTime();
days = (int) (time / (24 * 60 * 60 * 1000)); // days = (int) (time / (24 * 60 * 60 * 1000));
//
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return days;
// }
} catch (ParseException e) { /**
e.printStackTrace(); * @param startDay
} * @return int
return days; * @descriptions 计算日期茶 days
* @author bamanker
* @date 2026/1/8 12:38
*/
public static int getDayDiff(String startDay) {
LocalDate dateNow = LocalDate.now();
LocalDate dateStart = LocalDate.parse(startDay);
return (int) ChronoUnit.DAYS.between(dateStart, dateNow);
} }
} }

View File

@@ -15,15 +15,16 @@ DL:
boy-birthday: 1995-3-30 boy-birthday: 1995-3-30
love-day: 2022-07-16 love-day: 2022-07-16
cat-birthday: 2022-10-23 cat-birthday: 2022-10-23
wedding-day: 2025-10-08
wechat: wechat:
app-id: wxba68702957f8b93e app-id: wxba68702957f8b93e
app-secret: 834078bb149409bfca4fe693ea7c4c1c app-secret: 834078bb149409bfca4fe693ea7c4c1c
#ME: oo5bL6bK_4TC0tb-Wa5oiugTPVeQ # ME: oo5bL6bK_4TC0tb-Wa5oiugTPVeQ
#LILI: oo5bL6QafHJa9zQNYKS0fIhFC0zM #LILI: oo5bL6QafHJa9zQNYKS0fIhFC0zM
open-id: oo5bL6QafHJa9zQNYKS0fIhFC0zM open-id: oo5bL6bK_4TC0tb-Wa5oiugTPVeQ
template-id-morning: 1yx1fahCs923nOmMh0_KLWN0nXGKd8_pHQrfpdMblrQ template-id-morning: dWNAL-ZOzpBhnByFoTamt9DlJQYLB5z3ldKLvQstyU4
template-id-night: QG-5NBX-jip46ulGVsaE3Uhl30GUxvNmtKOxwMHFkx0 template-id-night: oraLiXC-8740stYc1a7mpzUFHiAIRaM3JikqibZ2grE
color: color:
now: '#99CCCC' now: '#99CCCC'
@@ -39,6 +40,7 @@ wechat:
bbir: '#FF3399' bbir: '#FF3399'
cbir: '#FF3399' cbir: '#FF3399'
loveDay: '#FF3399' loveDay: '#FF3399'
weddingDay: '#FF3399'
remark: '#FF6666' remark: '#FF6666'
city: "" city: ""
tips: "" tips: ""
@@ -52,6 +54,26 @@ tianxin:
logging: logging:
level: level:
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口可多个 reactor.netty.http.client: debug
scanclass: false
scanclass: false # Actuator 配置
management:
# 端点配置
endpoints:
web:
exposure:
# 暴露健康端点,生产环境要慎重,别把敏感信息暴露了
include: health,info
# 健康端点配置
endpoint:
health:
# 显示详细的健康信息,方便调试
# 生产环境建议设为 when-authorized需要认证才能看详情
show-details: always
# 开启探针支持,这个必须设置
probes:
enabled: true
# 在主端口上也暴露探针路径
# 这样 K8s 探针可以直接访问应用端口,不用单独配置 management 端口
add-additional-paths: true

View File

@@ -1,15 +1,31 @@
package com.bamanker.dailylove; package com.bamanker.dailylove;
import com.bamanker.dailylove.service.DataRemoteService;
import com.bamanker.dailylove.service.WechatRequestService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import tools.jackson.databind.json.JsonMapper;
@SpringBootTest @SpringBootTest
@Slf4j @Slf4j
class DailyLoveApplicationTests { class DailyLoveApplicationTests {
//
// @Resource // @Resource
// DataRemoteClient dataRemoteClient; // DataRemoteClient dataRemoteClient;
//
@Resource
DataRemoteService dataRemoteService;
@Resource
WechatRequestService wechatRequestService;
@Autowired
JsonMapper mapper;
//
// String remark = "❤"; // String remark = "❤";
// //
// @Test // @Test
@@ -89,29 +105,195 @@ class DailyLoveApplicationTests {
// @Test // @Test
// void test2() { // void test2() {
// //
// ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
// DailyLoveConfigure.Template_ID_Night,
// DailyLoveConfigure.Color_Top);
//
// TianXinReqParam param1 = new TianXinReqParam(); // TianXinReqParam param1 = new TianXinReqParam();
// param1.setKey(DailyLoveConfigure.TianXin_Key); // param1.setKey(DailyLoveConfigure.TianXin_Key);
// param1.setCity(DailyLoveConfigure.City_ID); // param1.setCity(DailyLoveConfigure.City_ID);
// param1.setType("7"); // param1.setType("7");
// String weatherJson = dataRemoteClient.getWeather(param1); // Mono<String> weatherRespMono = dataRemoteService.getWeather(param1.getKey(), param1.getCity(), param1.getType());
// log.info("weather:{}", weatherJson); // Mono<ResultVo> resultVoMono1 = weatherRespMono
// JSONObject resWeather = JSONObject.parseObject(weatherJson); // .map(respJson -> mapper.readTree(respJson)
// JSONObject result = resWeather.getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(2); // .get("result")
// .get("area")
// .toString())
// .flatMap(city -> {
// resultVo.setAttribute("city", new DataItem(city, DailyLoveConfigure.Color_city));
// return Mono.just(resultVo);
// });
// Mono<ResultVo> resultVoMono2 = weatherRespMono
// .map(respJson -> mapper.readTree(respJson)
// .get("result")
// .get("list")
// .get(1))
// .map(respJson -> mapper.treeToValue(respJson, Weather.class))
// .flatMap(weather -> {
// resultVo.setAttribute("tomorrow", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_tomorrow));
// resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather));
// resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem));
// resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem));
// resultVo.setAttribute("quality", new DataItem(weather.getVis(), DailyLoveConfigure.Color_quality));
// return Mono.just(resultVo);
// });
//// Mono<Tuple2<ResultVo, ResultVo>> zip = Mono.zip(resultVoMono1, resultVoMono);
//
//
// TianXinReqParam param2 = new TianXinReqParam();
// param2.setKey(DailyLoveConfigure.TianXin_Key);
//
// Mono<ResultVo> resultVoMono3 = dataRemoteService.getTips(param2.getKey(), param2.getCity(), param2.getType())
// .map(respJson -> mapper.readTree(respJson)
// .get("result")
// .get("content").asString())
// .flatMap(tips -> {
// resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
// return Mono.just(resultVo);
// });
// Mono<ResultVo> resultVoMono4 = dataRemoteService.getNight(param2.getKey(), param2.getCity(), param2.getType())
// .map(respJson -> mapper.readTree(respJson)
// .get("result")
// .get("content").asString())
// .flatMap(night -> {
// resultVo.setAttribute("night", new DataItem(night, DailyLoveConfigure.Color_night));
// return Mono.just(resultVo);
// });
// Mono<ResultVo> resultVoMono5 = dataRemoteService.getRainbow(param2.getKey(), param2.getCity(), param2.getType())
// .map(respJson -> mapper.readTree(respJson)
// .get("result")
// .get("content").asString())
// .flatMap(rainbow -> {
// resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
// return Mono.just(resultVo);
// });
//
// Mono<ResultVo> resultVoMono = Mono.zip(resultVoMono1, resultVoMono2, resultVoMono3, resultVoMono4, resultVoMono5)
// .flatMap(new Function<Tuple5<ResultVo, ResultVo, ResultVo, ResultVo, ResultVo>, Mono<? extends ResultVo>>() {
// @Override
// public Mono<? extends ResultVo> apply(Tuple5<ResultVo, ResultVo, ResultVo, ResultVo, ResultVo> tuple) {
// return Mono.just(tuple.getT1());
// }
// });
//
// ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(LocalDate.now().toString()));
// String festival = chineseDate.getFestivals();
// String term = chineseDate.getTerm();
// resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate));
// resultVo.setAttribute("festival", new DataItem(festival + " " + term, DailyLoveConfigure.Color_festival));
//
//
// int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday);
// log.info("gbir_days:{}", girlBirthdays);
// resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays - 1 + "", DailyLoveConfigure.Color_gbir));
//
// int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday);
// log.info("bbir_days:{}", boyBirthdays);
// resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays - 1 + "", DailyLoveConfigure.Color_bbir));
//
// int catBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Cat_Birthday);
// log.info("cbir_days:{}", catBirthdays);
// resultVo.setAttribute("cbir_day", new DataItem(catBirthdays - 1 + "", DailyLoveConfigure.Color_cbir));
//
// String words = "普通的一天";
//
// if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 1) {
// words = "明天是恋爱周年纪念日!永远爱你~mua";
// } else if ((DataUtils.getDayDiff(DailyLoveConfigure.Love_Day)) % 100 == 99) {
// words = "明天是恋爱百日纪念日!提前庆祝哦~";
// } else if (DataUtils.getBirthdays(DailyLoveConfigure.Wedding_Day) == 1) {
// words = "明天是结婚周年纪念日!提前庆祝哦~";
// } else if (girlBirthdays == 1) {
// words = "明天是lili大宝贝的生日啦";
// } else if (boyBirthdays == 1) {
// words = "明天是菘菘的生日!别忘了哦~";
// } else if (catBirthdays == 1) {
// words = "明天是小离谱的生日!别忘了小鱼干!";
// }
//
// resultVo.setAttribute("words", new DataItem(words, DailyLoveConfigure.Color_remark));
//
// int loveDays = DataUtils.getDayDiff(DailyLoveConfigure.Love_Day);
// log.info("love_days:{}", loveDays);
// resultVo.setAttribute("love_day", new DataItem(loveDays + 1 + "", DailyLoveConfigure.Color_loveDay));
//
// int weddingDays = DataUtils.getDayDiff(DailyLoveConfigure.Wedding_Day);
// log.info("wedding_days:{}", weddingDays);
// resultVo.setAttribute("wedding_day", new DataItem(weddingDays + 1 + "", DailyLoveConfigure.Color_weddingDay));
//
// resultVoMono.flatMap(new Function<ResultVo, Mono<?>>() {
// @Override
// public Mono<?> apply(ResultVo resultVo) {
// return Mono.just(resultVo);
// }
// }).log().block();
//
// WechatTokenParam param3 = new WechatTokenParam();
// param3.setAppid(DailyLoveConfigure.App_ID);
// param3.setSecret(DailyLoveConfigure.App_Secret);
//
// String accessToken = wechatRequestService.getAccessToken(param3.getGrant_type(), param3.getAppid(), param3.getSecret())
// .map(respJson -> {
// return mapper.readTree(respJson)
// .get("access_token").asString();
// }).log().block();
// wechatRequestService.sendMsg(accessToken, resultVo).log().block();
// String tips = mapper.readTree(tipsResp).get("result").get("content").asString();
// log.info("weather:{}", weatherResp);
// JsonNode weatherJson = mapper.readTree(weatherResp).get("result").get("list").get(1);
// System.out.println("-----------------------------");
// System.out.println(weatherJson);
// String city = mapper.readTree(weatherResp).get("result").get("area").asString();
// System.out.println("-----------------------------");
// System.out.println(city);
// Weather weather = mapper.treeToValue(weatherJson, Weather.class);
// System.out.println("-----------------------------");
// System.out.println(weather);
//
// resultVo.setAttribute("tomorrow", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_tomorrow));
// resultVo.setAttribute("city", new DataItem(city, DailyLoveConfigure.Color_city));
// resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather));
// resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem));
// resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem));
// resultVo.setAttribute("quality", new DataItem(weather.getVis(), DailyLoveConfigure.Color_quality));
//
// System.out.println("-----------------------------");
// System.out.println(resultVo);
// TianXinReqParam param2 = new TianXinReqParam();
// param2.setKey(DailyLoveConfigure.TianXin_Key);
//
// String tipsResp = dataRemoteClient.getTips(param2);
// String tips = mapper.readTree(tipsResp).get("result").get("content").asString();
//
// System.out.println("-----------------------------");
// System.out.println(tips);
//
// TianXinReqParam param1 = new TianXinReqParam();
// param1.setKey(DailyLoveConfigure.TianXin_Key);
// param1.setCity(DailyLoveConfigure.City_ID);
// param1.setType("1");
// String weatherResp = dataRemoteClient.getWeather(param1);
// JsonNode weatherJson = mapper.readTree(weatherResp).get("result");
// Weather weather = mapper.treeToValue(weatherJson, Weather.class);
//
// System.out.println("-----------------------------");
// System.out.println(weather);
// log.info("----result----:{}", result); // log.info("----result----:{}", result);
// Weather weather = result.toJavaObject(Weather.class);
// log.info("weather:{}", weather);
// ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(weather.getDate())); //}
// System.out.println("--------------55555----------"+weather.getDate());
// System.out.println("------------------------"+chineseDate);
//
//
// }
// //
// //
// @Test // @Test
// void test1() { // void test1() {
// int loveDays = getBirthdays("2023-05-14"); // int weddingDays = DataUtils.getWeddingDays("2025-10-08");
// log.info("-------------------------------{}", loveDays); // log.info("wedding_days:{}", weddingDays);
// } // }
// //
// public static int getLoveDays(String loveday) { // public static int getLoveDays(String loveday) {
@@ -185,6 +367,6 @@ class DailyLoveApplicationTests {
// log.info("resultVo:{}", resultVo); // log.info("resultVo:{}", resultVo);
// }
} }
//}