-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/paths-controller-v2
- Loading branch information
Showing
18 changed files
with
569 additions
and
50 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
api/src/main/java/com/walking/api/domain/traffic/dto/AddFavoriteTrafficUseCaseRequest.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,21 @@ | ||
package com.walking.api.domain.traffic.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@EqualsAndHashCode | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class AddFavoriteTrafficUseCaseRequest { | ||
|
||
private Long memberId; | ||
private Long trafficId; | ||
private String trafficAlias; | ||
} |
19 changes: 19 additions & 0 deletions
19
...rc/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseRequest.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,19 @@ | ||
package com.walking.api.domain.traffic.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@EqualsAndHashCode | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder(toBuilder = true) | ||
public class BrowseFavoriteTrafficsUseCaseRequest { | ||
|
||
private Long memberId; | ||
} |
20 changes: 20 additions & 0 deletions
20
...src/main/java/com/walking/api/domain/traffic/dto/DeleteFavoriteTrafficUseCaseRequest.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,20 @@ | ||
package com.walking.api.domain.traffic.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@EqualsAndHashCode | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class DeleteFavoriteTrafficUseCaseRequest { | ||
|
||
private Long favoriteTrafficId; | ||
private Long memberId; | ||
} |
22 changes: 22 additions & 0 deletions
22
...src/main/java/com/walking/api/domain/traffic/dto/UpdateFavoriteTrafficUseCaseRequest.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,22 @@ | ||
package com.walking.api.domain.traffic.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@EqualsAndHashCode | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Builder | ||
public class UpdateFavoriteTrafficUseCaseRequest { | ||
|
||
private Long memberId; | ||
private Long favoriteTrafficId; | ||
private String trafficAlias; | ||
} |
32 changes: 32 additions & 0 deletions
32
api/src/main/java/com/walking/api/domain/traffic/usecase/AddFavoriteTrafficUseCase.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,32 @@ | ||
package com.walking.api.domain.traffic.usecase; | ||
|
||
import com.walking.api.domain.traffic.dto.AddFavoriteTrafficUseCaseRequest; | ||
import com.walking.api.repository.traffic.TrafficFavoritesRepository; | ||
import com.walking.data.entity.member.MemberEntity; | ||
import com.walking.data.entity.member.TrafficFavoritesEntity; | ||
import com.walking.data.entity.traffic.TrafficEntity; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class AddFavoriteTrafficUseCase { | ||
|
||
private final TrafficFavoritesRepository trafficFavoritesRepository; | ||
|
||
@Transactional | ||
public boolean execute(AddFavoriteTrafficUseCaseRequest request) { | ||
TrafficFavoritesEntity entity = | ||
TrafficFavoritesEntity.builder() | ||
.memberFk(MemberEntity.builder().id(request.getMemberId()).build()) | ||
.trafficFk(TrafficEntity.builder().id(request.getTrafficId()).build()) | ||
.alias(request.getTrafficAlias()) | ||
.build(); | ||
|
||
trafficFavoritesRepository.save(entity); | ||
return true; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
api/src/main/java/com/walking/api/domain/traffic/usecase/BrowseFavoriteTrafficsUseCase.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,51 @@ | ||
package com.walking.api.domain.traffic.usecase; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseRequest; | ||
import com.walking.api.repository.traffic.TrafficFavoritesRepository; | ||
import com.walking.api.web.dto.response.BrowseFavoriteTrafficsResponse; | ||
import com.walking.api.web.dto.response.detail.FavoriteTrafficDetail; | ||
import com.walking.api.web.dto.response.detail.PointDetail; | ||
import com.walking.api.web.dto.response.detail.TrafficDetailInfo; | ||
import com.walking.data.entity.member.MemberEntity; | ||
import com.walking.data.entity.member.TrafficFavoritesEntity; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.locationtech.jts.geom.Point; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class BrowseFavoriteTrafficsUseCase { | ||
|
||
private final TrafficFavoritesRepository trafficFavoritesRepository; | ||
private final ObjectMapper objectMapper; | ||
|
||
@Transactional | ||
public BrowseFavoriteTrafficsResponse execute(BrowseFavoriteTrafficsUseCaseRequest request) { | ||
List<TrafficFavoritesEntity> trafficFavorites = | ||
trafficFavoritesRepository.findByMemberFk( | ||
MemberEntity.builder().id(request.getMemberId()).build()); | ||
|
||
List<FavoriteTrafficDetail> details = new ArrayList<>(); | ||
for (TrafficFavoritesEntity entity : trafficFavorites) { | ||
TrafficDetailInfo detailInfo = | ||
objectMapper.convertValue(entity.getTrafficFk().getDetail(), TrafficDetailInfo.class); | ||
Point point = entity.getTrafficFk().getPoint(); | ||
details.add( | ||
FavoriteTrafficDetail.builder() | ||
.id(entity.getId()) | ||
.detail(detailInfo) | ||
.name(entity.getAlias()) | ||
.point(PointDetail.builder().lat(point.getY()).lng(point.getX()).build()) | ||
.createdAt(entity.getCreatedAt()) | ||
.build()); | ||
} | ||
|
||
return BrowseFavoriteTrafficsResponse.builder().traffics(details).build(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
api/src/main/java/com/walking/api/domain/traffic/usecase/DeleteFavoriteTrafficUseCase.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,29 @@ | ||
package com.walking.api.domain.traffic.usecase; | ||
|
||
import com.walking.api.domain.traffic.dto.DeleteFavoriteTrafficUseCaseRequest; | ||
import com.walking.api.repository.traffic.TrafficFavoritesRepository; | ||
import com.walking.data.entity.member.MemberEntity; | ||
import com.walking.data.entity.member.TrafficFavoritesEntity; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class DeleteFavoriteTrafficUseCase { | ||
private final TrafficFavoritesRepository trafficFavoritesRepository; | ||
|
||
@Transactional | ||
public boolean execute(DeleteFavoriteTrafficUseCaseRequest request) { | ||
TrafficFavoritesEntity favoriteTraffic = | ||
trafficFavoritesRepository | ||
.findByIdAndMemberFkAndDeletedFalse( | ||
request.getFavoriteTrafficId(), | ||
MemberEntity.builder().id(request.getMemberId()).build()) | ||
.orElseThrow(() -> new IllegalArgumentException("해당 즐겨찾기 정보가 존재하지 않습니다.")); | ||
trafficFavoritesRepository.delete(favoriteTraffic); | ||
return true; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
api/src/main/java/com/walking/api/domain/traffic/usecase/UpdateFavoriteTrafficUseCase.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,29 @@ | ||
package com.walking.api.domain.traffic.usecase; | ||
|
||
import com.walking.api.domain.traffic.dto.UpdateFavoriteTrafficUseCaseRequest; | ||
import com.walking.api.repository.traffic.TrafficFavoritesRepository; | ||
import com.walking.data.entity.member.TrafficFavoritesEntity; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class UpdateFavoriteTrafficUseCase { | ||
|
||
private final TrafficFavoritesRepository trafficFavoritesRepository; | ||
|
||
@Transactional | ||
public boolean execute(UpdateFavoriteTrafficUseCaseRequest request) { | ||
TrafficFavoritesEntity favoriteTraffic = | ||
trafficFavoritesRepository | ||
.findByIdAndDeletedFalse(request.getFavoriteTrafficId()) | ||
.orElseThrow(() -> new RuntimeException("TrafficFavoritesEntity not found")); | ||
|
||
TrafficFavoritesEntity updatedAlias = favoriteTraffic.updateAlias(request.getTrafficAlias()); | ||
trafficFavoritesRepository.save(updatedAlias); | ||
return true; | ||
} | ||
} |
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
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
Oops, something went wrong.