mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-12 16:57:12 +08:00
重构:按功能初步拆分模块
This commit is contained in:
87
continew-admin-webapi/pom.xml
Normal file
87
continew-admin-webapi/pom.xml
Normal file
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>top.charles7c</groupId>
|
||||
<artifactId>continew-admin</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>continew-admin-webapi</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>API 模块(存放 Controller 层代码,打包部署的模块)</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统管理模块(存放系统管理模块相关功能,例如:部门管理、角色管理、用户管理等) -->
|
||||
<dependency>
|
||||
<groupId>top.charles7c</groupId>
|
||||
<artifactId>continew-admin-system</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- 设置构建的 jar 包名 -->
|
||||
<finalName>${project.parent.name}</finalName>
|
||||
<plugins>
|
||||
<!-- 单元测试配置插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>-Dfile.encoding=UTF-8</argLine>
|
||||
<!-- 根据启用环境执行对应 @Tag 的测试方法 -->
|
||||
<groups>${profiles.active}</groups>
|
||||
<!-- 排除标签 -->
|
||||
<excludedGroups>exclude</excludedGroups>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<!-- 如果没有该项配置,devtools 不会生效,应用不会自动重启 -->
|
||||
<fork>true</fork>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2022/12/8 23:15
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
public class ContinewAdminApplication {
|
||||
|
||||
private static Environment env;
|
||||
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(ContinewAdminApplication.class);
|
||||
ConfigurableApplicationContext context = application.run(args);
|
||||
|
||||
env = context.getEnvironment();
|
||||
log.info("------------------------------------------------------");
|
||||
log.info("{} backend service started successfully.", env.getProperty("continew-admin.name"));
|
||||
log.info("后端 API 地址:http://{}:{}", InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"));
|
||||
log.info("------------------------------------------------------");
|
||||
}
|
||||
|
||||
/**
|
||||
* 访问首页提示
|
||||
*
|
||||
* @return /
|
||||
*/
|
||||
@GetMapping("/")
|
||||
public String index() {
|
||||
return String.format("%s backend service started successfully.", env.getProperty("continew-admin.name"));
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
--- ### 服务器配置
|
||||
server:
|
||||
# HTTP 端口(默认 8080)
|
||||
port: 8000
|
||||
|
@@ -0,0 +1,5 @@
|
||||
--- ### 服务器配置
|
||||
server:
|
||||
# HTTP 端口(默认 8080)
|
||||
port: 18000
|
||||
|
62
continew-admin-webapi/src/main/resources/application.yml
Normal file
62
continew-admin-webapi/src/main/resources/application.yml
Normal file
@@ -0,0 +1,62 @@
|
||||
--- ### 项目配置
|
||||
continew-admin:
|
||||
# 名称
|
||||
name: ContiNew-Admin
|
||||
# 应用名称
|
||||
appName: @project.name@
|
||||
# 版本
|
||||
version: @project.version@
|
||||
|
||||
--- ### 日志配置(重叠部分,优先级高于 logback-spring.xml 中的配置)
|
||||
logging:
|
||||
level:
|
||||
top.charles7c: @logging.level@
|
||||
file:
|
||||
path: @logging.file.path@
|
||||
config: classpath:logback-spring.xml
|
||||
|
||||
--- ### 服务器配置
|
||||
server:
|
||||
servlet:
|
||||
# 应用访问路径
|
||||
context-path: /
|
||||
## Undertow 服务器配置
|
||||
undertow:
|
||||
# HTTP POST 请求内容的大小上限(默认 -1 不限制)
|
||||
max-http-post-size: -1
|
||||
# 以下的配置会影响 buffer,这些 buffer 会用于服务器连接的 IO 操作,有点类似 Netty 的池化内存管理
|
||||
# 每块 buffer的空间大小(越小的空间被利用越充分,不要设置太大,以免影响其他应用,合适即可)
|
||||
buffer-size: 512
|
||||
# 是否分配的直接内存(NIO 直接分配的堆外内存)
|
||||
direct-buffers: true
|
||||
threads:
|
||||
# 设置 IO 线程数,它主要执行非阻塞的任务,它们会负责多个连接(默认每个 CPU 核心一个线程)
|
||||
io: 8
|
||||
# 阻塞任务线程池,当执行类似 Servlet 请求阻塞操作,Undertow 会从这个线程池中取得线程(它的值设置取决于系统的负载)
|
||||
worker: 256
|
||||
|
||||
--- ### Spring 配置
|
||||
spring:
|
||||
application:
|
||||
name: ${continew-admin.appName}
|
||||
## 环境配置
|
||||
profiles:
|
||||
# 启用的环境
|
||||
# 配合 Maven Profile 选择不同配置文件进行启动,在 IntelliJ IDEA 右侧 Maven 工具窗口可以快速切换环境
|
||||
active: @profiles.active@
|
||||
## JSON 配置
|
||||
jackson:
|
||||
# 时区配置
|
||||
time-zone: GMT+8
|
||||
# 日期格式化
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
# 序列化配置(Bean -> JSON)
|
||||
serialization:
|
||||
# 是否格式化输出
|
||||
indent_output: false
|
||||
# 忽略无法转换的对象
|
||||
fail_on_empty_beans: false
|
||||
# 反序列化配置(JSON -> Bean)
|
||||
deserialization:
|
||||
# 忽略 JSON 中不存在的属性
|
||||
fail_on_unknown_properties: false
|
8
continew-admin-webapi/src/main/resources/banner.txt
Normal file
8
continew-admin-webapi/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
____ _ _ _ _ _ _ _
|
||||
/ ___| ___ _ __ | |_ (_)| \ | | ___ __ __ / \ __| | _ __ ___ (_) _ __
|
||||
| | / _ \ | '_ \ | __|| || \| | / _ \\ \ /\ / /_____ / _ \ / _` || '_ ` _ \ | || '_ \
|
||||
| |___| (_) || | | || |_ | || |\ || __/ \ V V /|_____|/ ___ \| (_| || | | | | || || | | |
|
||||
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
|
||||
|
||||
:: ${continew-admin.name} :: v${continew-admin.version}
|
||||
:: Spring Boot :: v${spring-boot.version}
|
71
continew-admin-webapi/src/main/resources/logback-spring.xml
Normal file
71
continew-admin-webapi/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 日志级别从低到高分为 TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为 WARN,则低于 WARN 的信息都不会输出 -->
|
||||
<!-- scan:当此属性设置为 true 时,配置文档如果发生改变,将会被重新加载,默认值为 true -->
|
||||
<!-- scanPeriod:设置监测配置文档是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。
|
||||
当 scan 为 true 时,此属性生效。默认的时间间隔为 1 分钟。 -->
|
||||
<!-- debug:当此属性设置为 true 时,将打印出 logback 内部日志信息,实时查看 logback 运行状态。默认值为 false。 -->
|
||||
<configuration debug="false" scan="true" scanPeriod="30 seconds">
|
||||
|
||||
<!-- 应用名 -->
|
||||
<springProperty name="APP_NAME" source="spring.application.name" scope="context" />
|
||||
<!-- 保存路径 -->
|
||||
<property name="LOG_PATH" value="${LOG_PATH:-./logs}" />
|
||||
<!-- 字符集 -->
|
||||
<property name="LOG_CHARSET" value="utf-8" />
|
||||
<!-- 控制台输出格式(带颜色) -->
|
||||
<!-- 格式化输出:%d 表示日期;%thread 表示线程名;%-5level:级别从左显示 5 个字符宽度;%msg:日志消息;%n 是换行符 -->
|
||||
<property name="CONSOLE_LOG_PATTERN" value="%red(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %green([%thread]) %boldMagenta(%logger{50}) - %msg%n" />
|
||||
<!-- 文件输出格式 -->
|
||||
<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{50} - %msg%n"/>
|
||||
|
||||
<!-- 输出日志到控制台 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
<charset>${LOG_CHARSET}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 输出日志到文件 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
<charset>${LOG_CHARSET}</charset>
|
||||
</encoder>
|
||||
<!-- 循环政策:基于时间和大小创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!-- 日志文件输出的文件名 -->
|
||||
<fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd, aux}/${APP_NAME}.%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
|
||||
<!-- 日志保存 10 天(一小时生成一个,一天 24 个文件) -->
|
||||
<maxHistory>240</maxHistory>
|
||||
<!-- 单个日志文件最大的大小 -->
|
||||
<maxFileSize>20MB</maxFileSize>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<!-- 异步输出日志到文件 -->
|
||||
<appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<!-- 不丢失日志,默认:如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 -->
|
||||
<discardingThreshold>0</discardingThreshold>
|
||||
<!-- 更改默认的队列的深度,该值会影响性能,默认:256 -->
|
||||
<queueSize>512</queueSize>
|
||||
<!-- 添加附加的 appender,最多只能添加一个 -->
|
||||
<appender-ref ref="FILE"/>
|
||||
</appender>
|
||||
|
||||
<!-- 开发环境:只打印到控制台 -->
|
||||
<springProfile name="dev">
|
||||
<!-- 如果配置的日志等级,和 application.yml 中的日志等级配置重叠,application.yml 配置优先级高 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
<!-- 生产环境:只输出到文件 -->
|
||||
<springProfile name="prod">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="ASYNC_FILE"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
</configuration>
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ContinewAdminApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user