forked from ebhomengo/niki
1
0
Fork 0
niki/service/admin/agent/get_all.go

31 lines
773 B
Go
Raw Permalink Normal View History

package adminagentservice
import (
"context"
param "git.gocasts.ir/ebhomengo/niki/param/admin/agent"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (s Service) GetAllAgent(ctx context.Context) (param.GetAllAgentResponse, error) {
const op = "adminagentservice.GetAllAgent"
agentsInfo := make([]param.Data, 0)
agents, err := s.repo.GetAllAgent(ctx)
if err != nil {
return param.GetAllAgentResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
}
for _, agent := range agents {
agentsInfo = append(agentsInfo, param.Data{
ID: agent.ID,
FirstName: agent.FirstName,
LastName: agent.LastName,
PhoneNumber: agent.PhoneNumber,
})
}
return param.GetAllAgentResponse{Data: agentsInfo}, nil
}