feat: 迁移游戏商务绑定审核流程和列表
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package business
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"kra/internal/biz/business"
|
||||
)
|
||||
|
||||
type PlatformProvider interface {
|
||||
Database(string) (*gorm.DB, error)
|
||||
}
|
||||
type platformAccountRepo struct{ data PlatformProvider }
|
||||
|
||||
func NewPlatformAccountRepo(data PlatformProvider) business.PlatformAccountRepo {
|
||||
return &platformAccountRepo{data: data}
|
||||
}
|
||||
|
||||
type platformAccountPO struct {
|
||||
ID uint64
|
||||
Account, Password string
|
||||
Status int
|
||||
}
|
||||
|
||||
func (platformAccountPO) TableName() string { return "tab_promote_business" }
|
||||
|
||||
func (r *platformAccountRepo) FindByAccount(ctx context.Context, source, account string) (*business.PlatformAccount, error) {
|
||||
source, err := business.NormalizePlatform(source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db, err := r.data.Database(source)
|
||||
if err != nil || db == nil {
|
||||
return nil, business.ErrPlatformUnavailable
|
||||
}
|
||||
var po platformAccountPO
|
||||
err = db.WithContext(ctx).Where("account = ?", account).First(&po).Error
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, business.ErrPlatformUnavailable
|
||||
}
|
||||
return &business.PlatformAccount{ID: po.ID, Account: po.Account, Password: po.Password, Status: po.Status}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user