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