forked from ebhomengo/niki
24 lines
770 B
Go
24 lines
770 B
Go
package mysqlkindbox
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
)
|
|
|
|
func (d DB) AssignReceiverAgent(ctx context.Context, kindBox entity.KindBox) error {
|
|
const op = "mysqlkindbox.AssignReceiverAgent"
|
|
|
|
query := `UPDATE kind_boxes SET receiver_agent_id = ?, status = ? WHERE status = ? AND id = ?`
|
|
_, err := d.conn.Conn().ExecContext(ctx, query,
|
|
kindBox.ReceiverAgentID, entity.KindBoxAssignedReceiverAgentStatus.String(), entity.KindBoxReadyToReturnStatus.String(), kindBox.ID)
|
|
if err != nil {
|
|
return richerror.New(op).WithErr(err).
|
|
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
|
|
}
|
|
|
|
return nil
|
|
}
|