2026-07-31 02:43:45 +01:00
|
|
|
package account
|
|
|
|
|
|
|
|
|
|
import "arimelody-web/model"
|
|
|
|
|
|
|
|
|
|
type AccountRepository interface {
|
2026-07-31 04:20:39 +01:00
|
|
|
GetAll() ([]*model.Account, error)
|
2026-07-31 02:43:45 +01:00
|
|
|
GetCount() (int, error)
|
2026-07-31 10:40:50 +01:00
|
|
|
// Fetches an account by ID, returning an error if one was encountered.
|
|
|
|
|
// If the account does not exist, both response fields are nil.
|
2026-07-31 02:43:45 +01:00
|
|
|
GetByID(id string) (*model.Account, error)
|
|
|
|
|
GetByUsername(username string) (*model.Account, error)
|
|
|
|
|
GetByEmail(email string) (*model.Account, error)
|
2026-07-31 04:20:39 +01:00
|
|
|
|
|
|
|
|
// Pulled this function: Cross-cutting concerns between accounts and sessions.
|
|
|
|
|
// Instead, fetch account ID from session and use GetByID()
|
|
|
|
|
// GetBySession(sessionToken string) (*model.Account, error)
|
2026-07-31 02:43:45 +01:00
|
|
|
|
|
|
|
|
// Create an account, returning the new account ID.
|
|
|
|
|
Create(username string, password string, email *string, avatarURL *string) (string, error)
|
|
|
|
|
|
2026-07-31 11:04:36 +01:00
|
|
|
// Deprecated in favour of more specialised Update* and Remove* functions.
|
2026-07-31 02:43:45 +01:00
|
|
|
Update(id string, username string, password string, email *string, avatarUrl *string) error
|
2026-07-31 11:04:36 +01:00
|
|
|
UpdateUsername(id string, username string) error
|
|
|
|
|
UpdatePassword(id string, password string) error
|
|
|
|
|
UpdateEmail(id string, email string) error
|
2026-07-31 02:43:45 +01:00
|
|
|
RemoveEmail(id string) error
|
2026-07-31 11:04:36 +01:00
|
|
|
UpdateAvatarURL(id string, avatarURL string) error
|
2026-07-31 02:43:45 +01:00
|
|
|
RemoveAvatar(id string) error
|
|
|
|
|
|
2026-07-31 04:20:39 +01:00
|
|
|
Delete(id string) error
|
2026-07-31 02:43:45 +01:00
|
|
|
|
|
|
|
|
// Increment the number of account login failure attempts,
|
|
|
|
|
// returning the current fail count.
|
2026-07-31 04:20:39 +01:00
|
|
|
IncrementFails(id string) (int, error)
|
|
|
|
|
ResetFails(id string) error
|
2026-07-31 11:04:36 +01:00
|
|
|
SetLocked(id string, lock bool) error
|
2026-07-31 02:43:45 +01:00
|
|
|
}
|