From 714b75905036189dfc35a2917ca4771c9b6dee2e Mon Sep 17 00:00:00 2001 From: wol <1293433164@qq.com> Date: Thu, 14 Aug 2025 00:39:03 +0800 Subject: [PATCH] config --- .../src/main/resources/application-dev.yml | 57 +++++++++++++++++++ .../src/main/resources/application.yml | 13 ++++- agileboot-common/wol-common-core/pom.xml | 7 ++- agileboot-common/wol-common-mybatis/pom.xml | 14 +++++ .../src/main/resources/common-mybatis.yml | 3 +- .../system/config/db/SysConfigMapper.java | 15 ----- .../config/db/SysConfigServiceImpl.java | 35 ------------ .../agileboot-system-base/pom.xml | 4 ++ .../controller/SysConfigController.java | 11 ++++ .../system/config/mapper/SysConfigMapper.java | 16 ++++++ .../config/mapper/xml/SysConfigMapper.xml | 6 ++ .../system/config/pojo}/dto/ConfigDTO.java | 21 ++++--- .../system/config/pojo/entity/SysConfig.java | 18 +++--- .../config/service/ISysConfigService.java | 6 +- .../service/impl/SysConfigServiceImpl.java | 34 +++++++++++ pom.xml | 1 + 16 files changed, 181 insertions(+), 80 deletions(-) create mode 100644 agileboot-boot-start/src/main/resources/application-dev.yml delete mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigMapper.java delete mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigServiceImpl.java create mode 100644 agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/mapper/SysConfigMapper.java create mode 100644 agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/mapper/xml/SysConfigMapper.xml rename {agileboot-domain/src/main/java/com/agileboot/domain/system/config => agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/pojo}/dto/ConfigDTO.java (64%) rename agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigEntity.java => agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/pojo/entity/SysConfig.java (78%) rename agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigService.java => agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/service/ISysConfigService.java (59%) create mode 100644 agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/service/impl/SysConfigServiceImpl.java diff --git a/agileboot-boot-start/src/main/resources/application-dev.yml b/agileboot-boot-start/src/main/resources/application-dev.yml new file mode 100644 index 0000000..6645816 --- /dev/null +++ b/agileboot-boot-start/src/main/resources/application-dev.yml @@ -0,0 +1,57 @@ +# 数据源配置 +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: agileboot + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: + primary: master + strict: false + druid: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + datasource: + master: + url: jdbc:mysql://mysql2.sqlpub.com:3307/agileboot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&sslMode=REQUIRED + username: ENC(s4kjpEsplGGLeV3YRNvJpJhDSOAO0tEf) + password: ENC(hg/hxmducWsI8u83/eXgAi8yHBDFbB5z0xzwNtBejPc=) +jasypt: + encryptor: + password: ${JASYPT_ENCRYPTOR_PASSWORD:} \ No newline at end of file diff --git a/agileboot-boot-start/src/main/resources/application.yml b/agileboot-boot-start/src/main/resources/application.yml index f293551..2bbcbe4 100644 --- a/agileboot-boot-start/src/main/resources/application.yml +++ b/agileboot-boot-start/src/main/resources/application.yml @@ -1,4 +1,13 @@ server: - port: 8080 + port: 8088 servlet: - context-path: /api \ No newline at end of file + context-path: /api + tomcat: + uri-encoding: UTF-8 # tomcat的URI编码 + accept-count: 1000 # 连接数满后的排队数,默认为100 + threads: + max: 800 # tomcat最大线程数,默认为200 + min-spare: 100 # Tomcat启动初始化的线程数,默认值10 +spring: + profiles: + active: dev \ No newline at end of file diff --git a/agileboot-common/wol-common-core/pom.xml b/agileboot-common/wol-common-core/pom.xml index 7fba0e3..6763664 100644 --- a/agileboot-common/wol-common-core/pom.xml +++ b/agileboot-common/wol-common-core/pom.xml @@ -85,7 +85,12 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + 2.1.1 + diff --git a/agileboot-common/wol-common-mybatis/pom.xml b/agileboot-common/wol-common-mybatis/pom.xml index 406bfa6..914e99f 100644 --- a/agileboot-common/wol-common-mybatis/pom.xml +++ b/agileboot-common/wol-common-mybatis/pom.xml @@ -20,6 +20,20 @@ com.baomidou mybatis-plus-spring-boot3-starter + + com.baomidou + dynamic-datasource-spring-boot3-starter + ${dynamic-ds.version} + + + com.alibaba + druid + 1.2.20 + + + com.mysql + mysql-connector-j + \ No newline at end of file diff --git a/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml b/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml index 19d90d5..2386071 100644 --- a/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml +++ b/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml @@ -3,6 +3,7 @@ # https://baomidou.com/config/ mybatis-plus: mapper-locations: classpath*:com/agileboot/**/mapper/xml/*Mapper.xml + mapperPackage: com.agileboot.**.mapper* # 启动时是否检查 MyBatis XML 文件的存在,默认不检查 checkConfigLocation: false configuration: @@ -23,7 +24,7 @@ mybatis-plus: dbConfig: idType: ASSIGN_ID # 主键类型: AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID table-underline: true # 默认数据库表下划线命名 -# logic-delete-field: logic_status # 全局逻辑删除字段名 + # logic-delete-field: logic_status # 全局逻辑删除字段名 logicDeleteValue: 1 # 逻辑已删除值(框架表均使用此值 禁止随意修改) logicNotDeleteValue: 0 # 逻辑未删除值 insertStrategy: NOT_NULL diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigMapper.java deleted file mode 100644 index 5cadbc8..0000000 --- a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.agileboot.domain.system.config.db; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - *

