package logic

import (
	"context"

	"juwan-backend/app/search/rpc/internal/svc"
	"juwan-backend/app/search/rpc/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelFavoritesLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelFavoritesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelFavoritesLogic {
	return &DelFavoritesLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DelFavoritesLogic) DelFavorites(in *pb.DelFavoritesReq) (*pb.DelFavoritesResp, error) {
	err := l.svcCtx.SearchModelRW.Favorites.DeleteOneID(in.GetId()).Exec(l.ctx)
	if err != nil {
		logx.Errorf("delFavorites err: %v", err)
		return nil, err
	}

	return &pb.DelFavoritesResp{}, nil
}
