mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-05-02 09:05:20 +08:00
wip: oauth2登录和oauth2 otp登录验证
This commit is contained in:
24
server/internal/sys/infrastructure/persistence/auth.go
Normal file
24
server/internal/sys/infrastructure/persistence/auth.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/pkg/gormx"
|
||||
)
|
||||
|
||||
type authAccountRepoImpl struct{}
|
||||
|
||||
func newAuthAccountRepo() repository.OAuthAccount {
|
||||
return new(authAccountRepoImpl)
|
||||
}
|
||||
|
||||
func (a *authAccountRepoImpl) GetOAuthAccount(condition *entity.OAuthAccount, cols ...string) error {
|
||||
return gormx.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
func (a *authAccountRepoImpl) SaveOAuthAccount(e *entity.OAuthAccount) error {
|
||||
if e.Id == 0 {
|
||||
return gormx.Insert(e)
|
||||
}
|
||||
return gormx.UpdateById(e)
|
||||
}
|
||||
@@ -3,17 +3,22 @@ package persistence
|
||||
import "mayfly-go/internal/sys/domain/repository"
|
||||
|
||||
var (
|
||||
accountRepo = newAccountRepo()
|
||||
configRepo = newConfigRepo()
|
||||
resourceRepo = newResourceRepo()
|
||||
roleRepo = newRoleRepo()
|
||||
syslogRepo = newSyslogRepo()
|
||||
accountRepo = newAccountRepo()
|
||||
authAccountRepo = newAuthAccountRepo()
|
||||
configRepo = newConfigRepo()
|
||||
resourceRepo = newResourceRepo()
|
||||
roleRepo = newRoleRepo()
|
||||
syslogRepo = newSyslogRepo()
|
||||
)
|
||||
|
||||
func GetAccountRepo() repository.Account {
|
||||
return accountRepo
|
||||
}
|
||||
|
||||
func GetOAuthAccountRepo() repository.OAuthAccount {
|
||||
return authAccountRepo
|
||||
}
|
||||
|
||||
func GetConfigRepo() repository.Config {
|
||||
return configRepo
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user