- * 参数配置表 Mapper 接口 - *

- * - * @author valarchie - * @since 2022-06-09 - */ -public interface SysConfigMapper extends BaseMapper { - -} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigServiceImpl.java b/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigServiceImpl.java deleted file mode 100644 index 7e56254..0000000 --- a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.agileboot.domain.system.config.db; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 参数配置表 服务实现类 - *

- * - * @author valarchie - * @since 2022-06-09 - */ -@Service -public class SysConfigServiceImpl extends ServiceImpl implements - SysConfigService { - - @Override - public String getConfigValueByKey(String key) { - if (StrUtil.isBlank(key)) { - return StrUtil.EMPTY; - } - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("config_key", key); - SysConfigEntity one = this.getOne(queryWrapper); - if (one == null || one.getConfigValue() == null) { - return StrUtil.EMPTY; - } - return one.getConfigValue(); - } - - -} diff --git a/agileboot-system/agileboot-system-base/pom.xml b/agileboot-system/agileboot-system-base/pom.xml index 331885d..a8e9418 100644 --- a/agileboot-system/agileboot-system-base/pom.xml +++ b/agileboot-system/agileboot-system-base/pom.xml @@ -16,6 +16,10 @@ com.agileboot wol-common-web + + com.agileboot + wol-common-mybatis + diff --git a/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/controller/SysConfigController.java b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/controller/SysConfigController.java index 9ce0c3e..2fda7c3 100644 --- a/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/controller/SysConfigController.java +++ b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/controller/SysConfigController.java @@ -1,7 +1,11 @@ package com.agileboot.system.config.controller; +import com.agileboot.common.core.core.R; +import com.agileboot.common.core.exception.BizException; +import com.agileboot.system.config.service.ISysConfigService; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -14,4 +18,11 @@ import org.springframework.web.bind.annotation.RestController; @Validated @RequiredArgsConstructor public class SysConfigController { + + private final ISysConfigService sysConfigService; + + @GetMapping("/test") + public R test() { + return R.ok(sysConfigService.getConfigValueByKey("sys.config.test")); + } } diff --git a/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/mapper/SysConfigMapper.java b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/mapper/SysConfigMapper.java new file mode 100644 index 0000000..113cdc9 --- /dev/null +++ b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/mapper/SysConfigMapper.java @@ -0,0 +1,16 @@ +package com.agileboot.system.config.mapper; + +import com.agileboot.system.config.pojo.entity.SysConfig; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 参数配置表 Mapper 接口 + *

