2023-07-22 20:51:46 +08:00
|
|
|
package application
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"mayfly-go/internal/auth/domain/entity"
|
|
|
|
|
"mayfly-go/internal/auth/domain/repository"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Oauth2 interface {
|
|
|
|
|
GetOAuthAccount(condition *entity.Oauth2Account, cols ...string) error
|
|
|
|
|
|
|
|
|
|
BindOAuthAccount(e *entity.Oauth2Account) error
|
2023-07-24 22:36:07 +08:00
|
|
|
|
|
|
|
|
Unbind(accountId uint64)
|
2023-07-22 20:51:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newAuthApp(oauthAccountRepo repository.Oauth2Account) Oauth2 {
|
|
|
|
|
return &oauth2AppImpl{
|
|
|
|
|
oauthAccountRepo: oauthAccountRepo,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type oauth2AppImpl struct {
|
|
|
|
|
oauthAccountRepo repository.Oauth2Account
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *oauth2AppImpl) GetOAuthAccount(condition *entity.Oauth2Account, cols ...string) error {
|
2023-10-26 17:15:49 +08:00
|
|
|
return a.oauthAccountRepo.GetBy(condition, cols...)
|
2023-07-22 20:51:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *oauth2AppImpl) BindOAuthAccount(e *entity.Oauth2Account) error {
|
2023-10-26 17:15:49 +08:00
|
|
|
if e.Id == 0 {
|
|
|
|
|
return a.oauthAccountRepo.Insert(e)
|
|
|
|
|
}
|
|
|
|
|
return a.oauthAccountRepo.UpdateById(e)
|
2023-07-22 20:51:46 +08:00
|
|
|
}
|
2023-07-24 22:36:07 +08:00
|
|
|
|
|
|
|
|
func (a *oauth2AppImpl) Unbind(accountId uint64) {
|
2023-10-26 17:15:49 +08:00
|
|
|
a.oauthAccountRepo.DeleteByCond(&entity.Oauth2Account{AccountId: accountId})
|
2023-07-24 22:36:07 +08:00
|
|
|
}
|