Skip to content

Commit

Permalink
Merge pull request #89 from SWM-M3PRO/develop
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
koomin1227 authored Oct 6, 2024
2 parents 976e236 + c84c5be commit 1135869
Show file tree
Hide file tree
Showing 35 changed files with 1,006 additions and 39 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cd_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
echo "APPLE_PRIVATE_KEY=${{ secrets.APPLE_PRIVATE_KEY }}" >> .env
echo "LATEST_VERSION=${{ secrets.LATEST_VERSION }}" >> .env
echo "FORCE_UPDATE_VERSION=${{ secrets.FORCE_UPDATE_VERSION }}" >> .env
echo "GEOCODING_API=${{ secrets.GEOCODING_API }}" >> .env
echo "SPRING_PROFILES_ACTIVE=dev" >> .env
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cd_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
echo "APPLE_PRIVATE_KEY=${{ secrets.APPLE_PRIVATE_KEY }}" >> .env
echo "LATEST_VERSION=${{ secrets.LATEST_VERSION_PROD }}" >> .env
echo "FORCE_UPDATE_VERSION=${{ secrets.FORCE_UPDATE_VERSION_PROD }}" >> .env
echo "GEOCODING_API=${{ secrets.GEOCODING_API }}" >> .env
- name: gradlew에 실행 권한 부여
run: chmod +x ./gradlew
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/com/m3pro/groundflip/controller/PixelController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.web.bind.annotation.RestController;

