package svc import ( "fusenapi/initalize" "fusenapi/model/gmodel" "fusenapi/server/ldap-admin/internal/config" "fusenapi/utils/ldap_lib" "gorm.io/gorm" ) type ServiceContext struct { Config config.Config MysqlConn *gorm.DB AllModels *gmodel.AllModelsGen RabbitMq *initalize.RabbitMqHandle Ldap *ldap_lib.Ldap } func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) ldapConn := initalize.InitLdap(c.Ldap.Host, c.Ldap.BindDN, c.Ldap.Password) return &ServiceContext{ Config: c, MysqlConn: conn, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), Ldap: ldap_lib.NewLdap(ldapConn, c.Ldap.BaseDN, c.Ldap.RootDN, c.Ldap.PeopleGroupDN, c.Auth.AccessSecret), } }