+ * + * @author valarchie + * @since 2022-06-09 + */ +public interface SysConfigMapper extends BaseMapper { + +} diff --git a/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/mapper/xml/SysConfigMapper.xml b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/mapper/xml/SysConfigMapper.xml new file mode 100644 index 0000000..f23ec0b --- /dev/null +++ b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/mapper/xml/SysConfigMapper.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/dto/ConfigDTO.java b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/pojo/dto/ConfigDTO.java similarity index 64% rename from agileboot-domain/src/main/java/com/agileboot/domain/system/config/dto/ConfigDTO.java rename to agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/pojo/dto/ConfigDTO.java index 6be4a1c..f5362f4 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/dto/ConfigDTO.java +++ b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/pojo/dto/ConfigDTO.java @@ -1,32 +1,31 @@ -package com.agileboot.domain.system.config.dto; +package com.agileboot.system.config.pojo.dto; -import cn.hutool.core.collection.ListUtil; import cn.hutool.core.convert.Convert; import cn.hutool.json.JSONUtil; -import com.agileboot.common.enums.common.YesOrNoEnum; -import com.agileboot.common.enums.BasicEnumUtil; -import com.agileboot.domain.system.config.db.SysConfigEntity; -import io.swagger.v3.oas.annotations.media.Schema; +import com.agileboot.common.core.enums.BasicEnumUtil; +import com.agileboot.common.core.enums.common.YesOrNoEnum; +import com.agileboot.system.config.pojo.entity.SysConfig; +import lombok.Data; + +import java.util.Collections; import java.util.Date; import java.util.List; -import lombok.Data; /** * @author valarchie */ @Data -@Schema(name = "ConfigDTO", description = "配置信息") public class ConfigDTO { - public ConfigDTO(SysConfigEntity entity) { + public ConfigDTO(SysConfig entity) { if (entity != null) { configId = entity.getConfigId() + ""; configName = entity.getConfigName(); configKey = entity.getConfigKey(); configValue = entity.getConfigValue(); configOptions = - JSONUtil.isTypeJSONArray(entity.getConfigOptions()) ? JSONUtil.toList(entity.getConfigOptions(), - String.class) : ListUtil.empty(); + JSONUtil.isTypeJSONArray(entity.getConfigOptions()) ? JSONUtil.toList(entity.getConfigOptions(), + String.class) : Collections.emptyList(); isAllowChange = Convert.toInt(entity.getIsAllowChange()); isAllowChangeStr = BasicEnumUtil.getDescriptionByBool(YesOrNoEnum.class, entity.getIsAllowChange()); remark = entity.getRemark(); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigEntity.java b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/pojo/entity/SysConfig.java similarity index 78% rename from agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigEntity.java rename to agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/pojo/entity/SysConfig.java index e91dce1..2631c9e 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigEntity.java +++ b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/pojo/entity/SysConfig.java @@ -1,16 +1,17 @@ -package com.agileboot.domain.system.config.db; +package com.agileboot.system.config.pojo.entity; -import com.agileboot.common.core.base.BaseEntity; +import com.agileboot.common.mybatis.core.domain.BaseEntity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.Serializable; import lombok.Getter; import lombok.Setter; +import java.io.Serial; + /** *

* 参数配置表 @@ -22,9 +23,10 @@ import lombok.Setter; @Getter @Setter @TableName("sys_config") -@ApiModel(value = "SysConfigEntity对象", description = "参数配置表") -public class SysConfigEntity extends BaseEntity { +@ApiModel(value = "SysConfig对象", description = "参数配置表") +public class SysConfig extends BaseEntity { + @Serial private static final long serialVersionUID = 1L; @ApiModelProperty("参数主键") @@ -55,10 +57,4 @@ public class SysConfigEntity extends BaseEntity { @TableField("remark") private String remark; - - @Override - public Serializable pkVal() { - return this.configId; - } - } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigService.java b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/service/ISysConfigService.java similarity index 59% rename from agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigService.java rename to agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/service/ISysConfigService.java index 39c5a85..484bc97 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/system/config/db/SysConfigService.java +++ b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/service/ISysConfigService.java @@ -1,6 +1,4 @@ -package com.agileboot.domain.system.config.db; - -import com.baomidou.mybatisplus.extension.service.IService; +package com.agileboot.system.config.service; /** *

@@ -10,7 +8,7 @@ import com.baomidou.mybatisplus.extension.service.IService; * @author valarchie * @since 2022-06-09 */ -public interface SysConfigService extends IService { +public interface ISysConfigService { /** * 通过key获取配置 diff --git a/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/service/impl/SysConfigServiceImpl.java b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/service/impl/SysConfigServiceImpl.java new file mode 100644 index 0000000..934b019 --- /dev/null +++ b/agileboot-system/agileboot-system-base/src/main/java/com/agileboot/system/config/service/impl/SysConfigServiceImpl.java @@ -0,0 +1,34 @@ +package com.agileboot.system.config.service.impl; + +import com.agileboot.system.config.mapper.SysConfigMapper; +import com.agileboot.system.config.pojo.entity.SysConfig; +import com.agileboot.system.config.service.ISysConfigService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +/** + *

+ * 参数配置表 服务实现类 + *

+ * + * @author valarchie + * @since 2022-06-09 + */ +@Service +public class SysConfigServiceImpl extends ServiceImpl implements ISysConfigService { + + @Override + public String getConfigValueByKey(String key) { + if (StringUtils.isBlank(key)) { + return ""; + } + + SysConfig one = this.lambdaQuery().eq(SysConfig::getConfigKey, key).one(); + if (one == null || one.getConfigValue() == null) { + return ""; + } + return one.getConfigValue(); + } + +} diff --git a/pom.xml b/pom.xml index 7f02bd2..c0b1892 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,7 @@ 3.5.4 3.5.16 3.5.12 + 4.3.1 2.8.9 0.15.0 5.8.38