chore: load erpgo settings from root config.yaml
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/go-admin-team/go-admin-core/sdk"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"go-admin/app/admin/models"
|
||||
ext "go-admin/config"
|
||||
"gorm.io/gorm"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -34,12 +35,12 @@ func (e ShopeeProduct) GetByShopeeID(c *gin.Context) {
|
||||
e.Error(400, fmt.Errorf("shopeeId is required"), "参数错误")
|
||||
return
|
||||
}
|
||||
configured := os.Getenv("ERP_API_KEY")
|
||||
configured := ext.ExtConfig.Huohanhan.APIKey
|
||||
if configured != "" && apiKey(c) != configured {
|
||||
e.Error(401, fmt.Errorf("invalid api key"), "未授权")
|
||||
return
|
||||
}
|
||||
base := strings.TrimRight(os.Getenv("HUOHANHAN_BASE_URL"), "/")
|
||||
base := strings.TrimRight(ext.ExtConfig.Huohanhan.BaseURL, "/")
|
||||
if base == "" {
|
||||
base = "https://www.huohanhan.com"
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ settings:
|
||||
dbname: dbname
|
||||
# 代码生成是使用前端代码存放位置,需要指定到src文件夹,相对路径
|
||||
frontpath: ../go-admin-ui/src
|
||||
extend: # 扩展项使用说明
|
||||
extend: # 扩展项使用说明`r`n huohanhan:`r`n base_url: https://www.huohanhan.com`r`n account: ""`r`n password: ""`r`n ocr_url: https://ocr.ilapage.cn/ocr`r`n state_db: ./huohanhan-state.db`r`n api_key: change-me
|
||||
demo:
|
||||
name: data
|
||||
cache:
|
||||
@@ -71,4 +71,4 @@ settings:
|
||||
# blockingTimeout: 5
|
||||
# reclaimInterval: 1
|
||||
locker:
|
||||
redis:
|
||||
redis:
|
||||
|
||||
+11
-8
@@ -2,15 +2,18 @@ package config
|
||||
|
||||
var ExtConfig Extend
|
||||
|
||||
// Extend 扩展配置
|
||||
// extend:
|
||||
// demo:
|
||||
// name: demo-name
|
||||
// 使用方法: config.ExtConfig......即可!!
|
||||
type Extend struct {
|
||||
AMap AMap // 这里配置对应配置文件的结构即可
|
||||
AMap AMap `yaml:"demo"`
|
||||
Huohanhan HuohanhanConfig `yaml:"huohanhan"`
|
||||
}
|
||||
|
||||
type AMap struct {
|
||||
Key string
|
||||
Key string `yaml:"key"`
|
||||
}
|
||||
type HuohanhanConfig struct {
|
||||
BaseURL string `yaml:"base_url"`
|
||||
Account string `yaml:"account"`
|
||||
Password string `yaml:"password"`
|
||||
OCRURL string `yaml:"ocr_url"`
|
||||
StateDB string `yaml:"state_db"`
|
||||
APIKey string `yaml:"api_key"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user