87 lines
4.8 KiB
Go
87 lines
4.8 KiB
Go
package repository
|
|
|
|
import (
|
|
"carrotskin/internal/model"
|
|
"context"
|
|
)
|
|
|
|
// UserRepository 用户仓储接口
|
|
type UserRepository interface {
|
|
Create(ctx context.Context, user *model.User) error
|
|
FindByID(ctx context.Context, id int64) (*model.User, error)
|
|
FindByUsername(ctx context.Context, username string) (*model.User, error)
|
|
FindByEmail(ctx context.Context, email string) (*model.User, error)
|
|
FindByIDs(ctx context.Context, ids []int64) ([]*model.User, error) // 批量查询
|
|
Update(ctx context.Context, user *model.User) error
|
|
UpdateFields(ctx context.Context, id int64, fields map[string]interface{}) error
|
|
BatchUpdate(ctx context.Context, ids []int64, fields map[string]interface{}) (int64, error) // 批量更新
|
|
Delete(ctx context.Context, id int64) error
|
|
BatchDelete(ctx context.Context, ids []int64) (int64, error) // 批量删除
|
|
CreateLoginLog(ctx context.Context, log *model.UserLoginLog) error
|
|
CreatePointLog(ctx context.Context, log *model.UserPointLog) error
|
|
UpdatePoints(ctx context.Context, userID int64, amount int, changeType, reason string) error
|
|
}
|
|
|
|
// ProfileRepository 档案仓储接口
|
|
type ProfileRepository interface {
|
|
Create(ctx context.Context, profile *model.Profile) error
|
|
FindByUUID(ctx context.Context, uuid string) (*model.Profile, error)
|
|
FindByName(ctx context.Context, name string) (*model.Profile, error)
|
|
FindByUserID(ctx context.Context, userID int64) ([]*model.Profile, error)
|
|
FindByUUIDs(ctx context.Context, uuids []string) ([]*model.Profile, error) // 批量查询
|
|
Update(ctx context.Context, profile *model.Profile) error
|
|
UpdateFields(ctx context.Context, uuid string, updates map[string]interface{}) error
|
|
BatchUpdate(ctx context.Context, uuids []string, updates map[string]interface{}) (int64, error) // 批量更新
|
|
Delete(ctx context.Context, uuid string) error
|
|
BatchDelete(ctx context.Context, uuids []string) (int64, error) // 批量删除
|
|
CountByUserID(ctx context.Context, userID int64) (int64, error)
|
|
UpdateLastUsedAt(ctx context.Context, uuid string) error
|
|
GetByNames(ctx context.Context, names []string) ([]*model.Profile, error)
|
|
GetKeyPair(ctx context.Context, profileId string) (*model.KeyPair, error)
|
|
UpdateKeyPair(ctx context.Context, profileId string, keyPair *model.KeyPair) error
|
|
}
|
|
|
|
// TextureRepository 材质仓储接口
|
|
type TextureRepository interface {
|
|
Create(ctx context.Context, texture *model.Texture) error
|
|
FindByID(ctx context.Context, id int64) (*model.Texture, error)
|
|
FindByHash(ctx context.Context, hash string) (*model.Texture, error)
|
|
FindByHashAndUploaderID(ctx context.Context, hash string, uploaderID int64) (*model.Texture, error) // 根据Hash和上传者ID查找
|
|
FindByIDs(ctx context.Context, ids []int64) ([]*model.Texture, error) // 批量查询
|
|
FindByUploaderID(ctx context.Context, uploaderID int64, page, pageSize int) ([]*model.Texture, int64, error)
|
|
Search(ctx context.Context, keyword string, textureType model.TextureType, publicOnly bool, page, pageSize int) ([]*model.Texture, int64, error)
|
|
Update(ctx context.Context, texture *model.Texture) error
|
|
UpdateFields(ctx context.Context, id int64, fields map[string]interface{}) error
|
|
BatchUpdate(ctx context.Context, ids []int64, fields map[string]interface{}) (int64, error) // 批量更新
|
|
Delete(ctx context.Context, id int64) error
|
|
BatchDelete(ctx context.Context, ids []int64) (int64, error) // 批量删除
|
|
IncrementDownloadCount(ctx context.Context, id int64) error
|
|
IncrementFavoriteCount(ctx context.Context, id int64) error
|
|
DecrementFavoriteCount(ctx context.Context, id int64) error
|
|
CreateDownloadLog(ctx context.Context, log *model.TextureDownloadLog) error
|
|
IsFavorited(ctx context.Context, userID, textureID int64) (bool, error)
|
|
AddFavorite(ctx context.Context, userID, textureID int64) error
|
|
RemoveFavorite(ctx context.Context, userID, textureID int64) error
|
|
GetUserFavorites(ctx context.Context, userID int64, page, pageSize int) ([]*model.Texture, int64, error)
|
|
CountByUploaderID(ctx context.Context, uploaderID int64) (int64, error)
|
|
}
|
|
|
|
|
|
// YggdrasilRepository Yggdrasil仓储接口
|
|
type YggdrasilRepository interface {
|
|
GetPasswordByID(ctx context.Context, id int64) (string, error)
|
|
ResetPassword(ctx context.Context, id int64, password string) error
|
|
}
|
|
|
|
// ClientRepository Client仓储接口
|
|
type ClientRepository interface {
|
|
Create(ctx context.Context, client *model.Client) error
|
|
FindByClientToken(ctx context.Context, clientToken string) (*model.Client, error)
|
|
FindByUUID(ctx context.Context, uuid string) (*model.Client, error)
|
|
FindByUserID(ctx context.Context, userID int64) ([]*model.Client, error)
|
|
Update(ctx context.Context, client *model.Client) error
|
|
IncrementVersion(ctx context.Context, clientUUID string) error
|
|
DeleteByClientToken(ctx context.Context, clientToken string) error
|
|
DeleteByUserID(ctx context.Context, userID int64) error
|
|
}
|