-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] feat: 발자국 삭제 및 발자국 상태 수동 변경 구현 #460
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.happy.friendogly.footprint.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record UpdateWalkStatusManualRequest( | ||
|
||
@NotBlank(message = "walkStatus는 빈 문자열이나 null을 입력할 수 없습니다.") | ||
String walkStatus | ||
) { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.happy.friendogly.footprint.dto.response; | ||
|
||
import com.happy.friendogly.footprint.domain.WalkStatus; | ||
import java.time.LocalDateTime; | ||
|
||
public record UpdateWalkStatusAutoResponse( | ||
WalkStatus walkStatus, | ||
LocalDateTime changedWalkStatusTime | ||
) { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.happy.friendogly.footprint.dto.response; | ||
|
||
import com.happy.friendogly.footprint.domain.WalkStatus; | ||
import java.time.LocalDateTime; | ||
|
||
public record UpdateWalkStatusManualResponse( | ||
WalkStatus walkStatus, | ||
LocalDateTime changedWalkStatusTime | ||
) { | ||
|
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,10 @@ | |
import com.happy.friendogly.footprint.domain.Location; | ||
import com.happy.friendogly.footprint.domain.WalkStatus; | ||
import com.happy.friendogly.footprint.dto.request.SaveFootprintRequest; | ||
import com.happy.friendogly.footprint.dto.request.UpdateWalkStatusRequest; | ||
import com.happy.friendogly.footprint.dto.request.UpdateWalkStatusAutoRequest; | ||
import com.happy.friendogly.footprint.dto.response.SaveFootprintResponse; | ||
import com.happy.friendogly.footprint.dto.response.UpdateWalkStatusResponse; | ||
import com.happy.friendogly.footprint.dto.response.UpdateWalkStatusAutoResponse; | ||
import com.happy.friendogly.footprint.dto.response.UpdateWalkStatusManualResponse; | ||
import com.happy.friendogly.footprint.repository.FootprintRepository; | ||
import com.happy.friendogly.member.domain.Member; | ||
import com.happy.friendogly.member.repository.MemberRepository; | ||
|
@@ -103,7 +104,7 @@ private void sendWalkComingNotification(String memberName, List<String> nearDevi | |
); | ||
} | ||
|
||
public UpdateWalkStatusResponse updateWalkStatus(Long memberId, UpdateWalkStatusRequest request) { | ||
public UpdateWalkStatusAutoResponse updateWalkStatusAuto(Long memberId, UpdateWalkStatusAutoRequest request) { | ||
Footprint footprint = footprintRepository.getTopOneByMemberIdOrderByCreatedAtDesc(memberId); | ||
if (footprint.isDeleted()) { | ||
throw new FriendoglyException("가장 최근 발자국이 삭제된 상태입니다."); | ||
|
@@ -112,14 +113,15 @@ public UpdateWalkStatusResponse updateWalkStatus(Long memberId, UpdateWalkStatus | |
WalkStatus beforeWalkStatus = footprint.getWalkStatus(); | ||
|
||
footprint.updateWalkStatusWithCurrentLocation(new Location(request.latitude(), request.longitude())); | ||
|
||
if (beforeWalkStatus.isBefore() && footprint.getWalkStatus().isOngoing()) { | ||
Member startWalkMember = memberRepository.getById(memberId); | ||
List<String> nearDeviceTokens = findNearDeviceTokensWithoutMine(footprint, startWalkMember); | ||
String memberName = footprint.getMember().getName().getValue(); | ||
sendWalkStartNotification(memberName, nearDeviceTokens); | ||
} | ||
|
||
return new UpdateWalkStatusResponse(footprint.getWalkStatus()); | ||
return new UpdateWalkStatusAutoResponse(footprint.getWalkStatus(), footprint.findChangedWalkStatusTime()); | ||
} | ||
|
||
private void sendWalkStartNotification(String startMemberName, List<String> nearDeviceTokens) { | ||
|
@@ -130,6 +132,20 @@ private void sendWalkStartNotification(String startMemberName, List<String> near | |
); | ||
} | ||
|
||
public UpdateWalkStatusManualResponse updateWalkStatusManual(Long memberId) { | ||
Comment on lines
134
to
+135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 산책 상태를 AFTER로 변경한다는 것을 네이밍에 더 드러내는 것은 어떨까요? |
||
Footprint footprint = footprintRepository.getTopOneByMemberIdOrderByCreatedAtDesc(memberId); | ||
footprint.finishWalkingManual(); | ||
Comment on lines
+136
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return new UpdateWalkStatusManualResponse(footprint.getWalkStatus(), footprint.findChangedWalkStatusTime()); | ||
} | ||
|
||
public void delete(Long memberId, Long footprintId) { | ||
Footprint footprint = footprintRepository.getById(footprintId); | ||
if (!footprint.isCreatedBy(memberId)) { | ||
throw new FriendoglyException("본인의 발자국만 삭제 가능합니다."); | ||
} | ||
Comment on lines
+143
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분은 인가에 관한 예외라고 생각합니다.! 상태코드로 구체화 하면 어떨까요? |
||
footprint.updateToDeleted(); | ||
} | ||
|
||
private List<String> findNearDeviceTokensWithoutMine(Footprint standardFootprint, Member member) { | ||
List<Footprint> footprints = footprintRepository.findAllByIsDeletedFalse(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
footprintId
를 입력받지 않고도 로그인한memberId
로 조회할 수 있지 않을까요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최신 발자국을 삭제하는 것이 아닌 특정발자국을 삭제하는 api라 id를 받았습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수동삭제가 가능해져서 api가 다채로워졌네요~. 고생 많으십니다. ㅠㅠ