From 504cd486155ab1f4d1d3398aa64d74289bb7c455 Mon Sep 17 00:00:00 2001 From: yunji118 Date: Sun, 7 Jan 2024 20:26:22 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[feat]=ED=8C=90=EB=A7=A4=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=ED=8F=BC=20=EC=83=81=EC=84=B8=EB=B3=B4=EA=B8=B0=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=EC=84=A4=EC=A0=95=20#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myorder/sales/controller/MyOrderSalesController.java | 8 ++++---- .../mypage/myorder/sales/service/MyOrderSalesService.java | 8 ++++++-- .../controller/MySalesProjectController.java | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java index 4c6afad..d82192a 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/controller/MyOrderSalesController.java @@ -27,12 +27,12 @@ public MyOrderFormListResponseDto getMyOrderList(@RequestParam(value = "page", d //나의 판매 주문폼 상세보기 @GetMapping("/detail/{order_id}") - public MyOrderSalesDetailResponseDto getMyDetailOrder(@PathVariable Long order_id){ - return myOrderService.findMyOrderFormDetail(order_id); + public MyOrderSalesDetailResponseDto getMyDetailOrder(@PathVariable Long order_id, @AuthenticationPrincipal User user){ + return myOrderService.findMyOrderFormDetail(order_id, user); } - //나의 주문폼 취소하기 - @DeleteMapping("/detail/{order_id}") + //나의 판매 주문폼 취소하기 + @PutMapping("/detail/{order_id}") public ResponseEntity deleteMyOrder(@PathVariable Long order_id){ return myOrderService.deleteMyOrderFormDetail(order_id); } diff --git a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderSalesService.java b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderSalesService.java index bf474ae..f90b474 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderSalesService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myorder/sales/service/MyOrderSalesService.java @@ -39,10 +39,14 @@ public MyOrderFormListResponseDto findAllMyOrderForm(Pageable pageable, User use } @Transactional(readOnly = true) - public MyOrderSalesDetailResponseDto findMyOrderFormDetail(Long order_id){ + public MyOrderSalesDetailResponseDto findMyOrderFormDetail(Long order_id, User user){ List ordersDetails = orderDetailRepository.findByOrders_Id(order_id); List orderFormDetailDtos = ordersDetails.stream().map(MyOrderSalesDetailItemDto::new).collect(Collectors.toList()); - Orders orders = orderRepository.findById(order_id).get(); + Orders orders = orderRepository.findById(order_id).orElseThrow(()->new ResponseStatusException(HttpStatus.BAD_REQUEST)); + if (user == null || user.getId() != orders.getUser().getId()){ + throw new ResponseStatusException(HttpStatus.BAD_REQUEST); + } + String address = orders.getAddress(); if (orders.getProject().getReceive_type().equals("pickup")) address = orders.getProject().getReceive_address(); 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 913c06a..e0aeef4 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("/myproject") +@RequestMapping("/myproject/sales") @RequiredArgsConstructor public class MySalesProjectController { private final MySalesProjectService mySalesProjectService; @@ -25,6 +25,7 @@ public MySalesListResponseDto getMySalesList(@RequestParam(value = "page", defau return mySalesProjectService.findAllMySalesForm(pageable, user); } + //판매 등록폼 종료 @PutMapping("/{project_id}") public ResponseEntity finishMySales(@PathVariable Long project_id){ return mySalesProjectService.finishMySalesForm(project_id); From d96b438e4b633f2a07d4556a9c848e541d3bbd5d Mon Sep 17 00:00:00 2001 From: yunji118 Date: Sun, 7 Jan 2024 20:36:00 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[feat]=ED=8C=90=EB=A7=A4=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=ED=8F=BC=20=EC=A2=85=EB=A3=8C=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myproject/MySalesOrder/service/MySalesOrderService.java | 2 +- .../MySalesProject/controller/MySalesProjectController.java | 4 ++-- .../MySalesProject/service/MySalesProjectService.java | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesOrder/service/MySalesOrderService.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesOrder/service/MySalesOrderService.java index 0840874..e772d5a 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesOrder/service/MySalesOrderService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesOrder/service/MySalesOrderService.java @@ -70,7 +70,7 @@ public MySalesOrderDetailResponseDto findMySalesOrderDetail(Long order_id, User List orderDetails = orderDetailRepository.findByOrders_Id(order_id); String address = orders.getAddress(); - if (orders.getProject().getReceive_type().equals("pickup")) + if (orders.getProject().getReceive_type().equals("PICKUP")) address = orders.getProject().getReceive_address(); List orderDetailDtos = orderDetails.stream().map(MySalesOrderDetailDto::new).collect(Collectors.toList()); MySalesOrderDetailResponseDto responseDto = new MySalesOrderDetailResponseDto(orderDetailDtos, orders, address); 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 e0aeef4..2832971 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 @@ -27,8 +27,8 @@ public MySalesListResponseDto getMySalesList(@RequestParam(value = "page", defau //판매 등록폼 종료 @PutMapping("/{project_id}") - public ResponseEntity finishMySales(@PathVariable Long project_id){ - return mySalesProjectService.finishMySalesForm(project_id); + public ResponseEntity finishMySales(@PathVariable Long project_id, @AuthenticationPrincipal User user){ + return mySalesProjectService.finishMySalesForm(project_id, user); } //판매 등록폼 상세보기 diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java index 7d2ae41..22d16a2 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java @@ -40,9 +40,12 @@ public MySalesListResponseDto findAllMySalesForm(Pageable pageable, User user){ } @Transactional - public ResponseEntity finishMySalesForm(Long project_id){ + public ResponseEntity finishMySalesForm(Long project_id, User user){ Project project = projectRepository.findById(project_id) .orElseThrow(()->new ResponseStatusException(HttpStatus.BAD_REQUEST)); + if (user == null || project.getUser().getId() != user.getId()){ + throw new ResponseStatusException(HttpStatus.BAD_REQUEST); + } if (project.isEnd() == false) project.setEnd(true); return new ResponseEntity(HttpStatus.OK); From 2c4c661898c30523f58605d803aa24ab18a3ea8d Mon Sep 17 00:00:00 2001 From: yunji118 Date: Sun, 7 Jan 2024 21:47:29 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[feat]receiveTypeConverter=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../converter/ReceiveTypeConverter.java | 21 +++++++ .../wowmarket/wow_server/domain/Category.java | 2 + .../wowmarket/wow_server/domain/Project.java | 25 ++++++++ .../wow_server/domain/ReceiveType.java | 19 +++++- .../controller/MySalesProjectController.java | 8 +++ .../dto/MySalesProjectModifyRequestDto.java | 62 +++++++++++++++++++ .../service/MySalesProjectService.java | 16 +++-- 7 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 src/main/java/wowmarket/wow_server/converter/ReceiveTypeConverter.java create mode 100644 src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java diff --git a/src/main/java/wowmarket/wow_server/converter/ReceiveTypeConverter.java b/src/main/java/wowmarket/wow_server/converter/ReceiveTypeConverter.java new file mode 100644 index 0000000..482b8f0 --- /dev/null +++ b/src/main/java/wowmarket/wow_server/converter/ReceiveTypeConverter.java @@ -0,0 +1,21 @@ +package wowmarket.wow_server.converter; + +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; +import wowmarket.wow_server.domain.ReceiveType; + +@Converter +public class ReceiveTypeConverter implements AttributeConverter { + + @Override + public Long convertToDatabaseColumn(ReceiveType receiveType) { + if (receiveType == null) + return null; + return receiveType.getCode(); + } + + @Override + public ReceiveType convertToEntityAttribute(Long dbData) { + return ReceiveType.ofReceiveType(dbData); + } +} diff --git a/src/main/java/wowmarket/wow_server/domain/Category.java b/src/main/java/wowmarket/wow_server/domain/Category.java index 57f0ee5..235b9fe 100644 --- a/src/main/java/wowmarket/wow_server/domain/Category.java +++ b/src/main/java/wowmarket/wow_server/domain/Category.java @@ -15,4 +15,6 @@ public class Category { private Long id; private String name; + + } diff --git a/src/main/java/wowmarket/wow_server/domain/Project.java b/src/main/java/wowmarket/wow_server/domain/Project.java index d772bb0..d5d0199 100644 --- a/src/main/java/wowmarket/wow_server/domain/Project.java +++ b/src/main/java/wowmarket/wow_server/domain/Project.java @@ -3,6 +3,8 @@ import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.Check; +import wowmarket.wow_server.converter.ReceiveTypeConverter; +import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesProjectModifyRequestDto; import java.time.LocalDate; import java.time.LocalDateTime; @@ -48,6 +50,7 @@ public class Project extends BaseEntity{ @Enumerated(EnumType.STRING) + @Convert(converter = ReceiveTypeConverter.class) private ReceiveType receive_type; //delivery, pickup private String receive_address; //직접수령 시 픽업장소 private String deliveryType; // 배송 시 배송 방법 @@ -85,6 +88,28 @@ public void setCategory(Category category){ this.category = category; } + public void modify(MySalesProjectModifyRequestDto requestDto){ + this.projectName = requestDto.getProjectName(); + this.description = requestDto.getDescription(); + this.sellerName = requestDto.getSellerName(); + this.phoneNumber = requestDto.getSellerPhoneNumber(); + this.email = requestDto.getSellerEmail(); + this.sellerEtc = requestDto.getSellerEtc(); + this.category = requestDto.getCategoryId(); + this.thumbnail = requestDto.getThumbnail(); + this.image1 = requestDto.getImage1(); + this.image2 = requestDto.getImage2(); + this.image3 = requestDto.getImage3(); + this.startDate = requestDto.getStartDate(); + this.endDate = requestDto.getEndDate(); + this.receive_type = ReceiveType.ofReceiveType(requestDto.getCategoryId()); + this.receive_address = requestDto.getReceiveAddress(); + this.delivery_fee = requestDto.getDeliveryFee(); + this.bank = requestDto.getSellerBank(); + this.account = requestDto.getSellerAccount(); + this.account_holder_name = requestDto.getSellerAccountName(); + //this.sellToAll = sellToAll; + } } diff --git a/src/main/java/wowmarket/wow_server/domain/ReceiveType.java b/src/main/java/wowmarket/wow_server/domain/ReceiveType.java index 3aa6abc..b16010f 100644 --- a/src/main/java/wowmarket/wow_server/domain/ReceiveType.java +++ b/src/main/java/wowmarket/wow_server/domain/ReceiveType.java @@ -1,8 +1,25 @@ package wowmarket.wow_server.domain; import com.fasterxml.jackson.databind.annotation.EnumNaming; +import lombok.Getter; +import java.util.Arrays; + +@Getter public enum ReceiveType { - DELIVERY, PICKUP, ALL; + DELIVERY(1L), PICKUP(2L), ALL(3L); + + private Long code; + + private ReceiveType(Long code) { + this.code = code; + } + + public static ReceiveType ofReceiveType(Long code){ + return Arrays.stream(ReceiveType.values()) + .filter(v -> v.getCode().equals(code)) + .findAny() + .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 수령방법입니다.")); + } } 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 2832971..c1c2a68 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 @@ -1,5 +1,6 @@ package wowmarket.wow_server.mypage.myproject.MySalesProject.controller; +import com.nimbusds.oauth2.sdk.Response; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -10,6 +11,7 @@ import wowmarket.wow_server.domain.User; import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesDetailResponseDto; import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesListResponseDto; +import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesProjectModifyRequestDto; import wowmarket.wow_server.mypage.myproject.MySalesProject.service.MySalesProjectService; @RestController @@ -37,4 +39,10 @@ public MySalesDetailResponseDto getMySalesDetail(@PathVariable Long project_id){ return mySalesProjectService.findMySalesDetail(project_id); } + //판매 등록폼 수정하기 + @PutMapping("/{project_id}/modify") + public ResponseEntity modifyMySalesProject(@PathVariable Long project_id, @RequestBody MySalesProjectModifyRequestDto requestDto, @AuthenticationPrincipal User user){ + return mySalesProjectService.modifyMySalesProject(project_id, requestDto, user); + } + } diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java new file mode 100644 index 0000000..4c985cb --- /dev/null +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java @@ -0,0 +1,62 @@ +package wowmarket.wow_server.mypage.myproject.MySalesProject.dto; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import wowmarket.wow_server.domain.Category; +import wowmarket.wow_server.domain.ReceiveType; + +import java.time.LocalDateTime; +import java.util.List; + +@Getter +@NoArgsConstructor +public class MySalesProjectModifyRequestDto { + private String projectName; + private String description; + private String thumbnail; + private Long categoryId; + private String image1; + private String image2; + private String image3; + private List itemList; + private LocalDateTime startDate; + private LocalDateTime endDate; + private String receiveType; + private String receiveAddress; + private String sellerBank; + private String sellerAccount; + private String sellerAccountName; + private String sellerName; + private Long deliveryFee; + private String sellerPhoneNumber; + private String sellerEmail; + private String sellerEtc; + + @Builder + public MySalesProjectModifyRequestDto(String projectName, String description, String sellerName, String phoneNumber, String email, String sellerEtc, + Long categoryId, String thumbnail, String image1, String image2, String image3, LocalDateTime startDate, + LocalDateTime endDate, String receiveType, String receiveAddress, Long deliveryFee, String bank, String account, + String accountHolderName, List itemList){ + this.projectName = projectName; + this.description = description; + this.sellerName = sellerName; + this.sellerPhoneNumber = phoneNumber; + this.sellerEmail = email; + this.sellerEtc = sellerEtc; + this.categoryId = categoryId; + this.thumbnail = thumbnail; + this.image1 = image1; + this.image2 = image2; + this.image3 = image3; + this.startDate = startDate; + this.endDate = endDate; + this.receiveType = receiveType; + this.receiveAddress = receiveAddress; + this.deliveryFee = deliveryFee; + this.sellerBank = bank; + this.sellerAccount = account; + this.sellerAccountName = accountHolderName; + this.itemList = itemList; + } +} diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java index 22d16a2..05b9377 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java @@ -1,5 +1,6 @@ package wowmarket.wow_server.mypage.myproject.MySalesProject.service; +import com.nimbusds.oauth2.sdk.Response; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -12,10 +13,7 @@ import wowmarket.wow_server.domain.Project; import wowmarket.wow_server.domain.User; import wowmarket.wow_server.global.jwt.SecurityUtil; -import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesDetailResponseDto; -import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesFormDto; -import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesItemDto; -import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesListResponseDto; +import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.*; import wowmarket.wow_server.repository.*; import java.util.List; @@ -61,4 +59,14 @@ public MySalesDetailResponseDto findMySalesDetail(Long project_id){ return responseDto; } + @Transactional + public ResponseEntity modifyMySalesProject(Long projectId, MySalesProjectModifyRequestDto requestDto, User user){ + Project project = projectRepository.findById(projectId).orElseThrow(()->new IllegalArgumentException("해당 project id가 없습니다.")); + if (user == null || project.getUser().getId() != user.getId()){ + throw new ResponseStatusException(HttpStatus.BAD_REQUEST); + } + project.modify(requestDto); + return new ResponseEntity(HttpStatus.OK); + } + } From db19dbee06e768b48f3e8425b673ef236180c5b8 Mon Sep 17 00:00:00 2001 From: yunji118 Date: Sun, 7 Jan 2024 22:29:39 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[feat]=ED=8C=90=EB=A7=A4=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=ED=8F=BC=20=EC=88=98=EC=A0=95-item=EC=A0=9C=EC=99=B8?= =?UTF-8?q?=20#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/wowmarket/wow_server/domain/Project.java | 7 ++++--- .../dto/MySalesProjectModifyRequestDto.java | 8 ++++---- .../MySalesProject/service/MySalesProjectService.java | 6 +++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/wowmarket/wow_server/domain/Project.java b/src/main/java/wowmarket/wow_server/domain/Project.java index d5d0199..da9e7f8 100644 --- a/src/main/java/wowmarket/wow_server/domain/Project.java +++ b/src/main/java/wowmarket/wow_server/domain/Project.java @@ -88,28 +88,29 @@ public void setCategory(Category category){ this.category = category; } - public void modify(MySalesProjectModifyRequestDto requestDto){ + public void modify(MySalesProjectModifyRequestDto requestDto, Category category){ this.projectName = requestDto.getProjectName(); this.description = requestDto.getDescription(); this.sellerName = requestDto.getSellerName(); this.phoneNumber = requestDto.getSellerPhoneNumber(); this.email = requestDto.getSellerEmail(); this.sellerEtc = requestDto.getSellerEtc(); - this.category = requestDto.getCategoryId(); this.thumbnail = requestDto.getThumbnail(); this.image1 = requestDto.getImage1(); this.image2 = requestDto.getImage2(); this.image3 = requestDto.getImage3(); this.startDate = requestDto.getStartDate(); this.endDate = requestDto.getEndDate(); - this.receive_type = ReceiveType.ofReceiveType(requestDto.getCategoryId()); + this.receive_type = ReceiveType.ofReceiveType(requestDto.getReceiveType()); this.receive_address = requestDto.getReceiveAddress(); this.delivery_fee = requestDto.getDeliveryFee(); this.bank = requestDto.getSellerBank(); this.account = requestDto.getSellerAccount(); this.account_holder_name = requestDto.getSellerAccountName(); + this.category = category; //this.sellToAll = sellToAll; } + } diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java index 4c985cb..b83bc7c 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java @@ -15,14 +15,14 @@ public class MySalesProjectModifyRequestDto { private String projectName; private String description; private String thumbnail; - private Long categoryId; + private int categoryId; private String image1; private String image2; private String image3; private List itemList; private LocalDateTime startDate; private LocalDateTime endDate; - private String receiveType; + private Long receiveType; private String receiveAddress; private String sellerBank; private String sellerAccount; @@ -35,8 +35,8 @@ public class MySalesProjectModifyRequestDto { @Builder public MySalesProjectModifyRequestDto(String projectName, String description, String sellerName, String phoneNumber, String email, String sellerEtc, - Long categoryId, String thumbnail, String image1, String image2, String image3, LocalDateTime startDate, - LocalDateTime endDate, String receiveType, String receiveAddress, Long deliveryFee, String bank, String account, + int categoryId, String thumbnail, String image1, String image2, String image3, LocalDateTime startDate, + LocalDateTime endDate, Long receiveType, String receiveAddress, Long deliveryFee, String bank, String account, String accountHolderName, List itemList){ this.projectName = projectName; this.description = description; diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java index 05b9377..4f0a30f 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.server.ResponseStatusException; +import wowmarket.wow_server.domain.Category; import wowmarket.wow_server.domain.Item; import wowmarket.wow_server.domain.Project; import wowmarket.wow_server.domain.User; @@ -25,6 +26,7 @@ public class MySalesProjectService { private final ProjectRepository projectRepository; private final ItemRepository itemRepository; private final UserRepository userRepository; + private final CategoryRepository categoryRepository; @Transactional(readOnly = true) public MySalesListResponseDto findAllMySalesForm(Pageable pageable, User user){ @@ -65,7 +67,9 @@ public ResponseEntity modifyMySalesProject(Long projectId, MySalesProjectModifyR if (user == null || project.getUser().getId() != user.getId()){ throw new ResponseStatusException(HttpStatus.BAD_REQUEST); } - project.modify(requestDto); + Category category = categoryRepository.findById(Long.valueOf(requestDto.getCategoryId())).orElseThrow(() -> new IllegalArgumentException("해당 category id가 없습니다.")); + project.modify(requestDto, category); + projectRepository.save(project); return new ResponseEntity(HttpStatus.OK); } From 870f4155d9f1dbb867c61744f44b382e1de1fb1f Mon Sep 17 00:00:00 2001 From: yunji118 Date: Sun, 7 Jan 2024 22:30:01 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[feat]=ED=8C=90=EB=A7=A4=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=ED=8F=BC=20=EC=88=98=EC=A0=95-item=EC=A0=9C=EC=99=B8?= =?UTF-8?q?=20#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/wowmarket/wow_server/domain/Category.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/wowmarket/wow_server/domain/Category.java b/src/main/java/wowmarket/wow_server/domain/Category.java index 235b9fe..6502258 100644 --- a/src/main/java/wowmarket/wow_server/domain/Category.java +++ b/src/main/java/wowmarket/wow_server/domain/Category.java @@ -16,5 +16,4 @@ public class Category { private String name; - } From 2ff38d60cbc1aa05cf44414e2907542f6b7b269f Mon Sep 17 00:00:00 2001 From: yunji118 Date: Sun, 7 Jan 2024 22:41:54 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[feat]=ED=8C=90=EB=A7=A4=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=ED=8F=BC=20=EC=88=98=EC=A0=95=20=EC=99=84=EB=A3=8C=20?= =?UTF-8?q?#137?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/wowmarket/wow_server/domain/Item.java | 8 ++++++++ .../myproject/MySalesProject/dto/MySalesItemDto.java | 2 ++ .../dto/MySalesProjectModifyRequestDto.java | 4 ++-- .../service/MySalesProjectService.java | 12 ++++++++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/wowmarket/wow_server/domain/Item.java b/src/main/java/wowmarket/wow_server/domain/Item.java index 9d33e91..035305e 100644 --- a/src/main/java/wowmarket/wow_server/domain/Item.java +++ b/src/main/java/wowmarket/wow_server/domain/Item.java @@ -3,6 +3,7 @@ import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.ColumnDefault; +import wowmarket.wow_server.mypage.myproject.MySalesProject.dto.MySalesItemDto; @Entity @Getter @@ -31,4 +32,11 @@ public void setProject(Project project){ this.project = project; } + public void modify(MySalesItemDto itemDto){ + this.name = itemDto.getItemName(); + this.price = itemDto.getPrice(); + this.goal = itemDto.getGoal(); + this.limits = itemDto.getLimits(); + } + } diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesItemDto.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesItemDto.java index 9f4a6f7..601dbc3 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesItemDto.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesItemDto.java @@ -10,6 +10,7 @@ public class MySalesItemDto { private Long itemId; private String itemName; private Long price; + private int limits; private int goal; public MySalesItemDto(Item item){ @@ -17,5 +18,6 @@ public MySalesItemDto(Item item){ this.itemName = item.getName(); this.price = item.getPrice(); this.goal = item.getGoal(); + this.limits = item.getLimits(); } } diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java index b83bc7c..fd66f50 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/dto/MySalesProjectModifyRequestDto.java @@ -15,7 +15,7 @@ public class MySalesProjectModifyRequestDto { private String projectName; private String description; private String thumbnail; - private int categoryId; + private Long categoryId; private String image1; private String image2; private String image3; @@ -35,7 +35,7 @@ public class MySalesProjectModifyRequestDto { @Builder public MySalesProjectModifyRequestDto(String projectName, String description, String sellerName, String phoneNumber, String email, String sellerEtc, - int categoryId, String thumbnail, String image1, String image2, String image3, LocalDateTime startDate, + Long categoryId, String thumbnail, String image1, String image2, String image3, LocalDateTime startDate, LocalDateTime endDate, Long receiveType, String receiveAddress, Long deliveryFee, String bank, String account, String accountHolderName, List itemList){ this.projectName = projectName; diff --git a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java index 4f0a30f..76782e5 100644 --- a/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java +++ b/src/main/java/wowmarket/wow_server/mypage/myproject/MySalesProject/service/MySalesProjectService.java @@ -25,7 +25,6 @@ public class MySalesProjectService { private final ProjectRepository projectRepository; private final ItemRepository itemRepository; - private final UserRepository userRepository; private final CategoryRepository categoryRepository; @Transactional(readOnly = true) @@ -67,8 +66,17 @@ public ResponseEntity modifyMySalesProject(Long projectId, MySalesProjectModifyR if (user == null || project.getUser().getId() != user.getId()){ throw new ResponseStatusException(HttpStatus.BAD_REQUEST); } - Category category = categoryRepository.findById(Long.valueOf(requestDto.getCategoryId())).orElseThrow(() -> new IllegalArgumentException("해당 category id가 없습니다.")); + Category category = categoryRepository.findById(requestDto.getCategoryId()).orElseThrow(() -> new IllegalArgumentException("해당 category id가 없습니다.")); project.modify(requestDto, category); + + + for(int i=0;i