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

[ALL] RESTful API 디자인 원칙에 기반하여 기존 API path를 수정 #107

Merged
merged 2 commits into from
Jul 30, 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 @@ -17,7 +17,7 @@ public class AttendeeController {

private final AttendeeService attendeeService;

@PostMapping("/api/v1/login/{uuid}")
@PostMapping("/api/v1/meetings/{uuid}/login")
public MomoApiResponse<TokenResponse> login(
@PathVariable String uuid, @RequestBody @Valid AttendeeLoginRequest request
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ public class MeetingController {

private final MeetingService meetingService;

@GetMapping("/api/v1/meeting/{uuid}")
public MomoApiResponse<MeetingResponse> find(@PathVariable String uuid) {
MeetingResponse meetingResponse = meetingService.findByUUID(uuid);
return new MomoApiResponse<>(meetingResponse);
}

@PostMapping("/api/v1/meeting")
@PostMapping("/api/v1/meetings")
public ResponseEntity<MomoApiResponse<MeetingSharingResponse>> create(
@RequestBody @Valid MeetingCreateRequest request
) {
Expand All @@ -36,7 +30,13 @@ public ResponseEntity<MomoApiResponse<MeetingSharingResponse>> create(
.body(new MomoApiResponse<>(response));
}

@GetMapping("/api/v1/meeting/{uuid}/sharing")
@GetMapping("/api/v1/meetings/{uuid}")
public MomoApiResponse<MeetingResponse> find(@PathVariable String uuid) {
MeetingResponse meetingResponse = meetingService.findByUUID(uuid);
return new MomoApiResponse<>(meetingResponse);
}

@GetMapping("/api/v1/meetings/{uuid}/sharing")
public MomoApiResponse<MeetingSharingResponse> findMeetingSharing(@PathVariable String uuid) {
MeetingSharingResponse response = meetingService.findMeetingSharing(uuid);
return new MomoApiResponse<>(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ public class ScheduleController {

private final ScheduleService scheduleService;

@PostMapping("/api/v1/schedule/{uuid}")
@PostMapping("/api/v1/meetings/{uuid}/schedules")
public void create(
@PathVariable String uuid, @AuthAttendee long id, @RequestBody @Valid ScheduleCreateRequest request
) {
scheduleService.create(uuid, id, request);
}

@GetMapping("/api/v1/meeting/{uuid}/schedules")
@GetMapping("/api/v1/meetings/{uuid}/schedules")
public MomoApiResponse<SchedulesResponse> findAllSchedules(@PathVariable String uuid) {
SchedulesResponse response = scheduleService.findAllSchedules(uuid);
return new MomoApiResponse<>(response);
}

@GetMapping(path = "/api/v1/meeting/{uuid}/schedules", params = "attendeeName")
@GetMapping(path = "/api/v1/meetings/{uuid}/schedules", params = "attendeeName")
public MomoApiResponse<ScheduleOneAttendeeResponse> findSchedulesOfAttendee(
@PathVariable String uuid, String attendeeName
) {
ScheduleOneAttendeeResponse response = scheduleService.findSingleSchedule(uuid, attendeeName);
return new MomoApiResponse<>(response);
}

@GetMapping("/api/v1/meeting/{uuid}/my-schedule")
@GetMapping("/api/v1/meetings/{uuid}/attendees/me/schedules")
public MomoApiResponse<ScheduleOneAttendeeResponse> findMySchedule(
@PathVariable String uuid, @AuthAttendee long id
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void login() {
RestAssured.given().log().all()
.contentType(ContentType.JSON)
.body(request)
.when().post("/api/v1/login/{uuid}", meeting.getUuid())
.when().post("/api/v1/meetings/{uuid}/login", meeting.getUuid())
.then().log().all()
.statusCode(HttpStatus.OK.value());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void find() {

Response response = RestAssured.given().log().all()
.contentType(ContentType.JSON)
.when().get("/api/v1/meeting/{uuid}", meeting.getUuid());
.when().get("/api/v1/meetings/{uuid}", meeting.getUuid());

String meetingName = response.jsonPath().getString("data.meetingName");
String firstTime = response.jsonPath().getString("data.firstTime");
Expand All @@ -87,7 +87,7 @@ void findMeetingSharing() {

RestAssured.given().log().all()
.contentType(ContentType.JSON)
.when().get("/api/v1/meeting/{uuid}/sharing", meeting.getUuid())
.when().get("/api/v1/meetings/{uuid}/sharing", meeting.getUuid())
.then().log().all()
.statusCode(HttpStatus.OK.value());
}
Expand All @@ -97,7 +97,7 @@ void findMeetingSharing() {
void findMeetingSharingFailedWithInvalidUUID() {
RestAssured.given().log().all()
.contentType(ContentType.JSON)
.when().get("/api/v1/meeting/{uuid}/sharing", "1234")
.when().get("/api/v1/meetings/{uuid}/sharing", "1234")
.then().log().all()
.statusCode(HttpStatus.BAD_REQUEST.value());
}
Expand All @@ -116,7 +116,7 @@ void create() {
RestAssured.given().log().all()
.contentType(ContentType.JSON)
.body(request)
.when().post("/api/v1/meeting")
.when().post("/api/v1/meetings")
.then().log().all()
.assertThat()
.statusCode(HttpStatus.CREATED.value())
Expand All @@ -138,7 +138,7 @@ void createByDuplicatedName() {
RestAssured.given().log().all()
.contentType(ContentType.JSON)
.body(request)
.when().post("/api/v1/meeting")
.when().post("/api/v1/meetings")
.then().log().all()
.assertThat()
.statusCode(HttpStatus.BAD_REQUEST.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void create() {
String token = RestAssured.given().log().all()
.contentType(ContentType.JSON)
.body(loginRequest)
.when().post("/api/v1/login/{uuid}", meeting.getUuid())
.when().post("/api/v1/meetings/{uuid}/login", meeting.getUuid())
.then().log().all()
.statusCode(HttpStatus.OK.value())
.extract().jsonPath().getString("data.token");
Expand All @@ -89,7 +89,7 @@ void create() {
.pathParam("uuid", meeting.getUuid())
.contentType(ContentType.JSON)
.body(scheduleCreateRequest)
.when().post("/api/v1/schedule/{uuid}")
.when().post("/api/v1/meetings/{uuid}/schedules")
.then().log().all()
.statusCode(HttpStatus.OK.value());
}
Expand All @@ -102,7 +102,7 @@ void findSchedulesOfAttendee() {
RestAssured.given().log().all()
.pathParam("uuid", meeting.getUuid())
.queryParam("attendeeName", attendee.name())
.when().get("/api/v1/meeting/{uuid}/schedules")
.when().get("/api/v1/meetings/{uuid}/schedules")
.then().log().all()
.statusCode(HttpStatus.OK.value());
}
Expand All @@ -112,7 +112,7 @@ void findSchedulesOfAttendee() {
void findAllSchedules() {
RestAssured.given().log().all()
.contentType(ContentType.JSON)
.when().get("/api/v1/meeting/{uuid}/schedules", meeting.getUuid())
.when().get("/api/v1/meetings/{uuid}/schedules", meeting.getUuid())
.then().log().all()
.statusCode(HttpStatus.OK.value());
}
Expand All @@ -127,7 +127,7 @@ void findMySchedule() {
String token = RestAssured.given().log().all()
.contentType(ContentType.JSON)
.body(loginRequest)
.when().post("/api/v1/login/{uuid}", meeting.getUuid())
.when().post("/api/v1/meetings/{uuid}/login", meeting.getUuid())
.then().log().all()
.statusCode(HttpStatus.OK.value())
.extract().jsonPath().getString("data.token");
Expand All @@ -136,7 +136,7 @@ void findMySchedule() {
.header("Authorization", "Bearer " + token)
.pathParam("uuid", meeting.getUuid())
.contentType(ContentType.JSON)
.when().get("/api/v1/meeting/{uuid}/my-schedule")
.when().get("/api/v1/meetings/{uuid}/attendees/me/schedules")
.then().log().all()
.statusCode(HttpStatus.OK.value());
}
Expand Down