thehrz 0b880bece8
All checks were successful
CI / deploy (push) Successful in 57s
pref: rename project
2025-01-24 17:12:15 +08:00

37 lines
924 B
Go

package yggdrasil
import (
"context"
"errors"
"fmt"
"tinyskin/db/ent/user"
"tinyskin/db/ent/userprofile"
"tinyskin/model"
utilsService "tinyskin/service/utils"
)
var (
ErrUUIDNotEq = errors.New("uuid 不相同")
)
func (y *Yggdrasil) delTexture(ctx context.Context, userProfileID int, textureType string) error {
return utilsService.DelTexture(ctx, userProfileID, textureType, y.client, y.config.TexturePath)
}
func (y *Yggdrasil) DelTexture(ctx context.Context, t *model.TokenClaims, textureType string) error {
up, err := y.client.UserProfile.Query().Where(userprofile.HasUserWith(user.ID(t.UID))).First(ctx)
if err != nil {
return fmt.Errorf("DelTexture: %w", err)
}
err = y.delTexture(ctx, up.ID, textureType)
if err != nil {
return fmt.Errorf("DelTexture: %w", err)
}
err = y.cache.Del([]byte("Profile" + t.Subject))
if err != nil {
return fmt.Errorf("DelTexture: %w", err)
}
return nil
}