Skip to content

Commit 76040cb

Browse files
committed
refactor: 받은 제안 Response 수정
1 parent e067036 commit 76040cb

File tree

4 files changed

+49
-14
lines changed

4 files changed

+49
-14
lines changed

api/src/main/java/com/sponus/sponusbe/domain/propose/controller/ProposeController.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
import com.sponus.sponusbe.domain.organization.dto.response.PageResponse;
1717
import com.sponus.sponusbe.domain.propose.dto.request.ProposeCreateRequest;
1818
import com.sponus.sponusbe.domain.propose.dto.response.ProposeCreateResponse;
19-
import com.sponus.sponusbe.domain.propose.dto.response.ProposeGetResponse;
19+
import com.sponus.sponusbe.domain.propose.dto.response.ReceiveProposeGetResponse;
20+
import com.sponus.sponusbe.domain.propose.dto.response.SendProposeGetResponse;
2021
import com.sponus.sponusbe.domain.propose.service.ProposeQueryService;
2122
import com.sponus.sponusbe.domain.propose.service.ProposeService;
2223

@@ -42,15 +43,15 @@ public ApiResponse<ProposeCreateResponse> createPropose(
4243
}
4344

4445
@GetMapping("/send")
45-
public ApiResponse<PageResponse<ProposeGetResponse>> getSendPropose(
46+
public ApiResponse<PageResponse<SendProposeGetResponse>> getSendPropose(
4647
@AuthOrganization Organization authOrganization,
4748
@ModelAttribute @Valid PageCondition pageCondition
4849
) {
4950
return ApiResponse.onSuccess(proposequeryService.getSendPropose(authOrganization, pageCondition));
5051
}
5152

52-
@GetMapping("/received")
53-
public ApiResponse<PageResponse<ProposeGetResponse>> getReceivedPropose(
53+
@GetMapping("/receive")
54+
public ApiResponse<PageResponse<ReceiveProposeGetResponse>> getReceivedPropose(
5455
@AuthOrganization Organization authOrganization,
5556
@ModelAttribute @Valid PageCondition pageCondition
5657
) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.sponus.sponusbe.domain.propose.dto.response;
2+
3+
import java.time.LocalDate;
4+
5+
import com.sponus.coredomain.domain.propose.Propose;
6+
import com.sponus.coredomain.domain.propose.ProposeStatus;
7+
8+
import lombok.Builder;
9+
10+
@Builder
11+
public record ReceiveProposeGetResponse(
12+
Long id,
13+
Long organizationId,
14+
Long target,
15+
String organizationName,
16+
String organizationImageUrl,
17+
ProposeStatus status,
18+
LocalDate createdAt
19+
) {
20+
21+
public static ReceiveProposeGetResponse from(Propose propose) {
22+
return ReceiveProposeGetResponse.builder()
23+
.id(propose.getId())
24+
.organizationId(propose.getOrganization().getId())
25+
.target(propose.getTarget().getId())
26+
.organizationName(propose.getOrganization().getName())
27+
.organizationImageUrl(propose.getOrganization().getImageUrl())
28+
.status(propose.getStatus())
29+
.createdAt(propose.getCreatedAt().toLocalDate())
30+
.build();
31+
}
32+
}

api/src/main/java/com/sponus/sponusbe/domain/propose/dto/response/ProposeGetResponse.java api/src/main/java/com/sponus/sponusbe/domain/propose/dto/response/SendProposeGetResponse.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import lombok.Builder;
99

1010
@Builder
11-
public record ProposeGetResponse(
11+
public record SendProposeGetResponse(
1212
Long id,
1313
Long organizationId,
1414
Long target,
@@ -18,8 +18,8 @@ public record ProposeGetResponse(
1818
LocalDate createdAt
1919
) {
2020

21-
public static ProposeGetResponse from(Propose propose) {
22-
return ProposeGetResponse.builder()
21+
public static SendProposeGetResponse from(Propose propose) {
22+
return SendProposeGetResponse.builder()
2323
.id(propose.getId())
2424
.organizationId(propose.getOrganization().getId())
2525
.target(propose.getTarget().getId())

api/src/main/java/com/sponus/sponusbe/domain/propose/service/ProposeQueryService.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
import com.sponus.coredomain.domain.propose.repository.ProposeRepository;
1313
import com.sponus.sponusbe.domain.organization.dto.request.PageCondition;
1414
import com.sponus.sponusbe.domain.organization.dto.response.PageResponse;
15-
import com.sponus.sponusbe.domain.propose.dto.response.ProposeGetResponse;
15+
import com.sponus.sponusbe.domain.propose.dto.response.ReceiveProposeGetResponse;
16+
import com.sponus.sponusbe.domain.propose.dto.response.SendProposeGetResponse;
1617

1718
import lombok.RequiredArgsConstructor;
1819

@@ -23,24 +24,25 @@ public class ProposeQueryService {
2324

2425
private final ProposeRepository proposeRepository;
2526

26-
public PageResponse<ProposeGetResponse> getSendPropose(Organization organization, PageCondition pageCondition) {
27+
public PageResponse<SendProposeGetResponse> getSendPropose(Organization organization, PageCondition pageCondition) {
2728
Pageable pageable = PageRequest.of(pageCondition.getPage() - 1, pageCondition.getSize());
28-
List<ProposeGetResponse> organizations = proposeRepository.findByOrganizationOrderByCreatedAtDesc(
29+
List<SendProposeGetResponse> organizations = proposeRepository.findByOrganizationOrderByCreatedAtDesc(
2930
organization, pageable)
3031
.stream()
31-
.map(ProposeGetResponse::from)
32+
.map(SendProposeGetResponse::from)
3233
.toList();
3334

3435
return PageResponse.of(
3536
PageableExecutionUtils.getPage(organizations, pageable,
3637
() -> proposeRepository.countByOrganization(organization)));
3738
}
3839

39-
public PageResponse<ProposeGetResponse> getReceivedPropose(Organization organization, PageCondition pageCondition) {
40+
public PageResponse<ReceiveProposeGetResponse> getReceivedPropose(Organization organization,
41+
PageCondition pageCondition) {
4042
Pageable pageable = PageRequest.of(pageCondition.getPage() - 1, pageCondition.getSize());
41-
List<ProposeGetResponse> organizations = proposeRepository.findByTargetAndOrganizationOrderByCreatedAtDesc(
43+
List<ReceiveProposeGetResponse> organizations = proposeRepository.findByTargetAndOrganizationOrderByCreatedAtDesc(
4244
organization, organization, pageable)
43-
.map(ProposeGetResponse::from)
45+
.map(ReceiveProposeGetResponse::from)
4446
.toList();
4547

4648
return PageResponse.of(

0 commit comments

Comments
 (0)