forked from ebhomengo/niki
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
|
package adminkindboxreqservice
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
||
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
||
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||
|
)
|
||
|
|
||
|
func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest) error {
|
||
|
const op = "adminkindboxreqservice.Update"
|
||
|
|
||
|
kindBoxReq, err := s.repo.GetByID(ctx, req.ID)
|
||
|
if err != nil {
|
||
|
return richerror.New(op).WithErr(err)
|
||
|
}
|
||
|
uErr := s.repo.UpdateKindBoxReq(ctx, entity.KindBoxReq{
|
||
|
ID: req.ID,
|
||
|
BenefactorID: kindBoxReq.BenefactorID,
|
||
|
KindBoxType: req.KindBoxType,
|
||
|
CountRequested: req.CountRequested,
|
||
|
CountAccepted: req.CountAccepted,
|
||
|
Description: req.Description,
|
||
|
Status: kindBoxReq.Status,
|
||
|
DeliverReferTimeID: req.DeliverReferTimeID,
|
||
|
DeliverReferDate: req.DeliverReferDate,
|
||
|
DeliverAddressID: req.DeliverAddressID,
|
||
|
SenderAgentID: req.SenderAgentID,
|
||
|
DeliveredAt: kindBoxReq.DeliveredAt,
|
||
|
})
|
||
|
if uErr != nil {
|
||
|
return richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|