代码拉取完成,页面将自动刷新
package sdk
import (
"fmt"
"gitee.com/linxing_3/youye-core/logger"
"gitee.com/linxing_3/youye-core/sdk/application"
"gitee.com/linxing_3/youye-core/sdk/config"
"gitee.com/linxing_3/youye-core/sdk/pkg/jwtauth"
"gitee.com/linxing_3/youye-core/storage"
"github.com/gin-gonic/gin"
"github.com/google/wire"
"gorm.io/gorm"
)
var Provider = wire.NewSet(
GetDefaultAppGorm,
GetCacheAdapte,
GetGinEngine,
GetLogger,
config.Provider,
)
func moduleUnregistErr(msg string) error {
return fmt.Errorf("%s not regist to app", msg)
}
func GetDefaultAppGorm(app application.IApplication) (*gorm.DB, error) {
db := app.GetDbByKey("*")
if db == nil {
return nil, moduleUnregistErr("gorm db")
}
return db, nil
}
func GetCacheAdapte(app application.IApplication) (storage.AdapterCache, error) {
adapter := app.GetCacheAdapter()
if adapter != nil {
return adapter, nil
}
return nil, moduleUnregistErr("cache adapter")
}
func GetGinEngine(app application.IApplication) (*gin.Engine, error) {
httpHandler := app.GetEngine()
switch h := httpHandler.(type) {
case *gin.Engine:
return h, nil
default:
return nil, moduleUnregistErr("gin engine")
}
}
func GetLogger(app application.IApplication) (logger.Logger, error) {
return app.GetLogger(), nil
}
func GetAuth(app application.IApplication) (jwtauth.IAuth, error) {
auth := app.GetAuth()
if auth != nil {
return auth, nil
}
return nil, moduleUnregistErr("auth")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。