Compare commits
2 Commits
v2.1-local
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12bbeaa39f | ||
|
|
f297aa823a |
@@ -1,3 +0,0 @@
|
|||||||
*
|
|
||||||
!target/dailylove*
|
|
||||||
!Dockerfile
|
|
||||||
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
FROM ubuntu:jammy-20231004
|
|
||||||
MAINTAINER bamanker
|
|
||||||
ARG NATIVE_FILE
|
|
||||||
ENV NATIVE_FILE=${NATIVE_FILE}
|
|
||||||
COPY target/${NATIVE_FILE} /home/${NATIVE_FILE}/app
|
|
||||||
EXPOSE 13145
|
|
||||||
WORKDIR /home/${NATIVE_FILE}/out
|
|
||||||
ENTRYPOINT /home/${NATIVE_FILE}/app -XX:StartFlightRecording='filename=recording.jfr,dumponexit=true,duration=10s'
|
|
||||||
12
LICENSE
Normal file
12
LICENSE
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Copyright (c) 2023 bamanker
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
# dailyLove
|
# dailyLove
|
||||||
|
|
||||||
#### 介绍
|
#### 介绍
|
||||||
公众号每日问候推送
|
|
||||||
|
|
||||||
#### 软件架构
|
#### 软件架构
|
||||||
软件架构说明
|
软件架构说明
|
||||||
|
|||||||
108
pom.xml
108
pom.xml
@@ -5,24 +5,22 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.1.5</version>
|
<version>2.4.3</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.bamanker</groupId>
|
<groupId>com.bamanker</groupId>
|
||||||
<artifactId>dailylove</artifactId>
|
<artifactId>dailyLove</artifactId>
|
||||||
<version>v2.1-local</version>
|
<version>0.1.3</version>
|
||||||
<name>dailyLove</name>
|
<name>dailyLove</name>
|
||||||
<description>dailylove</description>
|
<description>dailyLove</description>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>17</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<fastjson.version>2.0.21</fastjson.version>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<openfeign.version>3.1.5</openfeign.version>
|
||||||
<fastjson.version>2.0.25</fastjson.version>
|
<nacos.version>2021.1</nacos.version>
|
||||||
<openfeign.version>4.0.4</openfeign.version>
|
<hutool.version>5.8.10</hutool.version>
|
||||||
<hutool.version>5.8.18</hutool.version>
|
|
||||||
<docker.private.repository>172.17.0.1:10888/my_work</docker.private.repository>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -30,6 +28,25 @@
|
|||||||
<artifactId>hutool-core</artifactId>
|
<artifactId>hutool-core</artifactId>
|
||||||
<version>${hutool.version}</version>
|
<version>${hutool.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
<version>3.1.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
<version>${nacos.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
<version>${nacos.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
@@ -46,86 +63,27 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.graalvm.buildtools</groupId>
|
|
||||||
<artifactId>native-maven-plugin</artifactId>
|
|
||||||
<version>0.9.27</version>
|
|
||||||
<!--为本机映像程序添加配置,生成的配置文件位于
|
|
||||||
META-INF/native-image/groupID/artifactID/native-image.properties
|
|
||||||
也可以手动配置-->
|
|
||||||
<configuration>
|
|
||||||
<buildArgs>
|
|
||||||
<!--开启dashboard-->
|
|
||||||
<!-- <arg>-H:DashboardDump=dailylove -H:+DashboardAll</arg>-->
|
|
||||||
<arg->-H:+ReportExceptionStackTraces</arg->
|
|
||||||
<!--开启JFR-->
|
|
||||||
<arg>--enable-monitoring=jfr</arg>
|
|
||||||
<arg>--gc=G1</arg>
|
|
||||||
<!-- <arg>--pgo</arg>-->
|
|
||||||
<arg>-Ob</arg>
|
|
||||||
<!-- <arg>-march=native</arg>-->
|
|
||||||
<arg>-H:+BuildReport</arg>
|
|
||||||
</buildArgs>
|
|
||||||
<!--启动详细输出-->
|
|
||||||
<verbose>true</verbose>
|
|
||||||
<!--配置jvm参数-->
|
|
||||||
<!-- <jvmArgs>
|
|
||||||
</jvmArgs>-->
|
|
||||||
<!--<agent>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<options>
|
|
||||||
<option>experimental-class-loader-support</option>
|
|
||||||
</options>
|
|
||||||
</agent>-->
|
|
||||||
</configuration>
|
|
||||||
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>com.xenoamess.docker</groupId>
|
|
||||||
<artifactId>dockerfile-maven-plugin</artifactId>
|
|
||||||
<version>1.5.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>default</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>build</goal>
|
|
||||||
<goal>push</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<username>bamanker</username>
|
|
||||||
<password>Fz8803101</password>
|
|
||||||
<repository>${docker.private.repository}/${project.artifactId}</repository>
|
|
||||||
<tag>${project.version}</tag>
|
|
||||||
<buildArgs>
|
|
||||||
<NATIVE_FILE>${project.artifactId}</NATIVE_FILE>
|
|
||||||
</buildArgs>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,20 +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.EnableFeignClients;
|
||||||
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
|
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author bamanker
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableFeignClients
|
@EnableFeignClients
|
||||||
//开启定时任务
|
//开启定时任务
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
//@ImportAutoConfiguration({FeignAutoConfiguration.class})
|
|
||||||
public class DailyLoveApplication {
|
public class DailyLoveApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -1,138 +0,0 @@
|
|||||||
package com.bamanker.dailylove.config;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ClassUtil;
|
|
||||||
import jakarta.annotation.PostConstruct;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 反射将所有项目类扫描加入到服务, 大力出奇迹的操作,感觉不太合适,不过先让服务跑起来
|
|
||||||
*
|
|
||||||
* @author bamanker
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class ClassReflectConfig {
|
|
||||||
|
|
||||||
static boolean begin = true;
|
|
||||||
|
|
||||||
@Value("${scanclass}")
|
|
||||||
private Boolean scanclass;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ThreadPoolTaskExecutor executorService;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void init() {
|
|
||||||
|
|
||||||
if (scanclass) {
|
|
||||||
System.err.println("配置文件下 scanclass 开启了生成反射类");
|
|
||||||
} else {
|
|
||||||
System.err.println("配置文件下 scanclass 关闭了生成反射类");
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (ClassReflectConfig.class) {
|
|
||||||
if (begin && scanclass) {
|
|
||||||
begin = false;
|
|
||||||
executorService.submit(() -> {
|
|
||||||
|
|
||||||
// {
|
|
||||||
// // 先抓取上一次的文件,生成
|
|
||||||
// try {
|
|
||||||
// BufferedReader utf8Reader = ResourceUtil
|
|
||||||
// .getUtf8Reader("classpath:/META-INF/native-image/reflect-config.json");
|
|
||||||
// String res = utf8Reader.lines().collect(Collectors.joining());
|
|
||||||
// List object = ProJsonUtil.toObject(res, List.class);
|
|
||||||
// for (Object object2 : object) {
|
|
||||||
// try {
|
|
||||||
// Map object22 = (Map) object2;
|
|
||||||
// handlerClass(Class.forName(ProMapUtil.getStr(object22, "name")));
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// log.error("生成文件异常", e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
{
|
|
||||||
// 扫描系统第二级开始的包
|
|
||||||
String packageName = ClassReflectConfig.class.getPackageName();
|
|
||||||
String proPackageName = packageName.substring(0,
|
|
||||||
packageName.indexOf(".", packageName.indexOf(".") + 1));
|
|
||||||
|
|
||||||
// 可以在这个地方,添加除了服务以外其他的包,将会加入反射,以供graalvm生成配置
|
|
||||||
List<String> asList = Arrays.asList(proPackageName);
|
|
||||||
|
|
||||||
for (String spn : asList) {
|
|
||||||
try {
|
|
||||||
Set<Class<?>> doScan = ClassUtil.scanPackage(spn);
|
|
||||||
for (Class clazz : doScan) {
|
|
||||||
handlerClass(clazz);
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// handlerClass(RedisMessageListenerContainer.class);
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handlerClass(Class clazz) {
|
|
||||||
if (clazz.equals(ClassReflectConfig.class)) {
|
|
||||||
// 跳过自己,避免形成循环
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
executorService.submit(() -> {
|
|
||||||
try {
|
|
||||||
System.err.println("反射注入:" + clazz.getName());
|
|
||||||
// 生成所有的构造器
|
|
||||||
Constructor[] declaredConstructors = clazz.getDeclaredConstructors();
|
|
||||||
// 找到无参构造器然后实例化
|
|
||||||
Constructor declaredConstructor = clazz.getDeclaredConstructor();
|
|
||||||
declaredConstructor.setAccessible(true);
|
|
||||||
Object newInstance = declaredConstructor.newInstance();
|
|
||||||
Method[] methods = clazz.getDeclaredMethods();
|
|
||||||
for (Method method : methods) {
|
|
||||||
try {
|
|
||||||
// 实例化成功,那么调用一下
|
|
||||||
method.setAccessible(true);
|
|
||||||
// graalvm必须需要声明方法
|
|
||||||
method.invoke(newInstance);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Field[] fields = clazz.getDeclaredFields();
|
|
||||||
for (Field field : fields) {
|
|
||||||
try {
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.getType();
|
|
||||||
String name = field.getName();
|
|
||||||
field.get(newInstance);
|
|
||||||
|
|
||||||
} catch (Throwable e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.err.println("反射注入完成:" + clazz.getName());
|
|
||||||
} catch (Throwable e) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,7 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@RefreshScope
|
||||||
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}";
|
||||||
// public static String Send_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
|
// public static String Send_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
|
||||||
|
|||||||
@@ -8,13 +8,9 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class PushTask {
|
public class PushTask {
|
||||||
|
|
||||||
final
|
@Autowired
|
||||||
PushDailyController pushDailyController;
|
PushDailyController pushDailyController;
|
||||||
|
|
||||||
public PushTask(PushDailyController pushDailyController) {
|
|
||||||
this.pushDailyController = pushDailyController;
|
|
||||||
}
|
|
||||||
|
|
||||||
//每日 早上7.30,晚上22点 定时推送
|
//每日 早上7.30,晚上22点 定时推送
|
||||||
@Scheduled(cron = "0 30 7 * * ?")
|
@Scheduled(cron = "0 30 7 * * ?")
|
||||||
public void scheduledPushMorning(){
|
public void scheduledPushMorning(){
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ import com.bamanker.dailylove.service.DataRemoteClient;
|
|||||||
import com.bamanker.dailylove.service.WechatRequestClient;
|
import com.bamanker.dailylove.service.WechatRequestClient;
|
||||||
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.beans.factory.annotation.Autowired;
|
|
||||||
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 jakarta.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -21,17 +20,12 @@ import java.util.Date;
|
|||||||
@RestController
|
@RestController
|
||||||
public class PushDailyController {
|
public class PushDailyController {
|
||||||
|
|
||||||
final
|
@Resource
|
||||||
DataRemoteClient dataRemoteClient;
|
DataRemoteClient dataRemoteClient;
|
||||||
|
|
||||||
final
|
@Resource
|
||||||
WechatRequestClient wechatRequestClient;
|
WechatRequestClient wechatRequestClient;
|
||||||
|
|
||||||
public PushDailyController(DataRemoteClient dataRemoteClient, WechatRequestClient wechatRequestClient) {
|
|
||||||
this.dataRemoteClient = dataRemoteClient;
|
|
||||||
this.wechatRequestClient = wechatRequestClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送晚安
|
* 推送晚安
|
||||||
*
|
*
|
||||||
@@ -104,7 +98,7 @@ public class PushDailyController {
|
|||||||
|
|
||||||
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.getLoveDays(DailyLoveConfigure.Love_Day)) % 100 == 1) {
|
||||||
words = "明天是恋爱百日纪念日!提前庆祝哦~";
|
words = "明天是恋爱百日纪念日!提前庆祝哦~";
|
||||||
} else if (girlBirthdays == 1) {
|
} else if (girlBirthdays == 1) {
|
||||||
words = "明天是lili大宝贝的生日啦";
|
words = "明天是lili大宝贝的生日啦";
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.bamanker.dailylove.controller;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author bamanker
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
public class TestController {
|
|
||||||
|
|
||||||
@GetMapping("/test")
|
|
||||||
public String test(){
|
|
||||||
return "test ok!!!!!!!!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,11 +2,24 @@ server:
|
|||||||
port: 13145
|
port: 13145
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
profiles:
|
||||||
|
active: prob
|
||||||
application:
|
application:
|
||||||
name: dailyLove
|
name: dailyLove
|
||||||
cloud:
|
cloud:
|
||||||
refresh:
|
nacos:
|
||||||
enabled: false
|
config:
|
||||||
|
server-addr: ${url.nacos} # nacos地址配置中心
|
||||||
|
file-extension: yaml
|
||||||
|
group: Group1
|
||||||
|
|
||||||
|
discovery:
|
||||||
|
#持久化实例 ture为临时实例 false为持久化实例 临时实例发生异常直接剔除, 而持久化实例等待恢复
|
||||||
|
ephemeral: true
|
||||||
|
#注册中心地址
|
||||||
|
server-addr: ${url.nacos}
|
||||||
|
url:
|
||||||
|
nacos: 127.0.0.1:8848
|
||||||
|
|
||||||
DL:
|
DL:
|
||||||
tianxin-key: 72fbbb9e75e338ea6a240e83972f287c
|
tianxin-key: 72fbbb9e75e338ea6a240e83972f287c
|
||||||
@@ -53,5 +66,3 @@ tianxin:
|
|||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口(可多个)
|
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口(可多个)
|
||||||
|
|
||||||
scanclass: false
|
|
||||||
@@ -13,140 +13,138 @@ import org.bouncycastle.util.Strings;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static com.bamanker.dailylove.utils.DataUtils.getBirthdays;
|
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@Slf4j
|
@Slf4j
|
||||||
class DailyLoveApplicationTests {
|
class DailyLoveApplicationTests {
|
||||||
|
|
||||||
// @Resource
|
@Resource
|
||||||
// DataRemoteClient dataRemoteClient;
|
DataRemoteClient dataRemoteClient;
|
||||||
//
|
|
||||||
// String remark = "❤";
|
String remark = "❤";
|
||||||
//
|
|
||||||
// @Test
|
@Test
|
||||||
// void test4(){
|
void test4(){
|
||||||
// log.info("mark: {}",205%100);
|
log.info("mark: {}",205%100);
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
// @Test
|
@Test
|
||||||
// void test3() {
|
void test3() {
|
||||||
//
|
|
||||||
//
|
|
||||||
// //获取输入的生日
|
//获取输入的生日
|
||||||
// String boyBirthday = DailyLoveConfigure.Boy_Birthday;
|
String boyBirthday = DailyLoveConfigure.Boy_Birthday;
|
||||||
// //获取农历生日
|
//获取农历生日
|
||||||
// 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();
|
||||||
// //计算时间差
|
//计算时间差
|
||||||
// long days = haveThisDay(chineseMonth, chineseDay, dateToday, todayYear, chineseDate, gregorianDay);
|
long days = haveThisDay(chineseMonth, chineseDay, dateToday, todayYear, chineseDate, gregorianDay);
|
||||||
// log.info("days:{}", days);
|
log.info("days:{}", days);
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 需要递归计算日期差
|
* 需要递归计算日期差
|
||||||
// *
|
*
|
||||||
// * @param chineseMonth 农历月
|
* @param chineseMonth 农历月
|
||||||
// * @param chineseDay 农历日
|
* @param chineseDay 农历日
|
||||||
// * @param dateToday 今天的日期类
|
* @param dateToday 今天的日期类
|
||||||
// * @param todayYear 当前的年
|
* @param todayYear 当前的年
|
||||||
// * @param chineseDate 组装的待计算的新日期
|
* @param chineseDate 组装的待计算的新日期
|
||||||
// * @param gregorianDay 判断是否存在农历日期的参数,-1代表今年不存在这个农历日期
|
* @param gregorianDay 判断是否存在农历日期的参数,-1代表今年不存在这个农历日期
|
||||||
// * @return 计算好的天数
|
* @return 计算好的天数
|
||||||
// */
|
*/
|
||||||
// private static long haveThisDay(int chineseMonth, int chineseDay, Calendar dateToday, int todayYear, ChineseDate chineseDate, int gregorianDay) {
|
private static long haveThisDay(int chineseMonth, int chineseDay, Calendar dateToday, int todayYear, ChineseDate chineseDate, int gregorianDay) {
|
||||||
// //判断当前年份是否存在农历日对应的阳历日
|
//判断当前年份是否存在农历日对应的阳历日
|
||||||
// while (gregorianDay == -1) {
|
while (gregorianDay == -1) {
|
||||||
// //不存在,计算明年
|
//不存在,计算明年
|
||||||
// todayYear += 1;
|
todayYear += 1;
|
||||||
// chineseDate = new ChineseDate(todayYear, chineseMonth, chineseDay, false);
|
chineseDate = new ChineseDate(todayYear, chineseMonth, chineseDay, false);
|
||||||
// gregorianDay = chineseDate.getGregorianDay();
|
gregorianDay = chineseDate.getGregorianDay();
|
||||||
// }
|
}
|
||||||
// //存在
|
//存在
|
||||||
// //将农历日期改为阳历日期
|
//将农历日期改为阳历日期
|
||||||
// Calendar gregorianbir = chineseDate.getGregorianCalendar();
|
Calendar gregorianbir = chineseDate.getGregorianCalendar();
|
||||||
// //判断这个日期是否和今年是同一年
|
//判断这个日期是否和今年是同一年
|
||||||
// if (todayYear == dateToday.get(Calendar.YEAR)) {
|
if (todayYear == dateToday.get(Calendar.YEAR)) {
|
||||||
// //是同一年,判断这一天过了没
|
//是同一年,判断这一天过了没
|
||||||
// if (gregorianbir.get(Calendar.DAY_OF_YEAR) < dateToday.get(Calendar.DAY_OF_YEAR)) {
|
if (gregorianbir.get(Calendar.DAY_OF_YEAR) < dateToday.get(Calendar.DAY_OF_YEAR)) {
|
||||||
// //这一天过了,计算明年
|
//这一天过了,计算明年
|
||||||
// todayYear += 1;
|
todayYear += 1;
|
||||||
// chineseDate = new ChineseDate(todayYear, chineseMonth, chineseDay, false);
|
chineseDate = new ChineseDate(todayYear, chineseMonth, chineseDay, false);
|
||||||
// gregorianDay = chineseDate.getGregorianDay();
|
gregorianDay = chineseDate.getGregorianDay();
|
||||||
// //递归计算下一年是否存在对应的阳历日
|
//递归计算下一年是否存在对应的阳历日
|
||||||
// return haveThisDay(chineseMonth, chineseDay, dateToday, todayYear, chineseDate, gregorianDay);
|
return haveThisDay(chineseMonth, chineseDay, dateToday, todayYear, chineseDate, gregorianDay);
|
||||||
// }
|
}
|
||||||
// //没有过,直接计算
|
//没有过,直接计算
|
||||||
// }
|
}
|
||||||
// //不是同一年,直接计算
|
//不是同一年,直接计算
|
||||||
// Date time = dateToday.getTime();
|
Date time = dateToday.getTime();
|
||||||
// log.info("当前的日期是:{}", time);
|
log.info("当前的日期是:{}", time);
|
||||||
// Date time1 = gregorianbir.getTime();
|
Date time1 = gregorianbir.getTime();
|
||||||
// log.info("下一个生日的日期:{}", time1);
|
log.info("下一个生日的日期:{}", time1);
|
||||||
// return DateUtil.between(dateToday.getTime(), gregorianbir.getTime(), DateUnit.DAY);
|
return DateUtil.between(dateToday.getTime(), gregorianbir.getTime(), DateUnit.DAY);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test
|
@Test
|
||||||
// void test2() {
|
void test2() {
|
||||||
//
|
|
||||||
// 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);
|
String weatherJson = dataRemoteClient.getWeather(param1);
|
||||||
// log.info("weather:{}", weatherJson);
|
log.info("weather:{}", weatherJson);
|
||||||
// JSONObject resWeather = JSONObject.parseObject(weatherJson);
|
JSONObject resWeather = JSONObject.parseObject(weatherJson);
|
||||||
// JSONObject result = resWeather.getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(2);
|
JSONObject result = resWeather.getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(2);
|
||||||
// log.info("----result----:{}", result);
|
log.info("----result----:{}", result);
|
||||||
// Weather weather = result.toJavaObject(Weather.class);
|
Weather weather = result.toJavaObject(Weather.class);
|
||||||
// log.info("weather:{}", weather);
|
log.info("weather:{}", weather);
|
||||||
// ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(weather.getDate()));
|
ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(weather.getDate()));
|
||||||
// System.out.println("--------------55555----------"+weather.getDate());
|
System.out.println("--------------55555----------"+weather.getDate());
|
||||||
// System.out.println("------------------------"+chineseDate);
|
System.out.println("------------------------"+chineseDate);
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Test
|
@Test
|
||||||
// void test1() {
|
void test1() {
|
||||||
// int loveDays = getBirthdays("2023-05-14");
|
int loveDays = getLoveDays("2021-07-16");
|
||||||
// log.info("-------------------------------{}", loveDays);
|
log.info("-------------------------------{}", loveDays);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// 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) {
|
} catch (ParseException e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// }
|
}
|
||||||
// return days;
|
return days;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test
|
@Test
|
||||||
// void contextLoads() {
|
void contextLoads() {
|
||||||
// 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);
|
||||||
@@ -203,6 +201,6 @@ class DailyLoveApplicationTests {
|
|||||||
// log.info("resultVo:{}", resultVo);
|
// log.info("resultVo:{}", resultVo);
|
||||||
|
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
target/dailylove
BIN
target/dailylove
Binary file not shown.
Reference in New Issue
Block a user