2024-08-01 10:20:18 +00:00
|
|
|
package adminagentservice
|
2024-06-10 14:49:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/agent"
|
2024-06-10 14:49:13 +00:00
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) GetAllAgent(ctx context.Context) (param.GetAllAgentResponse, error) {
|
2024-08-01 10:20:18 +00:00
|
|
|
const op = "adminagentservice.GetAllAgent"
|
2024-06-10 14:49:13 +00:00
|
|
|
|
2024-09-10 20:55:19 +00:00
|
|
|
agentsInfo := make([]param.Data, 0)
|
2024-06-10 14:49:13 +00:00
|
|
|
|
|
|
|
agents, err := s.repo.GetAllAgent(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return param.GetAllAgentResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, agent := range agents {
|
2024-09-10 20:55:19 +00:00
|
|
|
agentsInfo = append(agentsInfo, param.Data{
|
2024-06-10 14:49:13 +00:00
|
|
|
ID: agent.ID,
|
|
|
|
FirstName: agent.FirstName,
|
|
|
|
LastName: agent.LastName,
|
|
|
|
PhoneNumber: agent.PhoneNumber,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-09-10 20:55:19 +00:00
|
|
|
return param.GetAllAgentResponse{Data: agentsInfo}, nil
|
2024-06-10 14:49:13 +00:00
|
|
|
}
|