Skip to content
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

Revert "feat1: 보물상자 api 수정" #42

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static TreasureBox toEntity(TreasureBoxRequestDTO.CreateTreasureBoxDTO cr
public static TreasureBoxResponseDTO toDTO(TreasureBox treasureBox) {
return TreasureBoxResponseDTO.builder()
.id(treasureBox.getId())
.userId(treasureBox.getUser().getId())
.createdAt(treasureBox.getCreatedAt())
.deadline(treasureBox.getDeadline())
.status(treasureBox.getStatus())
.title(treasureBox.getTitle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import umc_haekathon_4.demo.web.dto.TreasureBoxRequestDTO;
import umc_haekathon_4.demo.web.dto.TreasureBoxResponseDTO;

import java.util.List;

@Service
@RequiredArgsConstructor
public class TreasureBoxService {
Expand Down Expand Up @@ -82,10 +80,6 @@ public TreasureBoxResponseDTO delayDeadline(Long id, TreasureBoxRequestDTO.Updat
return TreasureBoxConverter.toDTO(treasureBox);
}


public List<TreasureBox> getTreasureBoxes() {
return treasureBoxRepository.findAll();

public boolean canOpenTreasureBox(Long id, TreasureBoxRequestDTO.initialLocationDTO userLocation) {
TreasureBox treasureBox = treasureBoxRepository.findById(id)
.orElseThrow(() -> new RuntimeException("TreasureBox not found"));
Expand Down Expand Up @@ -120,6 +114,5 @@ private double calculateDistance(double lat1, double lon1, double lat2, double l
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
double distance = R * c * 1000; // convert to meters
return distance;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import umc_haekathon_4.demo.web.dto.TreasureBoxRequestDTO;
import umc_haekathon_4.demo.web.dto.TreasureBoxResponseDTO;

import java.util.List;

@RestController
@RequestMapping("/")
@RequiredArgsConstructor
Expand All @@ -28,15 +26,8 @@ public ApiResponse<TreasureBoxResponseDTO> create(@RequestBody @Valid TreasureBo
}


//보물상자 리스트
@GetMapping("/treasurebox/list")
public ApiResponse<List<TreasureBox>> getTreasureBoxes() {
List<TreasureBox> treasureBoxes = treasureBoxService.getTreasureBoxes();
return ApiResponse.onSuccess(treasureBoxes);
}

//보물상자 조회
@GetMapping("/treasurebox/list/choose")
@GetMapping("/treasurebox/list")
public ApiResponse<TreasureBox> getTreasureBox(Long treasureId) {
TreasureBox treasureBox = treasureBoxService.getTreasureBox(treasureId);
return ApiResponse.onSuccess(treasureBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
@AllArgsConstructor
public class TreasureBoxResponseDTO {
private Long id;
private Long userId;
private LocalDateTime createdAt;
private LocalDate deadline;
private String status;
private String title;

private String body;
private double latitude;
private double longitude;
Expand Down
Loading