This commit is contained in:
laodaming
2023-11-22 10:12:46 +08:00
parent 040016d88f
commit 53a99c36b1
17 changed files with 55 additions and 68 deletions

View File

@@ -4,7 +4,7 @@ import (
"fusenapi/initalize"
"fusenapi/model/gmodel"
"fusenapi/server/ldap-admin/internal/config"
"github.com/go-ldap/ldap/v3"
"fusenapi/utils/ldap_lib"
"gorm.io/gorm"
)
@@ -13,17 +13,17 @@ type ServiceContext struct {
MysqlConn *gorm.DB
AllModels *gmodel.AllModelsGen
RabbitMq *initalize.RabbitMqHandle
Ldap *ldap.Conn
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: initalize.InitLdap(c.Ldap.Host, c.Ldap.BindDN, c.Ldap.Password),
Ldap: ldap_lib.NewLdap(ldapConn, c.Ldap.BaseDN, c.Ldap.RootDN, c.Ldap.PeopleGroupDN, c.Auth.AccessSecret),
}
}