chore: 使用属性变量消除配置文件中分散的 ContiNew Admin 品牌元素
1.项目配置属性前缀由 continew-admin 改为 project(暂时未发现属性前缀 project 冲突) 2.配置文件中涉及到项目元素信息使用的,统一通过变量引用项目配置属性(如此改动之后,仅需要修改项目配置即可快速调整大量项目配置信息)
This commit is contained in:
parent
cd3ac8a120
commit
54ea41048a
@ -29,7 +29,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.config.properties.ContiNewAdminProperties;
|
import top.charles7c.cnadmin.common.config.properties.ProjectProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口文档配置
|
* 接口文档配置
|
||||||
@ -42,17 +42,17 @@ import top.charles7c.cnadmin.common.config.properties.ContiNewAdminProperties;
|
|||||||
@ConditionalOnProperty(name = "springdoc.swagger-ui.enabled", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(name = "springdoc.swagger-ui.enabled", havingValue = "true", matchIfMissing = true)
|
||||||
public class SwaggerConfiguration {
|
public class SwaggerConfiguration {
|
||||||
|
|
||||||
private final ContiNewAdminProperties continewAdminProperties;
|
private final ProjectProperties projectProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口文档配置
|
* 接口文档配置
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public OpenAPI openApi() {
|
public OpenAPI openApi() {
|
||||||
return new OpenAPI().info(new Info().title(continewAdminProperties.getName() + " 接口文档")
|
return new OpenAPI().info(new Info().title(projectProperties.getName() + " 接口文档")
|
||||||
.version(String.format("v%s", continewAdminProperties.getVersion()))
|
.version(String.format("v%s", projectProperties.getVersion()))
|
||||||
.description(continewAdminProperties.getDescription()).termsOfService(continewAdminProperties.getUrl())
|
.description(projectProperties.getDescription()).termsOfService(projectProperties.getUrl())
|
||||||
.contact(continewAdminProperties.getAuthor()).license(continewAdminProperties.getLicense()));
|
.contact(projectProperties.getAuthor()).license(projectProperties.getLicense()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,8 +36,8 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "continew-admin")
|
@ConfigurationProperties(prefix = "project")
|
||||||
public class ContiNewAdminProperties {
|
public class ProjectProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
@ -87,6 +87,6 @@ public class ContiNewAdminProperties {
|
|||||||
public static final boolean IP_ADDR_LOCAL_PARSE_ENABLED;
|
public static final boolean IP_ADDR_LOCAL_PARSE_ENABLED;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
IP_ADDR_LOCAL_PARSE_ENABLED = Convert.toBool(SpringUtil.getProperty("continew-admin.ipAddrLocalParseEnabled"));
|
IP_ADDR_LOCAL_PARSE_ENABLED = Convert.toBool(SpringUtil.getProperty("project.ipAddrLocalParseEnabled"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ import cn.hutool.http.HttpUtil;
|
|||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.config.properties.ContiNewAdminProperties;
|
import top.charles7c.cnadmin.common.config.properties.ProjectProperties;
|
||||||
|
|
||||||
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
||||||
import net.dreamlu.mica.ip2region.core.IpInfo;
|
import net.dreamlu.mica.ip2region.core.IpInfo;
|
||||||
@ -55,7 +55,7 @@ public class IpUtils {
|
|||||||
* @return 归属地信息
|
* @return 归属地信息
|
||||||
*/
|
*/
|
||||||
public static String getCityInfo(String ip) {
|
public static String getCityInfo(String ip) {
|
||||||
if (ContiNewAdminProperties.IP_ADDR_LOCAL_PARSE_ENABLED) {
|
if (ProjectProperties.IP_ADDR_LOCAL_PARSE_ENABLED) {
|
||||||
return getLocalCityInfo(ip);
|
return getLocalCityInfo(ip);
|
||||||
} else {
|
} else {
|
||||||
return getHttpCityInfo(ip);
|
return getHttpCityInfo(ip);
|
||||||
|
@ -38,7 +38,7 @@ import cn.hutool.core.convert.Convert;
|
|||||||
import cn.hutool.core.util.URLUtil;
|
import cn.hutool.core.util.URLUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.config.properties.ContiNewAdminProperties;
|
import top.charles7c.cnadmin.common.config.properties.ProjectProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
@ -54,7 +54,7 @@ import top.charles7c.cnadmin.common.config.properties.ContiNewAdminProperties;
|
|||||||
@ComponentScan(basePackages = {"top.charles7c.cnadmin", "cn.hutool.extra.spring"})
|
@ComponentScan(basePackages = {"top.charles7c.cnadmin", "cn.hutool.extra.spring"})
|
||||||
public class ContiNewAdminApplication implements ApplicationRunner {
|
public class ContiNewAdminApplication implements ApplicationRunner {
|
||||||
|
|
||||||
private final ContiNewAdminProperties properties;
|
private final ProjectProperties projectProperties;
|
||||||
private final ServerProperties serverProperties;
|
private final ServerProperties serverProperties;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -70,7 +70,7 @@ public class ContiNewAdminApplication implements ApplicationRunner {
|
|||||||
@SaIgnore
|
@SaIgnore
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String index() {
|
public String index() {
|
||||||
return String.format("%s backend service started successfully.", properties.getName());
|
return String.format("%s backend service started successfully.", projectProperties.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,7 +80,7 @@ public class ContiNewAdminApplication implements ApplicationRunner {
|
|||||||
String contextPath = serverProperties.getServlet().getContextPath();
|
String contextPath = serverProperties.getServlet().getContextPath();
|
||||||
String baseUrl = URLUtil.normalize(String.format("%s:%s%s", hostAddress, port, contextPath));
|
String baseUrl = URLUtil.normalize(String.format("%s:%s%s", hostAddress, port, contextPath));
|
||||||
log.info("------------------------------------------------------");
|
log.info("------------------------------------------------------");
|
||||||
log.info("{} backend service started successfully.", properties.getName());
|
log.info("{} backend service started successfully.", projectProperties.getName());
|
||||||
log.info("后端 API 地址:{}", baseUrl);
|
log.info("后端 API 地址:{}", baseUrl);
|
||||||
Boolean docEnabled = Convert.toBool(SpringUtil.getProperty("springdoc.swagger-ui.enabled"));
|
Boolean docEnabled = Convert.toBool(SpringUtil.getProperty("springdoc.swagger-ui.enabled"));
|
||||||
if (Boolean.TRUE.equals(docEnabled)) {
|
if (Boolean.TRUE.equals(docEnabled)) {
|
||||||
|
@ -40,7 +40,7 @@ import cn.hutool.core.util.IdUtil;
|
|||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.config.properties.CaptchaProperties;
|
import top.charles7c.cnadmin.common.config.properties.CaptchaProperties;
|
||||||
import top.charles7c.cnadmin.common.config.properties.ContiNewAdminProperties;
|
import top.charles7c.cnadmin.common.config.properties.ProjectProperties;
|
||||||
import top.charles7c.cnadmin.common.constant.CacheConsts;
|
import top.charles7c.cnadmin.common.constant.CacheConsts;
|
||||||
import top.charles7c.cnadmin.common.constant.RegexConsts;
|
import top.charles7c.cnadmin.common.constant.RegexConsts;
|
||||||
import top.charles7c.cnadmin.common.model.vo.CaptchaVO;
|
import top.charles7c.cnadmin.common.model.vo.CaptchaVO;
|
||||||
@ -65,7 +65,7 @@ import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
|||||||
public class CaptchaController {
|
public class CaptchaController {
|
||||||
|
|
||||||
private final CaptchaProperties captchaProperties;
|
private final CaptchaProperties captchaProperties;
|
||||||
private final ContiNewAdminProperties properties;
|
private final ProjectProperties projectProperties;
|
||||||
|
|
||||||
@Operation(summary = "获取图片验证码", description = "获取图片验证码(Base64编码,带图片格式:data:image/gif;base64)")
|
@Operation(summary = "获取图片验证码", description = "获取图片验证码(Base64编码,带图片格式:data:image/gif;base64)")
|
||||||
@GetMapping("/img")
|
@GetMapping("/img")
|
||||||
@ -101,7 +101,7 @@ public class CaptchaController {
|
|||||||
Long expirationInMinutes = captchaMail.getExpirationInMinutes();
|
Long expirationInMinutes = captchaMail.getExpirationInMinutes();
|
||||||
String content = TemplateUtils.render(captchaMail.getTemplatePath(),
|
String content = TemplateUtils.render(captchaMail.getTemplatePath(),
|
||||||
Dict.create().set("captcha", captcha).set("expiration", expirationInMinutes));
|
Dict.create().set("captcha", captcha).set("expiration", expirationInMinutes));
|
||||||
MailUtils.sendHtml(email, String.format("【%s】邮箱验证码", properties.getName()), content);
|
MailUtils.sendHtml(email, String.format("【%s】邮箱验证码", projectProperties.getName()), content);
|
||||||
|
|
||||||
// 保存验证码
|
// 保存验证码
|
||||||
String captchaKey = RedisUtils.formatKey(captchaKeyPrefix, email);
|
String captchaKey = RedisUtils.formatKey(captchaKeyPrefix, email);
|
||||||
|
@ -37,7 +37,7 @@ import cn.hutool.core.lang.tree.Tree;
|
|||||||
import cn.hutool.core.util.ClassUtil;
|
import cn.hutool.core.util.ClassUtil;
|
||||||
|
|
||||||
import top.charles7c.cnadmin.common.base.BaseEnum;
|
import top.charles7c.cnadmin.common.base.BaseEnum;
|
||||||
import top.charles7c.cnadmin.common.config.properties.ContiNewAdminProperties;
|
import top.charles7c.cnadmin.common.config.properties.ProjectProperties;
|
||||||
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
import top.charles7c.cnadmin.common.model.query.SortQuery;
|
||||||
import top.charles7c.cnadmin.common.model.vo.LabelValueVO;
|
import top.charles7c.cnadmin.common.model.vo.LabelValueVO;
|
||||||
import top.charles7c.cnadmin.common.model.vo.R;
|
import top.charles7c.cnadmin.common.model.vo.R;
|
||||||
@ -67,7 +67,7 @@ public class CommonController {
|
|||||||
private final DeptService deptService;
|
private final DeptService deptService;
|
||||||
private final MenuService menuService;
|
private final MenuService menuService;
|
||||||
private final RoleService roleService;
|
private final RoleService roleService;
|
||||||
private final ContiNewAdminProperties properties;
|
private final ProjectProperties projectProperties;
|
||||||
|
|
||||||
@Operation(summary = "查询部门树", description = "查询树结构的部门列表")
|
@Operation(summary = "查询部门树", description = "查询树结构的部门列表")
|
||||||
@GetMapping("/tree/dept")
|
@GetMapping("/tree/dept")
|
||||||
@ -95,7 +95,7 @@ public class CommonController {
|
|||||||
@GetMapping("/dict/enum/{enumTypeName}")
|
@GetMapping("/dict/enum/{enumTypeName}")
|
||||||
public R<List<LabelValueVO>> listEnumDict(@PathVariable String enumTypeName) {
|
public R<List<LabelValueVO>> listEnumDict(@PathVariable String enumTypeName) {
|
||||||
// 扫描所有 BaseEnum 枚举基类的子类
|
// 扫描所有 BaseEnum 枚举基类的子类
|
||||||
Set<Class<?>> classSet = ClassUtil.scanPackageBySuper(properties.getBasePackage(), BaseEnum.class);
|
Set<Class<?>> classSet = ClassUtil.scanPackageBySuper(projectProperties.getBasePackage(), BaseEnum.class);
|
||||||
Optional<Class<?>> first =
|
Optional<Class<?>> first =
|
||||||
classSet.stream().filter(c -> c.getSimpleName().equalsIgnoreCase(enumTypeName)).findFirst();
|
classSet.stream().filter(c -> c.getSimpleName().equalsIgnoreCase(enumTypeName)).findFirst();
|
||||||
if (!first.isPresent()) {
|
if (!first.isPresent()) {
|
||||||
|
@ -157,8 +157,8 @@ local-storage:
|
|||||||
avatarMaxSizeInMb: 5
|
avatarMaxSizeInMb: 5
|
||||||
## Windows 系统本地存储配置
|
## Windows 系统本地存储配置
|
||||||
windows:
|
windows:
|
||||||
file: C:\continew-admin\data\file\
|
file: C:\${project.appName}\data\file\
|
||||||
avatar: C:\continew-admin\data\avatar\
|
avatar: C:\${project.appName}\data\avatar\
|
||||||
## Linux 系统本地存储配置
|
## Linux 系统本地存储配置
|
||||||
linux:
|
linux:
|
||||||
file: /data/file/
|
file: /data/file/
|
||||||
|
@ -154,8 +154,8 @@ local-storage:
|
|||||||
avatarMaxSizeInMb: 5
|
avatarMaxSizeInMb: 5
|
||||||
## Windows 系统本地存储配置
|
## Windows 系统本地存储配置
|
||||||
windows:
|
windows:
|
||||||
file: C:\continew-admin\data\file\
|
file: C:\${project.appName}\data\file\
|
||||||
avatar: C:\continew-admin\data\avatar\
|
avatar: C:\${project.appName}\data\avatar\
|
||||||
## Linux 系统本地存储配置
|
## Linux 系统本地存储配置
|
||||||
linux:
|
linux:
|
||||||
file: /data/file/
|
file: /data/file/
|
||||||
@ -169,8 +169,7 @@ local-storage:
|
|||||||
cors:
|
cors:
|
||||||
# 配置允许跨域的域名
|
# 配置允许跨域的域名
|
||||||
allowedOrigins:
|
allowedOrigins:
|
||||||
- http://cnadmin.charles7c.top
|
- ${project.url}
|
||||||
- https://cnadmin.charles7c.top
|
|
||||||
# 配置允许跨域的请求方式
|
# 配置允许跨域的请求方式
|
||||||
allowedMethods: '*'
|
allowedMethods: '*'
|
||||||
# 配置允许跨域的请求头
|
# 配置允许跨域的请求头
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--- ### 项目配置
|
--- ### 项目配置
|
||||||
continew-admin:
|
project:
|
||||||
# 名称
|
# 名称
|
||||||
name: ContiNew Admin
|
name: ContiNew Admin
|
||||||
# 应用名称
|
# 应用名称
|
||||||
@ -9,7 +9,7 @@ continew-admin:
|
|||||||
# 描述
|
# 描述
|
||||||
description: ContiNew Admin 中后台管理框架/脚手架,Continue New Admin,持续以最新流行技术栈构建,拥抱变化,迭代优化。
|
description: ContiNew Admin 中后台管理框架/脚手架,Continue New Admin,持续以最新流行技术栈构建,拥抱变化,迭代优化。
|
||||||
# URL
|
# URL
|
||||||
url: https://github.com/Charles7c/continew-admin
|
url: https://cnadmin.charles7c.top
|
||||||
# 基本包
|
# 基本包
|
||||||
basePackage: top.charles7c.cnadmin
|
basePackage: top.charles7c.cnadmin
|
||||||
## 作者信息配置
|
## 作者信息配置
|
||||||
@ -61,27 +61,27 @@ springdoc:
|
|||||||
group-configs:
|
group-configs:
|
||||||
- group: 'all'
|
- group: 'all'
|
||||||
paths-to-match: '/**'
|
paths-to-match: '/**'
|
||||||
packages-to-scan: top.charles7c.cnadmin.webapi.controller
|
packages-to-scan: ${project.basePackage}.webapi.controller
|
||||||
- group: 'auth'
|
- group: 'auth'
|
||||||
display-name: '系统认证'
|
display-name: '系统认证'
|
||||||
paths-to-match: '/auth/**'
|
paths-to-match: '/auth/**'
|
||||||
packages-to-scan: top.charles7c.cnadmin.webapi.controller.auth
|
packages-to-scan: ${project.basePackage}.webapi.controller.auth
|
||||||
- group: 'common'
|
- group: 'common'
|
||||||
display-name: '通用接口'
|
display-name: '通用接口'
|
||||||
paths-to-match: '/common/**'
|
paths-to-match: '/common/**'
|
||||||
packages-to-scan: top.charles7c.cnadmin.webapi.controller.common
|
packages-to-scan: ${project.basePackage}.webapi.controller.common
|
||||||
- group: 'system'
|
- group: 'system'
|
||||||
display-name: '系统管理'
|
display-name: '系统管理'
|
||||||
paths-to-match: '/system/**'
|
paths-to-match: '/system/**'
|
||||||
packages-to-scan: top.charles7c.cnadmin.webapi.controller.system
|
packages-to-scan: ${project.basePackage}.webapi.controller.system
|
||||||
- group: 'tool'
|
- group: 'tool'
|
||||||
display-name: '系统工具'
|
display-name: '系统工具'
|
||||||
paths-to-match: '/tool/**'
|
paths-to-match: '/tool/**'
|
||||||
packages-to-scan: top.charles7c.cnadmin.webapi.controller.tool
|
packages-to-scan: ${project.basePackage}.webapi.controller.tool
|
||||||
- group: 'monitor'
|
- group: 'monitor'
|
||||||
display-name: '系统监控'
|
display-name: '系统监控'
|
||||||
paths-to-match: '/monitor/**'
|
paths-to-match: '/monitor/**'
|
||||||
packages-to-scan: top.charles7c.cnadmin.webapi.controller.monitor
|
packages-to-scan: ${project.basePackage}.webapi.controller.monitor
|
||||||
## 接口文档增强配置
|
## 接口文档增强配置
|
||||||
knife4j:
|
knife4j:
|
||||||
enable: true
|
enable: true
|
||||||
@ -93,7 +93,7 @@ knife4j:
|
|||||||
# 是否自定义 footer(默认 false 非自定义)
|
# 是否自定义 footer(默认 false 非自定义)
|
||||||
enable-footer-custom: true
|
enable-footer-custom: true
|
||||||
# 自定义 footer 内容,支持 Markdown 语法
|
# 自定义 footer 内容,支持 Markdown 语法
|
||||||
footer-custom-content: 'Copyright © 2022-present [${continew-admin.author.name}](${continew-admin.author.url}) ⋅ [${continew-admin.name}](${continew-admin.url}) v${continew-admin.version}'
|
footer-custom-content: 'Copyright © 2022-present [${project.author.name}](${project.author.url}) ⋅ [${project.name}](${project.url}) v${project.version}'
|
||||||
|
|
||||||
--- ### Sa-Token 配置
|
--- ### Sa-Token 配置
|
||||||
sa-token:
|
sa-token:
|
||||||
@ -124,11 +124,11 @@ sa-token:
|
|||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
# Mapper 接口扫描包配置(该配置为自定义配置,非 MP 配置,不支持多包,如有需要可通过注解配置或提升扫描包层级)
|
# Mapper 接口扫描包配置(该配置为自定义配置,非 MP 配置,不支持多包,如有需要可通过注解配置或提升扫描包层级)
|
||||||
# 该配置目前的唯一使用场景为:@MapperScan("${mybatis-plus.mapper-package}")
|
# 该配置目前的唯一使用场景为:@MapperScan("${mybatis-plus.mapper-package}")
|
||||||
mapper-package: top.charles7c.**.mapper
|
mapper-package: ${project.basePackage}.**.mapper
|
||||||
# Mapper XML 文件目录配置
|
# Mapper XML 文件目录配置
|
||||||
mapper-locations: classpath*:/mapper/**/*Mapper.xml
|
mapper-locations: classpath*:/mapper/**/*Mapper.xml
|
||||||
# 类型别名扫描包配置
|
# 类型别名扫描包配置
|
||||||
type-aliases-package: top.charles7c.**.model
|
type-aliases-package: ${project.basePackage}.**.model
|
||||||
check-config-location: true
|
check-config-location: true
|
||||||
configuration:
|
configuration:
|
||||||
# 自动驼峰命名规则(camel case)映射
|
# 自动驼峰命名规则(camel case)映射
|
||||||
@ -180,7 +180,7 @@ server:
|
|||||||
--- ### Spring 配置
|
--- ### Spring 配置
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: ${continew-admin.appName}
|
name: ${project.appName}
|
||||||
## 环境配置
|
## 环境配置
|
||||||
profiles:
|
profiles:
|
||||||
# 启用的环境
|
# 启用的环境
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
| |___| (_) || | | || |_ | || |\ || __/ \ V V /|_____|/ ___ \| (_| || | | | | || || | | |
|
| |___| (_) || | | || |_ | || |\ || __/ \ V V /|_____|/ ___ \| (_| || | | | | || || | | |
|
||||||
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
|
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
|
||||||
|
|
||||||
:: ${continew-admin.name} :: v${continew-admin.version}
|
:: ${project.name} :: v${project.version}
|
||||||
:: Spring Boot :: v${spring-boot.version}
|
:: Spring Boot :: v${spring-boot.version}
|
||||||
|
Loading…
Reference in New Issue
Block a user