package logic

import (
	"context"

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

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

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

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

func (l *DelNotificationsLogic) DelNotifications(in *pb.DelNotificationsReq) (*pb.DelNotificationsResp, error) {
	err := l.svcCtx.NotificationModelRW.Notifications.DeleteOneID(in.GetId()).Exec(l.ctx)
	if err != nil {
		logx.Errorf("delNotifications err: %v", err)
		return nil, err
	}

	return &pb.DelNotificationsResp{}, nil
}
