-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
117 additions
and
26 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/java/com/gaaji/auth/applicationservice/AuthRetrieveService.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,8 @@ | ||
package com.gaaji.auth.applicationservice; | ||
|
||
import com.gaaji.auth.controller.dto.RetrieveResponse; | ||
|
||
public interface AuthRetrieveService { | ||
|
||
RetrieveResponse retrieveAuth(String authId); | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/gaaji/auth/applicationservice/AuthRetrieveServiceImpl.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,25 @@ | ||
package com.gaaji.auth.applicationservice; | ||
|
||
import com.gaaji.auth.controller.dto.RetrieveResponse; | ||
import com.gaaji.auth.domain.Auth; | ||
import com.gaaji.auth.domain.AuthId; | ||
import com.gaaji.auth.repository.AuthRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@RequiredArgsConstructor | ||
@Transactional | ||
@Service | ||
public class AuthRetrieveServiceImpl implements | ||
AuthRetrieveService { | ||
|
||
private final AuthRepository authRepository; | ||
|
||
@Override | ||
public RetrieveResponse retrieveAuth(String authId) { | ||
Auth auth = authRepository.findById(authId) | ||
.orElseThrow(); | ||
return RetrieveResponse.of(authId, auth.getNickname(), auth.getMannerTemperature()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
src/main/java/com/gaaji/auth/controller/AuthRetrieveController.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,25 @@ | ||
package com.gaaji.auth.controller; | ||
|
||
|
||
import com.gaaji.auth.applicationservice.AuthRetrieveService; | ||
import com.gaaji.auth.controller.dto.RetrieveResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class AuthRetrieveController { | ||
|
||
private final AuthRetrieveService authRetrieveService; | ||
|
||
@GetMapping("/auth/{authId}") | ||
public ResponseEntity<RetrieveResponse> retrieveAuth(@PathVariable("authId") String authId){ | ||
|
||
RetrieveResponse dto = authRetrieveService.retrieveAuth(authId); | ||
return ResponseEntity.ok(dto); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/gaaji/auth/controller/dto/RetrieveResponse.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,25 @@ | ||
package com.gaaji.auth.controller.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor | ||
public class RetrieveResponse { | ||
|
||
private String authId; | ||
private String nickname; | ||
private double mannerTemperature; | ||
|
||
|
||
public static RetrieveResponse of(String authId, String nickname, double mannerTemperature) { | ||
return new RetrieveResponse(authId, validateNickname(nickname), mannerTemperature); | ||
} | ||
|
||
private static String validateNickname(String nickname){ | ||
return nickname == null ? "익명" : nickname; | ||
} | ||
} |
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
17 changes: 0 additions & 17 deletions
17
src/main/java/com/gaaji/auth/domain/MannerTemparature.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/main/java/com/gaaji/auth/domain/MannerTemperature.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,24 @@ | ||
package com.gaaji.auth.domain; | ||
|
||
import javax.persistence.Access; | ||
import javax.persistence.AccessType; | ||
import javax.persistence.Embeddable; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Access(AccessType.FIELD) | ||
@Embeddable @NoArgsConstructor | ||
public class MannerTemperature { | ||
|
||
private double temperature; | ||
|
||
private MannerTemperature(double temperature) { | ||
this.temperature = temperature; | ||
} | ||
public static MannerTemperature of(double temperature){ | ||
return new MannerTemperature(temperature); | ||
} | ||
|
||
public double getTemperature() { | ||
return temperature; | ||
} | ||
} |