Skip to content

Commit

Permalink
Merge pull request #139 from UMC-WOWMARKET/feat/v2fix
Browse files Browse the repository at this point in the history
Feat/v2fix
  • Loading branch information
yunji118 authored Dec 28, 2023
2 parents 0023cd8 + dd37c72 commit 470ae10
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/main/java/wowmarket/wow_server/domain/Orders.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;

import java.time.LocalDateTime;

Expand Down Expand Up @@ -35,9 +36,9 @@ public class Orders extends BaseEntity {
@Setter
private int order_status;

@Column(columnDefinition="tinyint(0) default 0")
@ColumnDefault("0")
@Setter
private boolean isDel;
private int isDel;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "buyer_id", referencedColumnName = "user_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ 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);
}

//나의 주문폼 취소하기
@DeleteMapping("/detail/{order_id}")
public ResponseEntity deleteMyOrder(@PathVariable Long order_id){
return myOrderService.deleteMyOrderFormDetail(order_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public class MyOrderFormDetailResponseDto {
private String buyer_account;
private String buyer_account_name;
private String deposittime;
private String project_name;
private String description;
private int total_price;
private String thumbnail;
private int status;
private int is_del;
private Long order_id;

public MyOrderFormDetailResponseDto(List<MyOrderFormDetailDto> itemList, Orders orders, String address){
this.itemList = itemList;
Expand All @@ -43,6 +50,13 @@ public MyOrderFormDetailResponseDto(List<MyOrderFormDetailDto> itemList, Orders
this.buyer_account = orders.getAccount();
this.buyer_account_name = orders.getDepositor();
this.deposittime = orders.getDepositTime();
this.project_name = orders.getProject().getName();
this.description = orders.getProject().getDescription();
this.total_price = orders.getTotal_price();
this.thumbnail = orders.getProject().getThumbnail();
this.status = orders.getOrder_status();
this.is_del = orders.getIsDel();
this.order_id = orders.getId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ public class MyOrderFormResponseDto {
private String name;
private LocalDateTime createdtime;
private int status;
private boolean isdel;
private int is_del;
private int price;
private String description;
private String thumbnail;

public MyOrderFormResponseDto(Orders order){
this.orderId = order.getId();
this.name = order.getProject().getName();
this.createdtime = order.getCreated_time();
this.status = order.getOrder_status();
this.isdel = order.isDel();
this.is_del = order.getIsDel();
this.price = order.getTotal_price();
this.thumbnail = order.getProject().getThumbnail();
this.description = order.getProject().getDescription();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public MyOrderFormDetailResponseDto findMyOrderFormDetail(Long order_id){
public ResponseEntity deleteMyOrderFormDetail(Long order_id){
Orders orders = orderRepository.findById(order_id)
.orElseThrow(()->new ResponseStatusException(HttpStatus.BAD_REQUEST));
if (orders.isDel() == false)
orders.setDel(true);
if (orders.getIsDel() == 0)
orders.setIsDel(1);
return new ResponseEntity(HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public MySalesOrderDetailResponseDto findMySalesOrderDetail(Long order_id){
public ResponseEntity deleteMySalesOrder(Long order_id){
Orders orders = orderRepository.findById(order_id)
.orElseThrow(()->new ResponseStatusException(HttpStatus.BAD_REQUEST));;
if (orders.isDel() == false)
orders.setDel(true);
if (orders.getIsDel() == 0)
orders.setIsDel(1);
return new ResponseEntity(HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
public class MySalesProjectController {
private final MySalesProjectService mySalesProjectService;

//판매 등록폼 전체보기
@GetMapping()
public MySalesListResponseDto getMySalesList(@RequestParam(value = "page", defaultValue = "1", required = false)int page, @AuthenticationPrincipal User user){
Pageable pageable = PageRequest.of(page - 1, 10);
Expand All @@ -29,6 +30,7 @@ public ResponseEntity finishMySales(@PathVariable Long project_id){
return mySalesProjectService.finishMySalesForm(project_id);
}

//판매 등록폼 상세보기
@GetMapping("/detail/{project_id}")
public MySalesDetailResponseDto getMySalesDetail(@PathVariable Long project_id){
return mySalesProjectService.findMySalesDetail(project_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public class MySalesDetailResponseDto {
private String seller_account;
private String seller_account_name;
private String seller_nickname;
private Long delivery_fee;
private String seller_phone_number;
private String seller_email;
private String seller_etc;


public MySalesDetailResponseDto(Project project, List<MySalesItemDto> itemDtos){
this.projectId = project.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ public class MySalesFormDto {
private String name;
private LocalDateTime createdtime;
private int status;
private String description;
private String thumbnail;

public MySalesFormDto(Project project){
this.id = project.getId();
this.name = project.getName();
this.createdtime = project.getCreated_time();
this.status = (project.isEnd() == false? 0 : 1);
this.description = project.getDescription();
this.thumbnail = project.getThumbnail();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface ItemRepository extends JpaRepository<Item, Long> {

@Query("SELECT COALESCE(SUM(od.count), 0) FROM OrderDetail od " +
"WHERE od.item.project = :project " +
"AND od.orders.isDel = false")
"AND od.orders.isDel = 0")
int getTotalOrderCountByProject(@Param("project") Project project);
//OrderDetail이 아닌 Item에서 주문 개수를 고려하여 프로젝트 별 주문 개수의 합을 구하는 쿼리

Expand Down

0 comments on commit 470ae10

Please sign in to comment.