Files
apskel-pos-backend/internal/service/customer_outlet_service.go
T

41 lines
1.1 KiB
Go
Raw Normal View History

2026-09-30 19:21:13 +07:00
package service
import (
"context"
"errors"
"github.com/google/uuid"
"apskel-pos-be/internal/constants"
"apskel-pos-be/internal/contract"
"apskel-pos-be/internal/processor"
"apskel-pos-be/internal/repository"
)
// CustomerOutletService serves the outlets list of the customer app.
type CustomerOutletService interface {
List(ctx context.Context, customerID uuid.UUID) *contract.Response
}
type CustomerOutletServiceImpl struct {
outlets *processor.CustomerOutletProcessor
}
func NewCustomerOutletService(outlets *processor.CustomerOutletProcessor) *CustomerOutletServiceImpl {
return &CustomerOutletServiceImpl{outlets: outlets}
}
func (s *CustomerOutletServiceImpl) List(ctx context.Context, customerID uuid.UUID) *contract.Response {
outlets, err := s.outlets.List(ctx, customerID)
if err != nil {
code := constants.InternalServerErrorCode
if errors.Is(err, repository.ErrWalletNotFound) {
code = constants.NotFoundErrorCode
}
return contract.BuildErrorResponse([]*contract.ResponseError{
contract.NewResponseError(code, constants.RequestEntity, err.Error()),
})
}
return contract.BuildSuccessResponse(outlets)
}