package logic

import (
	"context"

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

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

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

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

func (l *DelReviewsLogic) DelReviews(in *pb.DelReviewsReq) (*pb.DelReviewsResp, error) {
	err := l.svcCtx.ReviewModelRW.Reviews.DeleteOneID(in.GetId()).Exec(l.ctx)
	if err != nil {
		logx.Errorf("delReviews err: %v", err)
		return nil, err
	}
	return &pb.DelReviewsResp{}, nil
}
