1. 重构模块与服务的生成器,使用模板的方式进行支持
This commit is contained in:
13
demo-server/Dockerfile
Normal file
13
demo-server/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FROM openjdk:17-jre-slim
|
||||||
|
|
||||||
|
# 设置应用目录
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 复制应用文件
|
||||||
|
COPY target/demo-server.jar /app/demo-server.jar
|
||||||
|
|
||||||
|
# 暴露端口
|
||||||
|
EXPOSE 48100
|
||||||
|
|
||||||
|
# 运行应用
|
||||||
|
ENTRYPOINT ["java", "-jar", "/app/demo-server.jar"]
|
||||||
99
demo-server/pom.xml
Normal file
99
demo-server/pom.xml
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>demo-server</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>demo-server</name>
|
||||||
|
<description>Demo 服务器</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-module-system-server</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-module-infra-server</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 服务保障相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-protection</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Registry 注册中心相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Config 配置中心相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- RPC 远程调用相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-rpc</artifactId>
|
||||||
|
<!-- 目的:yudao-server 单体启动,禁用 openfeign -->
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<!-- 设置构建的 jar 包名 -->
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<!-- 打包 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package cn.iocoder.yudao.demoserver;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Demo 服务器的启动类
|
||||||
|
*
|
||||||
|
* @author chenbw
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package}
|
||||||
|
@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.demoserver", "${yudao.info.base-package}.module"},
|
||||||
|
excludeName = {})
|
||||||
|
public class DemoServerApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(DemoServerApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package cn.iocoder.yudao.demoserver.controller.demo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* demo 控制器
|
||||||
|
*
|
||||||
|
* @author chenbw
|
||||||
|
*/
|
||||||
|
@Tag(name = "demo")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/demo")
|
||||||
|
public class DemoController {
|
||||||
|
|
||||||
|
@GetMapping("/hello")
|
||||||
|
@Operation(summary = "Hello demo")
|
||||||
|
public CommonResult<String> hello() {
|
||||||
|
return success("Hello, demo!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
118
demo-server/src/main/resources/application-dev.yml
Normal file
118
demo-server/src/main/resources/application-dev.yml
Normal file
File diff suppressed because it is too large
Load Diff
117
demo-server/src/main/resources/application-local.yml
Normal file
117
demo-server/src/main/resources/application-local.yml
Normal file
File diff suppressed because it is too large
Load Diff
109
demo-server/src/main/resources/application.yml
Normal file
109
demo-server/src/main/resources/application.yml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -56,5 +56,10 @@
|
|||||||
<groupId>uk.co.jemos.podam</groupId> <!-- 单元测试,随机生成 POJO 类 -->
|
<groupId>uk.co.jemos.podam</groupId> <!-- 单元测试,随机生成 POJO 类 -->
|
||||||
<artifactId>podam</artifactId>
|
<artifactId>podam</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package cn.iocoder.yudao.framework.test.core.ut;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码生成器通用工具类
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
public class GeneratorUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首字母大写
|
||||||
|
*
|
||||||
|
* @param str 字符串
|
||||||
|
* @return 首字母大写后的字符串
|
||||||
|
*/
|
||||||
|
public static String capitalize(String str) {
|
||||||
|
if (str == null || str.isEmpty()) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将小驼峰命名转换为短横线分割的命名
|
||||||
|
* 例如:orderManagement -> order-management
|
||||||
|
*
|
||||||
|
* @param camelCase 驼峰命名的字符串
|
||||||
|
* @return 短横线分割的字符串
|
||||||
|
*/
|
||||||
|
public static String camelToKebabCase(String camelCase) {
|
||||||
|
if (camelCase == null || camelCase.isEmpty()) {
|
||||||
|
return camelCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (int i = 0; i < camelCase.length(); i++) {
|
||||||
|
char c = camelCase.charAt(i);
|
||||||
|
if (Character.isUpperCase(c) && i > 0) {
|
||||||
|
result.append('-');
|
||||||
|
}
|
||||||
|
result.append(Character.toLowerCase(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 kebab-case 转换为 PascalCase
|
||||||
|
* 例如:demo-server -> DemoServer
|
||||||
|
*
|
||||||
|
* @param kebabCase 短横线分割的字符串
|
||||||
|
* @return 帕斯卡命名的字符串
|
||||||
|
*/
|
||||||
|
public static String toPascalCase(String kebabCase) {
|
||||||
|
if (kebabCase == null || kebabCase.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return Arrays.stream(kebabCase.split("-"))
|
||||||
|
.map(s -> {
|
||||||
|
if (s.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return s.substring(0, 1).toUpperCase() + s.substring(1);
|
||||||
|
})
|
||||||
|
.collect(Collectors.joining());
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user