-
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
1 parent
9c14325
commit b81c2a0
Showing
7 changed files
with
67 additions
and
20 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
38 changes: 33 additions & 5 deletions
38
src/main/java/com/smunity/petition/domain/petition/dto/RespondResponse.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,28 +1,56 @@ | ||
package com.smunity.petition.domain.petition.dto; | ||
|
||
import com.smunity.petition.domain.petition.entity.Petition; | ||
import com.smunity.petition.domain.petition.entity.Respond; | ||
import lombok.*; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class RespondResponse { | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public static class respondDTO { | ||
private String content; | ||
public static class respondDetail { | ||
private Long id; | ||
private Petition petition; | ||
private Long userId; | ||
private LocalDateTime createdDate; | ||
private LocalDateTime modifiedDate; | ||
|
||
public static respondDTO from(Respond respond) { | ||
return respondDTO.builder() | ||
.content(respond.getContent()) | ||
public static respondDetail from(Respond respond) { | ||
return respondDetail.builder() | ||
.petition(respond.getPetition()) | ||
.userId(respond.getUser().getId()) | ||
.createdDate(respond.getCreateDate()) | ||
.modifiedDate(respond.getModifyDate()) | ||
.build(); | ||
} | ||
} | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public static class respondList { | ||
private Long id; | ||
private Long userId; | ||
private Petition petition; | ||
|
||
|
||
public static respondList from(Respond respond) { | ||
return respondList.builder() | ||
.id(respond.getId()) | ||
.userId(respond.getUser().getId()) | ||
.petition(respond.getPetition()) | ||
.build(); | ||
} | ||
public static List<respondList> from(List<Respond> responds) { | ||
return responds.stream().map(respondList::from).collect(Collectors.toList()); | ||
} | ||
} | ||
|
||
|
||
} |
9 changes: 4 additions & 5 deletions
9
src/main/java/com/smunity/petition/domain/petition/entity/Agreement.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
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
8 changes: 6 additions & 2 deletions
8
src/main/java/com/smunity/petition/domain/petition/repository/RespondRepository.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,15 +1,19 @@ | ||
package com.smunity.petition.domain.petition.repository; | ||
|
||
import com.smunity.petition.domain.petition.dto.RespondResponse; | ||
import com.smunity.petition.domain.petition.entity.Respond; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
public interface RespondRepository extends JpaRepository<Respond, Long> { | ||
|
||
@Query( "select r " + | ||
"from Respond r " + | ||
"where r.petition.id = :petitionId") | ||
RespondResponse.respondDTO findByPetitionId(@Param("petitionId") Long petitionId); | ||
//RespondResponse.respondDetail -> Respond | ||
Respond findByPetitionId(@Param("petitionId") Long petitionId); | ||
|
||
List<Respond> findAll(); | ||
} |
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