Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix 11 9 0101 #103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public interface GuardianRepository extends JpaRepository<Guardian, Long> {

boolean existsByPhone(String phone);

boolean existsByPhoneNotId(String phone, Long id);

Optional<Guardian> findByLineUserId(String userId);

List<Guardian> findByAlertTime(LocalTime currentTime);
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/dbdr/domain/guardian/service/GuardianService.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public GuardianMyPageResponse getMyPageGuardianInfo(Long guardianId) {

public GuardianMyPageResponse updateAlertTime(Long guardianId,
GuardianAlertTimeRequest request) {
ensureUniquePhone(request.phone());
ensureUniquePhoneButNotId(request.phone(), guardianId);
Guardian guardian = findGuardianById(guardianId);
guardian.updateAlertTime(request.name(), request.phone(), request.alertTime());
guardianRepository.save(guardian);
Expand All @@ -47,7 +47,7 @@ public GuardianResponse updateGuardianById(
Long guardianId,
GuardianRequest guardianRequest
) {
ensureUniquePhone(guardianRequest.phone());
ensureUniquePhoneButNotId(guardianRequest.phone(), guardianId);

Guardian guardian = findGuardianById(guardianId);
guardian.updateGuardian(guardianRequest.phone(), guardianRequest.name());
Expand Down Expand Up @@ -95,6 +95,12 @@ private void ensureUniquePhone(String phone) {
}
}

private void ensureUniquePhoneButNotId(String phone, Long id) {
if(guardianRepository.existsByPhoneNotId(phone, id)) {
throw new ApplicationException(ApplicationError.DUPLICATE_PHONE);
}
}

public Guardian findByLineUserId(String userId) {
return guardianRepository.findByLineUserId(userId)
.orElse(null);
Expand Down
74 changes: 0 additions & 74 deletions src/test/java/dbdr/testhelper/DefaultEntity.java

This file was deleted.

11 changes: 4 additions & 7 deletions src/test/java/dbdr/testhelper/TestHelper.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package dbdr.testhelper;

import dbdr.domain.admin.entity.Admin;
import dbdr.domain.careworker.entity.Careworker;
import dbdr.domain.guardian.entity.Guardian;
import dbdr.domain.institution.entity.Institution;
import dbdr.security.dto.LoginRequest;
import dbdr.security.dto.TokenDTO;
import dbdr.security.model.Role;
import java.util.HashMap;
import java.util.Map;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.ResponseSpec;
Expand All @@ -17,7 +14,7 @@ public class TestHelper {
private Integer port;
private Object user;
private String authHeader;
private Map<String,String> queryParam;
private Map<String,String> queryParam = new HashMap<>();
private Object requestBody;
private String uri;

Expand Down Expand Up @@ -70,9 +67,9 @@ public ResponseSpec delete(){


private String userLogin() {
TokenDTO tokenDTO = restClient.post().uri("/auth/login/"+userRole.toString()).body(convertUserToLoginRequest()).retrieve().toEntity(
TokenDTO tokenDTO = restClient.post().uri("/auth/login/" + userRole.toString()).body(convertUserToLoginRequest()).retrieve().toEntity(
TokenDTO.class).getBody();
return "Bearer "+tokenDTO.accessToken();
return "Bearer " + tokenDTO.accessToken();
}

private LoginRequest convertUserToLoginRequest(){
Expand Down
60 changes: 0 additions & 60 deletions src/test/java/dbdr/testhelper/TestHelperTest.java

This file was deleted.