init repo

This commit is contained in:
liuyuanchuang
2025-12-10 18:33:37 +08:00
commit 48e63894eb
2408 changed files with 1053045 additions and 0 deletions

77
config/config.go Normal file
View File

@@ -0,0 +1,77 @@
package config
import (
"gitea.com/bitwsd/core/common/log"
"github.com/spf13/viper"
)
type Config struct {
Log log.LogConfig `mapstructure:"log"`
Server ServerConfig `mapstructure:"server"`
Database DatabaseConfig `mapstructure:"database"`
Redis RedisConfig `mapstructure:"redis"`
UploadDir string `mapstructure:"upload_dir"`
Limit LimitConfig `mapstructure:"limit"`
Aliyun AliyunConfig `mapstructure:"aliyun"`
}
type LimitConfig struct {
FormulaRecognition int `mapstructure:"formula_recognition"`
}
type ServerConfig struct {
Port int `mapstructure:"port"`
Mode string `mapstructure:"mode"`
}
func (c *ServerConfig) IsDebug() bool {
return c.Mode == "debug"
}
type RedisConfig struct {
Addr string `mapstructure:"addr"`
Password string `mapstructure:"password"`
DB int `mapstructure:"db"`
}
type DatabaseConfig struct {
Driver string `mapstructure:"driver"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
DBName string `mapstructure:"dbname"`
MaxIdle int `mapstructure:"max_idle"`
MaxOpen int `mapstructure:"max_open"`
}
type OSSConfig struct {
Endpoint string `mapstructure:"endpoint"` // 外网endpoint
InnerEndpoint string `mapstructure:"inner_endpoint"` // 内网endpoint
AccessKeyID string `mapstructure:"access_key_id"`
AccessKeySecret string `mapstructure:"access_key_secret"`
BucketName string `mapstructure:"bucket_name"`
}
type SmsConfig struct {
AccessKeyID string `mapstructure:"access_key_id"`
AccessKeySecret string `mapstructure:"access_key_secret"`
SignName string `mapstructure:"sign_name"`
TemplateCode string `mapstructure:"template_code"`
}
type AliyunConfig struct {
Sms SmsConfig `mapstructure:"sms"`
OSS OSSConfig `mapstructure:"oss"`
}
var GlobalConfig Config
func Init(configPath string) error {
viper.SetConfigFile(configPath)
if err := viper.ReadInConfig(); err != nil {
return err
}
return viper.Unmarshal(&GlobalConfig)
}

46
config/config_dev.yaml Normal file
View File

@@ -0,0 +1,46 @@
server:
port: 8024
mode: debug # debug/release
database:
driver: mysql
host: 182.92.150.161
port: 3006
username: root
password: yoge@coder%%%123321!
dbname: doc_ai
max_idle: 10
max_open: 100
redis:
addr: 182.92.150.161:6379
password: yoge@123321!
db: 0
limit:
formula_recognition: 3
log:
appName: document_ai
level: info # debug, info, warn, error
format: console # json, console
outputPath: ./logs/app.log # 日志文件路径
maxSize: 2 # 单个日志文件最大尺寸单位MB
maxAge: 1 # 日志保留天数
maxBackups: 1 # 保留的旧日志文件最大数量
compress: false # 是否压缩旧日志
aliyun:
sms:
access_key_id: "LTAI5tB9ur4ExCF4dYPq7hLz"
access_key_secret: "91HulOdaCpwhfBesrUDiKYvyi0Qkx1"
sign_name: "北京比特智源科技"
template_code: "SMS_291510729"
oss:
endpoint: oss-cn-beijing.aliyuncs.com
inner_endpoint: oss-cn-beijing-internal.aliyuncs.com
access_key_id: LTAI5tKogxeiBb4gJGWEePWN
access_key_secret: l4oCxtt5iLSQ1DAs40guTzKUfrxXwq
bucket_name: bitwsd-doc-ai

45
config/config_prod.yaml Normal file
View File

@@ -0,0 +1,45 @@
server:
port: 8024
mode: release # debug/release
database:
driver: mysql
host: rm-bp1uh3e1qop18gz4wto.mysql.rds.aliyuncs.com
port: 3306
username: root
password: bitwsdttestESAadb12@3341
dbname: doc_ai
max_idle: 10
max_open: 100
redis:
addr: 172.31.32.138:6379
password: bitwsd@8912WE!
db: 0
limit:
formula_recognition: 2
log:
appName: document_ai
level: info # debug, info, warn, error
format: json # json, console
outputPath: /app/logs/app.log # 日志文件路径
maxSize: 10 # 单个日志文件最大尺寸单位MB
maxAge: 60 # 日志保留天数
maxBackups: 100 # 保留的旧日志文件最大数量
compress: false # 是否压缩旧日志
aliyun:
sms:
access_key_id: "LTAI5tB9ur4ExCF4dYPq7hLz"
access_key_secret: "91HulOdaCpwhfBesrUDiKYvyi0Qkx1"
sign_name: "北京比特智源科技"
template_code: "SMS_291510729"
oss:
endpoint: oss-cn-beijing.aliyuncs.com
inner_endpoint: oss-cn-beijing-internal.aliyuncs.com
access_key_id: LTAI5tKogxeiBb4gJGWEePWN
access_key_secret: l4oCxtt5iLSQ1DAs40guTzKUfrxXwq
bucket_name: bitwsd-doc-ai