forked from ebhomengo/niki
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package adminservice
|
|
|
|
import (
|
|
"context"
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/admin"
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
)
|
|
|
|
func (s Service) AdminExistByID(ctx context.Context, req param.AdminExistByIDRequest) (param.AdminExistByIDResponse, error) {
|
|
const op = "adminservice.AdminExistByID"
|
|
|
|
admin, err := s.repo.GetAdminByID(ctx, req.AdminID)
|
|
if err != nil {
|
|
return param.AdminExistByIDResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
}
|
|
|
|
return param.AdminExistByIDResponse{Admin: admin}, nil
|
|
}
|
|
|
|
func (s Service) AdminGetProfile(ctx context.Context, req param.ProfileRequest) (param.ProfileResponse, error) {
|
|
const op = "adminservice.AdminGetProfile"
|
|
|
|
admin, err := s.repo.GetAdminByID(ctx, req.AdminID)
|
|
if err != nil {
|
|
return param.ProfileResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
}
|
|
|
|
return param.ProfileResponse{
|
|
Data: param.Data{
|
|
ID: admin.ID,
|
|
FirstName: admin.FirstName,
|
|
LastName: admin.LastName,
|
|
PhoneNumber: admin.PhoneNumber,
|
|
Role: admin.Role,
|
|
Description: admin.Description,
|
|
Email: admin.Email,
|
|
Gender: admin.Gender,
|
|
Status: admin.Status,
|
|
},
|
|
}, nil
|
|
}
|