refactor: sqlexec组件重构优化、新增数据库相关系统参数配置、相关问题修复

This commit is contained in:
meilin.huang
2023-02-13 21:11:16 +08:00
parent 77aa724003
commit 70b586e45a
35 changed files with 2486 additions and 2120 deletions

View File

@@ -3,10 +3,13 @@ package entity
import (
"encoding/json"
"mayfly-go/pkg/model"
"strconv"
)
const (
ConfigKeyUseLoginCaptcha string = "UseLoginCaptcha" // 是否使用登录验证码
ConfigKeyDbQueryMaxCount string = "DbQueryMaxCount" // 数据库查询的最大数量
ConfigKeyDbSaveQuerySQL string = "DbSaveQuerySQL" // 数据库是否记录查询相关sql
)
type Config struct {
@@ -41,3 +44,16 @@ func (c *Config) GetJsonMap() map[string]string {
_ = json.Unmarshal([]byte(c.Value), &res)
return res
}
// 获取配置的int值如果配置值非int或不存在则返回默认值
func (c *Config) IntValue(defaultValue int) int {
// 如果值不存在,则返回默认值
if c.Id == 0 {
return defaultValue
}
if intV, err := strconv.Atoi(c.Value); err != nil {
return defaultValue
} else {
return intV
}
}