2024-07-02 20:17:40 +00:00
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
func (s Service) AssignReceiverAgent(ctx context.Context, req param.AssignReceiverRequest) (param.AssignReceiverResponse, error) {
|
2024-07-02 20:17:40 +00:00
|
|
|
const op = "AdminKindBoxService.AssignReceiverAgent"
|
2024-08-01 10:20:18 +00:00
|
|
|
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{
|
2024-07-02 20:17:40 +00:00
|
|
|
ID: req.KindBoxID,
|
|
|
|
ReceiverAgentID: req.ReceiverAgentID,
|
|
|
|
})
|
2024-08-01 10:20:18 +00:00
|
|
|
if aErr != nil {
|
|
|
|
return param.AssignReceiverResponse{}, richerror.New(op).WithErr(aErr)
|
2024-07-02 20:17:40 +00:00
|
|
|
}
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
return param.AssignReceiverResponse{}, nil
|
2024-07-02 20:17:40 +00:00
|
|
|
}
|