Skip to content

Commit

Permalink
fix: delete admin_agency relation when deleting admin
Browse files Browse the repository at this point in the history
  • Loading branch information
idriss.naji committed Nov 28, 2022
1 parent 5b249f0 commit e612558
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.caritas.cob.userservice.api.admin.service.admin.delete;

import de.caritas.cob.userservice.api.port.out.AdminAgencyRepository;
import de.caritas.cob.userservice.api.port.out.AdminRepository;
import de.caritas.cob.userservice.api.port.out.IdentityClient;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -10,8 +12,12 @@
public class DeleteAdminService {

private final @NonNull AdminRepository adminRepository;
private final @NonNull AdminAgencyRepository adminAgencyRepository;
private final @NonNull IdentityClient identityClient;

public void deleteAgencyAdmin(String adminId) {
this.adminAgencyRepository.deleteByAdminId(adminId);
this.identityClient.deleteUser(adminId);
this.adminRepository.deleteById(adminId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import org.springframework.data.repository.CrudRepository;

public interface AdminAgencyRepository extends CrudRepository<AdminAgency, Long> {

List<AdminAgency> findByAdminId(String adminId);

List<AdminAgency> findByAdminIdAndAgencyId(String adminId, Long agencyId);

void deleteByAdminIdAndAgencyId(String adminId, Long agencyId);

void deleteByAdminId(String adminId);

List<AdminAgency> findByAdminIdIn(Set<String> adminIds);
}

0 comments on commit e612558

Please sign in to comment.