-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] create get user's university api
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 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
21 changes: 21 additions & 0 deletions
21
src/main/java/org/hankki/hankkiserver/api/user/service/UserQueryService.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,21 @@ | ||
package org.hankki.hankkiserver.api.user.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.hankki.hankkiserver.api.user.service.response.UserUniversityFindResponse; | ||
import org.hankki.hankkiserver.common.code.UserUniversityErrorCode; | ||
import org.hankki.hankkiserver.common.exception.NotFoundException; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UserQueryService { | ||
|
||
private final UserUniversityFinder userUniversityFinder; | ||
|
||
@Transactional(readOnly = true) | ||
public UserUniversityFindResponse findUserUniversity(Long userId) { | ||
return UserUniversityFindResponse.of(userUniversityFinder.findByUserId(userId) | ||
.orElseThrow(() -> new NotFoundException(UserUniversityErrorCode.USER_UNIVERSITY_NOT_FOUND))); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...in/java/org/hankki/hankkiserver/api/user/service/response/UserUniversityFindResponse.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,13 @@ | ||
package org.hankki.hankkiserver.api.user.service.response; | ||
|
||
import org.hankki.hankkiserver.domain.user.model.UserUniversity; | ||
|
||
public record UserUniversityFindResponse(long id, | ||
String name, | ||
double longitude, | ||
double latitude) { | ||
public static UserUniversityFindResponse of (UserUniversity userUniversity) { | ||
return new UserUniversityFindResponse(userUniversity.getUniversityId(), userUniversity.getUniversityName(), | ||
userUniversity.getLongitude(), userUniversity.getLatitude()); | ||
} | ||
} |