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/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/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..dda1f60 --- /dev/null +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/demand/controller/MyDemandOrderController.java @@ -0,0 +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/controller/MyOrderController.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java similarity index 68% 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/MyOrderSalesController.java index c4f330e..14fa408 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/controller/MyOrderController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java @@ -1,32 +1,31 @@ -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.MyOrderSalesService; @RestController -@RequestMapping("/mypage/myorder") +@RequestMapping("/myorder-sales") @RequiredArgsConstructor -public class MyOrderController { +public class MyOrderSalesController { - private final MyOrderService myOrderService; + private final MyOrderSalesService 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); 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/MyOrderSalesService.java similarity index 86% 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/MyOrderSalesService.java index 787b0c6..ae36df1 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/service/MyOrderService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderSalesService.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; @@ -22,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/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; 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); +}