Skip to content

Commit

Permalink
Merge pull request #42 from UMC-6th-Hackathon-Team-4/revert-41-feature/1
Browse files Browse the repository at this point in the history
Revert "feat1: 보물상자 api 수정"
  • Loading branch information
dldusgh318 authored Jul 4, 2024
2 parents 16150cc + dcbcd98 commit 8205d95
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
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

0 comments on commit 8205d95

Please sign in to comment.