-
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.
Merge pull request #174 from Troth-Cam/feat/transaction
feat(#125) : 메인화면 페이징 처리 & 거래하기 api 구현 & 에러코드 수정
- Loading branch information
Showing
12 changed files
with
194 additions
and
16 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
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 |
---|---|---|
@@ -1,11 +1,32 @@ | ||
package trothly.trothcam.controller.web; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import trothly.trothcam.domain.member.Member; | ||
import trothly.trothcam.dto.web.HistoryResDto; | ||
import trothly.trothcam.dto.web.TransactionReqDto; | ||
import trothly.trothcam.exception.base.BaseResponse; | ||
import trothly.trothcam.exception.custom.BadRequestException; | ||
import trothly.trothcam.service.web.HistoryService; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/history") | ||
public class HistoryController { | ||
|
||
private final HistoryService historyService; | ||
|
||
@PostMapping("/transaction") | ||
public BaseResponse<HistoryResDto> saveHistory(@RequestBody TransactionReqDto req, @AuthenticationPrincipal Member member) { | ||
if(req.getProductId() == null) { | ||
throw new BadRequestException("존재하지 않는 상품 아이디 입니다."); | ||
} | ||
|
||
HistoryResDto res = historyService.saveTransaction(req, member); | ||
return BaseResponse.onSuccess(res); | ||
} | ||
} |
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
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
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 trothly.trothcam.dto.web; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class HistoryResDto { | ||
private Long historyId; | ||
private Long productId; | ||
private Long buyerId; | ||
private Long sellerId; | ||
private Long price; | ||
private LocalDateTime soldAt; | ||
private Long newOwnerId; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/trothly/trothcam/dto/web/ProductsPagingListResDto.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,16 @@ | ||
package trothly.trothcam.dto.web; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class ProductsPagingListResDto { | ||
private List<ProductRankResDto> getProductRankResDto; | ||
private int totalPages; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/trothly/trothcam/dto/web/TransactionReqDto.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,14 @@ | ||
package trothly.trothcam.dto.web; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class TransactionReqDto { | ||
private Long productId; | ||
private Long price; | ||
} |
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
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