package logic

import (
	"context"
	"errors"

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

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

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

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

func (l *DelShopInvitationsLogic) DelShopInvitations(in *pb.DelShopInvitationsReq) (*pb.DelShopInvitationsResp, error) {
	err := l.svcCtx.ShopModelRW.ShopInvitations.DeleteOneID(in.Id).Exec(l.ctx)
	if err != nil {
		logx.Errorf("delete shop invitations failed, %s", err.Error())
		return nil, errors.New("delete failed")
	}

	return &pb.DelShopInvitationsResp{}, nil
}
