fix: remove duplicate tenant service method and handle not found
This commit is contained in:
@@ -56,15 +56,14 @@ func (h *TenantHandler) CheckExists(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
tenant, err := h.tenantService.GetBySubdomain(subdomain)
|
||||
if err != nil {
|
||||
if err == service.ErrTenantNotFound {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if tenant == nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
|
||||
}
|
||||
|
||||
@@ -79,11 +79,6 @@ func (s *TenantService) ListAll() ([]*domain.Tenant, error) {
|
||||
return s.tenantRepo.FindAll()
|
||||
}
|
||||
|
||||
// GetBySubdomain returns tenant by subdomain or nil
|
||||
func (s *TenantService) GetBySubdomain(subdomain string) (*domain.Tenant, error) {
|
||||
return s.tenantRepo.FindBySubdomain(subdomain)
|
||||
}
|
||||
|
||||
// Delete removes a tenant by ID
|
||||
func (s *TenantService) Delete(id uuid.UUID) error {
|
||||
if err := s.tenantRepo.Delete(id); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user