93 lines
3.8 KiB
Go
93 lines
3.8 KiB
Go
|
|
package domain
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"context"
|
|||
|
|
|
|||
|
|
tokenDomain "apps/backend/internal/module/token/domain"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// AccountUseCase — stand-alone AccountUseCase 完整能力(數字 uid)。
|
|||
|
|
type AccountUseCase interface {
|
|||
|
|
// 建立 / 登入
|
|||
|
|
CreateUserAccount(ctx context.Context, req CreateLoginUserRequest) (*Member, *tokenDomain.TokenPair, error)
|
|||
|
|
LoginPassword(ctx context.Context, loginID, password, platform string) (*Member, *tokenDomain.TokenPair, error)
|
|||
|
|
LoginOAuth(ctx context.Context, platform, subject, email, displayName string) (*Member, *tokenDomain.TokenPair, error)
|
|||
|
|
|
|||
|
|
// 查詢
|
|||
|
|
GetUIDByAccount(ctx context.Context, account, platform string) (uid int64, err error)
|
|||
|
|
GetUserAccountInfo(ctx context.Context, account, platform string) (*Identity, error)
|
|||
|
|
GetUserInfo(ctx context.Context, uid int64) (*Member, error)
|
|||
|
|
ListMember(ctx context.Context, page, pageSize int, query, status string) ([]*Member, int64, error)
|
|||
|
|
ListIdentities(ctx context.Context, uid int64) ([]*Identity, error)
|
|||
|
|
FindLoginIDsByUID(ctx context.Context, uid int64) ([]*Identity, error)
|
|||
|
|
|
|||
|
|
// 更新
|
|||
|
|
UpdateUserToken(ctx context.Context, loginID, platform, newPassword string) error
|
|||
|
|
UpdateUserInfo(ctx context.Context, uid int64, patch *UpdateUserInfoPatch) (*Member, error)
|
|||
|
|
UpdateStatus(ctx context.Context, uid int64, status string) (*Member, error)
|
|||
|
|
|
|||
|
|
// Session
|
|||
|
|
Refresh(ctx context.Context, refreshToken string) (*tokenDomain.TokenPair, error)
|
|||
|
|
Logout(refreshToken string)
|
|||
|
|
LogoutAll(ctx context.Context, uid int64) error
|
|||
|
|
|
|||
|
|
// Binding
|
|||
|
|
BindAccount(ctx context.Context, uid int64, loginID, platform, accountType, password string) (*Identity, error)
|
|||
|
|
UnbindAccount(ctx context.Context, uid int64, loginID, platform string) error
|
|||
|
|
BindVerifyEmail(ctx context.Context, uid int64, email string) error
|
|||
|
|
BindVerifyPhone(ctx context.Context, uid int64, phone string) error
|
|||
|
|
|
|||
|
|
// Verify codes
|
|||
|
|
GenerateCode(ctx context.Context, loginID, codeType string) (code string, err error)
|
|||
|
|
VerifyCode(ctx context.Context, loginID, codeType, code string, consume bool) error
|
|||
|
|
|
|||
|
|
// Platform password check (email/phone password)
|
|||
|
|
VerifyPlatformAuthResult(ctx context.Context, loginID, platform, password string) (bool, error)
|
|||
|
|
|
|||
|
|
// OAuth providers
|
|||
|
|
VerifyGoogleIDToken(ctx context.Context, idToken string) (subject, email, name string, err error)
|
|||
|
|
LineCodeToProfile(ctx context.Context, code, redirectURI string) (subject, displayName, email string, err error)
|
|||
|
|
|
|||
|
|
// Convenience Harbor Desk paths
|
|||
|
|
RegisterEmail(ctx context.Context, email, password, displayName string) (*Member, *tokenDomain.TokenPair, error)
|
|||
|
|
Me(ctx context.Context, uid int64) (*Member, error)
|
|||
|
|
// RequestPasswordReset returns code or ErrEmailNotRegistered if unknown email.
|
|||
|
|
RequestPasswordReset(ctx context.Context, email string) (code string, err error)
|
|||
|
|
ResetPassword(ctx context.Context, email, code, newPassword string) error
|
|||
|
|
SendEmailCode(ctx context.Context, uid int64) (string, error)
|
|||
|
|
VerifyEmailCode(ctx context.Context, uid int64, code string) (*Member, error)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// CreateLoginUserRequest — stand-alone create account
|
|||
|
|
type CreateLoginUserRequest struct {
|
|||
|
|
LoginID string
|
|||
|
|
Platform string // platform|google|line|apple
|
|||
|
|
AccountType string // email|phone|platform
|
|||
|
|
Password string // for platform
|
|||
|
|
DisplayName string
|
|||
|
|
Email string // profile email if oauth
|
|||
|
|
Phone string
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// UpdateUserInfoPatch — stand-alone UpdateUserInfoRequest
|
|||
|
|
type UpdateUserInfoPatch struct {
|
|||
|
|
DisplayName *string
|
|||
|
|
Nickname *string
|
|||
|
|
FullName *string
|
|||
|
|
AvatarURL *string
|
|||
|
|
Bio *string
|
|||
|
|
Timezone *string
|
|||
|
|
NotifyEmail *bool
|
|||
|
|
GenderCode *int8
|
|||
|
|
Birthdate *int64
|
|||
|
|
National *string
|
|||
|
|
Address *string
|
|||
|
|
PostCode *string
|
|||
|
|
PreferredLanguage *string
|
|||
|
|
Currency *string
|
|||
|
|
Email *string
|
|||
|
|
Phone *string
|
|||
|
|
CurrentPassword *string
|
|||
|
|
NewPassword *string
|
|||
|
|
}
|