From b554cc6cc72ac4d5147e9c33e343b53c300c31c3 Mon Sep 17 00:00:00 2001 From: yinxing Date: Wed, 15 Nov 2023 10:31:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201=E3=80=81=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 29 ++++ hbt-vehicle-management-api/pom.xml | 28 ++++ .../api/RemoteVehicleManagementService.java | 23 ++++ ...emoteVehicleManagementFallbackFactory.java | 26 ++++ hbt-vehicle-management-biz/Dockerfile | 4 + hbt-vehicle-management-biz/pom.xml | 83 ++++++++++++ .../vehicleManagementApplication.java | 25 ++++ .../src/main/resources/banner.txt | 9 ++ .../src/main/resources/bootstrap-dev.yml | 16 +++ .../src/main/resources/bootstrap.yml | 14 ++ .../src/main/resources/db/readme.txt | 4 + .../resources/db/template_01_init_struct.sql | 1 + .../resources/db/template_02_init_data.sql | 1 + .../resources/db/template_03_init_index.sql | 1 + pom.xml | 126 ++++++++++++++++++ replace.bat | 45 +++++++ 16 files changed, 435 insertions(+) create mode 100644 .gitignore create mode 100644 hbt-vehicle-management-api/pom.xml create mode 100644 hbt-vehicle-management-api/src/main/java/com/hbt/vehicle.management/api/RemoteVehicleManagementService.java create mode 100644 hbt-vehicle-management-api/src/main/java/com/hbt/vehicle.management/api/factory/RemoteVehicleManagementFallbackFactory.java create mode 100644 hbt-vehicle-management-biz/Dockerfile create mode 100644 hbt-vehicle-management-biz/pom.xml create mode 100644 hbt-vehicle-management-biz/src/main/java/com/hbt/vehicle/management/vehicleManagementApplication.java create mode 100644 hbt-vehicle-management-biz/src/main/resources/banner.txt create mode 100644 hbt-vehicle-management-biz/src/main/resources/bootstrap-dev.yml create mode 100644 hbt-vehicle-management-biz/src/main/resources/bootstrap.yml create mode 100644 hbt-vehicle-management-biz/src/main/resources/db/readme.txt create mode 100644 hbt-vehicle-management-biz/src/main/resources/db/template_01_init_struct.sql create mode 100644 hbt-vehicle-management-biz/src/main/resources/db/template_02_init_data.sql create mode 100644 hbt-vehicle-management-biz/src/main/resources/db/template_03_init_index.sql create mode 100644 pom.xml create mode 100644 replace.bat diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..444577b --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +*.class +*/logs + +#package files +*.war +*.ear + +#kdiff3 ignore +target/ + +#eclipse ignore +.settings/ +.project +.classpath + +#idea +.idea/ +/idea/ +*.ipr +*.iml +*.iws + +# temp file +*.log +*.cache +*.diff +*.patch +*.tmp +*.versionsBackup \ No newline at end of file diff --git a/hbt-vehicle-management-api/pom.xml b/hbt-vehicle-management-api/pom.xml new file mode 100644 index 0000000..2ec5b21 --- /dev/null +++ b/hbt-vehicle-management-api/pom.xml @@ -0,0 +1,28 @@ + + + + com.hbt.sass + hbt-vehicle-management + 1.0-SNAPSHOT + + 4.0.0 + + hbt-vehicle-management-api + + + + + com.hbt.onreal + hbt-onreal-common-security + + + + joda-time + joda-time + + + + + \ No newline at end of file diff --git a/hbt-vehicle-management-api/src/main/java/com/hbt/vehicle.management/api/RemoteVehicleManagementService.java b/hbt-vehicle-management-api/src/main/java/com/hbt/vehicle.management/api/RemoteVehicleManagementService.java new file mode 100644 index 0000000..e519eb7 --- /dev/null +++ b/hbt-vehicle-management-api/src/main/java/com/hbt/vehicle.management/api/RemoteVehicleManagementService.java @@ -0,0 +1,23 @@ +package com.hbt.vehicle.management.api; + +import com.hbt.common.core.domain.R; +import com.hbt.vehicle.management.api.factory.RemoteVehicleManagementFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +/** + * 车辆管理服务 + * + * @author hbt + */ +@FeignClient(contextId = "remoteVehicleManagementService", value = "hbt-vehicle-management", fallbackFactory = RemoteVehicleManagementFallbackFactory.class) +public interface RemoteVehicleManagementService +{ + /** + * 接口示例 + * + * @return 结果 + */ + @GetMapping(value = "/vehicle/action") + R action() ; +} diff --git a/hbt-vehicle-management-api/src/main/java/com/hbt/vehicle.management/api/factory/RemoteVehicleManagementFallbackFactory.java b/hbt-vehicle-management-api/src/main/java/com/hbt/vehicle.management/api/factory/RemoteVehicleManagementFallbackFactory.java new file mode 100644 index 0000000..c088ed5 --- /dev/null +++ b/hbt-vehicle-management-api/src/main/java/com/hbt/vehicle.management/api/factory/RemoteVehicleManagementFallbackFactory.java @@ -0,0 +1,26 @@ +package com.hbt.vehicle.management.api.factory; + +import com.hbt.common.core.domain.R; +import com.hbt.vehicle.management.api.RemoteVehicleManagementService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * 文件服务降级处理 + * + * @author hbt + */ +@Component +public class RemoteVehicleManagementFallbackFactory implements FallbackFactory +{ + private static final Logger log = LoggerFactory.getLogger(RemoteVehicleManagementFallbackFactory.class); + + @Override + public RemoteVehicleManagementService create(Throwable throwable) + { + log.error("template服务调用失败:{}", throwable.getMessage()); + return () -> R.fail("调用失败:" + throwable.getMessage()); + } +} diff --git a/hbt-vehicle-management-biz/Dockerfile b/hbt-vehicle-management-biz/Dockerfile new file mode 100644 index 0000000..965d09a --- /dev/null +++ b/hbt-vehicle-management-biz/Dockerfile @@ -0,0 +1,4 @@ +FROM 119.45.158.12:5000/mini-java8:latest +COPY target/hbt-template-1.0-SNAPSHOT.jar /app/app.jar +ENV NACOSIP="" +ENTRYPOINT ["sh","-c","java -Dnacos.ip=$NACOSIP -jar /app/app.jar"] \ No newline at end of file diff --git a/hbt-vehicle-management-biz/pom.xml b/hbt-vehicle-management-biz/pom.xml new file mode 100644 index 0000000..960125f --- /dev/null +++ b/hbt-vehicle-management-biz/pom.xml @@ -0,0 +1,83 @@ + + + + com.hbt.sass + hbt-vehicle-management + 1.0-SNAPSHOT + + 4.0.0 + + hbt-vehicle-management-biz + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + org.springframework.boot + spring-boot-starter-actuator + + + + com.hbt.onreal + hbt-onreal-common-datasource + + + + com.hbt.onreal + hbt-onreal-common-security + + + + com.hbt.onreal + hbt-onreal-common-swagger + + + + com.hbt.onreal + hbt-onreal-common-log + + + + io.springfox + springfox-swagger-ui + + + + mysql + mysql-connector-java + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + \ No newline at end of file diff --git a/hbt-vehicle-management-biz/src/main/java/com/hbt/vehicle/management/vehicleManagementApplication.java b/hbt-vehicle-management-biz/src/main/java/com/hbt/vehicle/management/vehicleManagementApplication.java new file mode 100644 index 0000000..7327fbf --- /dev/null +++ b/hbt-vehicle-management-biz/src/main/java/com/hbt/vehicle/management/vehicleManagementApplication.java @@ -0,0 +1,25 @@ +package com.hbt.vehicle.management; + +import com.hbt.common.security.annotation.EnableCustomConfig; +import com.hbt.common.security.annotation.EnableRyFeignClients; +import com.hbt.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.SpringCloudApplication; + +/** + * 入口类, 扫描并注入其他配置类和服务 + */ +@EnableCustomConfig +@SpringCloudApplication +@EnableCustomSwagger2 +@EnableRyFeignClients +@ServletComponentScan(basePackages = "com.hbt.vehicle.management") +public class vehicleManagementApplication { + + public static void main(String[] args) + { + SpringApplication.run(vehicleManagementApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 车辆管理系统启动成功 ლ(´ڡ`ლ)゙ "); + } +} diff --git a/hbt-vehicle-management-biz/src/main/resources/banner.txt b/hbt-vehicle-management-biz/src/main/resources/banner.txt new file mode 100644 index 0000000..53602f9 --- /dev/null +++ b/hbt-vehicle-management-biz/src/main/resources/banner.txt @@ -0,0 +1,9 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} +hbt-vehicle-management version: 1.0 + _ _ _ + | | | | | | + | |__ | |__ | |_ ______ ___ __ _ ___ ___ + | '_ \| '_ \| __|______/ __| / _` | / __| / __| + | | | | |_) | |_ \__ \ | (_| | \__ \ \__ \ + |_| |_|_.__/ \__| |___/ \__,_| |___/ |___/ diff --git a/hbt-vehicle-management-biz/src/main/resources/bootstrap-dev.yml b/hbt-vehicle-management-biz/src/main/resources/bootstrap-dev.yml new file mode 100644 index 0000000..78a8fbc --- /dev/null +++ b/hbt-vehicle-management-biz/src/main/resources/bootstrap-dev.yml @@ -0,0 +1,16 @@ +# Spring +spring: + cloud: + nacos: + username: nacos + password: zkhbt888 + discovery: + # 服务注册地址 + server-addr: ${nacos.ip}:8848 + config: + # 配置中心地址 + server-addr: ${nacos.ip}:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-dataids: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/hbt-vehicle-management-biz/src/main/resources/bootstrap.yml b/hbt-vehicle-management-biz/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..7b642af --- /dev/null +++ b/hbt-vehicle-management-biz/src/main/resources/bootstrap.yml @@ -0,0 +1,14 @@ +# Tomcat +server: + port: 9404 +# Spring +spring: + application: + # 应用名称 + name: hbt-vehicle-management + profiles: + # 环境配置 + active: dev + +nacos: + ip: 119.45.158.12 diff --git a/hbt-vehicle-management-biz/src/main/resources/db/readme.txt b/hbt-vehicle-management-biz/src/main/resources/db/readme.txt new file mode 100644 index 0000000..4a6d6b2 --- /dev/null +++ b/hbt-vehicle-management-biz/src/main/resources/db/readme.txt @@ -0,0 +1,4 @@ +执行顺序: +template_01_init_struct.sql -- 初始化表结构SQL +template_02_init_data.sql --初始化数据SQL +template_03_init_index.sql --初始化表索引SQL diff --git a/hbt-vehicle-management-biz/src/main/resources/db/template_01_init_struct.sql b/hbt-vehicle-management-biz/src/main/resources/db/template_01_init_struct.sql new file mode 100644 index 0000000..c629ec2 --- /dev/null +++ b/hbt-vehicle-management-biz/src/main/resources/db/template_01_init_struct.sql @@ -0,0 +1 @@ +-- 第一步初始化表结构 \ No newline at end of file diff --git a/hbt-vehicle-management-biz/src/main/resources/db/template_02_init_data.sql b/hbt-vehicle-management-biz/src/main/resources/db/template_02_init_data.sql new file mode 100644 index 0000000..f1b65e6 --- /dev/null +++ b/hbt-vehicle-management-biz/src/main/resources/db/template_02_init_data.sql @@ -0,0 +1 @@ +-- 第二步初始化数据 \ No newline at end of file diff --git a/hbt-vehicle-management-biz/src/main/resources/db/template_03_init_index.sql b/hbt-vehicle-management-biz/src/main/resources/db/template_03_init_index.sql new file mode 100644 index 0000000..13f5fa3 --- /dev/null +++ b/hbt-vehicle-management-biz/src/main/resources/db/template_03_init_index.sql @@ -0,0 +1 @@ +-- 第三步初始化表索引 \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..279845f --- /dev/null +++ b/pom.xml @@ -0,0 +1,126 @@ + + + 4.0.0 + + com.hbt.sass + hbt-vehicle-management + 1.0-SNAPSHOT + template + + hbt-vehicle-management-api + hbt-vehicle-management-biz + + pom + + + 3.7.0-SNAPSHOT + UTF-8 + UTF-8 + 1.8 + 2.7.7 + + + + + central + https://maven.aliyun.com/repository/public + + false + always + + + true + always + warn + + + + maven-public + http://81.70.119.104:8081/repository/maven-public/ + + false + always + + + true + always + warn + + + + + + maven-public + http://81.70.119.104:8081/repository/maven-public/ + + true + + + true + + + + + + maven-public + http://81.70.119.104:8081/repository/maven-releases/ + + + maven-public + http://81.70.119.104:8081/repository/maven-snapshots/ + + + + + + + + + com.hbt.onreal + hbt-onreal + ${hbt-cloud.version} + pom + import + + + + com.hbt.sass + hbt-vehicle-management-api + ${project.version} + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/replace.bat b/replace.bat new file mode 100644 index 0000000..bff374b --- /dev/null +++ b/replace.bat @@ -0,0 +1,45 @@ +chcp 65001 +@echo off & SetLocal EnableDelayedExpansion +echo 正在清理git文件 +@for /r . %%a in (.) do @if exist "%%a/.git" rd /s /q "%%a/.git" +@echo git已经全部删除 +set old=template + +Set /p new=请输入工程英文简称(如prevention): + +Set /p version=请输入onreal版本(如3.7.0): + +echo. +echo 正在替换文件内容 +:: 替换版本号 +for /f %%i in ('dir /b /s /a:-d pom.xml') do ( +powershell -Command "(Get-Content %%i -Encoding utf8) -replace '3.7.0-SNAPSHOT', '%version%' | Set-Content %%i -Encoding utf8" +) +:: 将当前目录(包括子目录)下的所有 java 文本中的 template 替换为输入字符 +for /f %%i in ('dir /b /s /a:-d *.java,pom.xml,*.yml,*.sql,*.txt,Dockerfile') do ( +powershell -Command "(Get-Content %%i -Encoding utf8) -replace '%old%', '%new%' | Set-Content %%i -Encoding utf8" +) +echo 替换文件内容完成 + +echo. +echo 正在替换文件夹名 +for /d /r %%i in (*.*) do ( +set t=%%~ni +set t=!t:%old%=%new%! +if not exist "%%~dpi!t!" ren "%%i" "!t!" +) +echo 替换文件夹名完成 + +echo. +echo 正在替换文件名 +for /f %%i in ('dir /a:-d /s /b *.java,pom.xml,*.yml,*.sql,*.txt') do ( +set t=%%~ni +set ext=%%~xi +set t=!t:%old%=%new%! +if not exist "%%~dpi!t!" ren "%%i" "!t!!ext!" 2>nul +) +echo 替换文件名完成 + +echo 替换完成 + +pause \ No newline at end of file