Compare commits
1 Commits
v3.0.6-nat
...
v2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5784db0746 |
@@ -1,170 +0,0 @@
|
|||||||
name: Build Push and Deploy Image
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
#tag 触发
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
# 分支触发
|
|
||||||
# branches:
|
|
||||||
# - main
|
|
||||||
workflow_dispatch: #手动构建h
|
|
||||||
|
|
||||||
#设置全局环境变量
|
|
||||||
env:
|
|
||||||
PATH: /opt/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
||||||
REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
|
|
||||||
IMAGE_NAMESPACE: bamanker # todo 可以通过读取pom文件获取下面这些属性值
|
|
||||||
IMAGE_NAME: dailylove
|
|
||||||
APP_NAME: daily-love
|
|
||||||
|
|
||||||
# 构建 Job
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-node22 # 如果host构建:linux_amd64
|
|
||||||
# container:
|
|
||||||
# image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/ghcr.io/catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Print system info 1
|
|
||||||
run: echo " The job was automatically triggered by a ${{ gitea.event_name }} event."
|
|
||||||
|
|
||||||
- name: Print system info 2
|
|
||||||
run: echo " This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
|
||||||
|
|
||||||
- name: Print system info 3
|
|
||||||
run: echo " The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
|
||||||
|
|
||||||
- name: Print env
|
|
||||||
run: env && blkid
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
apt-get update &&
|
|
||||||
apt-get install -y gettext &&
|
|
||||||
apt-get install -y maven &&
|
|
||||||
apt-get install -y sudo &&
|
|
||||||
apt-get install -y iptables
|
|
||||||
|
|
||||||
- name: Set up Docker
|
|
||||||
uses: http://139.9.216.111:3000/bamanker/setup-docker-action@v4.6.0
|
|
||||||
with:
|
|
||||||
# 版本大于28会有兼容性问题
|
|
||||||
version: type=archive,channel=stable,version=v27.4.0
|
|
||||||
daemon-config: |
|
|
||||||
{
|
|
||||||
"registry-mirrors":["https://docker.1ms.run"],
|
|
||||||
"dns": ["8.8.8.8", "114.114.114.114"]
|
|
||||||
}
|
|
||||||
- name: Generate maven config
|
|
||||||
uses: http://139.9.216.111:3000/bamanker/maven-settings-action@v3.1.0
|
|
||||||
with:
|
|
||||||
mirrors: '[{"id": "alimaven", "name": "aliyun maven", "mirrorOf": "central", "url": "http://maven.aliyun.com/nexus/content/groups/public/"}]'
|
|
||||||
|
|
||||||
# - uses: http://localhost:3000/bamanker/setup-node@v6
|
|
||||||
# with:
|
|
||||||
# node-version: 24
|
|
||||||
# cache: 'npm'
|
|
||||||
# - run: node -v
|
|
||||||
# 下载仓库源码,依赖node环境,因此构建服务器本地需要下载安装node并设置环境变量
|
|
||||||
|
|
||||||
- name: Checkout repository code
|
|
||||||
#使用自定义仓库action
|
|
||||||
uses: http://139.9.216.111:3000/bamanker/checkout@v4
|
|
||||||
|
|
||||||
# 获取 TAG 并设置为环境变量
|
|
||||||
- name: Get version
|
|
||||||
id: get_version
|
|
||||||
# e.g. refs/tags/v1.0.0
|
|
||||||
run: |
|
|
||||||
echo "APP_TAG=${GITHUB_REF/refs\/tags\/v}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
# 检查 TAG 并传参
|
|
||||||
- name: Set envVar
|
|
||||||
id: set_envar
|
|
||||||
run: |
|
|
||||||
echo "The app version is $APP_TAG" && echo "tag=$APP_TAG" >> $GITHUB_OUTPUT &&
|
|
||||||
echo "now workspace: ${{ github.workspace }}"
|
|
||||||
|
|
||||||
# 为其他配置文件注入环境变量
|
|
||||||
- name: Inject envVar
|
|
||||||
run: |
|
|
||||||
envsubst < ./deployment-temp.yml > ./deployment.yml &&
|
|
||||||
cat ./deployment.yml
|
|
||||||
|
|
||||||
# 安装java环境
|
|
||||||
- name: Set up Java
|
|
||||||
uses: http://139.9.216.111:3000/bamanker/setup-graalvm@v1
|
|
||||||
with:
|
|
||||||
distribution: 'graalvm'
|
|
||||||
java-version: '25.0.1'
|
|
||||||
cache: 'maven'
|
|
||||||
# maven 构建
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn clean native:compile -DskipTests -Pnative
|
|
||||||
|
|
||||||
# 登录镜像仓库,方便后续上传镜像
|
|
||||||
- name: Login to Docker Registry
|
|
||||||
uses: http://139.9.216.111:3000/bamanker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
|
|
||||||
# # 获取时间戳
|
|
||||||
# - name: Get datetime
|
|
||||||
# id: datetime
|
|
||||||
# run: |
|
|
||||||
# echo "datetime=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
# 构建并上传镜像
|
|
||||||
- name: Build and push Docker image
|
|
||||||
# uses: http://139.9.216.111:3000/bamanker/build-push-action@v4
|
|
||||||
# 获取上一步截取到的版本号,既 1.0.0
|
|
||||||
#只能这样接收
|
|
||||||
env:
|
|
||||||
TAG: ${{ steps.set_envar.outputs.tag }}
|
|
||||||
run: |
|
|
||||||
ls &&
|
|
||||||
docker build --file Dockerfile --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} . &&
|
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
|
||||||
|
|
||||||
# uses: http://139.9.216.111:3000/bamanker/docker-build-push@v5
|
|
||||||
# with:
|
|
||||||
# context: .
|
|
||||||
## platforms: linux/amd64
|
|
||||||
# file: Dockerfile
|
|
||||||
# push: true
|
|
||||||
# tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
|
||||||
|
|
||||||
#发布到 k8s
|
|
||||||
#安装 kubectl
|
|
||||||
- name: Setup kubectl
|
|
||||||
run: |
|
|
||||||
curl -LO "https://dl.k8s.io/release/v1.33.0/bin/linux/amd64/kubectl" &&
|
|
||||||
chmod +x kubectl &&
|
|
||||||
mv kubectl /usr/local/bin/
|
|
||||||
|
|
||||||
- name: Configure kubeconfig
|
|
||||||
# 假设您的 KUBE_CONFIG 秘密是 Base64 编码的 kubeconfig 文件内容
|
|
||||||
run: |
|
|
||||||
# 1. 创建 ~/.kube 目录
|
|
||||||
mkdir -p $HOME/.kube
|
|
||||||
|
|
||||||
# 2. 将 Base64 编码的 KUBE_CONFIG 秘密解码并写入默认配置文件
|
|
||||||
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > $HOME/.kube/config
|
|
||||||
|
|
||||||
# 3. 确保 kubectl 知道配置文件的位置 (可选, 但安全)
|
|
||||||
echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Deploy with kubectl
|
|
||||||
run: |
|
|
||||||
kubectl apply -f ./deployment.yml
|
|
||||||
|
|
||||||
- name: k8s Check Pods Health
|
|
||||||
run: |
|
|
||||||
kubectl get pod -n default -l app=${{ env.APP_NAME }}
|
|
||||||
|
|
||||||
- name: k8s Update Deployment
|
|
||||||
run: |
|
|
||||||
kubectl rollout restart deployment ${{ env.APP_NAME }}
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,6 @@
|
|||||||
HELP.md
|
HELP.md
|
||||||
target/
|
target/
|
||||||
.mvn/wrapper/maven-wrapper.jar
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
!**/src/main/**/target/
|
!**/src/main/**/target/
|
||||||
!**/src/test/**/target/
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
|||||||
11
.idea/.gitignore
generated
vendored
11
.idea/.gitignore
generated
vendored
@@ -1,11 +0,0 @@
|
|||||||
# 默认忽略的文件
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# 已忽略包含查询文件的默认文件夹
|
|
||||||
/queries/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
# 基于编辑器的 HTTP 客户端请求
|
|
||||||
/httpRequests/
|
|
||||||
/.idea/
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/ubuntu:jammy
|
FROM ubuntu:latest
|
||||||
MAINTAINER bamanker
|
MAINTAINER bamanker
|
||||||
COPY target/dailylove /root/dailylove/
|
ARG NATIVE_FILE
|
||||||
|
COPY target/${NATIVE_FILE} /home/dailylove/app
|
||||||
EXPOSE 13145
|
EXPOSE 13145
|
||||||
CMD /root/dailylove/dailylove -XX:StartFlightRecording='filename=recording.jfr,dumponexit=true,duration=10s'
|
ENTRYPOINT ["/home/dailylove/app"]
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: $APP_NAME
|
|
||||||
version: $APP_TAG
|
|
||||||
name: $APP_NAME
|
|
||||||
namespace: default #一定要写名称空间
|
|
||||||
spec:
|
|
||||||
progressDeadlineSeconds: 600
|
|
||||||
replicas: 1
|
|
||||||
revisionHistoryLimit: 2
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: $APP_NAME
|
|
||||||
strategy:
|
|
||||||
rollingUpdate:
|
|
||||||
maxSurge: 50%
|
|
||||||
maxUnavailable: 50%
|
|
||||||
type: RollingUpdate
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: $APP_NAME
|
|
||||||
version: $APP_TAG
|
|
||||||
spec:
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: dockerhub-id #提前在项目下配置访问阿里云的账号密码
|
|
||||||
containers:
|
|
||||||
- image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG
|
|
||||||
name: $APP_NAME
|
|
||||||
imagePullPolicy: Always
|
|
||||||
livenessProbe: # 存活探针:失败意味着应用彻底挂了,需要重启来恢复
|
|
||||||
httpGet:
|
|
||||||
path: /test
|
|
||||||
port: 13145
|
|
||||||
initialDelaySeconds: 10 # 延迟xx秒开始执行
|
|
||||||
periodSeconds: 15 # 每隔15秒执行一次
|
|
||||||
timeoutSeconds: 10 # 10秒未返回结果则超时
|
|
||||||
failureThreshold: 10 # 探测失败后的重试次数,当达到这个次数后就判定结果为失败
|
|
||||||
# successThreshold: 5
|
|
||||||
ports:
|
|
||||||
- containerPort: 13145
|
|
||||||
protocol: TCP
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: 99m
|
|
||||||
memory: 65Mi
|
|
||||||
env:
|
|
||||||
- name: TZ
|
|
||||||
value: "Asia/Shanghai"
|
|
||||||
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: $APP_NAME
|
|
||||||
name: $APP_NAME
|
|
||||||
namespace: default
|
|
||||||
spec:
|
|
||||||
type: NodePort
|
|
||||||
externalTrafficPolicy: Local
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
protocol: TCP
|
|
||||||
port: 13145
|
|
||||||
nodePort: 30045
|
|
||||||
selector:
|
|
||||||
app: $APP_NAME
|
|
||||||
144
pom.xml
144
pom.xml
@@ -5,38 +5,24 @@
|
|||||||
<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>4.0.1</version>
|
<version>3.1.5</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<url/>
|
|
||||||
<licenses>
|
|
||||||
<license/>
|
|
||||||
</licenses>
|
|
||||||
<developers>
|
|
||||||
<developer/>
|
|
||||||
</developers>
|
|
||||||
<scm>
|
|
||||||
<connection/>
|
|
||||||
<developerConnection/>
|
|
||||||
<tag/>
|
|
||||||
<url/>
|
|
||||||
</scm>
|
|
||||||
<groupId>com.bamanker</groupId>
|
<groupId>com.bamanker</groupId>
|
||||||
<artifactId>dailylove</artifactId>
|
<artifactId>dailylove</artifactId>
|
||||||
<version>v2.4.0-native</version>
|
<version>v2.1</version>
|
||||||
<name>dailylove</name>
|
<name>dailyLove</name>
|
||||||
<description>dailylove-forK8S</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>25</java.version>
|
<java.version>17</java.version>
|
||||||
<maven.compiler.source>25</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>25</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<!-- <fastjson.version>2.0.60</fastjson.version>-->
|
<fastjson.version>2.0.25</fastjson.version>
|
||||||
<openfeign.version>5.0.0</openfeign.version>
|
<openfeign.version>4.0.4</openfeign.version>
|
||||||
<hutool.version>5.8.25</hutool.version>
|
<hutool.version>5.8.18</hutool.version>
|
||||||
<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>-->
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -44,32 +30,20 @@
|
|||||||
<artifactId>hutool-core</artifactId>
|
<artifactId>hutool-core</artifactId>
|
||||||
<version>${hutool.version}</version>
|
<version>${hutool.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<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 -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>tools.jackson.core</groupId>
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>fastjson2</artifactId>
|
||||||
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.alibaba.fastjson2</groupId>-->
|
|
||||||
<!-- <artifactId>fastjson2</artifactId>-->
|
|
||||||
<!-- <version>${fastjson.version}</version>-->
|
|
||||||
<!-- </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>
|
||||||
@@ -89,83 +63,41 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>dailylove</finalName>
|
|
||||||
<!--指定filtering=true.maven的占位符解析表达式就可以用于它里面的文件-->
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.graalvm.buildtools</groupId>
|
<groupId>org.graalvm.buildtools</groupId>
|
||||||
<artifactId>native-maven-plugin</artifactId>
|
<artifactId>native-maven-plugin</artifactId>
|
||||||
<!--为本机映像程序添加配置,生成的配置文件位于
|
<version>0.9.27</version>
|
||||||
META-INF/native-image/groupID/artifactID/native-image.properties
|
|
||||||
也可以手动配置-->
|
|
||||||
<configuration>
|
|
||||||
<mainClass>com.bamanker.dailylove.DailyLoveApplication</mainClass>
|
|
||||||
<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>
|
|
||||||
<!--支持yaml读取pom的参数-->
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
<delimiters>
|
|
||||||
<delimiter>@</delimiter>
|
|
||||||
</delimiters>
|
|
||||||
<useDefaultDelimiters>false</useDefaultDelimiters>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<release>25</release>
|
|
||||||
<annotationProcessors>
|
|
||||||
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor
|
|
||||||
</annotationProcessor>
|
|
||||||
</annotationProcessors>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</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>
|
||||||
|
<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>
|
<configuration>
|
||||||
<excludes>
|
<username>bamanker</username>
|
||||||
<exclude>
|
<password>Fz8803101</password>
|
||||||
<groupId>org.projectlombok</groupId>
|
<repository>${docker.private.repository}/${project.artifactId}</repository>
|
||||||
<artifactId>lombok</artifactId>
|
<tag>${project.version}</tag>
|
||||||
</exclude>
|
<buildArgs>
|
||||||
</excludes>
|
<NATIVE_FILE>${project.artifactId}</NATIVE_FILE>
|
||||||
|
</buildArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,139 +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(){
|
||||||
|
|||||||
@@ -2,19 +2,17 @@ package com.bamanker.dailylove.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.date.ChineseDate;
|
import cn.hutool.core.date.ChineseDate;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
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.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.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 tools.jackson.databind.JsonNode;
|
import jakarta.annotation.Resource;
|
||||||
import tools.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -22,29 +20,18 @@ import java.util.Date;
|
|||||||
@RestController
|
@RestController
|
||||||
public class PushDailyController {
|
public class PushDailyController {
|
||||||
|
|
||||||
final
|
@Resource
|
||||||
ObjectMapper mapper;
|
|
||||||
|
|
||||||
|
|
||||||
final
|
|
||||||
DataRemoteClient dataRemoteClient;
|
DataRemoteClient dataRemoteClient;
|
||||||
|
|
||||||
final
|
@Resource
|
||||||
WechatRequestClient wechatRequestClient;
|
WechatRequestClient wechatRequestClient;
|
||||||
|
|
||||||
public PushDailyController(DataRemoteClient dataRemoteClient, WechatRequestClient wechatRequestClient, ObjectMapper mapper) {
|
|
||||||
this.dataRemoteClient = dataRemoteClient;
|
|
||||||
this.wechatRequestClient = wechatRequestClient;
|
|
||||||
this.mapper = mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送晚安
|
* 推送晚安
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/pushNight")
|
@GetMapping("/pushNight")
|
||||||
@RegisterReflectionForBinding(Weather.class)
|
|
||||||
public String pushNight() {
|
public String pushNight() {
|
||||||
|
|
||||||
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
|
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
|
||||||
@@ -56,11 +43,9 @@ public class PushDailyController {
|
|||||||
param1.setCity(DailyLoveConfigure.City_ID);
|
param1.setCity(DailyLoveConfigure.City_ID);
|
||||||
param1.setType("7");
|
param1.setType("7");
|
||||||
String weatherResp = dataRemoteClient.getWeather(param1);
|
String weatherResp = dataRemoteClient.getWeather(param1);
|
||||||
JsonNode weatherJson = mapper.readTree(weatherResp).get("result").get("list").get(1);
|
JSONObject weatherJson = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(1);
|
||||||
String city = mapper.readTree(weatherResp).get("result").get("area").asString();
|
String city = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getString("area");
|
||||||
// JSONObject weatherJson1 = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(1);
|
Weather weather = weatherJson.toJavaObject(Weather.class);
|
||||||
// String city1 = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getString("area");
|
|
||||||
Weather weather = mapper.treeToValue(weatherJson, Weather.class);
|
|
||||||
|
|
||||||
resultVo.setAttribute("tomorrow", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_tomorrow));
|
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));
|
||||||
@@ -74,18 +59,15 @@ public class PushDailyController {
|
|||||||
param2.setKey(DailyLoveConfigure.TianXin_Key);
|
param2.setKey(DailyLoveConfigure.TianXin_Key);
|
||||||
|
|
||||||
String tipsResp = dataRemoteClient.getTips(param2);
|
String tipsResp = dataRemoteClient.getTips(param2);
|
||||||
String tips = mapper.readTree(tipsResp).get("result").get("content").asString();
|
String tips = JSONObject.parseObject(tipsResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
// String tips1 = JSONObject.parseObject(tipsResp).getJSONArray("result").getJSONObject(0).getString("content");
|
|
||||||
resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
|
resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
|
||||||
|
|
||||||
String nightResp = dataRemoteClient.getNight(param2);
|
String nightResp = dataRemoteClient.getNight(param2);
|
||||||
String night = mapper.readTree(nightResp).get("result").get("content").asString();
|
String night = JSONObject.parseObject(nightResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
// String night1 = JSONObject.parseObject(nightResp).getJSONArray("result").getJSONObject(0).getString("content");
|
|
||||||
resultVo.setAttribute("night", new DataItem(night, DailyLoveConfigure.Color_night));
|
resultVo.setAttribute("night", new DataItem(night, DailyLoveConfigure.Color_night));
|
||||||
|
|
||||||
String rainbowResp = dataRemoteClient.getRainbow(param2);
|
String rainbowResp = dataRemoteClient.getRainbow(param2);
|
||||||
String rainbow = mapper.readTree(rainbowResp).get("result").get("content").asString();
|
String rainbow = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
// String rainbow1 = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content");
|
|
||||||
resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
|
resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
|
||||||
|
|
||||||
// String englishResp = dataRemoteClient.getDailyEnglish(param2);
|
// String englishResp = dataRemoteClient.getDailyEnglish(param2);
|
||||||
@@ -139,9 +121,9 @@ public class PushDailyController {
|
|||||||
|
|
||||||
String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam);
|
String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam);
|
||||||
log.debug("accessTokenJson:{}", accessTokenResp);
|
log.debug("accessTokenJson:{}", accessTokenResp);
|
||||||
String token = mapper.readTree(accessTokenResp).get("access_token").asString();
|
String token = JSONObject.parseObject(accessTokenResp).getString("access_token");
|
||||||
// String token1 = JSONObject.parseObject(accessTokenResp).getString("access_token");
|
String responseStr = wechatRequestClient.sendMsg(resultVo, token);
|
||||||
return wechatRequestClient.sendMsg(resultVo, token);
|
return responseStr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +131,6 @@ public class PushDailyController {
|
|||||||
* 推送早安
|
* 推送早安
|
||||||
*/
|
*/
|
||||||
@GetMapping("/pushMorning")
|
@GetMapping("/pushMorning")
|
||||||
@RegisterReflectionForBinding(Weather.class)
|
|
||||||
public String pushMorning() {
|
public String pushMorning() {
|
||||||
|
|
||||||
TianXinReqParam param1 = new TianXinReqParam();
|
TianXinReqParam param1 = new TianXinReqParam();
|
||||||
@@ -157,10 +138,9 @@ public class PushDailyController {
|
|||||||
param1.setCity(DailyLoveConfigure.City_ID);
|
param1.setCity(DailyLoveConfigure.City_ID);
|
||||||
param1.setType("1");
|
param1.setType("1");
|
||||||
String weatherResp = dataRemoteClient.getWeather(param1);
|
String weatherResp = dataRemoteClient.getWeather(param1);
|
||||||
JsonNode weatherJson = mapper.readTree(weatherResp).get("result");
|
|
||||||
Weather weather = mapper.treeToValue(weatherJson, Weather.class);
|
|
||||||
|
|
||||||
// Weather weather1 = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).toJavaObject(Weather.class);
|
Weather weather = 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,
|
||||||
@@ -182,13 +162,11 @@ public class PushDailyController {
|
|||||||
// resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
|
// resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips));
|
||||||
|
|
||||||
String morningResp = dataRemoteClient.getMorning(param2);
|
String morningResp = dataRemoteClient.getMorning(param2);
|
||||||
String morning = mapper.readTree(morningResp).get("result").get("content").asString();
|
String morning = JSONObject.parseObject(morningResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
// String morning1 = JSONObject.parseObject(morningResp).getJSONArray("result").getJSONObject(0).getString("content");
|
|
||||||
resultVo.setAttribute("morning", new DataItem(morning, DailyLoveConfigure.Color_morning));
|
resultVo.setAttribute("morning", new DataItem(morning, DailyLoveConfigure.Color_morning));
|
||||||
|
|
||||||
String rainbowResp = dataRemoteClient.getRainbow(param2);
|
String rainbowResp = dataRemoteClient.getRainbow(param2);
|
||||||
String rainbow = mapper.readTree(rainbowResp).get("result").get("content").asString();
|
String rainbow = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content");
|
||||||
// String rainbow1 = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content");
|
|
||||||
resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
|
resultVo.setAttribute("rainbow", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn));
|
||||||
|
|
||||||
// String englishResp = dataRemoteClient.getDailyEnglish(param2);
|
// String englishResp = dataRemoteClient.getDailyEnglish(param2);
|
||||||
@@ -244,9 +222,9 @@ public class PushDailyController {
|
|||||||
|
|
||||||
String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam);
|
String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam);
|
||||||
log.debug("accessTokenJson:{}", accessTokenResp);
|
log.debug("accessTokenJson:{}", accessTokenResp);
|
||||||
String token = mapper.readTree(accessTokenResp).get("access_token").asString();
|
String token = JSONObject.parseObject(accessTokenResp).getString("access_token");
|
||||||
// String token1 = JSONObject.parseObject(accessTokenResp).getString("access_token");
|
String responseStr = wechatRequestClient.sendMsg(resultVo, token);
|
||||||
return wechatRequestClient.sendMsg(resultVo, token);
|
return responseStr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,12 +234,9 @@ public class PushDailyController {
|
|||||||
* @param responseStr
|
* @param responseStr
|
||||||
*/
|
*/
|
||||||
private void printPushLog(String responseStr) {
|
private void printPushLog(String responseStr) {
|
||||||
JsonNode jsonNode = mapper.readTree(responseStr);
|
JSONObject jsonObject = JSONObject.parseObject(responseStr);
|
||||||
String msgCode = jsonNode.get("errcode").asString();
|
String msgCode = jsonObject.getString("errcode");
|
||||||
String msgContent = jsonNode.get("errmsg").asString();
|
String msgContent = jsonObject.getString("errmsg");
|
||||||
// JSONObject jsonObject = JSONObject.parseObject(responseStr);
|
|
||||||
// String msgCode1 = jsonObject.getString("errcode");
|
|
||||||
// String msgContent1 = jsonObject.getString("errmsg");
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
System.out.println("[ " + dateFormat.format(new Date()) + " ] : messageCode=" + msgCode + ",messageContent=" + msgContent);
|
System.out.println("[ " + dateFormat.format(new Date()) + " ] : messageCode=" + msgCode + ",messageContent=" + msgContent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,18 +10,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
public class TestController {
|
public class TestController {
|
||||||
/**
|
|
||||||
* 处理GET请求的测试方法。
|
|
||||||
*
|
|
||||||
* @return 返回一个字符串,内容为"test ok!!!!!!!!",用于验证功能的正常运行。
|
|
||||||
*/
|
|
||||||
|
|
||||||
@GetMapping("/test")
|
@GetMapping("/test")
|
||||||
public String test(){
|
public String test(){
|
||||||
return "test ok!!!!!!!!";
|
return "test ok!!!!!!!!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author bamanker
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -14,8 +11,4 @@ public class DataItem {
|
|||||||
private String value;
|
private String value;
|
||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: dailyLove
|
name: dailyLove
|
||||||
cloud:
|
|
||||||
refresh:
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
DL:
|
DL:
|
||||||
tianxin-key: 72fbbb9e75e338ea6a240e83972f287c
|
tianxin-key: 72fbbb9e75e338ea6a240e83972f287c
|
||||||
@@ -19,11 +16,11 @@ DL:
|
|||||||
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: oo5bL6QafHJa9zQNYKS0fIhFC0zM
|
||||||
template-id-morning: E7eBkU0uzBFDwC9MiqPtHNlSlByDafw4BIqZvfOtTOs
|
template-id-morning: 1yx1fahCs923nOmMh0_KLWN0nXGKd8_pHQrfpdMblrQ
|
||||||
template-id-night: 5ExwX0ID1ccueXNb7v-dqTcDH-lYtHatg0Mqt4FDIaY
|
template-id-night: QG-5NBX-jip46ulGVsaE3Uhl30GUxvNmtKOxwMHFkx0
|
||||||
|
|
||||||
color:
|
color:
|
||||||
now: '#99CCCC'
|
now: '#99CCCC'
|
||||||
@@ -53,5 +50,3 @@ tianxin:
|
|||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口(可多个)
|
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口(可多个)
|
||||||
|
|
||||||
scanclass: false
|
|
||||||
@@ -1,18 +1,25 @@
|
|||||||
package com.bamanker.dailylove;
|
package com.bamanker.dailylove;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.ChineseDate;
|
||||||
|
import cn.hutool.core.date.DateUnit;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.bamanker.dailylove.config.DailyLoveConfigure;
|
import com.bamanker.dailylove.config.DailyLoveConfigure;
|
||||||
import com.bamanker.dailylove.domain.DataItem;
|
|
||||||
import com.bamanker.dailylove.domain.TianXinReqParam;
|
import com.bamanker.dailylove.domain.TianXinReqParam;
|
||||||
import com.bamanker.dailylove.domain.Weather;
|
import com.bamanker.dailylove.domain.Weather;
|
||||||
import com.bamanker.dailylove.service.DataRemoteClient;
|
import com.bamanker.dailylove.service.DataRemoteClient;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.bouncycastle.util.Strings;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
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.JsonNode;
|
|
||||||
import tools.jackson.databind.ObjectMapper;
|
import jakarta.annotation.Resource;
|
||||||
import com.bamanker.dailylove.domain.*;
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static com.bamanker.dailylove.utils.DataUtils.getBirthdays;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -21,10 +28,6 @@ class DailyLoveApplicationTests {
|
|||||||
// @Resource
|
// @Resource
|
||||||
// DataRemoteClient dataRemoteClient;
|
// DataRemoteClient dataRemoteClient;
|
||||||
//
|
//
|
||||||
// @Autowired
|
|
||||||
// ObjectMapper mapper;
|
|
||||||
|
|
||||||
//
|
|
||||||
// String remark = "❤";
|
// String remark = "❤";
|
||||||
//
|
//
|
||||||
// @Test
|
// @Test
|
||||||
@@ -103,61 +106,24 @@ 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 weatherResp = dataRemoteClient.getWeather(param1);
|
// String weatherJson = dataRemoteClient.getWeather(param1);
|
||||||
//// log.info("weather:{}", weatherResp);
|
// log.info("weather:{}", weatherJson);
|
||||||
// JsonNode weatherJson = mapper.readTree(weatherResp).get("result").get("list").get(1);
|
// JSONObject resWeather = JSONObject.parseObject(weatherJson);
|
||||||
// System.out.println("-----------------------------");
|
// JSONObject result = resWeather.getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(2);
|
||||||
// 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
|
||||||
|
|||||||
Reference in New Issue
Block a user