2024-05-31 14:49:04 +00:00
|
|
|
package mysqlkindboxreq
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-06-14 08:41:36 +00:00
|
|
|
"time"
|
|
|
|
|
2024-05-31 14:49:04 +00:00
|
|
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
2024-07-30 11:05:41 +00:00
|
|
|
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
2024-05-31 14:49:04 +00:00
|
|
|
)
|
|
|
|
|
2024-07-30 11:05:41 +00:00
|
|
|
func (d *DB) DeleteKindBoxReqByID(ctx context.Context, kindBoxReqID uint) error {
|
|
|
|
const op = "mysqlkindboxreq.DeleteKindBoxReqByID"
|
|
|
|
|
|
|
|
query := `update kind_box_reqs set deleted_at = ? where id = ? and deleted_at is null`
|
|
|
|
//nolint
|
|
|
|
stmt, err := d.conn.PrepareStatement(ctx, mysql.StatementKeyKindBoxReqDeleteByID, query)
|
|
|
|
if err != nil {
|
|
|
|
return richerror.New(op).WithErr(err).
|
|
|
|
WithMessage(errmsg.ErrorMsgCantPrepareStatement).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = stmt.ExecContext(ctx, time.Now(), kindBoxReqID)
|
|
|
|
if err != nil {
|
|
|
|
return richerror.New(op).WithErr(err).
|
2024-05-31 14:49:04 +00:00
|
|
|
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-31 14:49:04 +00:00
|
|
|
return nil
|
|
|
|
}
|