-
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.
* Feat: Member DB 수정 - 한글이름, 영어이름, 기수, 과정 추가 - 과정 표현하는 Enumerate 추가 - 수정에 따른 오류 수정 - getNickname -> getKoreaName of getEnglishName Related to: #2 * Rename: Member DB Field 이름 변경 Related to: #2 * Feat: /api/auth/member 관련 DTO 작성 Related to: #2 * Feat: /api/auth/member API 관련 DTO 내용 추가 Related to: #2 * Feat: /api/auth/member 관련 MemberService 추가 Related to: #2 * Feat: /api/auth/member 관련 MemberContoller 추가 Related to: #2 * Feat: CORS Error 수정 Related to: #2 * Fix: RefreshToken 매번 생성 오류 수정 Related to: #2 * Refactor: 코드 리뷰 내용 반영 - 불필요 코드 삭제 - 반환값 오류 수정 Related to: #2
- Loading branch information
1 parent
90052aa
commit ea9533e
Showing
15 changed files
with
300 additions
and
8 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
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
package kaboo.kaboo_auth.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
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 ResponseEntity<ResponseDTO<?>> exceptionHandler(Exception e) { | ||
log.error("[Kaboo-Auth]: 예외가 발생하였습니다. {}", e.getMessage()); | ||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
true, | ||
e.getMessage(), | ||
null | ||
)); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
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,86 @@ | ||
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.response.MemberInfoResponse; | ||
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<String>> getMemberIntroduce( | ||
@RequestParam(name = "name", defaultValue = "") String koreaName) { | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
memberService.getMemberIntroduceByKoreaName(koreaName) | ||
)); | ||
} | ||
|
||
@PostMapping("/introduce") | ||
public ResponseEntity<ResponseDTO<String>> updateMemberIntrouce( | ||
@RequestParam(name = "name", defaultValue = "") String koreaName, | ||
@RequestBody String request) { | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(new ResponseDTO<>( | ||
memberService.updateMemberIntroduceByKoreaName(koreaName, request) | ||
)); | ||
} | ||
} |
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 kaboo.kaboo_auth.domain; | ||
|
||
public enum Course { | ||
AI("GenAI"), | ||
FULLSTACK("Fullstack"), | ||
CLOUD("Cloud"); | ||
|
||
private final String course; | ||
|
||
Course(String course) { | ||
this.course = course; | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/kaboo/kaboo_auth/domain/dto/request/MemberInfoUpdateRequest.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 kaboo.kaboo_auth.domain.dto.request; | ||
|
||
import kaboo.kaboo_auth.domain.Course; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MemberInfoUpdateRequest { | ||
private String koreaName; | ||
private String englishName; | ||
private int classNum; | ||
private Course course; | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/kaboo/kaboo_auth/domain/dto/response/MemberInfoResponse.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,20 @@ | ||
package kaboo.kaboo_auth.domain.dto.response; | ||
|
||
import kaboo.kaboo_auth.domain.Course; | ||
import kaboo.kaboo_auth.domain.entity.Member; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MemberInfoResponse { | ||
private final String koreaName; | ||
private final String englishName; | ||
private final int classNum; | ||
private final Course course; | ||
|
||
public MemberInfoResponse(Member member) { | ||
this.koreaName = member.getKoreaName(); | ||
this.englishName = member.getEnglishName(); | ||
this.classNum = member.getClassNum(); | ||
this.course = member.getCourse(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/kaboo/kaboo_auth/domain/dto/response/MemberListResponse.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 kaboo.kaboo_auth.domain.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import kaboo.kaboo_auth.domain.entity.Member; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MemberListResponse { | ||
private final int classNum; | ||
private final int memberNum; | ||
private final List<MemberInfoResponse> memberList; | ||
|
||
public MemberListResponse(List<Member> members, int classNum) { | ||
this.classNum = classNum; | ||
this.memberNum = members.size(); | ||
this.memberList = members.stream() | ||
.map(MemberInfoResponse::new) | ||
.toList(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/kaboo/kaboo_auth/domain/dto/response/ResponseDTO.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,18 @@ | ||
package kaboo.kaboo_auth.domain.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ResponseDTO<T> { | ||
private boolean success; | ||
private String message; | ||
private T data; | ||
|
||
public ResponseDTO(T data) { | ||
success = true; | ||
message = "요청이 성공적으로 처리되었습니다."; | ||
this.data = data; | ||
} | ||
} |
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
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.