Skip to content

Commit

Permalink
v3.10.0 (#50)
Browse files Browse the repository at this point in the history
* refactor(3.10.0): Init

* fix(3.10.1): Profile

* build(3.10.1): docker-compose

* build(3.10.1): init

* refactor(3.10.2):

remove redisEnable
fix: init

* refactor(3.10.2):

remove redisEnable
fix: init

* feat(3.10.3):

feat: initOtherSchema

* feat(3.10.3):

feat: initOtherSchema

* refactor(3.10.4):

feat: 提取方法

* fix(3.10.4):

remove stringRedisUtil

* refactor(3.10.4): mv

docs 注释

* build(3.10.4):

fix test

* refactor(3.10.5):
refactor 抽取方法
修改日志文件到~/.api/
修改dockerfile

* chore(deps): bump spring-boot-starter-parent from 2.7.5 to 3.0.0

Bumps [spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 2.7.5 to 3.0.0.
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v2.7.5...v3.0.0)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-parent
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* refactor(3.10.0): Init

* fix(3.10.1): Profile

* build(3.10.1): docker-compose

* build(3.10.1): init

* refactor(3.10.2):

remove redisEnable
fix: init

* feat(3.10.3):

feat: initOtherSchema

* feat(3.10.3):

feat: initOtherSchema

* refactor(3.10.4):

feat: 提取方法

* fix(3.10.4):

remove stringRedisUtil

* refactor(3.10.4): mv

docs 注释

* build(3.10.4):

fix test

* refactor(3.10.5):
refactor 抽取方法
修改日志文件到~/.api/
修改dockerfile

* chore(deps): bump aspectjweaver from 1.9.9.1 to 1.9.19

Bumps [aspectjweaver](https://github.com/eclipse/org.aspectj) from 1.9.9.1 to 1.9.19.
- [Release notes](https://github.com/eclipse/org.aspectj/releases)
- [Commits](https://github.com/eclipse/org.aspectj/commits)

---
updated-dependencies:
- dependency-name: org.aspectj:aspectjweaver
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump spring-boot-starter-parent from 2.7.5 to 3.0.1

Bumps [spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 2.7.5 to 3.0.1.
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v2.7.5...v3.0.1)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-parent
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* refactor(3.10.5):
springboot3

* chore(deps): bump smart-doc-maven-plugin from 2.6.2 to 2.6.3 (#45)

* Create dependabot.yml (#40)

* chore(deps): bump springdoc-openapi-ui from 1.6.12 to 1.6.13 (#43)

Bumps [springdoc-openapi-ui](https://github.com/springdoc/springdoc-openapi) from 1.6.12 to 1.6.13.
- [Release notes](https://github.com/springdoc/springdoc-openapi/releases)
- [Changelog](https://github.com/springdoc/springdoc-openapi/blob/master/CHANGELOG.md)
- [Commits](springdoc/springdoc-openapi@v1.6.12...v1.6.13)

---
updated-dependencies:
- dependency-name: org.springdoc:springdoc-openapi-ui
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump hutool-all from 5.8.9 to 5.8.10 (#41)

Bumps [hutool-all](https://github.com/looly/hutool) from 5.8.9 to 5.8.10.
- [Release notes](https://github.com/looly/hutool/releases)
- [Changelog](https://github.com/dromara/hutool/blob/v5-master/CHANGELOG.md)
- [Commits](dromara/hutool@5.8.9...5.8.10)

---
updated-dependencies:
- dependency-name: cn.hutool:hutool-all
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump dockerfile-maven-plugin from 1.4.9 to 1.4.13 (#44)

Bumps [dockerfile-maven-plugin](https://github.com/spotify/dockerfile-maven) from 1.4.9 to 1.4.13.
- [Release notes](https://github.com/spotify/dockerfile-maven/releases)
- [Changelog](https://github.com/spotify/dockerfile-maven/blob/master/CHANGELOG.md)
- [Commits](spotify/dockerfile-maven@v1.4.9...v1.4.13)

---
updated-dependencies:
- dependency-name: com.spotify:dockerfile-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump smart-doc-maven-plugin from 2.6.2 to 2.6.3

Bumps [smart-doc-maven-plugin](https://github.com/smart-doc-group/smart-doc-maven-plugin) from 2.6.2 to 2.6.3.
- [Release notes](https://github.com/smart-doc-group/smart-doc-maven-plugin/releases)
- [Changelog](https://github.com/smart-doc-group/smart-doc-maven-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smart-doc-group/smart-doc-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.github.shalousun:smart-doc-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: 冰彦糖 <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
BingChunMoLi and dependabot[bot] authored Dec 31, 2022
1 parent 97c59fe commit c27d4c8
Show file tree
Hide file tree
Showing 65 changed files with 26,521 additions and 2,047 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# 基础镜像
FROM openjdk:8-jdk-alpine
FROM openjdk:17-jdk-alpine

# 作者信息
MAINTAINER BingChunMoLi <[email protected]>

# 添加一个存储空间
VOLUME /api
VOLUME ~/.api/

# 暴露8090端口
EXPOSE 8090
Expand All @@ -14,7 +14,7 @@ EXPOSE 8090
ARG JAR_FILE

# 往容器中添加jar包
ADD /target/${JAR_FILE} /api/app.jar
ADD /target/${JAR_FILE} ~/.api/app.jar

# 启动镜像自动运行程序
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/urandom","-jar","/api/app.jar"]
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/urandom","-jar","~/.api/app.jar"]
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: 3.8
services:
moliapi:
build:
context: .
dockerfile: Dockerfile
ports:
- "8090:8090"
depends_on:
- mysql
- redis
links:
- mysql
- redis
mysql:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- ~/.api/mysql/data/:/var/lib/mysql
- ~/.api/mysql/conf/:/etc/mysql
- ~/.api/mysql/log/:/var/log/mysql
ports:
- "3306:3006"
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_general_ci
redis:
image: redis
ports:
- "6379:6379"
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<version>3.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>com.bingchunmoli</groupId>
<artifactId>moliapi</artifactId>
<version>3.9.0</version>
<version>3.10.0</version>
<name>MoLiApi</name>
<description>MoLiApi</description>

<properties>
<java.version>17</java.version>
<mybatis-plus.version>3.5.2</mybatis-plus.version>
<mybatis-plus.version>3.5.3</mybatis-plus.version>
<swagger.version>3.0.0</swagger.version>
<knife4j.version>3.0.3</knife4j.version>
<docker-plugin.version>1.4.13</docker-plugin.version>
<aspectjweaver.version>1.9.9.1</aspectjweaver.version>
<hutool.version>5.8.10</hutool.version>
<aspectjweaver.version>1.9.19</aspectjweaver.version>
<hutool.version>5.8.11</hutool.version>
<zxing.version>3.5.1</zxing.version>
<emoji.version>5.1.1</emoji.version>
<h2.version>2.1.214</h2.version>
<ip-info.version>2.2.0</ip-info.version>
<spring-doc.version>1.6.13</spring-doc.version>
<spring-doc.version>1.6.14</spring-doc.version>
<knife4j.version>3.0.3</knife4j.version>
</properties>

Expand All @@ -41,8 +41,8 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -168,7 +168,7 @@
<plugin>
<groupId>com.github.shalousun</groupId>
<artifactId>smart-doc-maven-plugin</artifactId>
<version>2.6.2</version>
<version>2.6.3</version>
<configuration>
<configFile>./src/main/resources/smart-doc.json</configFile>
<projectName>MoLiApi</projectName>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/bingchunmoli/api/bean/ApiConstant.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package com.bingchunmoli.api.bean;

import org.springframework.util.ResourceUtils;

/**
* Api常量
*
* @author BingChunMoLi
*/
public class ApiConstant {
public static final String YI_YAN = "yiYan";
public static final String SHI_CI = "shiCi";
public static final String YI_YAN_TABLE_NAME = "yi_yan";
public static final String SHI_CI_TABLE_NAME = "shi_ci";
public static final String PC_IMG = "pc";
public static final String MOBILE_IMG = "mobile";
public static final String SCHEMA_PATH_PREFIX = ResourceUtils.CLASSPATH_URL_PREFIX + "db/schema-";
public static final String DATA_PATH_PREFIX = ResourceUtils.CLASSPATH_URL_PREFIX + "db/data-";
public static final String SQL_PATH_SUFFIX = ".sql";
public static final String YI_YAN_DATA_PATH = ResourceUtils.CLASSPATH_URL_PREFIX + "db/yiyan.data";
public static final String SHI_CI_DATA_PATH = ResourceUtils.CLASSPATH_URL_PREFIX + "db/shici.data";


}
9 changes: 9 additions & 0 deletions src/main/java/com/bingchunmoli/api/bean/Init.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.bingchunmoli.api.bean;

import com.bingchunmoli.api.bean.enums.DriveType;


public record Init(DriveType driveType, String activeDataFilePath, String activeSchemaPath, String activeDataPath) {

}
//todo 功能开关?
20 changes: 20 additions & 0 deletions src/main/java/com/bingchunmoli/api/bean/enums/DriveType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.bingchunmoli.api.bean.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* 数据库类型
* @author MoLi
*/
@Getter
@AllArgsConstructor
public enum DriveType {
/**
* 数据库类型
*/
NONE(0, "NONE"), MYSQL(1, "MYSQL"), H2(2, "H2");

private final int type;
private final String driveName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ public BingImage getBingImageByRemote() {

@Async
void saveCache(BingImageVO cnBingImageVO, BingImageVO enBingImageVO, BingImage bingImage) {
if (redisUtil.isEnable()) {
redisUtil.setObject(BingEnum.CN_BING.getKey(), cnBingImageVO, 1, TimeUnit.DAYS);
redisUtil.setObject(BingEnum.EN_BING.getKey(), enBingImageVO, 1, TimeUnit.DAYS);
redisUtil.setObject(BingEnum.ALL_BING.getKey(), bingImage, 1, TimeUnit.DAYS);
}
redisUtil.setObject(BingEnum.CN_BING.getKey(), cnBingImageVO, 1, TimeUnit.DAYS);
redisUtil.setObject(BingEnum.EN_BING.getKey(), enBingImageVO, 1, TimeUnit.DAYS);
redisUtil.setObject(BingEnum.ALL_BING.getKey(), bingImage, 1, TimeUnit.DAYS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.bingchunmoli.api.bean.enums.CodeEnum;
import com.bingchunmoli.api.bean.enums.NotSupportHttpCode;
import com.bingchunmoli.api.interceptor.RequestTraceIdInterceptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -16,8 +18,6 @@
import org.springframework.web.bind.annotation.RestController;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/bingchunmoli/api/exception/ApiInitException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.bingchunmoli.api.exception;

/**
* @author MoLi
*/
public class ApiInitException extends ApiException{

public ApiInitException(String msg) {
super(msg);
}

public ApiInitException(Throwable e) {
super(e);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.bingchunmoli.api.host.controller;

import com.bingchunmoli.api.host.service.HostService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
Expand Down
43 changes: 26 additions & 17 deletions src/main/java/com/bingchunmoli/api/img/task/ImgTask.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bingchunmoli.api.img.task;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.bingchunmoli.api.bean.ApiConstant;
import com.bingchunmoli.api.bean.MailMessage;
import com.bingchunmoli.api.even.MailMessageEven;
Expand All @@ -17,6 +19,7 @@

/**
* 随即图定时任务 每月刷新
*
* @author BingChunMoLi
*/
@Component
Expand All @@ -31,24 +34,30 @@ public class ImgTask {
public void saveImg() {
List<Path> pcPath = null;
List<Path> mobilePath = null;
try {
pcPath = imgService.getImgListByFileSystem(apiConfig.getPcPath());
} catch (IOException e) {
e.printStackTrace();
applicationEventPublisher.publishEvent(new MailMessageEven(MailMessage.builder().title("pc定时任务失败").body("异常信息: " + e.getMessage() + " ").build()));
if (StrUtil.isNotBlank(apiConfig.getPcPath())) {
try {
pcPath = imgService.getImgListByFileSystem(apiConfig.getPcPath());
} catch (IOException e) {
e.printStackTrace();
applicationEventPublisher.publishEvent(new MailMessageEven(MailMessage.builder().title("pc定时任务失败").body("异常信息: " + e.getMessage() + "").build()));
}
if (CollectionUtil.isNotEmpty(pcPath)) {
redisTemplate.opsForList().trim(ApiConstant.PC_IMG, -2, -1);
redisTemplate.opsForList().leftPushAll(ApiConstant.PC_IMG, pcPath.stream().map(Path::toString).toArray());
}
}
try {
mobilePath = imgService.getImgListByFileSystem(apiConfig.getMobilePath());
} catch (IOException e) {
e.printStackTrace();
applicationEventPublisher.publishEvent(new MailMessageEven(MailMessage.builder().title("mobile定时任务失败").body("异常信息: " + e.getMessage() + " ").build()));
if (StrUtil.isNotBlank(apiConfig.getMobilePath())) {
try {
mobilePath = imgService.getImgListByFileSystem(apiConfig.getMobilePath());
} catch (IOException e) {
e.printStackTrace();
applicationEventPublisher.publishEvent(new MailMessageEven(MailMessage.builder().title("mobile定时任务失败").body("异常信息: " + e.getMessage() + "").build()));
}
if (CollectionUtil.isNotEmpty(mobilePath)) {
redisTemplate.opsForList().trim(ApiConstant.MOBILE_IMG, -1, -2);
redisTemplate.opsForList().leftPushAll(ApiConstant.MOBILE_IMG, mobilePath.stream().map(Path::toString).toArray());
}
}
assert pcPath != null;
assert mobilePath != null;
redisTemplate.opsForList().trim(ApiConstant.PC_IMG, - 2, - 1);
redisTemplate.opsForList().leftPushAll(ApiConstant.PC_IMG, pcPath.stream().map(Path :: toString).toArray());
redisTemplate.opsForList().trim(ApiConstant.MOBILE_IMG, - 1, - 2);
redisTemplate.opsForList().leftPushAll(ApiConstant.MOBILE_IMG, mobilePath.stream().map(Path :: toString).toArray());
applicationEventPublisher.publishEvent(new MailMessageEven(MailMessage.builder().title("随机图定时任务 更新成功").body("更新PC图片:" + pcPath.size() + " 更新移动图片:" + mobilePath.size()).build()));
applicationEventPublisher.publishEvent(new MailMessageEven(MailMessage.builder().title("随机图定时任务 更新成功").body("更新PC图片:" + pcPath.size() + " 更新移动图片:" + mobilePath.size()).build()));
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/bingchunmoli/api/init/ApiCommandLineRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.bingchunmoli.api.init;

import com.bingchunmoli.api.bean.MailMessage;
import com.bingchunmoli.api.even.MailMessageEven;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Map;

/**
* 一言,诗词,随机图初始化 仅限prod环境
* @author BingChunMoLi
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class ApiCommandLineRunner implements CommandLineRunner {
private final ApplicationEventPublisher applicationEventPublisher;
private final Map<String, InitService> initServiceMap;

@Override
public void run(String... args) {
for (InitService service:initServiceMap.values()) {
service.init();
}
applicationEventPublisher.publishEvent(new MailMessageEven(MailMessage.builder().title("系统初始化完成").body("系统初始化完成, 初始化当前时间:" + LocalDateTime.now()).build()));
}
}
30 changes: 30 additions & 0 deletions src/main/java/com/bingchunmoli/api/init/InitDataService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.bingchunmoli.api.init;

import java.nio.file.Path;
import java.util.List;

/**
* 初始化数据Service
* @author MoLi
*/
public interface InitDataService<T> extends InitSqlService {

/**
* 读取数据列表
* @return 数据列表
*/
List<T> readAll();

/**
* 读取数据列表从文件
* @return 数据列表
*/
List<T> readAllDataByFile();

/**
* 读取数据列表从文件
* @return 数据列表
*/
List<T> readAllDataByFile(Path path);

}
13 changes: 13 additions & 0 deletions src/main/java/com/bingchunmoli/api/init/InitService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.bingchunmoli.api.init;

/**
* 初始化Service
* @author MoLi
*/
public interface InitService {

/**
* 初始化
*/
void init();
}
Loading

0 comments on commit c27d4c8

Please sign in to comment.