Files
backend/internal/repository/yggdrasil_repository.go
lan a51535a465 feat: Add texture rendering endpoints and service methods
- Introduced new API endpoints for rendering textures, avatars, capes, and previews, enhancing the texture handling capabilities.
- Implemented corresponding service methods in the TextureHandler to process rendering requests and return appropriate responses.
- Updated the TextureRenderService interface to include methods for rendering textures, avatars, and capes, along with their respective parameters.
- Enhanced error handling for invalid texture IDs and added support for different rendering types and formats.
- Updated go.mod to include the webp library for image processing.
2025-12-07 10:10:28 +08:00

38 lines
862 B
Go

package repository
import (
"carrotskin/internal/model"
"context"
"gorm.io/gorm"
)
// yggdrasilRepository YggdrasilRepository的实现
type yggdrasilRepository struct {
db *gorm.DB
}
// NewYggdrasilRepository 创建YggdrasilRepository实例
func NewYggdrasilRepository(db *gorm.DB) YggdrasilRepository {
return &yggdrasilRepository{db: db}
}
func (r *yggdrasilRepository) GetPasswordByID(ctx context.Context, id int64) (string, error) {
var yggdrasil model.Yggdrasil
err := r.db.WithContext(ctx).Select("password").Where("id = ?", id).First(&yggdrasil).Error
if err != nil {
return "", err
}
return yggdrasil.Password, nil
}
func (r *yggdrasilRepository) ResetPassword(ctx context.Context, id int64, password string) error {
return r.db.WithContext(ctx).Model(&model.Yggdrasil{}).Where("id = ?", id).Update("password", password).Error
}