-
Notifications
You must be signed in to change notification settings - Fork 1
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
8 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
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
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,23 @@ | ||
package HeyPorori.transaction.dto; | ||
|
||
import HeyPorori.transaction.domain.Category; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Pattern; | ||
import javax.validation.constraints.Size; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PostReq { | ||
@Size(min = 1, max = 20, message = "거래 게시글 제목의 길이는 1 이상 20 이하입니다.") | ||
private String title; | ||
@Size(min = 1, max = 200, message = "거래 게시글 내용의 길이는 1 이상 200 이하입니다.") | ||
private String content; | ||
@Pattern(regexp = "^(전자제품|의류 및 액세서리|가구 및 가정용품|스포츠 및 레저|자동차 및 오토바이|도서 및 음악|아기 및 어린이 용품|기타)$", message = "유효하지 않은 카테고리입니다.") | ||
private String category; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/HeyPorori/transaction/service/TransactionService.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,10 +1,22 @@ | ||
package HeyPorori.transaction.service; | ||
|
||
import HeyPorori.transaction.domain.Transaction; | ||
import HeyPorori.transaction.dto.PostReq; | ||
import HeyPorori.transaction.repository.TransactionRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class TransactionService { | ||
private final TransactionRepository transactionRepository; | ||
private final UserService userService; | ||
|
||
public void createPost(String token, PostReq postReq) { | ||
userService.sendTestJwtRequest(token); | ||
transactionRepository.save(Transaction.toEntity(postReq, userService.getUserId(token))); | ||
} | ||
} |