forked from KakaoTech-BootCamp-Team-2/Kaboo-Auth
-
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: /api/auth/member 관련 MemberContoller 추가
Related to: KakaoTech-BootCamp-Team-2#2
- Loading branch information
1 parent
a025c6e
commit f8e64ac
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/kaboo/kaboo_auth/controller/MainControllerAdvice.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,23 @@ | ||
package kaboo.kaboo_auth.controller; | ||
|
||
import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
import kaboo.kaboo_auth.domain.dto.response.ResponseDTO; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class MainControllerAdvice { | ||
|
||
@ExceptionHandler({IllegalStateException.class, UsernameNotFoundException.class}) | ||
public ResponseDTO<?> exceptionHandler(Exception e) { | ||
log.error("[Kaboo-Auth]: 예외가 발생하였습니다. {}", e.getMessage()); | ||
return new ResponseDTO<>( | ||
true, | ||
e.getMessage(), | ||
null | ||
); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/kaboo/kaboo_auth/controller/MemberController.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,88 @@ | ||
package kaboo.kaboo_auth.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
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.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import kaboo.kaboo_auth.domain.dto.request.MemberInfoUpdateRequest; | ||
import kaboo.kaboo_auth.domain.dto.request.MemberIntroduceUpdateRequest; | ||
import kaboo.kaboo_auth.domain.dto.response.MemberInfoResponse; | ||
import kaboo.kaboo_auth.domain.dto.response.MemberIntroduceResponse; | ||
import kaboo.kaboo_auth.domain.dto.response.MemberListResponse; | ||
import kaboo.kaboo_auth.domain.dto.response.ResponseDTO; | ||
import kaboo.kaboo_auth.service.MemberService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/auth/member") | ||
public class MemberController { | ||
|
||
private final MemberService memberService; | ||
|
||
@GetMapping("/all") | ||
public ResponseEntity<ResponseDTO<MemberListResponse>> getAllMembers() { | ||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
memberService.getAllMembers() | ||
)); | ||
} | ||
|
||
@GetMapping("/class/{class}") | ||
public ResponseEntity<ResponseDTO<MemberListResponse>> getClassMembers( | ||
@PathVariable(name = "class") int classNum) { | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
memberService.getMembersByClassNum(classNum) | ||
)); | ||
} | ||
|
||
@GetMapping("") | ||
public ResponseEntity<ResponseDTO<MemberInfoResponse>> getMemberInfo( | ||
@RequestParam(name = "name", defaultValue = "") String koreaName) { | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
memberService.getMemberInfoByKoreaName(koreaName) | ||
)); | ||
} | ||
|
||
@PostMapping("") | ||
public ResponseEntity<ResponseDTO<MemberInfoResponse>> updateMemberInfo( | ||
@RequestParam(name = "name", defaultValue = "") String koreaName, | ||
@RequestBody MemberInfoUpdateRequest request) { | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
memberService.updateMemberInfoByKoreaName(koreaName, request) | ||
)); | ||
} | ||
|
||
@GetMapping("/introduce") | ||
public ResponseEntity<ResponseDTO<MemberIntroduceResponse>> getMemberIntroduce( | ||
@RequestParam(name = "name", defaultValue = "") String koreaName) { | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
memberService.getMemberIntroduceByKoreaName(koreaName) | ||
)); | ||
} | ||
|
||
@PostMapping("/introduce") | ||
public ResponseEntity<ResponseDTO<MemberIntroduceResponse>> updateMemberIntrouce( | ||
@RequestParam(name = "name", defaultValue = "") String koreaName, | ||
@RequestBody MemberIntroduceUpdateRequest request) { | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
memberService.updateMemberIntroduceByKoreaName(koreaName, request) | ||
)); | ||
} | ||
} |