-
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.
- Loading branch information
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/com/srltas/runtogether/adapter/in/UserNeighborhoodController.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,44 @@ | ||
package com.srltas.runtogether.adapter.in; | ||
|
||
import static com.srltas.runtogether.adapter.in.web.common.SessionAttribute.*; | ||
import static com.srltas.runtogether.adapter.in.web.common.UrlConstants.*; | ||
import static org.springframework.http.HttpStatus.*; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.srltas.runtogether.adapter.in.web.dto.AddUserNeighborhoodRequest; | ||
import com.srltas.runtogether.adapter.out.session.UserSessionDTO; | ||
import com.srltas.runtogether.application.port.in.AddUserNeighborhood; | ||
import com.srltas.runtogether.application.port.in.AddUserNeighborhoodCommand; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.servlet.http.HttpSession; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Tag(name = "내 동네 API", description = "내 동네 API") | ||
@RestController | ||
@RequiredArgsConstructor | ||
public class UserNeighborhoodController { | ||
|
||
private final AddUserNeighborhood addUserNeighborhood; | ||
|
||
@Operation( | ||
summary = "내 동네 등록", | ||
description = "사용자가 특정 동네를 자신의 동네로 등록합니다." | ||
) | ||
@ApiResponse(responseCode = "200", description = "내 동네 등록 성공") | ||
@PostMapping(USER_NEIGHBORHOOD_REGISTRATION) | ||
public ResponseEntity<Void> addUserNeighborhood( | ||
@RequestBody @Valid AddUserNeighborhoodRequest request, HttpSession session) { | ||
UserSessionDTO userSession = (UserSessionDTO)session.getAttribute(USER_SESSION); | ||
addUserNeighborhood.addNeighborhood( | ||
new AddUserNeighborhoodCommand(userSession.userId(), request.neighborhoodId())); | ||
return new ResponseEntity<>(CREATED); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/srltas/runtogether/adapter/in/web/dto/AddUserNeighborhoodRequest.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,11 @@ | ||
package com.srltas.runtogether.adapter.in.web.dto; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.PositiveOrZero; | ||
|
||
public record AddUserNeighborhoodRequest( | ||
@NotNull | ||
@PositiveOrZero(message = "동네 ID는 0 이상의 값이어야 합니다.") | ||
int neighborhoodId | ||
) { | ||
} |
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