mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-17 14:50:26 +08:00
feat: 新增简易版ioc
This commit is contained in:
@@ -14,27 +14,21 @@ type Oauth2 interface {
|
||||
Unbind(accountId uint64)
|
||||
}
|
||||
|
||||
func newAuthApp(oauthAccountRepo repository.Oauth2Account) Oauth2 {
|
||||
return &oauth2AppImpl{
|
||||
oauthAccountRepo: oauthAccountRepo,
|
||||
}
|
||||
}
|
||||
|
||||
type oauth2AppImpl struct {
|
||||
oauthAccountRepo repository.Oauth2Account
|
||||
Oauth2AccountRepo repository.Oauth2Account `inject:""`
|
||||
}
|
||||
|
||||
func (a *oauth2AppImpl) GetOAuthAccount(condition *entity.Oauth2Account, cols ...string) error {
|
||||
return a.oauthAccountRepo.GetBy(condition, cols...)
|
||||
return a.Oauth2AccountRepo.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
func (a *oauth2AppImpl) BindOAuthAccount(e *entity.Oauth2Account) error {
|
||||
if e.Id == 0 {
|
||||
return a.oauthAccountRepo.Insert(context.Background(), e)
|
||||
return a.Oauth2AccountRepo.Insert(context.Background(), e)
|
||||
}
|
||||
return a.oauthAccountRepo.UpdateById(context.Background(), e)
|
||||
return a.Oauth2AccountRepo.UpdateById(context.Background(), e)
|
||||
}
|
||||
|
||||
func (a *oauth2AppImpl) Unbind(accountId uint64) {
|
||||
a.oauthAccountRepo.DeleteByCond(context.Background(), &entity.Oauth2Account{AccountId: accountId})
|
||||
a.Oauth2AccountRepo.DeleteByCond(context.Background(), &entity.Oauth2Account{AccountId: accountId})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user