From bab37e422f140ee426a0da27b4c04efaf7a59db8 Mon Sep 17 00:00:00 2001 From: yunji118 Date: Tue, 2 Jan 2024 20:45:32 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[refactor]url=EC=97=90=EC=84=9C=20mypage=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wow_server/mypage/myorder/controller/MyOrderController.java | 2 +- .../MyDemandProject/controller/MyDemandProjectController.java | 2 +- .../MySalesOrder/controller/MySalesOrderController.java | 2 +- .../MySalesProject/controller/MySalesProjectController.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/controller/MyOrderController.java b/src/main/java/wowmarket/wow_server/mypage/myorder/controller/MyOrderController.java index c4f330e..d4262bd 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/controller/MyOrderController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/controller/MyOrderController.java @@ -13,7 +13,7 @@ import wowmarket.wow_server.mypage.myorder.service.MyOrderService; @RestController -@RequestMapping("/mypage/myorder") +@RequestMapping("/myorder") @RequiredArgsConstructor public class MyOrderController { diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MyDemandProject/controller/MyDemandProjectController.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MyDemandProject/controller/MyDemandProjectController.java index b9cf0e1..8cfd5f9 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MyDemandProject/controller/MyDemandProjectController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MyDemandProject/controller/MyDemandProjectController.java @@ -13,7 +13,7 @@ import wowmarket.wow_server.mypage.myproject.MyDemandProject.service.MyDemandProjectService; @RestController -@RequestMapping("/mypage/myproject/demand") +@RequestMapping("/myproject/demand") @RequiredArgsConstructor public class MyDemandProjectController { diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesOrder/controller/MySalesOrderController.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesOrder/controller/MySalesOrderController.java index 7bf82b7..333f037 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesOrder/controller/MySalesOrderController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesOrder/controller/MySalesOrderController.java @@ -14,7 +14,7 @@ import wowmarket.wow_server.mypage.myproject.MySalesOrder.service.MySalesOrderService; @RestController -@RequestMapping("/mypage/myproject/order") +@RequestMapping("/myproject/order") @RequiredArgsConstructor public class MySalesOrderController { diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/controller/MySalesProjectController.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/controller/MySalesProjectController.java index 0521778..913c06a 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/controller/MySalesProjectController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/controller/MySalesProjectController.java @@ -13,7 +13,7 @@ import wowmarket.wow_server.mypage.myproject.MySalesProject.service.MySalesProjectService; @RestController -@RequestMapping("/mypage/myproject") +@RequestMapping("/myproject") @RequiredArgsConstructor public class MySalesProjectController { private final MySalesProjectService mySalesProjectService; From 05f7b92364889cb9b3e351efc8c5ebe19c725412 Mon Sep 17 00:00:00 2001 From: yunji118 Date: Tue, 2 Jan 2024 20:50:39 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[refactor]=EC=9C=84=EC=B9=98=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20dto=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95=20#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/wowmarket/wow_server/domain/OrderDetail.java | 1 - .../{ => sales}/controller/MyOrderController.java | 9 ++++----- .../myorder/{ => sales}/dto/MyOrderFormDetailDto.java | 2 +- .../{ => sales}/dto/MyOrderFormDetailResponseDto.java | 5 +---- .../{ => sales}/dto/MyOrderFormItemListRequestDto.java | 2 +- .../{ => sales}/dto/MyOrderFormListResponseDto.java | 3 +-- .../myorder/{ => sales}/dto/MyOrderFormResponseDto.java | 2 +- .../myorder/{ => sales}/service/MyOrderService.java | 8 +++++--- 8 files changed, 14 insertions(+), 18 deletions(-) rename src/main/java/wowmarket/wow_server/mypage/myorder/{ => sales}/controller/MyOrderController.java (80%) rename src/main/java/wowmarket/wow_server/mypage/myorder/{ => sales}/dto/MyOrderFormDetailDto.java (91%) rename src/main/java/wowmarket/wow_server/mypage/myorder/{ => sales}/dto/MyOrderFormDetailResponseDto.java (93%) rename src/main/java/wowmarket/wow_server/mypage/myorder/{ => sales}/dto/MyOrderFormItemListRequestDto.java (69%) rename src/main/java/wowmarket/wow_server/mypage/myorder/{ => sales}/dto/MyOrderFormListResponseDto.java (87%) rename src/main/java/wowmarket/wow_server/mypage/myorder/{ => sales}/dto/MyOrderFormResponseDto.java (94%) rename src/main/java/wowmarket/wow_server/mypage/myorder/{ => sales}/service/MyOrderService.java (87%) diff --git a/src/main/java/wowmarket/wow_server/domain/OrderDetail.java b/src/main/java/wowmarket/wow_server/domain/OrderDetail.java index 6816781..8eacf5e 100644 --- a/src/main/java/wowmarket/wow_server/domain/OrderDetail.java +++ b/src/main/java/wowmarket/wow_server/domain/OrderDetail.java @@ -6,7 +6,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.ColumnDefault; -import wowmarket.wow_server.mypage.myorder.dto.MyOrderFormItemListRequestDto; @Entity @Getter diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/controller/MyOrderController.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java similarity index 80% rename from src/main/java/wowmarket/wow_server/mypage/myorder/controller/MyOrderController.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java index d4262bd..e4d3c71 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/controller/MyOrderController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java @@ -1,16 +1,15 @@ -package wowmarket.wow_server.mypage.myorder.controller; +package wowmarket.wow_server.mypage.myorder.sales.controller; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; import wowmarket.wow_server.domain.User; -import wowmarket.wow_server.mypage.myorder.dto.MyOrderFormDetailResponseDto; -import wowmarket.wow_server.mypage.myorder.dto.MyOrderFormListResponseDto; -import wowmarket.wow_server.mypage.myorder.service.MyOrderService; +import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormDetailResponseDto; +import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormListResponseDto; +import wowmarket.wow_server.mypage.myorder.sales.service.MyOrderService; @RestController @RequestMapping("/myorder") diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormDetailDto.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormDetailDto.java similarity index 91% rename from src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormDetailDto.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormDetailDto.java index 12cbe60..6dfa9e6 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormDetailDto.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormDetailDto.java @@ -1,4 +1,4 @@ -package wowmarket.wow_server.mypage.myorder.dto; +package wowmarket.wow_server.mypage.myorder.sales.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormDetailResponseDto.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormDetailResponseDto.java similarity index 93% rename from src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormDetailResponseDto.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormDetailResponseDto.java index 3450733..f4b2373 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormDetailResponseDto.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormDetailResponseDto.java @@ -1,12 +1,9 @@ -package wowmarket.wow_server.mypage.myorder.dto; +package wowmarket.wow_server.mypage.myorder.sales.dto; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import wowmarket.wow_server.domain.Orders; -import wowmarket.wow_server.domain.Project; -import java.time.LocalDateTime; import java.util.List; @Getter diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormItemListRequestDto.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormItemListRequestDto.java similarity index 69% rename from src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormItemListRequestDto.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormItemListRequestDto.java index 3fd824c..96546fb 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormItemListRequestDto.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormItemListRequestDto.java @@ -1,4 +1,4 @@ -package wowmarket.wow_server.mypage.myorder.dto; +package wowmarket.wow_server.mypage.myorder.sales.dto; import lombok.Getter; diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormListResponseDto.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormListResponseDto.java similarity index 87% rename from src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormListResponseDto.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormListResponseDto.java index c937d8b..20df86b 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormListResponseDto.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormListResponseDto.java @@ -1,6 +1,5 @@ -package wowmarket.wow_server.mypage.myorder.dto; +package wowmarket.wow_server.mypage.myorder.sales.dto; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormResponseDto.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormResponseDto.java similarity index 94% rename from src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormResponseDto.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormResponseDto.java index d7cc5d5..c18b903 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/dto/MyOrderFormResponseDto.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/dto/MyOrderFormResponseDto.java @@ -1,4 +1,4 @@ -package wowmarket.wow_server.mypage.myorder.dto; +package wowmarket.wow_server.mypage.myorder.sales.dto; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/service/MyOrderService.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderService.java similarity index 87% rename from src/main/java/wowmarket/wow_server/mypage/myorder/service/MyOrderService.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderService.java index 787b0c6..3053b33 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/service/MyOrderService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderService.java @@ -1,4 +1,4 @@ -package wowmarket.wow_server.mypage.myorder.service; +package wowmarket.wow_server.mypage.myorder.sales.service; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -11,8 +11,10 @@ import wowmarket.wow_server.domain.OrderDetail; import wowmarket.wow_server.domain.Orders; import wowmarket.wow_server.domain.User; -import wowmarket.wow_server.global.jwt.SecurityUtil; -import wowmarket.wow_server.mypage.myorder.dto.*; +import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormDetailDto; +import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormDetailResponseDto; +import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormListResponseDto; +import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormResponseDto; import wowmarket.wow_server.repository.OrderDetailRepository; import wowmarket.wow_server.repository.OrderRepository; import wowmarket.wow_server.repository.UserRepository; From 98fff526015c827f47cd7236f20a29ed567e31eb Mon Sep 17 00:00:00 2001 From: yunji118 Date: Tue, 2 Jan 2024 20:57:33 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[feat]myorder=20url=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=B0=8F=20security=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wow_server/global/config/SecurityConfig.java | 1 + .../demand/controller/MyDemandOrderController.java | 10 ++++++++++ .../myorder/sales/controller/MyOrderController.java | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java diff --git a/src/main/java/wowmarket/wow_server/global/config/SecurityConfig.java b/src/main/java/wowmarket/wow_server/global/config/SecurityConfig.java index 1257bd7..28f96b7 100644 --- a/src/main/java/wowmarket/wow_server/global/config/SecurityConfig.java +++ b/src/main/java/wowmarket/wow_server/global/config/SecurityConfig.java @@ -40,6 +40,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .cors(cors -> cors.configurationSource(corsConfigurationSource())) .authorizeRequests() // 요청에 대한 접근 권한을 설정하는 메서드 .requestMatchers("/mypage/**").authenticated() + .requestMatchers("/myorder-sales/**").authenticated() .requestMatchers("/register/**").authenticated() .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() // Preflight Request 허용해주기 .anyRequest().permitAll(); diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java new file mode 100644 index 0000000..ce43d76 --- /dev/null +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java @@ -0,0 +1,10 @@ +package wowmarket.wow_server.mypage.myorder.demand.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/myorder-demand") +public class MyDemandOrderController { + +} diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java index e4d3c71..68db4b1 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java @@ -12,20 +12,20 @@ import wowmarket.wow_server.mypage.myorder.sales.service.MyOrderService; @RestController -@RequestMapping("/myorder") +@RequestMapping("/myorder-sales") @RequiredArgsConstructor public class MyOrderController { private final MyOrderService myOrderService; - //나의 주문폼 목록 불러오기 + //나의 판매 주문폼 목록 불러오기 @GetMapping() public MyOrderFormListResponseDto getMyOrderList(@RequestParam(value = "page", defaultValue = "1", required = false)int page, @AuthenticationPrincipal User user){ Pageable pageable = PageRequest.of(page - 1, 10); return myOrderService.findAllMyOrderForm(pageable, user); } - //나의 주문폼 상세 보기 + //나의 판매 주문폼 상세 보기 @GetMapping("/detail/{order_id}") public MyOrderFormDetailResponseDto getMyDetailOrder(@PathVariable Long order_id){ return myOrderService.findMyOrderFormDetail(order_id); From 9b55aba6d76c11c32f4e186c4e977e922be1b52b Mon Sep 17 00:00:00 2001 From: yunji118 Date: Tue, 2 Jan 2024 21:42:44 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[feat]=EB=82=98=EC=9D=98=20=EC=88=98?= =?UTF-8?q?=EC=9A=94=EC=A1=B0=EC=82=AC=20=EC=A3=BC=EB=AC=B8=ED=8F=BC=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=EB=B3=B4=EA=B8=B0=20#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wow_server/domain/DemandDetail.java | 8 +++-- .../wow_server/domain/DemandOrder.java | 31 +++++++++++++++++ .../controller/MyDemandOrderController.java | 2 ++ .../demand/dto/MyDemandOrderFormDto.java | 28 +++++++++++++++ .../dto/MyDemandOrderFormListResponseDto.java | 21 ++++++++++++ .../demand/service/MyOrderDemandService.java | 34 +++++++++++++++++++ ...oller.java => MyOrderSalesController.java} | 6 ++-- ...rService.java => MyOrderSalesService.java} | 3 +- .../repository/DemandOrderRepository.java | 11 ++++++ 9 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 src/main/java/wowmarket/wow_server/domain/DemandOrder.java create mode 100644 src/main/java/wowmarket/wow_server/mypage/myorder/demand/dto/MyDemandOrderFormDto.java create mode 100644 src/main/java/wowmarket/wow_server/mypage/myorder/demand/dto/MyDemandOrderFormListResponseDto.java create mode 100644 src/main/java/wowmarket/wow_server/mypage/myorder/demand/service/MyOrderDemandService.java rename src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/{MyOrderController.java => MyOrderSalesController.java} (93%) rename src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/{MyOrderService.java => MyOrderSalesService.java} (97%) create mode 100644 src/main/java/wowmarket/wow_server/repository/DemandOrderRepository.java diff --git a/src/main/java/wowmarket/wow_server/domain/DemandDetail.java b/src/main/java/wowmarket/wow_server/domain/DemandDetail.java index e12a7f3..856f4cd 100644 --- a/src/main/java/wowmarket/wow_server/domain/DemandDetail.java +++ b/src/main/java/wowmarket/wow_server/domain/DemandDetail.java @@ -21,9 +21,13 @@ public class DemandDetail extends BaseEntity{ @JoinColumn(name = "demand_item_id", referencedColumnName = "demand_item_id") private DemandItem demandItem; +// @ManyToOne(fetch = FetchType.LAZY) +// @JoinColumn(name = "buyer_id", referencedColumnName = "user_id") +// private User user; + @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "buyer_id", referencedColumnName = "user_id") - private User user; + @JoinColumn(name = "demand_order_id", referencedColumnName = "demand_order_id") + private DemandOrder demandOrder; @ColumnDefault("0") private int count; diff --git a/src/main/java/wowmarket/wow_server/domain/DemandOrder.java b/src/main/java/wowmarket/wow_server/domain/DemandOrder.java new file mode 100644 index 0000000..21d666f --- /dev/null +++ b/src/main/java/wowmarket/wow_server/domain/DemandOrder.java @@ -0,0 +1,31 @@ +package wowmarket.wow_server.domain; + +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.annotations.ColumnDefault; + +@Entity +@Getter +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "demand_orders") +@AttributeOverride(name = "created_time", column = @Column(name = "order_time")) +public class DemandOrder extends BaseEntity{ + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "demand_order_id") + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "buyer_id", referencedColumnName = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "demand_project_id", referencedColumnName = "demand_project_id") + private DemandProject demandProject; + + @ColumnDefault("0") + @Setter + private int isDel; +} diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java index ce43d76..dda1f60 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java @@ -1,10 +1,12 @@ package wowmarket.wow_server.mypage.myorder.demand.controller; +import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/myorder-demand") +@RequiredArgsConstructor public class MyDemandOrderController { } diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/demand/dto/MyDemandOrderFormDto.java b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/dto/MyDemandOrderFormDto.java new file mode 100644 index 0000000..79ac346 --- /dev/null +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/dto/MyDemandOrderFormDto.java @@ -0,0 +1,28 @@ +package wowmarket.wow_server.mypage.myorder.demand.dto; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import wowmarket.wow_server.domain.DemandOrder; + +import java.time.LocalDateTime; + +@Getter +@NoArgsConstructor +public class MyDemandOrderFormDto { + private Long demand_order_id; + private String name; + private LocalDateTime createdtime; + private int is_del; + private String description; + private String thumbnail; + + public MyDemandOrderFormDto(DemandOrder order){ + this.demand_order_id = order.getId(); + this.name = order.getDemandProject().getProjectName(); + this.createdtime = order.getCreated_time(); + this.is_del = order.getIsDel(); + this.description = order.getDemandProject().getDescription(); + this.thumbnail = order.getDemandProject().getThumbnail(); + + } +} diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/demand/dto/MyDemandOrderFormListResponseDto.java b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/dto/MyDemandOrderFormListResponseDto.java new file mode 100644 index 0000000..1f23583 --- /dev/null +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/dto/MyDemandOrderFormListResponseDto.java @@ -0,0 +1,21 @@ +package wowmarket.wow_server.mypage.myorder.demand.dto; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@NoArgsConstructor +public class MyDemandOrderFormListResponseDto { + //나의 수요조사 주문폼 전체보기 리스트 dto + private List demand_order_list; + private int total_page; + private int current_page; + + public MyDemandOrderFormListResponseDto(List demand_order_list, int total_page, int current_page){ + this.demand_order_list = demand_order_list; + this.total_page = total_page; + this.current_page = current_page; + } +} diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/demand/service/MyOrderDemandService.java b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/service/MyOrderDemandService.java new file mode 100644 index 0000000..6a9dd76 --- /dev/null +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/service/MyOrderDemandService.java @@ -0,0 +1,34 @@ +package wowmarket.wow_server.mypage.myorder.demand.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.server.ResponseStatusException; +import wowmarket.wow_server.domain.DemandOrder; +import wowmarket.wow_server.domain.User; +import wowmarket.wow_server.mypage.myorder.demand.dto.MyDemandOrderFormDto; +import wowmarket.wow_server.mypage.myorder.demand.dto.MyDemandOrderFormListResponseDto; +import wowmarket.wow_server.repository.DemandDetailRepository; +import wowmarket.wow_server.repository.DemandOrderRepository; + +@Service +@RequiredArgsConstructor +public class MyOrderDemandService { + private final DemandOrderRepository demandOrderRepository; + private final DemandDetailRepository demandDetailRepository; + + @Transactional(readOnly = true) + public MyDemandOrderFormListResponseDto findMyAllDemandOrderForm(Pageable pageable, User user){ + if (user == null) + throw new ResponseStatusException(HttpStatus.BAD_REQUEST); + Page demandOrders = demandOrderRepository.findByUser_Id(user.getId(), pageable); + Page demandOrderFormDtos = demandOrders.map(MyDemandOrderFormDto::new); + MyDemandOrderFormListResponseDto responseDto = new MyDemandOrderFormListResponseDto(demandOrderFormDtos.getContent(), + demandOrderFormDtos.getTotalPages(), demandOrderFormDtos.getNumber()); + return responseDto; + } + +} diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java similarity index 93% rename from src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java index 68db4b1..14fa408 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java @@ -9,14 +9,14 @@ import wowmarket.wow_server.domain.User; import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormDetailResponseDto; import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormListResponseDto; -import wowmarket.wow_server.mypage.myorder.sales.service.MyOrderService; +import wowmarket.wow_server.mypage.myorder.sales.service.MyOrderSalesService; @RestController @RequestMapping("/myorder-sales") @RequiredArgsConstructor -public class MyOrderController { +public class MyOrderSalesController { - private final MyOrderService myOrderService; + private final MyOrderSalesService myOrderService; //나의 판매 주문폼 목록 불러오기 @GetMapping() diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderService.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderSalesService.java similarity index 97% rename from src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderService.java rename to src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderSalesService.java index 3053b33..ae36df1 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderSalesService.java @@ -24,10 +24,9 @@ @Service @RequiredArgsConstructor -public class MyOrderService { +public class MyOrderSalesService { private final OrderRepository orderRepository; private final OrderDetailRepository orderDetailRepository; - private final UserRepository userRepository; @Transactional(readOnly = true) public MyOrderFormListResponseDto findAllMyOrderForm(Pageable pageable, User user){ diff --git a/src/main/java/wowmarket/wow_server/repository/DemandOrderRepository.java b/src/main/java/wowmarket/wow_server/repository/DemandOrderRepository.java new file mode 100644 index 0000000..11fe83f --- /dev/null +++ b/src/main/java/wowmarket/wow_server/repository/DemandOrderRepository.java @@ -0,0 +1,11 @@ +package wowmarket.wow_server.repository; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import wowmarket.wow_server.domain.DemandOrder; + +public interface DemandOrderRepository extends JpaRepository { + + Page findByUser_Id(Long buyer_id, Pageable pageable); +}