-
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
6 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/main/java/com/gaaji/auth/applicationservice/NicknameRegisterService.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,7 @@ | ||
package com.gaaji.auth.applicationservice; | ||
|
||
public interface NicknameRegisterService { | ||
|
||
void registerNickname(String authId, String nickname); | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/gaaji/auth/applicationservice/NicknameRegisterServiceImpl.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.applicationservice; | ||
|
||
import com.gaaji.auth.domain.Auth; | ||
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 NicknameRegisterServiceImpl implements NicknameRegisterService{ | ||
|
||
private final AuthRepository authRepository; | ||
|
||
|
||
public void registerNickname(String authId, String nickname){ | ||
Auth auth = authRepository | ||
.findById(authId) | ||
.orElseThrow(); // TODO Exception 추가 | ||
|
||
auth.registerNickname(nickname); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/gaaji/auth/controller/NicknameRegisterController.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,32 @@ | ||
package com.gaaji.auth.controller; | ||
|
||
import com.gaaji.auth.applicationservice.NicknameRegisterService; | ||
import com.gaaji.auth.controller.dto.NicknameRegisterRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class NicknameRegisterController { | ||
|
||
private final NicknameRegisterService nicknameRegisterService; | ||
|
||
@PatchMapping("/auth/nickname") | ||
public ResponseEntity<Void> registerNickname(@RequestHeader("AUTH-ID") String authId, @RequestBody NicknameRegisterRequest dto){ | ||
// body | ||
nicknameRegisterService.registerNickname(authId, dto.getNickname()); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@PatchMapping("/profile/nickname") | ||
public ResponseEntity<Void> registerProfileNickname(@RequestHeader("AUTH-ID") String authId, @RequestBody NicknameRegisterRequest dto){ | ||
// body | ||
nicknameRegisterService.registerNickname(authId, dto.getNickname()); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/gaaji/auth/controller/dto/NicknameRegisterRequest.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,9 @@ | ||
package com.gaaji.auth.controller.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class NicknameRegisterRequest { | ||
private String 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
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