feat: 迁移plant

This commit is contained in:
Blizzard
2026-05-23 13:55:05 +08:00
parent a93477ea8e
commit ae6d03d351
228 changed files with 25296 additions and 917 deletions
+10 -3
View File
@@ -1,6 +1,3 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1
package svc
import (
@@ -9,7 +6,10 @@ import (
"sundynix-micro-go/app/plant/rpc/plantservice"
"sundynix-micro-go/app/system/rpc/systemservice"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/zrpc"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type ServiceContext struct {
@@ -17,13 +17,20 @@ type ServiceContext struct {
PlantRpc plantservice.PlantService
UserRpc systemservice.SystemService
FileRpc fileservice.FileService
DB *gorm.DB
}
func NewServiceContext(c config.Config) *ServiceContext {
db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
if err != nil {
logx.Errorf("连接数据库失败: %v", err)
}
return &ServiceContext{
Config: c,
PlantRpc: plantservice.NewPlantService(zrpc.MustNewClient(c.PlantRpc)),
UserRpc: systemservice.NewSystemService(zrpc.MustNewClient(c.UserRpc)),
FileRpc: fileservice.NewFileService(zrpc.MustNewClient(c.FileRpc)),
DB: db,
}
}