import com.m3pro.groundflip.domain.dto.Response;
import com.m3pro.groundflip.domain.dto.pixel.ClusteredPixelCount;
import com.m3pro.groundflip.domain.dto.pixel.CommunityModePixelResponse;
import com.m3pro.groundflip.domain.dto.pixel.CommunityPixelInfoResponse;
import com.m3pro.groundflip.domain.dto.pixel.IndividualHistoryPixelResponse;
Expand All @@ -23,6 +24,7 @@
import com.m3pro.groundflip.domain.dto.pixelUser.IndividualHistoryPixelInfoResponse;
import com.m3pro.groundflip.service.PixelManager;
import com.m3pro.groundflip.service.PixelReader;
import com.m3pro.groundflip.service.RegionService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -44,6 +46,7 @@
public class PixelController {
private final PixelManager pixelManager;
private final PixelReader pixelReader;
private final RegionService regionService;

@Operation(summary = "개인전 픽셀 조회", description = "특정 좌표를 중심으로 반경 내 개인전 픽셀 정보를 조회 API")
@Parameters({
Expand All @@ -60,6 +63,17 @@ public Response<List<IndividualModePixelResponse>> getNearIndividualPixels(
pixelReader.getNearIndividualModePixelsByCoordinate(currentLatitude, currentLongitude, radius));
}

@GetMapping("/individual-mode/test")
public Response<List<IndividualModePixelResponse>> getNearIndividualPixelsTest(
@RequestParam(name = "x") int x,
@RequestParam(name = "y") int y,
@RequestParam(name = "width") int width,
@RequestParam(name = "height") int height
) {
return Response.createSuccess(
pixelReader.getNeaerIndividualModePixelsTest(x, y, width, height));
}

@Operation(summary = "그룹전 픽셀 조회", description = "특정 좌표를 중심으로 반경 내 개인전 픽셀 정보를 조회 API")
@Parameters({
@Parameter(name = "current-latitude", description = "원의 중심 좌표의 위도", example = "37.503717"),
Expand Down Expand Up @@ -153,5 +167,65 @@ public Response<PixelCountResponse> getCommunityPixelCount(
@RequestParam(name = "community-id") @NotNull() Long communityId) {
return Response.createSuccess(pixelReader.getCommunityPixelCount(communityId));
}

@Operation(summary = "개인전 클러스터링된 픽셀 조회", description = "특정 좌표를 중심으로 반경 내 개인전 클러스터링된 픽셀 정보 API")
@Parameters({
@Parameter(name = "current-latitude", description = "원의 중심 좌표의 위도", example = "37.503717"),
@Parameter(name = "current-longitude", description = "원의 중심 좌표의 경도", example = "127.044317"),
@Parameter(name = "radius", description = "미터 단위의 반경", example = "1000"),
})
@GetMapping("/individual-mode/clustered")
public Response<List<ClusteredPixelCount>> getNearIndividualClusteredPixels(
@RequestParam(name = "current-latitude") @Min(-90) @Max(90) double currentLatitude,
@RequestParam(name = "current-longitude") @Min(-180) @Max(180) double currentLongitude,
@RequestParam(name = "radius") @Min(0) int radius) {

return Response.createSuccess(
regionService.getIndividualModeClusteredPixelCount(currentLatitude, currentLongitude, radius));
}

@Operation(summary = "개인기록 클러스터링된 픽셀 조회", description = "특정 좌표를 중심으로 반경 내 개인기록 클러스터링된 픽셀 정보 API")
@Parameters({
@Parameter(name = "current-latitude", description = "원의 중심 좌표의 위도", example = "37.503717"),
@Parameter(name = "current-longitude", description = "원의 중심 좌표의 경도", example = "127.044317"),
@Parameter(name = "radius", description = "미터 단위의 반경", example = "1000"),
@Parameter(name = "user-id", description = "찾고자 하는 user의 id", example = "127"),
})
@GetMapping("/individual-history/clustered")
public Response<List<ClusteredPixelCount>> getNearIndividualHistoryClusteredPixels(
@RequestParam(name = "current-latitude") @Min(-90) @Max(90) double currentLatitude,
@RequestParam(name = "current-longitude") @Min(-180) @Max(180) double currentLongitude,
@RequestParam(name = "radius") @Min(0) int radius,
@RequestParam(name = "user-id") @NotNull() Long userId) {

return Response.createSuccess(
regionService.getIndividualHistoryClusteredPixelCount(currentLatitude, currentLongitude, radius, userId));
}

@Operation(summary = "그룹전 클러스터링된 픽셀 조회", description = "특정 좌표를 중심으로 반경 내 그룹전 클러스터링된 픽셀 정보를 조회 API")
@Parameters({
@Parameter(name = "current-latitude", description = "원의 중심 좌표의 위도", example = "37.503717"),
@Parameter(name = "current-longitude", description = "원의 중심 좌표의 경도", example = "127.044317"),
@Parameter(name = "radius", description = "미터 단위의 반경", example = "1000"),
})
@GetMapping("/community-mode/clustered")
public Response<List<ClusteredPixelCount>> getNearCommunityClusteredPixels(
@RequestParam(name = "current-latitude") @Min(-90) @Max(90) double currentLatitude,
@RequestParam(name = "current-longitude") @Min(-180) @Max(180) double currentLongitude,
@RequestParam(name = "radius") @Min(0) int radius) {

return Response.createSuccess(
regionService.getCommunityModeClusteredPixelCount(currentLatitude, currentLongitude, radius));
}

@Operation(summary = "주간 픽셀 개수 조회", description = "특정 유저의 주간 방문한 픽셀을 조회하는 api")
@GetMapping("/count/daily/{userId}")
public Response<List<Integer>> getDailyPixel(
@PathVariable(name = "userId") @NotNull() Long userId,
@RequestParam(name = "start-date") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
@RequestParam(name = "end-date") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate
) {
return Response.createSuccess(pixelReader.getDailyPixel(userId, startDate, endDate));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ public class LoginRequest {
@Schema(description = "프로바이더로부터 받은 액세스 토큰", example = "dslafjkdsrtjlejldfkajlasljdf")
private String accessToken;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.m3pro.groundflip.domain.dto.pixel;

import com.m3pro.groundflip.enums.RegionLevel;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Schema()
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class ClusteredPixelCount {
@Schema(description = "지역 ID", example = "1234")
private Long regionId;

@Schema(description = "지역 이름", example = "홍길동")
private String regionName;

@Schema(description = "지역별 픽셀 개수", example = "3")
private int count;

@Schema(description = "지역의 중심 위도", example = "37.6464")
private double latitude;

@Schema(description = "지역의 중심 경도", example = "127.6897")
private double longitude;

@Schema(description = "집계 단위", example = "127.6897")
private RegionLevel regionLevel;

public static ClusteredPixelCount from(Long regionId, String regionName, int count, double latitude,
double longitude, RegionLevel regionLevel) {
return ClusteredPixelCount.builder()
.regionId(regionId)
.regionName(regionName)
.count(count)
.latitude(latitude)
.longitude(longitude)
.regionLevel(regionLevel)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.m3pro.groundflip.domain.dto.pixel;

import java.util.Arrays;
import java.util.List;

import com.m3pro.groundflip.domain.entity.Pixel;
Expand Down Expand Up @@ -31,7 +32,8 @@ public static CommunityPixelInfoResponse from(Pixel pixel, PixelOwnerCommunityRe
if (addressArr[0].equals("대한민국")) {
realAddress = addressArr[0];
} else {
realAddress = addressArr[1] + ' ' + addressArr[2];
realAddress = String.join(" ", Arrays.copyOfRange(addressArr, 1, addressArr.length));
;
}
} else {
realAddress = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.m3pro.groundflip.domain.dto.pixel;

import java.util.Arrays;
import java.util.List;

import com.m3pro.groundflip.domain.entity.Pixel;
Expand Down Expand Up @@ -31,7 +32,8 @@ public static IndividualPixelInfoResponse from(Pixel pixel, PixelOwnerUserRespon
if (addressArr[0].equals("대한민국")) {
realAddress = addressArr[0];
} else {
realAddress = addressArr[1] + ' ' + addressArr[2];
realAddress = String.join(" ", Arrays.copyOfRange(addressArr, 1, addressArr.length));
;
}
} else {
realAddress = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.m3pro.groundflip.domain.dto.pixel;

public interface RegionInfo {
Long getRegionId();

double getLatitude();

double getLongitude();

String getName();

Integer getCount();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.m3pro.groundflip.domain.dto.pixel.naverApi;

import com.fasterxml.jackson.annotation.JsonProperty;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@Schema(title = "네이버 api json 결과")
public class ReverseGeocodingResult {
@JsonProperty("region")
private String regionName;

@JsonProperty("region_id")
private Long regionId;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.m3pro.groundflip.domain.dto.pixelUser;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

import com.m3pro.groundflip.domain.entity.Pixel;
Expand Down Expand Up @@ -28,7 +29,7 @@ public static IndividualHistoryPixelInfoResponse from(Pixel pixel, List<LocalDat
if (addressArr[0].equals("대한민국")) {
realAddress = addressArr[0];
} else {
realAddress = addressArr[1] + ' ' + addressArr[2];
realAddress = String.join(" ", Arrays.copyOfRange(addressArr, 1, addressArr.length));
}
} else {
realAddress = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.m3pro.groundflip.domain.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class CompetitionCount {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "competition_count_id")
private Long id;

private Integer individualModeCount;

private Integer communityModeCount;

private Integer year;

private Integer week;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "region_id")
private Region region;

public void increaseIndividualModeCount() {
this.individualModeCount++;
}

public void increaseCommunityModeCount() {
this.communityModeCount++;
}
}
39 changes: 39 additions & 0 deletions src/main/java/com/m3pro/groundflip/domain/entity/DailyPixel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.m3pro.groundflip.domain.entity;

import java.time.LocalDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@Table(name = "daily_pixel")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class DailyPixel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "daily_pixel_id")
private Long id;

private Integer dailyPixelCount;

private LocalDateTime createdAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;
}
10 changes: 7 additions & 3 deletions src/main/java/com/m3pro/groundflip/domain/entity/Pixel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -22,7 +23,6 @@
@Builder
public class Pixel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "pixel_id")
private Long id;

Expand All @@ -42,6 +42,10 @@ public class Pixel {

private Long communityId;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "region_id")
private Region region;

private LocalDateTime createdAt;

private LocalDateTime userOccupiedAt;
Expand Down
Loading

0 comments on commit 1135869

Please sign in to comment.