-
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.
Browse files
Browse the repository at this point in the history
모임 기능 1차 프로토타입 개발
- Loading branch information
Showing
26 changed files
with
1,011 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...fice/src/main/java/dev/office/networkoffice/gathering/controller/GatheringController.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,65 @@ | ||
package dev.office.networkoffice.gathering.controller; | ||
|
||
import dev.office.networkoffice.gathering.controller.docs.GatheringApiDocs; | ||
import dev.office.networkoffice.gathering.controller.dto.request.GatheringCancelDto; | ||
import dev.office.networkoffice.gathering.controller.dto.request.GatheringDto; | ||
import dev.office.networkoffice.gathering.controller.dto.request.GatheringSuccessDto; | ||
import dev.office.networkoffice.gathering.controller.dto.response.GatheringClosedResponse; | ||
import dev.office.networkoffice.gathering.controller.dto.response.GatheringListResponseDto; | ||
import dev.office.networkoffice.gathering.controller.dto.response.GatheringResponseDto; | ||
import dev.office.networkoffice.gathering.service.GatheringService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.security.Principal; | ||
|
||
@RestController | ||
@RequestMapping("api/v1/gathering") | ||
@RequiredArgsConstructor | ||
public class GatheringController implements GatheringApiDocs { | ||
|
||
private final GatheringService gatheringService; | ||
|
||
@GetMapping | ||
public GatheringListResponseDto findGatheringList(Principal principal, | ||
@RequestParam("si") String si, | ||
@RequestParam("dong") String dong, | ||
@RequestParam("gu") String gu) { | ||
return gatheringService.getGatheringByPlace(si, dong, gu); | ||
} | ||
|
||
@PostMapping | ||
public GatheringResponseDto createGathering(Principal principal, | ||
@RequestBody GatheringDto gatheringDto) { | ||
Long userId = getUserId(principal); | ||
return gatheringService.createGathering(userId, gatheringDto); | ||
} | ||
|
||
@PutMapping("{gatheringId}") | ||
public GatheringResponseDto modifyGatheringByHost(Principal principal, | ||
@PathVariable("gatheringId") Long gatheringId, | ||
@RequestBody GatheringDto gatheringDto) { | ||
Long userId = getUserId(principal); | ||
return gatheringService.modifyGatheringInfoByHost(userId, gatheringId, gatheringDto); | ||
} | ||
|
||
@PostMapping("{gatheringId}/success") | ||
public GatheringClosedResponse successGatheringByHost(Principal principal, | ||
@PathVariable("gatheringId") Long gatheringId, | ||
GatheringSuccessDto successDto) { | ||
Long userId = getUserId(principal); | ||
return gatheringService.successGatheringByHost(userId, gatheringId, successDto); | ||
} | ||
|
||
@PostMapping("{gatheringId}/cancel") | ||
public GatheringClosedResponse cancelGatheringByHost(Principal principal, | ||
@PathVariable("gatheringId") Long gatheringId, | ||
GatheringCancelDto cancelDto) { | ||
Long userId = getUserId(principal); | ||
return gatheringService.cancelGatheringByHost(userId, gatheringId, cancelDto); | ||
} | ||
|
||
private Long getUserId(Principal principal) { | ||
return Long.parseLong(principal.getName()); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...ce/src/main/java/dev/office/networkoffice/gathering/controller/docs/GatheringApiDocs.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,89 @@ | ||
package dev.office.networkoffice.gathering.controller.docs; | ||
|
||
import dev.office.networkoffice.gathering.controller.dto.request.GatheringCancelDto; | ||
import dev.office.networkoffice.gathering.controller.dto.request.GatheringDto; | ||
import dev.office.networkoffice.gathering.controller.dto.request.GatheringSuccessDto; | ||
import dev.office.networkoffice.gathering.controller.dto.response.GatheringClosedResponse; | ||
import dev.office.networkoffice.gathering.controller.dto.response.GatheringListResponseDto; | ||
import dev.office.networkoffice.gathering.controller.dto.response.GatheringResponseDto; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
import java.security.Principal; | ||
|
||
@Tag(name = "모임", description = "모임 관련 API") | ||
public interface GatheringApiDocs { | ||
|
||
@Operation(summary = "모임 조회") | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "요청이 정상적으로 처리되었을 때" | ||
), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "유효하지 않은 코드가 전달되었을 때" | ||
) | ||
}) | ||
GatheringListResponseDto findGatheringList(Principal principal, String si, String dong, String gu); | ||
|
||
@Operation(summary = "모임 생성") | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "요청이 정상적으로 처리되었을 때" | ||
), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "유효하지 않은 코드가 전달되었을 때" | ||
) | ||
}) | ||
GatheringResponseDto createGathering(Principal principal, GatheringDto gatheringDto); | ||
|
||
@Operation(summary = "모임 수정") | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "요청이 정상적으로 처리되었을 때" | ||
), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "유효하지 않은 코드가 전달되었을 때" | ||
) | ||
}) | ||
GatheringResponseDto modifyGatheringByHost(Principal principal, | ||
Long gatheringId, | ||
GatheringDto gatheringDto); | ||
|
||
@Operation(summary = "모임 파토") | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "요청이 정상적으로 처리되었을 때" | ||
), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "유효하지 않은 코드가 전달되었을 때" | ||
) | ||
}) | ||
GatheringClosedResponse cancelGatheringByHost(Principal principal, | ||
Long gatheringId, | ||
GatheringCancelDto cancelDto); | ||
|
||
@Operation(summary = "모임 성공적 종료") | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "요청이 정상적으로 처리되었을 때" | ||
), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "유효하지 않은 코드가 전달되었을 때" | ||
) | ||
}) | ||
GatheringClosedResponse successGatheringByHost(Principal principal, | ||
Long gatheringId, | ||
GatheringSuccessDto successDto); | ||
} |
8 changes: 8 additions & 0 deletions
8
...in/java/dev/office/networkoffice/gathering/controller/dto/request/GatheringCancelDto.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,8 @@ | ||
package dev.office.networkoffice.gathering.controller.dto.request; | ||
|
||
import dev.office.networkoffice.gathering.domain.ReasonForCanceled; | ||
|
||
public record GatheringCancelDto( | ||
ReasonForCanceled reason | ||
) { | ||
} |
41 changes: 41 additions & 0 deletions
41
...src/main/java/dev/office/networkoffice/gathering/controller/dto/request/GatheringDto.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,41 @@ | ||
package dev.office.networkoffice.gathering.controller.dto.request; | ||
|
||
import java.time.LocalDateTime; | ||
import dev.office.networkoffice.gathering.entity.PlaceInfo; | ||
import dev.office.networkoffice.gathering.entity.TimeInfo; | ||
|
||
public record GatheringDto( | ||
String title, | ||
String category, | ||
String description, | ||
|
||
String place, | ||
String detailPlace, | ||
|
||
String si, | ||
String dong, | ||
String gu, | ||
|
||
Double x, | ||
Double y, | ||
|
||
String date, | ||
LocalDateTime startTime, | ||
LocalDateTime endTime | ||
) { | ||
public PlaceInfo placeInfoConstructor() { | ||
return PlaceInfo.builder() | ||
.place(place).detailPlace(detailPlace) | ||
.si(si).dong(dong).gu(gu) | ||
.x(x).y(y) | ||
.build(); | ||
} | ||
|
||
public TimeInfo timeInfoConstructor() { | ||
return TimeInfo.builder() | ||
.date(date) | ||
.startTime(startTime) | ||
.endTime(endTime) | ||
.build(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...n/java/dev/office/networkoffice/gathering/controller/dto/request/GatheringSuccessDto.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,7 @@ | ||
package dev.office.networkoffice.gathering.controller.dto.request; | ||
|
||
public record GatheringSuccessDto( | ||
String review, | ||
Integer star | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
...a/dev/office/networkoffice/gathering/controller/dto/response/GatheringClosedResponse.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,9 @@ | ||
package dev.office.networkoffice.gathering.controller.dto.response; | ||
|
||
public record GatheringClosedResponse( | ||
String gatheringStatus | ||
) { | ||
public static GatheringClosedResponse from(String gatheringStatus) { | ||
return new GatheringClosedResponse(gatheringStatus); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../dev/office/networkoffice/gathering/controller/dto/response/GatheringListResponseDto.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 dev.office.networkoffice.gathering.controller.dto.response; | ||
|
||
import java.util.List; | ||
|
||
public record GatheringListResponseDto( | ||
List<GatheringResponseDto> gatherings | ||
) { | ||
public static GatheringListResponseDto from(List<GatheringResponseDto> gatherings) { | ||
return new GatheringListResponseDto(gatherings); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...java/dev/office/networkoffice/gathering/controller/dto/response/GatheringResponseDto.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,40 @@ | ||
package dev.office.networkoffice.gathering.controller.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import dev.office.networkoffice.gathering.entity.Gathering; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record GatheringResponseDto( | ||
Long id, | ||
String title, | ||
String category, | ||
String description, | ||
|
||
String place, | ||
String detailPlace, | ||
|
||
Double x, | ||
Double y, | ||
|
||
String date, | ||
LocalDateTime startTime, | ||
LocalDateTime endTime | ||
) { | ||
public static GatheringResponseDto from(Gathering gathering) { | ||
return GatheringResponseDto.builder() | ||
.id(gathering.getId()) | ||
.title(gathering.getTitle()) | ||
.category(String.valueOf(gathering.getCategory())) | ||
.description(gathering.getDescription()) | ||
.place(gathering.getPlaceInfo().getPlace()) | ||
.detailPlace(gathering.getPlaceInfo().getDetailPlace()) | ||
.x(gathering.getPlaceInfo().getX()) | ||
.y(gathering.getPlaceInfo().getY()) | ||
.date(gathering.getTimeInfo().getDate()) | ||
.startTime(gathering.getTimeInfo().getStartTime()) | ||
.endTime(gathering.getTimeInfo().getEndTime()) | ||
.build(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Network-Office/src/main/java/dev/office/networkoffice/gathering/domain/Category.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 dev.office.networkoffice.gathering.domain; | ||
|
||
public enum Category { | ||
SPORT, | ||
CULTURE, | ||
PARTY, | ||
FOOD, | ||
VOLUNTEER, | ||
COFFEE, | ||
STUDY, | ||
WALK, | ||
ETC | ||
} |
11 changes: 11 additions & 0 deletions
11
Network-Office/src/main/java/dev/office/networkoffice/gathering/domain/GatheringStatus.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 dev.office.networkoffice.gathering.domain; | ||
|
||
/** | ||
* 모임의 상태를 정의 합니다. | ||
*/ | ||
public enum GatheringStatus { | ||
CANCELED, | ||
SUCCESSFUL, | ||
REPORT, | ||
IN_PROGRESS | ||
} |
10 changes: 10 additions & 0 deletions
10
...ork-Office/src/main/java/dev/office/networkoffice/gathering/domain/ReasonForCanceled.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,10 @@ | ||
package dev.office.networkoffice.gathering.domain; | ||
|
||
/** | ||
* 모임 터짐 사유 종류를 정의 합니다. | ||
*/ | ||
public enum ReasonForCanceled { | ||
INSUFFICIENT_PEOPLE, | ||
PERSONAL_REASON, | ||
BAD_CONTENTS_GATHERINGS | ||
} |
13 changes: 13 additions & 0 deletions
13
...-Office/src/main/java/dev/office/networkoffice/gathering/domain/ReasonForDeportation.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 dev.office.networkoffice.gathering.domain; | ||
|
||
/** | ||
* 모임 추방 사유를 정의 합니다. | ||
*/ | ||
public enum ReasonForDeportation { | ||
PAPERING, | ||
CUSS_WORD, | ||
SEXUAL_CONTENTS, | ||
ADVERTISEMENT, | ||
RELIGIOUS_POLITICAL_SPEECH, | ||
CRIMINAL_ACTS | ||
} |
Oops, something went wrong.