-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
dcd4832
commit 2a50039
Showing
4 changed files
with
49 additions
and
6 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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/example/MangoWafflee/Follow/DTO/FollowRequestDTO.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,9 +1,37 @@ | ||
package com.example.MangoWafflee.Follow.DTO; | ||
|
||
import com.example.MangoWafflee.DTO.UserDTO; | ||
import com.example.MangoWafflee.Entity.UserEntity; | ||
import com.example.MangoWafflee.Follow.Entity.FollowRequest; | ||
import com.example.MangoWafflee.Follow.Entity.FollowRequestStatus; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class FollowRequestDTO { | ||
private Long id; | ||
private Long senderId; | ||
private Long receiverId; | ||
private FollowRequestStatus status; | ||
private LocalDateTime requestDate; | ||
|
||
//엔티티를 직접 반환하게 하지않고 필요한 데이터만 포함한 객체를 반환하도록 DTO를 사용 | ||
public static FollowRequestDTO entityToDto(FollowRequest followRequest) { | ||
return new FollowRequestDTO( | ||
followRequest.getId(), | ||
followRequest.getSender().getId(), | ||
followRequest.getReceiver().getId(), | ||
followRequest.getStatus(), | ||
followRequest.getRequestDate() | ||
); | ||
} | ||
|
||
public FollowRequest dtoToEntity(UserEntity sender, UserEntity receiver) { | ||
return new FollowRequest(id, sender, receiver, status, requestDate); | ||
} | ||
} |
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