forked from ebhomengo/niki
1
0
Fork 0
niki/repository/mysql/kind_box_req/update.go

26 lines
1.1 KiB
Go
Raw Normal View History

package mysqlkindboxreq
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) UpdateKindBoxReq(ctx context.Context, kindBoxReq entity.KindBoxReq) error {
const op = "mysqlkindboxreq.UpdateKindBoxReq"
query := `UPDATE kind_box_reqs
SET benfactor_id = ?, kind_box_type = ?, count_requested = ?, count_accepted = ?, description = ?, status = ?, deliver_refer_time_id = ?, deliver_refer_date = ?, deliver_address_id + ?, sender_agent_id = ?, delivered_at = ?
WHERE id = ? AND deleted_at IS NULL`
_, uErr := d.conn.Conn().ExecContext(ctx, query, kindBoxReq.BenefactorID, kindBoxReq.KindBoxType, kindBoxReq.CountRequested, kindBoxReq.CountAccepted, kindBoxReq.Description, kindBoxReq.Status, kindBoxReq.DeliverReferTimeID, kindBoxReq.DeliverReferDate, kindBoxReq.DeliverAddressID, kindBoxReq.SenderAgentID, kindBoxReq.DeliveredAt)
if uErr != nil {
return richerror.New(op).WithErr(uErr).WithMessage(errmsg.ErrorMsgCantUpdateRecord).
WithKind(richerror.KindUnexpected)
}
return nil
}