-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
refactor - Facade 패턴 적용 및 리팩토링
- Loading branch information
Showing
29 changed files
with
323 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/sopt/org/hmh/domain/app/service/ChallengeAppService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package sopt.org.hmh.domain.app.service; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import sopt.org.hmh.domain.app.domain.ChallengeApp; | ||
import sopt.org.hmh.domain.app.domain.exception.AppError; | ||
import sopt.org.hmh.domain.app.domain.exception.AppException; | ||
import sopt.org.hmh.domain.app.dto.request.ChallengeAppRequest; | ||
import sopt.org.hmh.domain.app.repository.ChallengeAppRepository; | ||
import sopt.org.hmh.domain.challenge.domain.Challenge; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ChallengeAppService { | ||
|
||
private final ChallengeAppRepository challengeAppRepository; | ||
|
||
public void removeApp(Challenge challenge, String appcode, String os) { | ||
ChallengeApp appToRemove = | ||
challengeAppRepository.findFirstByChallengeIdAndAppCodeAndOsOrElseThrow(challenge.getId(), appcode, os); | ||
challengeAppRepository.delete(appToRemove); | ||
} | ||
|
||
public void addApps(Challenge challenge, List<ChallengeAppRequest> requests, String os) { | ||
challengeAppRepository.saveAll( | ||
requests.stream().map( | ||
request -> { | ||
validateAppExist(challenge.getId(), request.appCode(), os); | ||
return request.toEntity(challenge, os); | ||
}).toList()); | ||
} | ||
|
||
private void validateAppExist(Long challengeId, String appCode, String os) { | ||
if (challengeAppRepository.existsByChallengeIdAndAppCodeAndOs(challengeId, appCode, os)) { | ||
throw new AppException(AppError.APP_EXIST_ALREADY); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
src/main/java/sopt/org/hmh/domain/auth/dto/response/LoginResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,11 @@ | ||
package sopt.org.hmh.domain.auth.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import sopt.org.hmh.domain.user.domain.User; | ||
import sopt.org.hmh.global.auth.jwt.TokenResponse; | ||
|
||
public record LoginResponse( | ||
Long userId, | ||
@JsonProperty(value = "token") | ||
TokenResponse tokenResponse | ||
){ | ||
|
||
public static LoginResponse of(User loginUser, TokenResponse tokenResponse) { | ||
return new LoginResponse( | ||
loginUser.getId(), | ||
tokenResponse | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.