package repository import ( "carrotskin/internal/model" ) // UserRepository 用户仓储接口 type UserRepository interface { Create(user *model.User) error FindByID(id int64) (*model.User, error) FindByUsername(username string) (*model.User, error) FindByEmail(email string) (*model.User, error) Update(user *model.User) error UpdateFields(id int64, fields map[string]interface{}) error Delete(id int64) error CreateLoginLog(log *model.UserLoginLog) error CreatePointLog(log *model.UserPointLog) error UpdatePoints(userID int64, amount int, changeType, reason string) error } // ProfileRepository 档案仓储接口 type ProfileRepository interface { Create(profile *model.Profile) error FindByUUID(uuid string) (*model.Profile, error) FindByName(name string) (*model.Profile, error) FindByUserID(userID int64) ([]*model.Profile, error) Update(profile *model.Profile) error UpdateFields(uuid string, updates map[string]interface{}) error Delete(uuid string) error CountByUserID(userID int64) (int64, error) SetActive(uuid string, userID int64) error UpdateLastUsedAt(uuid string) error GetByNames(names []string) ([]*model.Profile, error) GetKeyPair(profileId string) (*model.KeyPair, error) UpdateKeyPair(profileId string, keyPair *model.KeyPair) error } // TextureRepository 材质仓储接口 type TextureRepository interface { Create(texture *model.Texture) error FindByID(id int64) (*model.Texture, error) FindByHash(hash string) (*model.Texture, error) FindByUploaderID(uploaderID int64, page, pageSize int) ([]*model.Texture, int64, error) Search(keyword string, textureType model.TextureType, publicOnly bool, page, pageSize int) ([]*model.Texture, int64, error) Update(texture *model.Texture) error UpdateFields(id int64, fields map[string]interface{}) error Delete(id int64) error IncrementDownloadCount(id int64) error IncrementFavoriteCount(id int64) error DecrementFavoriteCount(id int64) error CreateDownloadLog(log *model.TextureDownloadLog) error IsFavorited(userID, textureID int64) (bool, error) AddFavorite(userID, textureID int64) error RemoveFavorite(userID, textureID int64) error GetUserFavorites(userID int64, page, pageSize int) ([]*model.Texture, int64, error) CountByUploaderID(uploaderID int64) (int64, error) } // TokenRepository 令牌仓储接口 type TokenRepository interface { Create(token *model.Token) error FindByAccessToken(accessToken string) (*model.Token, error) GetByUserID(userId int64) ([]*model.Token, error) GetUUIDByAccessToken(accessToken string) (string, error) GetUserIDByAccessToken(accessToken string) (int64, error) DeleteByAccessToken(accessToken string) error DeleteByUserID(userId int64) error BatchDelete(accessTokens []string) (int64, error) } // SystemConfigRepository 系统配置仓储接口 type SystemConfigRepository interface { GetByKey(key string) (*model.SystemConfig, error) GetPublic() ([]model.SystemConfig, error) GetAll() ([]model.SystemConfig, error) Update(config *model.SystemConfig) error UpdateValue(key, value string) error } // YggdrasilRepository Yggdrasil仓储接口 type YggdrasilRepository interface { GetPasswordByID(id int64) (string, error) ResetPassword(id int64, password string) error }