Skip to content

Commit

Permalink
[feat]order isDel boolean->int로 변경#137
Browse files Browse the repository at this point in the history
  • Loading branch information
yunji118 committed Dec 28, 2023
1 parent 8aff1e0 commit 41dcd08
Show file tree
Hide file tree
Showing 6 changed files with 13 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 @@ -14,13 +14,13 @@ public class MyOrderFormResponseDto {
private String name;
private LocalDateTime createdtime;
private int status;
private boolean isdel;
private int isdel;

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.isdel = order.getIsDel();
}
}
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 @@ -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 41dcd08

Please sign in to comment.