Skip to content

Commit

Permalink
Merge pull request #210 from prgrms-web-devcourse-final-project/develop
Browse files Browse the repository at this point in the history
[merge] main 브랜치 병합
  • Loading branch information
DongWooKim4343 authored Dec 8, 2024
2 parents 1b40c7e + 00315b4 commit ad8d2ff
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -146,16 +147,21 @@ public ResponseEntity<List<MapBoundsResponse>> getMarkersInBounds(

List<MapBoundsResponse> articlesInBounds;

log.info("지도에서 글타래 조회");

// 대분류 소분류
// 대분류 null 인경우 전체 조회
// 대분류 존재하는 경우 해당 값 조회 // 시설/위치 ---구조 ---목격 ---사용자 등록 정보
// 시설/위치는 소분류도 존재
// 사용자 등록 정보는?
if (articleType == null || articleType.isEmpty()) { // 대분류 null 전체 조회
if (Objects.equals(articleType, "all") || articleType == null
|| articleType.isEmpty()) { // 대분류 null 전체 조회
log.info("전체 조회");
articlesInBounds = locationService.findArticlesInBounds(
southWestLat, southWestLon,
northEastLat, northEastLon);
} else { // 대준류 null 아님
log.info("대분류 조회");
if (placeCategory == null || placeCategory.isEmpty()) { // 소분류 없는 경우 // 글타래 타입 기준 조회
articlesInBounds = locationService.findArticlesInBoundsByType(
southWestLat, southWestLon,
Expand All @@ -165,8 +171,8 @@ public ResponseEntity<List<MapBoundsResponse>> getMarkersInBounds(
southWestLat, southWestLon,
northEastLat, northEastLon, articleType, placeCategory);
}

}

return ResponseEntity.ok(articlesInBounds);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public List<MapBoundsResponse> findArticlesInBounds(double southWestLat, double
"SELECT a.article_id, a.type, a.title, ST_X(a.geography) AS latitude, " +
"ST_Y(a.geography) AS longitude, a.description " +
"FROM article a " +
"WHERE MBRContains(ST_GeomFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))', 4326), a.geography)",
"WHERE MBRContains(ST_GeomFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))', 4326), a.geography) "
+ "AND a.map_visibility = 'VISIBLE'",
southWestLat, southWestLon,
southWestLat, northEastLon,
northEastLat, northEastLon,
Expand Down Expand Up @@ -52,7 +53,8 @@ public List<MapBoundsResponse> findArticlesInBoundsByType(double southWestLat,
"SELECT a.article_id, a.type, a.title, ST_X(a.geography) AS latitude, " +
"ST_Y(a.geography) AS longitude, a.description " +
"FROM article a " +
"WHERE MBRContains(ST_GeomFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))', 4326), a.geography) AND a.type = '%s'",
"WHERE MBRContains(ST_GeomFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))', 4326), a.geography) "
+ "AND a.type = '%s' AND a.map_visibility = 'VISIBLE'",
southWestLat, southWestLon,
southWestLat, northEastLon,
northEastLat, northEastLon,
Expand Down Expand Up @@ -85,7 +87,7 @@ public List<MapBoundsResponse> findPlaceArticlesInBoundsByType(double southWestL
"FROM place_article p "
+ "JOIN article a ON p.article_id = a.article_id "
+ "WHERE MBRContains(ST_GeomFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))', 4326), a.geography) "
+ "AND p.is_public_data = %b",
+ "AND p.is_public_data = %b AND a.map_visibility = 'VISIBLE'",
southWestLat, southWestLon,
southWestLat, northEastLon,
northEastLat, northEastLon,
Expand Down Expand Up @@ -119,7 +121,7 @@ public List<MapBoundsResponse> findPlaceArticlesInBoundsByCategory(double southW
"FROM place_article p "
+ "JOIN article a ON p.article_id = a.article_id "
+ "WHERE MBRContains(ST_GeomFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))', 4326), a.geography) "
+ "AND p.category = '%s' AND p.is_public_data = %b",
+ "AND p.category = '%s' AND p.is_public_data = %b AND a.map_visibility = 'VISIBLE'",
southWestLat, southWestLon,
southWestLat, northEastLon,
northEastLat, northEastLon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -84,8 +85,15 @@ public ResponseEntity<PageResponse<CommunityListResponse>> getCommunityPostByCat
@PathVariable String categoryName,
@RequestParam(defaultValue = "1") int page
) {
log.info("=== Request received - category: {}, page: {}", categoryName, page);

PageRequest pageRequest = PageRequest.of(page - 1, 10);
return ResponseEntity.ok(PageResponse.from(boardService.getCommunityBoardsByCategory(categoryName, pageRequest)));

var result = boardService.getCommunityBoardsByCategory(categoryName, pageRequest);
log.info("=== Request processed successfully");

return ResponseEntity.ok(PageResponse.from(result));
// return ResponseEntity.ok(PageResponse.from(boardService.getCommunityBoardsByCategory(categoryName, pageRequest)));
}

@Operation(summary = "커뮤니티 특정 게시글 수정", description = "특정 커뮤니티 게시글을 수정합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class CommunityListResponse {
private final Long boardId;
private final String title;
private final String content;
private final String writer;
private final String categoryName;
private final int viewCount;
Expand All @@ -21,6 +22,7 @@ public class CommunityListResponse {
public CommunityListResponse(Board board) {
this.boardId = board.getBoardId();
this.title = board.getTitle();
this.content = board.getContent();
this.writer = board.getMember().getNickname().getValue();
this.categoryName = board.getCategory().getName();
this.viewCount = board.getViewCnt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class SightingListResponse {
private final Long boardId;
private final String title;
private final String content;
private final String writer;
private final String categoryName;
private final String address;
Expand All @@ -23,6 +24,7 @@ public class SightingListResponse {
public SightingListResponse(Board board) {
this.boardId = board.getBoardId();
this.title = board.getTitle();
this.content = board.getContent();
this.writer = board.getMember().getNickname().getValue();
this.categoryName = board.getCategory().getName();
this.address = board.getAddress();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/mallangs/global/jwt/filter/JWTFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
String path = request.getServletPath();

Map<String, String> patternVariableMap = new HashMap<>();
patternVariableMap.put("/api/v1/board/community/category/{categoryId}", "categoryId");
patternVariableMap.put("/api/v1/comments/board/{boardId}", "boardId");
patternVariableMap.put("/api/v1/comments/article/{articleId}", "articleId");
patternVariableMap.put("/api/v1/board/sighting/category/{categoryId}", "categoryId");
patternVariableMap.put("/api/v1/place-articles/{placeArticleId}/reviews", "placeArticleId");
patternVariableMap.put("/api/v1/place-articles/{placeArticleId}/reviews/average-score", "placeArticleId");

Expand Down Expand Up @@ -106,6 +104,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
//게시판
("GET".equals(method) && uri.startsWith("/api/v1/board/community")) ||
("GET".equals(method) && uri.startsWith("/api/v1/board/community/keyword")) ||
("GET".equals(method) && uri.startsWith("/api/v1/board/community/category")) ||
("GET".equals(method) && uri.startsWith("/api/v1/board/sighting")) ||
("GET".equals(method) && uri.startsWith("/api/v1/board/sighting/keyword")) ||

Expand Down

0 comments on commit ad8d2ff

Please sign in to comment.