-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
121 additions
and
11 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/main/java/trothly/trothcam/controller/web/HistoryController.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,11 @@ | ||
package trothly.trothcam.controller.web; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/history") | ||
public class HistoryController { | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/trothly/trothcam/domain/history/HistoryRepository.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,12 @@ | ||
package trothly.trothcam.domain.history; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface HistoryRepository extends JpaRepository<History, Long> { | ||
|
||
List<History> findAllByProductId(Long productId); | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/trothly/trothcam/dto/web/ProductDetailResDto.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,34 @@ | ||
package trothly.trothcam.dto.web; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import trothly.trothcam.domain.history.History; | ||
import trothly.trothcam.domain.product.Public; | ||
|
||
import java.sql.Timestamp; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class ProductDetailResDto { | ||
|
||
private Long productId; | ||
private Long imageId; | ||
private Long ownerId; | ||
private String title; | ||
private int tags; | ||
private Long price; | ||
private String description; | ||
private int views; | ||
private Long likes; | ||
private Public publicYN; | ||
private LocalDateTime createdAt; | ||
private LocalDateTime updatedAt; | ||
private boolean liked; | ||
private List<History> histories; | ||
|
||
} |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/trothly/trothcam/service/web/HistoryService.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,35 @@ | ||
package trothly.trothcam.service.web; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import trothly.trothcam.domain.history.History; | ||
import trothly.trothcam.domain.history.HistoryRepository; | ||
import trothly.trothcam.domain.product.ProductRepository; | ||
import trothly.trothcam.dto.web.ProductReqDto; | ||
import trothly.trothcam.exception.base.BaseException; | ||
|
||
import java.util.List; | ||
|
||
import static trothly.trothcam.exception.base.ErrorCode.HISTORIES_NOT_FOUND; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class HistoryService { | ||
|
||
private final HistoryRepository historyRepository; | ||
private final ProductRepository productRepository; | ||
|
||
// 거래 내역 전체 조회 | ||
public List<History> findAllHistory(ProductReqDto req) { | ||
List<History> findHistories = historyRepository.findAllByProductId(req.getProductId()); | ||
if(findHistories == null || findHistories.isEmpty()) { | ||
throw new BaseException(HISTORIES_NOT_FOUND); | ||
} | ||
|
||
return findHistories; | ||
} | ||
|
||
// 거래 내역 저장 | ||
} |
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