config
This commit is contained in:
57
agileboot-boot-start/src/main/resources/application-dev.yml
Normal file
57
agileboot-boot-start/src/main/resources/application-dev.yml
Normal file
@@ -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:}
|
||||
@@ -1,4 +1,13 @@
|
||||
server:
|
||||
port: 8080
|
||||
port: 8088
|
||||
servlet:
|
||||
context-path: /api
|
||||
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
|
||||
@@ -85,7 +85,12 @@
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--ENC加密-->
|
||||
<dependency>
|
||||
<groupId>com.github.ulisesbocchio</groupId>
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger注解 -->
|
||||
<dependency>
|
||||
|
||||
@@ -20,6 +20,20 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
|
||||
<version>${dynamic-ds.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.2.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -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
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.agileboot.domain.system.config.db;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数配置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-06-09
|
||||
*/
|
||||
public interface SysConfigMapper extends BaseMapper<SysConfigEntity> {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数配置表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-06-09
|
||||
*/
|
||||
@Service
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfigEntity> implements
|
||||
SysConfigService {
|
||||
|
||||
@Override
|
||||
public String getConfigValueByKey(String key) {
|
||||
if (StrUtil.isBlank(key)) {
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
QueryWrapper<SysConfigEntity> 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -16,6 +16,10 @@
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-mybatis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -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<String> test() {
|
||||
return R.ok(sysConfigService.getConfigValueByKey("sys.config.test"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数配置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-06-09
|
||||
*/
|
||||
public interface SysConfigMapper extends BaseMapper<SysConfig> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.config.pojo.entity.SysConfig">
|
||||
|
||||
</mapper>
|
||||
@@ -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();
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数配置表
|
||||
@@ -22,9 +23,10 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_config")
|
||||
@ApiModel(value = "SysConfigEntity对象", description = "参数配置表")
|
||||
public class SysConfigEntity extends BaseEntity<SysConfigEntity> {
|
||||
@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<SysConfigEntity> {
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
|
||||
@Override
|
||||
public Serializable pkVal() {
|
||||
return this.configId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
package com.agileboot.domain.system.config.db;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
package com.agileboot.system.config.service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -10,7 +8,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @author valarchie
|
||||
* @since 2022-06-09
|
||||
*/
|
||||
public interface SysConfigService extends IService<SysConfigEntity> {
|
||||
public interface ISysConfigService {
|
||||
|
||||
/**
|
||||
* 通过key获取配置
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数配置表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-06-09
|
||||
*/
|
||||
@Service
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> 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();
|
||||
}
|
||||
|
||||
}
|
||||
1
pom.xml
1
pom.xml
@@ -31,6 +31,7 @@
|
||||
<spring.boot.version>3.5.4</spring.boot.version>
|
||||
<mybatis.version>3.5.16</mybatis.version>
|
||||
<mybatis-plus.version>3.5.12</mybatis-plus.version>
|
||||
<dynamic-ds.version>4.3.1</dynamic-ds.version>
|
||||
<springdoc.version>2.8.9</springdoc.version>
|
||||
<therapi-javadoc.version>0.15.0</therapi-javadoc.version>
|
||||
<hutool.version>5.8.38</hutool.version>
|
||||
|
||||
Reference in New Issue
Block a user