forked from ebhomengo/niki
1
0
Fork 0
niki/service/admin/kind_box/assign_receiver_agent.go

26 lines
856 B
Go

package adminkindboxservice
import (
"context"
"git.gocasts.ir/ebhomengo/niki/entity"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (s Service) AssignReceiverAgent(ctx context.Context, req param.AssignReceiverRequest) (param.AssignReceiverResponse, error) {
const op = "AdminKindBoxService.AssignReceiverAgent"
if fieldErrors, vErr := s.vld.ValidateAssignReceiverAgent(ctx, req); vErr != nil {
return param.AssignReceiverResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
}
aErr := s.repo.AssignReceiverAgent(ctx, entity.KindBox{
ID: req.KindBoxID,
ReceiverAgentID: req.ReceiverAgentID,
})
if aErr != nil {
return param.AssignReceiverResponse{}, richerror.New(op).WithErr(aErr)
}
return param.AssignReceiverResponse{}, nil
}