2023-11-13 09:52:20 +00:00
|
|
|
package svc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fusenapi/initalize"
|
|
|
|
"fusenapi/model/gmodel"
|
|
|
|
"fusenapi/server/ldap-admin/internal/config"
|
2023-11-14 09:33:05 +00:00
|
|
|
"github.com/go-ldap/ldap/v3"
|
2023-11-13 09:52:20 +00:00
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ServiceContext struct {
|
2023-11-14 09:33:05 +00:00
|
|
|
Config config.Config
|
|
|
|
MysqlConn *gorm.DB
|
|
|
|
AllModels *gmodel.AllModelsGen
|
|
|
|
RabbitMq *initalize.RabbitMqHandle
|
|
|
|
Ldap *ldap.Conn
|
2023-11-13 09:52:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewServiceContext(c config.Config) *ServiceContext {
|
|
|
|
conn := initalize.InitMysql(c.SourceMysql)
|
|
|
|
|
|
|
|
return &ServiceContext{
|
2023-11-14 09:33:05 +00:00
|
|
|
Config: c,
|
|
|
|
MysqlConn: conn,
|
|
|
|
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
|
|
|
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
|
|
|
Ldap: initalize.InitLdap(c.Ldap.Host, c.Ldap.BindDN, c.Ldap.Password),
|
2023-11-13 09:52:20 +00:00
|
|
|
}
|
|
|
|
}
|