Skip to content

Commit

Permalink
Merge pull request #111 from Likelion-YeungNam-Univ/feature-user
Browse files Browse the repository at this point in the history
User 짝꿍연결 valid 추가 및 명세 수정
  • Loading branch information
iampingu99 authored Aug 5, 2024
2 parents 07f7224 + b223a2c commit bc878b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand Down Expand Up @@ -74,6 +77,16 @@ public interface UserApi {
@Operation(summary = "짝꿍 연결", description = "사용자가 대상 사용자와 짝꿍으로 연결하기 위한 API 입니다")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "짝꿍 연결 성공"),
@ApiResponse(responseCode = "400", description = "정상적인 코드가 아닌 경우 코드는 10자리 숫자",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(value = """
{
"timestamp": "2024-07-19T17:56:39.188+00:00",
"name": "SYSTEM_ERROR",
"cause": "400 BAD_REQUEST Validation failure"
}
""")
})),
@ApiResponse(responseCode = "404", description = "사용자 또는 대상 사용자를 조회할 수 없는 경우",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(name = "USER_NOT_FOUND", value = """
Expand Down Expand Up @@ -109,7 +122,7 @@ public interface UserApi {
"""),
}))
})
ResponseEntity<String> connectMate(HttpServletRequest request, @PathVariable Long socialId);
ResponseEntity<String> connectMate(HttpServletRequest request, @Valid @NotNull @Pattern(regexp = "^\\d{10}$") @PathVariable String socialId);

@PatchMapping("/disconnect")
@Operation(summary = "짝꿍 해제", description = "사용자가 기존 짝궁과 연결을 해제하기 위한 API 입니다")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import com.example.holing.bounded_context.user.exception.UserExceptionCode;
import com.example.holing.bounded_context.user.service.UserService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -84,11 +87,11 @@ public ResponseEntity<UserInfoResponseDto> read(HttpServletRequest request) {
// return ResponseEntity.ok().body(response);
// }

public ResponseEntity<String> connectMate(HttpServletRequest request, @PathVariable Long socialId) {
public ResponseEntity<String> connectMate(HttpServletRequest request, @Valid @NotNull @Pattern(regexp = "^\\d{10}$") @PathVariable String socialId) {
String accessToken = jwtProvider.getToken(request);
String userId = jwtProvider.getUserId(accessToken);

userService.connectMate(Long.parseLong(userId), socialId);
userService.connectMate(Long.parseLong(userId), Long.parseLong(socialId));

return ResponseEntity.ok().body("짝꿍 연결에 성공했습니다.");
}
Expand Down

0 comments on commit bc878b7

Please sign in to comment.