Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User 짝꿍연결 valid 추가 및 명세 수정 #111

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading