feat(api): add client app service endpoints

This commit is contained in:
david
2026-07-30 18:04:34 +08:00
parent 47d352b22e
commit 550efb3812
29 changed files with 2147 additions and 44 deletions

View File

@@ -4,6 +4,7 @@ package config
import (
"net"
"net/url"
"strings"
"git.apinb.com/bsm-sdk/core/conf"
)
@@ -13,8 +14,16 @@ var Spec SrvConfig
// GlobalConfig 保存多个管理端共用的运行参数。
type GlobalConfig struct {
UserRegisterURL string `yaml:"UserRegisterURL"`
ManualRechargeMaxAmount int64 `yaml:"ManualRechargeMaxAmount"`
UserRegisterURL string `yaml:"UserRegisterURL"`
ManualRechargeMaxAmount int64 `yaml:"ManualRechargeMaxAmount"`
MockVerificationEnabled bool `yaml:"MockVerificationEnabled"`
MockVerificationCode string `yaml:"MockVerificationCode"`
VerificationTTLSeconds int `yaml:"VerificationTTLSeconds"`
VerificationSendIntervalSeconds int `yaml:"VerificationSendIntervalSeconds"`
MockPaymentEnabled bool `yaml:"MockPaymentEnabled"`
DeliveryArrivalRadiusMeters float64 `yaml:"DeliveryArrivalRadiusMeters"`
UploadVideoMaxSize int64 `yaml:"UploadVideoMaxSize"`
FieldEncryptionKey string `yaml:"FieldEncryptionKey"`
}
// WalletConfig 是平台既有钱包逻辑的内部兼容视图,值由 Global 注入。
@@ -42,6 +51,18 @@ func New(srvKey string) {
if Spec.Global.ManualRechargeMaxAmount <= 0 {
panic("Global.ManualRechargeMaxAmount must be greater than zero")
}
if Spec.Global.VerificationTTLSeconds <= 0 || Spec.Global.VerificationSendIntervalSeconds <= 0 {
panic("Global verification timeouts must be greater than zero")
}
if Spec.Global.MockVerificationEnabled && len(Spec.Global.MockVerificationCode) < 4 {
panic("Global.MockVerificationCode must contain at least four characters")
}
if Spec.Global.DeliveryArrivalRadiusMeters <= 0 || Spec.Global.UploadVideoMaxSize <= 0 {
panic("Global delivery radius and upload video size must be greater than zero")
}
if len(strings.TrimSpace(Spec.Global.FieldEncryptionKey)) < 32 {
panic("Global.FieldEncryptionKey must contain at least 32 characters")
}
Spec.Wallet.ManualRechargeMaxAmount = Spec.Global.ManualRechargeMaxAmount
registerURL, err := url.ParseRequestURI(Spec.Global.UserRegisterURL)
if err != nil || (registerURL.Scheme != "http" && registerURL.Scheme != "https") || registerURL.Host == "" {