Skip to content

Commit

Permalink
Merge pull request #148 from UMC-WOWMARKET/feat/MyOrderManage-137
Browse files Browse the repository at this point in the history
[feat, refactor] 등록폼, 수집폼, 주문폼 관리 수정
  • Loading branch information
yunji118 authored Jan 4, 2024
2 parents e062370 + 89ccf42 commit a9e8709
Show file tree
Hide file tree
Showing 29 changed files with 349 additions and 230 deletions.
2 changes: 1 addition & 1 deletion src/main/java/wowmarket/wow_server/domain/DemandOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public class DemandOrder extends BaseEntity{

@ColumnDefault("0")
@Setter
private int isDel;
private int status;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package wowmarket.wow_server.mypage.myorder.demand.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
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.demand.dto.MyOrderDemandDetailResponseDto;
import wowmarket.wow_server.mypage.myorder.demand.dto.MyOrderDemandFormListResponseDto;
import wowmarket.wow_server.mypage.myorder.demand.service.MyOrderDemandService;

@RestController
@RequestMapping("/myorder/demand")
@RequiredArgsConstructor
public class MyOrderDemandController {
private final MyOrderDemandService myOrderDemandService;

//나의 수요조사 주문폼 목록 불러오기
@GetMapping()
public MyOrderDemandFormListResponseDto getMyOrderDemandList(@RequestParam(value = "page", defaultValue = "1", required = false)int page, @AuthenticationPrincipal User user){
Pageable pageable = PageRequest.of(page - 1, 10);
return myOrderDemandService.findMyAllDemandOrderForm(pageable, user);
}

//나의 수요조사 주문폼 상세보기
@GetMapping("/detail/{demand_order_id}")
public MyOrderDemandDetailResponseDto getMyOrderDemandDetail(@PathVariable Long demand_order_id){
return myOrderDemandService.findMyOrderDemandDetail(demand_order_id);
}


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package wowmarket.wow_server.mypage.myorder.demand.dto;

import lombok.Getter;
import lombok.NoArgsConstructor;
import wowmarket.wow_server.domain.DemandOrder;

import java.time.LocalDateTime;
import java.util.List;

@Getter
@NoArgsConstructor
public class MyOrderDemandDetailResponseDto {
private Long demandOrderId;
private LocalDateTime createdDate;
private int status;
private String projectName;
private String description;
private String thumbnail;
private List<MyOrderDemandItemDto> itemList;

public MyOrderDemandDetailResponseDto(List<MyOrderDemandItemDto> itemList, DemandOrder demandOrder){
this.demandOrderId = demandOrder.getId();
this.createdDate = demandOrder.getCreated_time();
this.status = demandOrder.getStatus();
this.projectName = demandOrder.getDemandProject().getProjectName();
this.description = demandOrder.getDemandProject().getDescription();
this.thumbnail = demandOrder.getDemandProject().getThumbnail();
this.itemList = itemList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

@Getter
@NoArgsConstructor
public class MyDemandOrderFormDto {
private Long demand_order_id;
public class MyOrderDemandFormDto {
private Long demandOrderId;
private String name;
private LocalDateTime createdtime;
private int is_del;
private LocalDateTime createdTime;
private int status;
private String description;
private String thumbnail;

public MyDemandOrderFormDto(DemandOrder order){
this.demand_order_id = order.getId();
public MyOrderDemandFormDto(DemandOrder order){
this.demandOrderId = order.getId();
this.name = order.getDemandProject().getProjectName();
this.createdtime = order.getCreated_time();
this.is_del = order.getIsDel();
this.createdTime = order.getCreated_time();
this.status = order.getStatus();
this.description = order.getDemandProject().getDescription();
this.thumbnail = order.getDemandProject().getThumbnail();

Expand Down
Original file line number Diff line number Diff line change
@@ -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 MyOrderDemandFormListResponseDto {
//나의 수요조사 주문폼 전체보기 리스트 dto
private List<MyOrderDemandFormDto> demandOrderList;
private int totalPage;
private int currentPage;

public MyOrderDemandFormListResponseDto(List<MyOrderDemandFormDto> demand_order_list, int total_page, int current_page){
this.demandOrderList = demand_order_list;
this.totalPage = total_page;
this.currentPage = current_page;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package wowmarket.wow_server.mypage.myorder.demand.dto;

import lombok.Getter;
import lombok.NoArgsConstructor;
import wowmarket.wow_server.domain.DemandDetail;

@Getter
@NoArgsConstructor
public class MyOrderDemandItemDto {
private Long itemId;
private String itemName;
private Long price;
private int count;

public MyOrderDemandItemDto(DemandDetail demandDetail){
this.itemId = demandDetail.getDemandItem().getId();
this.itemName = demandDetail.getDemandItem().getName();
this.price = demandDetail.getDemandItem().getPrice();
this.count = demandDetail.getCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,45 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.server.ResponseStatusException;
import wowmarket.wow_server.domain.DemandDetail;
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.mypage.myorder.demand.dto.MyOrderDemandDetailResponseDto;
import wowmarket.wow_server.mypage.myorder.demand.dto.MyOrderDemandFormDto;
import wowmarket.wow_server.mypage.myorder.demand.dto.MyOrderDemandFormListResponseDto;
import wowmarket.wow_server.mypage.myorder.demand.dto.MyOrderDemandItemDto;
import wowmarket.wow_server.repository.DemandDetailRepository;
import wowmarket.wow_server.repository.DemandOrderRepository;

import java.util.List;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class MyOrderDemandService {
private final DemandOrderRepository demandOrderRepository;
private final DemandDetailRepository demandDetailRepository;

@Transactional(readOnly = true)
public MyDemandOrderFormListResponseDto findMyAllDemandOrderForm(Pageable pageable, User user){
public MyOrderDemandFormListResponseDto findMyAllDemandOrderForm(Pageable pageable, User user){
if (user == null)
throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
Page<DemandOrder> demandOrders = demandOrderRepository.findByUser_Id(user.getId(), pageable);
Page<MyDemandOrderFormDto> demandOrderFormDtos = demandOrders.map(MyDemandOrderFormDto::new);
MyDemandOrderFormListResponseDto responseDto = new MyDemandOrderFormListResponseDto(demandOrderFormDtos.getContent(),
Page<MyOrderDemandFormDto> demandOrderFormDtos = demandOrders.map(MyOrderDemandFormDto::new);
MyOrderDemandFormListResponseDto responseDto = new MyOrderDemandFormListResponseDto(demandOrderFormDtos.getContent(),
demandOrderFormDtos.getTotalPages(), demandOrderFormDtos.getNumber());
return responseDto;
}

@Transactional(readOnly = true)
public MyOrderDemandDetailResponseDto findMyOrderDemandDetail(Long demand_order_id){
List<DemandDetail> demandDetails = demandDetailRepository.findByDemandOrder_Id(demand_order_id);
List<MyOrderDemandItemDto> orderDemandItemDtos = demandDetails.stream().map(MyOrderDemandItemDto::new).collect(Collectors.toList());
DemandOrder demandOrder = demandOrderRepository.findById(demand_order_id).orElseThrow(() -> new NoSuchElementException("존재하지 않는 demand order id 입니다."));

MyOrderDemandDetailResponseDto responseDto = new MyOrderDemandDetailResponseDto(orderDemandItemDtos, demandOrder);
return responseDto;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
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.sales.dto.MyOrderFormDetailResponseDto;
import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderSalesDetailResponseDto;
import wowmarket.wow_server.mypage.myorder.sales.dto.MyOrderFormListResponseDto;
import wowmarket.wow_server.mypage.myorder.sales.service.MyOrderSalesService;

@RestController
@RequestMapping("/myorder-sales")
@RequestMapping("/myorder/sales")
@RequiredArgsConstructor
public class MyOrderSalesController {

Expand All @@ -25,9 +25,9 @@ public MyOrderFormListResponseDto getMyOrderList(@RequestParam(value = "page", d
return myOrderService.findAllMyOrderForm(pageable, user);
}

//나의 판매 주문폼 상세 보기
//나의 판매 주문폼 상세보기
@GetMapping("/detail/{order_id}")
public MyOrderFormDetailResponseDto getMyDetailOrder(@PathVariable Long order_id){
public MyOrderSalesDetailResponseDto getMyDetailOrder(@PathVariable Long order_id){
return myOrderService.findMyOrderFormDetail(order_id);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
@Getter
@NoArgsConstructor
public class MyOrderFormListResponseDto {
private List<MyOrderFormResponseDto> orderList;
private int totalpage;
private int currentpage;
private List<MyOrderSalesResponseDto> orderList;
private int totalPage;
private int currentPage;

public MyOrderFormListResponseDto(List<MyOrderFormResponseDto> newDtos, int totalpage, int currentpage){
public MyOrderFormListResponseDto(List<MyOrderSalesResponseDto> newDtos, int totalpage, int currentpage){
this.orderList = newDtos;
this.totalpage = totalpage;
this.currentpage = currentpage;
this.totalPage = totalpage;
this.currentPage = currentpage;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package wowmarket.wow_server.mypage.myorder.sales.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import wowmarket.wow_server.domain.OrderDetail;

@Getter
@NoArgsConstructor
public class MyOrderFormDetailDto {
private Long item_id;
private String name;
public class MyOrderSalesDetailItemDto {
private Long itemId;
private String itemName;
private Long price;
private int count;

public MyOrderFormDetailDto(OrderDetail orderDetail){
this.item_id = orderDetail.getItem().getId();
this.name = orderDetail.getItem().getName();
public MyOrderSalesDetailItemDto(OrderDetail orderDetail){
this.itemId = orderDetail.getItem().getId();
this.itemName = orderDetail.getItem().getName();
this.price = orderDetail.getItem().getPrice();
this.count = orderDetail.getCount();
}
Expand Down
Loading

0 comments on commit a9e8709

Please sign in to comment.