package mysqlkindboxreq

import (
	"context"
	"time"

	errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)

func (d DB) DeleteKindBoxReqByID(ctx context.Context, kindBoxReqID uint) error {
	const op = richerror.Op("mysqlkindboxreq.DeleteKindBoxReqByID")
	_, dErr := d.conn.Conn().ExecContext(ctx, "update kind_box_reqs set deleted_at = ? where id = ? and deleted_at is null", time.Now(), kindBoxReqID)
	if dErr != nil {
		return richerror.New(op).WithErr(dErr).
			WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
	}
	return nil
}
