diff --git a/src/main/java/com/smunity/petition/domain/petition/controller/AgreementController.java b/src/main/java/com/smunity/petition/domain/petition/controller/AgreementController.java deleted file mode 100644 index 576a496..0000000 --- a/src/main/java/com/smunity/petition/domain/petition/controller/AgreementController.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.smunity.petition.domain.petition.controller; - -import com.smunity.petition.domain.petition.dto.AgreementRequest; -import com.smunity.petition.domain.petition.dto.AgreementResponse; -import com.smunity.petition.domain.petition.dto.PetitionResponse; -import com.smunity.petition.domain.petition.service.AgreementService; -import com.smunity.petition.global.common.ApiResponse; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/v1/agreements") -public class AgreementController { - private final AgreementService agreementService; - -// @GetMapping -// public ApiResponse> getPetitionList() { -// List petitionLists = petitionService.getPetitions(); -// return ApiResponse.onSuccess(petitionLists); -// } - -// @PostMapping -// public ApiResponse createAgreement(@RequestBody AgreementRequest request) { -// -// } - - -} diff --git a/src/main/java/com/smunity/petition/domain/petition/controller/RespondController.java b/src/main/java/com/smunity/petition/domain/petition/controller/RespondController.java index 49de863..d2f1079 100644 --- a/src/main/java/com/smunity/petition/domain/petition/controller/RespondController.java +++ b/src/main/java/com/smunity/petition/domain/petition/controller/RespondController.java @@ -21,11 +21,11 @@ public ApiResponse getRespondDetail(@PathVariable return ApiResponse.onSuccess(respondDetail); } - @GetMapping - public ApiResponse> getRespondList() { - List respondLists = respondService.getResponds(); - return ApiResponse.onSuccess(respondLists); - } +// @GetMapping +// public ApiResponse> getRespondList() { +// List respondLists = respondService.getResponds(); +// return ApiResponse.onSuccess(respondLists); +// } @PostMapping public ApiResponse createRespond(@RequestBody RespondRequest.CreateRespondDTO request) { diff --git a/src/main/java/com/smunity/petition/domain/petition/dto/RespondRequest.java b/src/main/java/com/smunity/petition/domain/petition/dto/RespondRequest.java index 089d702..b73aa84 100644 --- a/src/main/java/com/smunity/petition/domain/petition/dto/RespondRequest.java +++ b/src/main/java/com/smunity/petition/domain/petition/dto/RespondRequest.java @@ -10,13 +10,13 @@ public class RespondRequest { @Getter public static class CreateRespondDTO { - private Petition petition; + private Long petitionId; private String content; - + //절대 엔티티 자체를 넣지 말자 public Respond toEntity() { return Respond.builder() - .petition(petition) + .petition(new Petition(petitionId)) .content(content) .build(); } diff --git a/src/main/java/com/smunity/petition/domain/petition/dto/RespondResponse.java b/src/main/java/com/smunity/petition/domain/petition/dto/RespondResponse.java index 488f2ef..4ad4649 100644 --- a/src/main/java/com/smunity/petition/domain/petition/dto/RespondResponse.java +++ b/src/main/java/com/smunity/petition/domain/petition/dto/RespondResponse.java @@ -15,14 +15,14 @@ public class RespondResponse { @AllArgsConstructor(access = AccessLevel.PRIVATE) public static class respondDetail { private Long id; - private Petition petition; + private Long petitionId; private Long userId; private LocalDateTime createdDate; private LocalDateTime modifiedDate; public static respondDetail from(Respond respond) { return respondDetail.builder() - .petition(respond.getPetition()) + .petitionId(respond.getPetition().getId()) .userId(respond.getUser().getId()) .createdDate(respond.getCreateDate()) .modifiedDate(respond.getModifyDate()) @@ -37,14 +37,13 @@ public static respondDetail from(Respond respond) { public static class respondList { private Long id; private Long userId; - private Petition petition; - + private Long petitionId; public static respondList from(Respond respond) { return respondList.builder() .id(respond.getId()) .userId(respond.getUser().getId()) - .petition(respond.getPetition()) + .petitionId(respond.getPetition().getId()) .build(); } public static List from(List responds) { diff --git a/src/main/java/com/smunity/petition/domain/petition/entity/Petition.java b/src/main/java/com/smunity/petition/domain/petition/entity/Petition.java index 39cf3a4..6a168d7 100644 --- a/src/main/java/com/smunity/petition/domain/petition/entity/Petition.java +++ b/src/main/java/com/smunity/petition/domain/petition/entity/Petition.java @@ -52,6 +52,10 @@ public void setUser(User user) { this.user.getPetitions().add(this); } + public Petition(Long id) { + this.id = id; + } + public void updatePetition(PetitionRequest.UpdateDTO updateDTO){ this.subject = updateDTO.getSubject(); this.content = updateDTO.getContent(); diff --git a/src/main/java/com/smunity/petition/domain/petition/entity/Respond.java b/src/main/java/com/smunity/petition/domain/petition/entity/Respond.java index c5221b0..4182329 100644 --- a/src/main/java/com/smunity/petition/domain/petition/entity/Respond.java +++ b/src/main/java/com/smunity/petition/domain/petition/entity/Respond.java @@ -23,7 +23,8 @@ public class Respond extends BaseEntity { @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "petition_id") - private Petition petition; + Petition petition; + private String content; diff --git a/src/main/java/com/smunity/petition/domain/petition/repository/PetitionRepository.java b/src/main/java/com/smunity/petition/domain/petition/repository/PetitionRepository.java index 554591d..25342e6 100644 --- a/src/main/java/com/smunity/petition/domain/petition/repository/PetitionRepository.java +++ b/src/main/java/com/smunity/petition/domain/petition/repository/PetitionRepository.java @@ -15,6 +15,4 @@ public interface PetitionRepository extends JpaRepository { @Query("select p from Petition p") List findAllPetition(); - - List findAll(); } diff --git a/src/main/java/com/smunity/petition/domain/petition/repository/RespondRepository.java b/src/main/java/com/smunity/petition/domain/petition/repository/RespondRepository.java index 39d583d..90b2a8a 100644 --- a/src/main/java/com/smunity/petition/domain/petition/repository/RespondRepository.java +++ b/src/main/java/com/smunity/petition/domain/petition/repository/RespondRepository.java @@ -15,5 +15,4 @@ public interface RespondRepository extends JpaRepository { //RespondResponse.respondDetail -> Respond Respond findByPetitionId(@Param("petitionId") Long petitionId); - List findAll(); }