Skip to content

Commit 0a362b6

Browse files
authored
Merge d1bb05d into 85b7e06
2 parents 85b7e06 + d1bb05d commit 0a362b6

File tree

11 files changed

+136
-49
lines changed

11 files changed

+136
-49
lines changed

src/main/java/sevenstar/marineleisure/global/api/kakao/service/PresetSchedulerService.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class PresetSchedulerService {
2323
@Transactional
2424
public void updateRegionApi() {
2525
LocalDate now = LocalDate.now();
26-
BestSpot emptySpot = new BestSpot(-1L, "없는 지역입니다", TotalIndex.NONE);
26+
BestSpot emptySpot = new BestSpot(-1L, "없는 지역입니다", TotalIndex.NONE, 0, 0);
2727
for (Region region : Region.getAllKoreaRegion()) {
2828
evictRegionCache(region);
2929
BestSpot bestSpotInFishing = outdoorSpotRepository.findBestSpotInFishing(region.getLatitude(),
@@ -36,10 +36,14 @@ public void updateRegionApi() {
3636
region.getLongitude(), now, PRESET_RADIUS).map(BestSpot::new).orElse(emptySpot);
3737

3838
spotPresetRepository.upsert(region.name(), bestSpotInFishing.getSpotId(), bestSpotInFishing.getName(),
39-
bestSpotInFishing.getTotalIndex().name(), bestSpotInMudflat.getSpotId(), bestSpotInMudflat.getName(),
40-
bestSpotInMudflat.getTotalIndex().name(), bestSpotInScuba.getSpotId(), bestSpotInScuba.getName(),
41-
bestSpotInScuba.getTotalIndex().name(), bestSpotInSurfing.getSpotId(), bestSpotInSurfing.getName(),
42-
bestSpotInSurfing.getTotalIndex().name());
39+
bestSpotInFishing.getTotalIndex().name(), bestSpotInFishing.getMonthView(),
40+
bestSpotInFishing.getWeekView(), bestSpotInMudflat.getSpotId(), bestSpotInMudflat.getName(),
41+
bestSpotInMudflat.getTotalIndex().name(), bestSpotInMudflat.getMonthView(),
42+
bestSpotInMudflat.getWeekView(), bestSpotInScuba.getSpotId(), bestSpotInScuba.getName(),
43+
bestSpotInScuba.getTotalIndex().name(), bestSpotInScuba.getMonthView(), bestSpotInScuba.getWeekView(),
44+
bestSpotInSurfing.getSpotId(), bestSpotInSurfing.getName(),
45+
bestSpotInSurfing.getTotalIndex().name(), bestSpotInSurfing.getMonthView(),
46+
bestSpotInSurfing.getWeekView());
4347
}
4448
}
4549

src/main/java/sevenstar/marineleisure/member/service/OauthService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import jakarta.transaction.Transactional;
2323
import lombok.RequiredArgsConstructor;
2424
import lombok.extern.slf4j.Slf4j;
25-
import sevenstar.marineleisure.global.util.PkceUtil;
25+
import sevenstar.marineleisure.global.enums.MemberStatus;
2626
import sevenstar.marineleisure.global.util.StateEncryptionUtil;
2727
import sevenstar.marineleisure.member.domain.Member;
2828
import sevenstar.marineleisure.member.dto.KakaoTokenResponse;
@@ -36,7 +36,6 @@ public class OauthService {
3636
private final MemberRepository memberRepository;
3737
private final WebClient webClient;
3838
private final StateEncryptionUtil stateEncryptionUtil;
39-
private final PkceUtil pkceUtil;
4039

4140
@Value("${kakao.login.api_key}")
4241
private String apiKey;
@@ -208,6 +207,7 @@ private Member saveOrUpdateKakaoUser(Map<String, Object> memberAttributes) {
208207
.longitude(BigDecimal.ZERO)
209208
.build());
210209
member.updateNickname(nickname);
210+
member.updateStatus(MemberStatus.ACTIVE); // 재가입 시 상태를 ACTIVE로 변경
211211

212212
return memberRepository.save(member);
213213
}

src/main/java/sevenstar/marineleisure/spot/domain/BestSpot.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ public class BestSpot {
1717
private String name;
1818
@Enumerated(EnumType.STRING)
1919
private TotalIndex totalIndex;
20+
private Integer monthView;
21+
private Integer weekView;
2022

21-
public BestSpot(Long spotId, String name, TotalIndex totalIndex) {
23+
public BestSpot(Long spotId, String name, TotalIndex totalIndex, Integer monthView, Integer weekView) {
2224
this.spotId = spotId;
2325
this.name = name;
2426
this.totalIndex = totalIndex;
27+
this.monthView = monthView;
28+
this.weekView = weekView;
2529
}
2630

2731
public BestSpot(BestSpotProjection bestSpotProjection) {
2832
this.spotId = bestSpotProjection.getId();
2933
this.name = bestSpotProjection.getName();
3034
this.totalIndex = bestSpotProjection.getTotalIndex();
35+
this.monthView = bestSpotProjection.getMonthView();
36+
this.weekView = bestSpotProjection.getWeekView();
3137
}
3238
}

src/main/java/sevenstar/marineleisure/spot/domain/SpotPreset.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,39 @@ public class SpotPreset {
2727
@AttributeOverrides({
2828
@AttributeOverride(name = "spotId",column = @Column(name = "fishing_spot_id")),
2929
@AttributeOverride(name = "name",column = @Column(name = "fishing_name")),
30-
@AttributeOverride(name = "totalIndex",column = @Column(name = "fishing_total_index"))
30+
@AttributeOverride(name = "totalIndex",column = @Column(name = "fishing_total_index")),
31+
@AttributeOverride(name = "monthView",column = @Column(name = "fishing_monthView")),
32+
@AttributeOverride(name = "weekView",column = @Column(name = "fishing_weekView"))
3133
})
3234
private BestSpot fishing;
3335

3436
@Embedded
3537
@AttributeOverrides({
3638
@AttributeOverride(name = "spotId",column = @Column(name = "mudflat_spot_id")),
3739
@AttributeOverride(name = "name",column = @Column(name = "mudflat_name")),
38-
@AttributeOverride(name = "totalIndex",column = @Column(name = "mudflat_total_index"))
40+
@AttributeOverride(name = "totalIndex",column = @Column(name = "mudflat_total_index")),
41+
@AttributeOverride(name = "monthView",column = @Column(name = "mudflat_monthView")),
42+
@AttributeOverride(name = "weekView",column = @Column(name = "mudflat_weekView"))
3943
})
4044
private BestSpot mudflat;
4145

4246
@Embedded
4347
@AttributeOverrides({
4448
@AttributeOverride(name = "spotId",column = @Column(name = "scuba_spot_id")),
4549
@AttributeOverride(name = "name",column = @Column(name = "scuba_name")),
46-
@AttributeOverride(name = "totalIndex",column = @Column(name = "scuba_total_index"))
50+
@AttributeOverride(name = "totalIndex",column = @Column(name = "scuba_total_index")),
51+
@AttributeOverride(name = "monthView",column = @Column(name = "scuba_monthView")),
52+
@AttributeOverride(name = "weekView",column = @Column(name = "scuba_weekView"))
4753
})
4854
private BestSpot scuba;
4955

5056
@Embedded
5157
@AttributeOverrides({
5258
@AttributeOverride(name = "spotId",column = @Column(name = "surfing_spot_id")),
5359
@AttributeOverride(name = "name",column = @Column(name = "surfing_name")),
54-
@AttributeOverride(name = "totalIndex",column = @Column(name = "surfing_total_index"))
60+
@AttributeOverride(name = "totalIndex",column = @Column(name = "surfing_total_index")),
61+
@AttributeOverride(name = "monthView",column = @Column(name = "surfing_monthView")),
62+
@AttributeOverride(name = "weekView",column = @Column(name = "surfing_weekView"))
5563
})
5664
private BestSpot surfing;
5765

src/main/java/sevenstar/marineleisure/spot/dto/projection/BestSpotProjection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ public interface BestSpotProjection {
66
Long getId();
77
String getName();
88
TotalIndex getTotalIndex();
9+
Integer getMonthView();
10+
Integer getWeekView();
911
}

src/main/java/sevenstar/marineleisure/spot/mapper/SpotMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static SpotReadResponse.SpotInfo toDto(SpotDistanceProjection spotDistanc
2020
return new SpotReadResponse.SpotInfo(spotDistanceProjection.getId(), spotDistanceProjection.getName(),
2121
ActivityCategory.parse(spotDistanceProjection.getCategory()),
2222
spotDistanceProjection.getLatitude().floatValue(), spotDistanceProjection.getLongitude().floatValue(),
23-
spotDistanceProjection.getDistance().floatValue(), totalIndex, spotViewQuartile.getMonthQuartile(),
23+
spotDistanceProjection.getDistance().floatValue() / 1000f, totalIndex, spotViewQuartile.getMonthQuartile(),
2424
spotViewQuartile.getWeekQuartile(), isFavorite);
2525
}
2626

src/main/java/sevenstar/marineleisure/spot/repository/OutdoorSpotRepository.java

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,20 @@ List<SpotDistanceProjection> findSpots(@Param("latitude") Float latitude, @Param
3131

3232
// Fishing Forecast
3333
@Query(value = """
34-
SELECT os.id AS id, os.name AS name, f.total_index AS totalIndex
34+
SELECT os.id AS id, os.name AS name, f.total_index AS totalIndex,
35+
COALESCE((
36+
SELECT SUM(svs.view_count)
37+
FROM spot_view_stats svs
38+
WHERE svs.spot_id = os.id
39+
AND svs.view_date BETWEEN :forecastDate - INTERVAL 6 DAY AND :forecastDate
40+
), 0) AS weekView,
41+
42+
COALESCE((
43+
SELECT SUM(svs.view_count)
44+
FROM spot_view_stats svs
45+
WHERE svs.spot_id = os.id
46+
AND svs.view_date BETWEEN :forecastDate - INTERVAL 29 DAY AND :forecastDate
47+
), 0) AS monthView
3548
FROM outdoor_spots os
3649
JOIN fishing_forecast f ON os.id = f.spot_id
3750
WHERE f.forecast_date = :forecastDate
@@ -53,7 +66,20 @@ Optional<BestSpotProjection> findBestSpotInFishing(@Param("latitude") double lat
5366

5467
// Mudflat Forecast
5568
@Query(value = """
56-
SELECT os.id AS id, os.name AS name, m.total_index AS totalIndex
69+
SELECT os.id AS id, os.name AS name, m.total_index AS totalIndex,
70+
COALESCE((
71+
SELECT SUM(svs.view_count)
72+
FROM spot_view_stats svs
73+
WHERE svs.spot_id = os.id
74+
AND svs.view_date BETWEEN :forecastDate - INTERVAL 6 DAY AND :forecastDate
75+
), 0) AS weekView,
76+
77+
COALESCE((
78+
SELECT SUM(svs.view_count)
79+
FROM spot_view_stats svs
80+
WHERE svs.spot_id = os.id
81+
AND svs.view_date BETWEEN :forecastDate - INTERVAL 29 DAY AND :forecastDate
82+
), 0) AS monthView
5783
FROM outdoor_spots os
5884
JOIN mudflat_forecast m ON os.id = m.spot_id
5985
WHERE m.forecast_date = :forecastDate
@@ -75,7 +101,20 @@ Optional<BestSpotProjection> findBestSpotInMudflat(@Param("latitude") double lat
75101

76102
// Surfing Forecast
77103
@Query(value = """
78-
SELECT os.id AS id, os.name AS name, s.total_index AS totalIndex
104+
SELECT os.id AS id, os.name AS name, s.total_index AS totalIndex,
105+
COALESCE((
106+
SELECT SUM(svs.view_count)
107+
FROM spot_view_stats svs
108+
WHERE svs.spot_id = os.id
109+
AND svs.view_date BETWEEN :forecastDate - INTERVAL 6 DAY AND :forecastDate
110+
), 0) AS weekView,
111+
112+
COALESCE((
113+
SELECT SUM(svs.view_count)
114+
FROM spot_view_stats svs
115+
WHERE svs.spot_id = os.id
116+
AND svs.view_date BETWEEN :forecastDate - INTERVAL 29 DAY AND :forecastDate
117+
), 0) AS monthView
79118
FROM outdoor_spots os
80119
JOIN surfing_forecast s ON os.id = s.spot_id
81120
WHERE s.forecast_date = :forecastDate
@@ -97,7 +136,20 @@ Optional<BestSpotProjection> findBestSpotInSurfing(@Param("latitude") double lat
97136

98137
// Scuba Forecast
99138
@Query(value = """
100-
SELECT os.id AS id, os.name AS name, s.total_index AS totalIndex
139+
SELECT os.id AS id, os.name AS name, s.total_index AS totalIndex,
140+
COALESCE((
141+
SELECT SUM(svs.view_count)
142+
FROM spot_view_stats svs
143+
WHERE svs.spot_id = os.id
144+
AND svs.view_date BETWEEN :forecastDate - INTERVAL 6 DAY AND :forecastDate
145+
), 0) AS weekView,
146+
147+
COALESCE((
148+
SELECT SUM(svs.view_count)
149+
FROM spot_view_stats svs
150+
WHERE svs.spot_id = os.id
151+
AND svs.view_date BETWEEN :forecastDate - INTERVAL 29 DAY AND :forecastDate
152+
), 0) AS monthView
101153
FROM outdoor_spots os
102154
JOIN scuba_forecast s ON os.id = s.spot_id
103155
WHERE s.forecast_date = :forecastDate

src/main/java/sevenstar/marineleisure/spot/repository/SpotPresetRepository.java

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,68 @@
1212
public interface SpotPresetRepository extends JpaRepository<SpotPreset, Region> {
1313
@Modifying
1414
@Query(value = """
15-
INSERT INTO spot_preset (
16-
region,
17-
fishing_spot_id, fishing_name, fishing_total_index,
18-
mudflat_spot_id, mudflat_name, mudflat_total_index,
19-
scuba_spot_id, scuba_name, scuba_total_index,
20-
surfing_spot_id, surfing_name, surfing_total_index
21-
)
22-
VALUES (
23-
:region,
24-
:fishingId, :fishingName, :fishingTotalIndex,
25-
:mudflatId, :mudflatName, :mudflatTotalIndex,
26-
:scubaId, :scubaName, :scubaTotalIndex,
27-
:surfingId, :surfingName, :surfingTotalIndex
28-
)
29-
ON DUPLICATE KEY UPDATE
30-
fishing_spot_id = VALUES(fishing_spot_id),
31-
fishing_name = VALUES(fishing_name),
32-
fishing_total_index = VALUES(fishing_total_index),
33-
mudflat_spot_id = VALUES(mudflat_spot_id),
34-
mudflat_name = VALUES(mudflat_name),
35-
mudflat_total_index = VALUES(mudflat_total_index),
36-
scuba_spot_id = VALUES(scuba_spot_id),
37-
scuba_name = VALUES(scuba_name),
38-
scuba_total_index = VALUES(scuba_total_index),
39-
surfing_spot_id = VALUES(surfing_spot_id),
40-
surfing_name = VALUES(surfing_name),
41-
surfing_total_index = VALUES(surfing_total_index)
42-
""", nativeQuery = true)
15+
INSERT INTO spot_preset (
16+
region,
17+
fishing_spot_id, fishing_name, fishing_total_index, fishing_month_view, fishing_week_view,
18+
mudflat_spot_id, mudflat_name, mudflat_total_index, mudflat_month_view, mudflat_week_view,
19+
scuba_spot_id, scuba_name, scuba_total_index, scuba_month_view, scuba_week_view,
20+
surfing_spot_id, surfing_name, surfing_total_index, surfing_month_view, surfing_week_view
21+
)
22+
VALUES (
23+
:region,
24+
:fishingId, :fishingName, :fishingTotalIndex,:fishingMonthView, :fishingWeekView,
25+
:mudflatId, :mudflatName, :mudflatTotalIndex,:mudflatMonthView, :mudflatWeekView,
26+
:scubaId, :scubaName, :scubaTotalIndex,:scubaMonthView, :scubaWeekView,
27+
:surfingId, :surfingName, :surfingTotalIndex,:surfingMonthView, :surfingWeekView
28+
)
29+
ON DUPLICATE KEY UPDATE
30+
fishing_spot_id = VALUES(fishing_spot_id),
31+
fishing_name = VALUES(fishing_name),
32+
fishing_total_index = VALUES(fishing_total_index),
33+
fishing_month_view= VALUES(fishing_month_view),
34+
fishing_week_view=VALUES(fishing_week_view),
35+
mudflat_spot_id = VALUES(mudflat_spot_id),
36+
mudflat_name = VALUES(mudflat_name),
37+
mudflat_total_index = VALUES(mudflat_total_index),
38+
mudflat_month_view = VALUES(mudflat_month_view),
39+
mudflat_week_view = VALUES(mudflat_week_view),
40+
scuba_spot_id = VALUES(scuba_spot_id),
41+
scuba_name = VALUES(scuba_name),
42+
scuba_total_index = VALUES(scuba_total_index),
43+
scuba_month_view = VALUES(scuba_month_view),
44+
scuba_week_view = VALUES(scuba_week_view),
45+
surfing_spot_id = VALUES(surfing_spot_id),
46+
surfing_name = VALUES(surfing_name),
47+
surfing_total_index = VALUES(surfing_total_index),
48+
surfing_month_view = VALUES(surfing_month_view),
49+
surfing_week_view = VALUES(surfing_week_view)
50+
""", nativeQuery = true)
4351
void upsert(
4452
@Param("region") String region,
4553

4654
@Param("fishingId") Long fishingId,
4755
@Param("fishingName") String fishingName,
4856
@Param("fishingTotalIndex") String fishingTotalIndex,
57+
@Param("fishingMonthView") Integer fishingMonthView,
58+
@Param("fishingWeekView") Integer fishingWeekView,
4959

5060
@Param("mudflatId") Long mudflatId,
5161
@Param("mudflatName") String mudflatName,
5262
@Param("mudflatTotalIndex") String mudflatTotalIndex,
63+
@Param("mudflatMonthView") Integer mudflatMonthView,
64+
@Param("mudflatWeekView") Integer mudflatWeekView,
5365

5466
@Param("scubaId") Long scubaId,
5567
@Param("scubaName") String scubaName,
5668
@Param("scubaTotalIndex") String scubaTotalIndex,
69+
@Param("scubaMonthView") Integer scubaMonthView,
70+
@Param("scubaWeekView") Integer scubaWeekView,
5771

5872
@Param("surfingId") Long surfingId,
5973
@Param("surfingName") String surfingName,
60-
@Param("surfingTotalIndex") String surfingTotalIndex
74+
@Param("surfingTotalIndex") String surfingTotalIndex,
75+
@Param("surfingMonthView") Integer surfingMonthView,
76+
@Param("surfingWeekView") Integer surfingWeekView
6177
);
6278

6379
}

src/main/java/sevenstar/marineleisure/spot/repository/SpotViewStatsRepository.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ INSERT INTO spot_view_stats (spot_id, view_date, view_count)
1818
VALUES (:spotId,:viewDate,1) ON DUPLICATE KEY UPDATE view_count = view_count + 1
1919
""", nativeQuery = true)
2020
void upsertViewStats(@Param("spotId") Long spotId, @Param("viewDate") LocalDate viewDate);
21-
2221
}

src/main/java/sevenstar/marineleisure/spot/service/SpotServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public SpotPreviewReadResponse preview(float latitude, float longitude) {
114114
Region region = geoUtils.searchRegion(latitude, longitude);
115115
if (region == Region.OCEAN) {
116116
LocalDate now = LocalDate.now();
117-
BestSpot emptySpot = new BestSpot(-1L, "없는 지역입니다", null);
117+
BestSpot emptySpot = new BestSpot(-1L, "없는 지역입니다", null,0,0);
118118
double radius = 500_000;
119119
BestSpot bestSpotInFishing = outdoorSpotRepository.findBestSpotInFishing(region.getLatitude(),
120120
region.getLongitude(), now, radius).map(BestSpot::new).orElse(emptySpot);

0 commit comments

Comments
 (0)