feat: 初次启动

This commit is contained in:
Blizzard
2026-04-27 21:23:13 +08:00
parent e515f6a287
commit bb8ad4d515
148 changed files with 8602 additions and 5678 deletions
+10 -27
View File
@@ -1,22 +1,20 @@
Name: radio-api
Log:
Encoding: plain
Host: 0.0.0.0
Port: 9005
Auth:
AccessSecret: 9149f2eb-d517-4a50-a03a-231dbcf0d872
AccessExpire: 7200
AccessSecret: sundynix-jwt-secret-2024
AccessExpire: 604800
# MySQL
DB:
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
RadioRpc:
Etcd:
Hosts:
- 192.168.100.127:2379
Key: radio.rpc
# Redis
Cache:
- Host: 127.0.0.1:6379
Pass: sundynix
Type: node
# RPC 依赖
UserRpc:
Etcd:
Hosts:
@@ -28,18 +26,3 @@ FileRpc:
Hosts:
- 192.168.100.127:2379
Key: file.rpc
# TTS 火山引擎
Tts:
AppId: "9604175735"
ResourceId: "seed-tts-2.0"
AccessKey: "IMSrxDQgXWOwaJnuF-5G7uppRQutwBny"
# 微信支付
WechatPay:
MchId: "1735188493"
MchCertificateSerialNumber: "3725BFCA9CA3AF819AEC5D0CB7D3540BBC67F2CF"
MchApiV3Key: "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6"
PrivateKeyPath: "/Users/blizzard/privateFolder/cert/apiclient_key.pem"
PublicKeyPath: "/Users/blizzard/privateFolder/cert/pub_key.pem"
NotifyUrl: "https://radio.sundynix.cn/api/wechatpay/notify"
+3 -23
View File
@@ -14,27 +14,7 @@ type Config struct {
AccessSecret string
AccessExpire int64
}
DB struct {
DataSource string
}
Cache []struct {
Host string
Pass string
Type string
}
UserRpc zrpc.RpcClientConf
FileRpc zrpc.RpcClientConf
Tts struct {
AppId string
ResourceId string
AccessKey string
}
WechatPay struct {
MchId string
MchCertificateSerialNumber string
MchApiV3Key string
PrivateKeyPath string
PublicKeyPath string
NotifyUrl string
}
RadioRpc zrpc.RpcClientConf
UserRpc zrpc.RpcClientConf
FileRpc zrpc.RpcClientConf
}
+9 -38
View File
@@ -6,53 +6,24 @@ package svc
import (
"sundynix-micro-go/app/file/rpc/fileservice"
"sundynix-micro-go/app/radio/api/internal/config"
radioModel "sundynix-micro-go/app/radio/model"
"sundynix-micro-go/app/radio/rpc/radioservice"
"sundynix-micro-go/app/user/rpc/userservice"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/zrpc"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type ServiceContext struct {
Config config.Config
DB *gorm.DB
UserRpc userservice.UserService
FileRpc fileservice.FileService
Config config.Config
RadioRpc radioservice.RadioService
UserRpc userservice.UserService
FileRpc fileservice.FileService
}
func NewServiceContext(c config.Config) *ServiceContext {
db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
if err != nil {
logx.Errorf("连接数据库失败: %v", err)
panic(err)
}
// 自动迁移
if err := db.AutoMigrate(
&radioModel.SundynixRadioUserProfile{},
&radioModel.SundynixRadioCategory{},
&radioModel.SundynixRadioChannel{},
&radioModel.SundynixRadioProgram{},
&radioModel.SundynixRadioVoice{},
&radioModel.SundynixRadioLike{},
&radioModel.SundynixRadioFavorite{},
&radioModel.SundynixRadioComment{},
&radioModel.SundynixRadioHistory{},
&radioModel.SundynixRadioSubscription{},
&radioModel.SundynixRadioSubscriptionOrder{},
&radioModel.SundynixRadioPayNotify{},
&radioModel.SundynixRadioVipConfig{},
&radioModel.SundynixRadioListenLog{},
); err != nil {
logx.Errorf("数据库迁移失败: %v", err)
}
return &ServiceContext{
Config: c,
DB: db,
UserRpc: userservice.NewUserService(zrpc.MustNewClient(c.UserRpc)),
FileRpc: fileservice.NewFileService(zrpc.MustNewClient(c.FileRpc)),
Config: c,
RadioRpc: radioservice.NewRadioService(zrpc.MustNewClient(c.RadioRpc)),
UserRpc: userservice.NewUserService(zrpc.MustNewClient(c.UserRpc)),
FileRpc: fileservice.NewFileService(zrpc.MustNewClient(c.FileRpc)),
}
}