2024-03-14 13:38:42 +00:00
|
|
|
package mysqlkindboxreq
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
entity "git.gocasts.ir/ebhomengo/niki/entity"
|
|
|
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
2024-07-24 23:45:04 +00:00
|
|
|
querier "git.gocasts.ir/ebhomengo/niki/pkg/query_transaction/sql"
|
2024-03-14 13:38:42 +00:00
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
2024-07-30 11:05:41 +00:00
|
|
|
func (d *DB) DeliverKindBoxReq(ctx context.Context, kindBoxReqID uint) error {
|
2024-03-14 13:38:42 +00:00
|
|
|
const op = "mysqlkindboxreq.DeliverKindBoxReq"
|
2024-07-12 21:25:20 +00:00
|
|
|
q, cErr := querier.GetQuerierFromContextOrNew(ctx).Continue(ctx, d.conn.Conn())
|
|
|
|
if cErr != nil {
|
|
|
|
return richerror.New(op).WithErr(cErr).
|
|
|
|
WithMessage(errmsg.ErrorMsgCantScanQueryResult).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
|
|
|
_, uErr := q.Conn().ExecContext(ctx, `update kind_box_reqs set status = ?, delivered_at = ? where id = ?`,
|
2024-05-17 20:16:28 +00:00
|
|
|
entity.KindBoxReqDeliveredStatus.String(), time.Now(), kindBoxReqID)
|
2024-07-12 21:25:20 +00:00
|
|
|
if uErr != nil {
|
|
|
|
return richerror.New(op).WithErr(uErr).
|
2024-03-14 13:38:42 +00:00
|
|
|
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-03-14 13:38:42 +00:00
|
|
|
return nil
|
|
|
|
}
|