From 2a183d718d0149224a35f79e1ea5b8251f59e763 Mon Sep 17 00:00:00 2001 From: Odongdong Date: Mon, 25 Sep 2023 23:31:49 +0900 Subject: [PATCH] Feat/auction registration (#60) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [feat] 경매 등록 기능 * feat:아이템관련 * Jong1 : Branch test * feat : 사진 resize 및 미리보기 출력 기능완료 * style : 필요없는 주석 삭제 * 테스트db 추가 * feat: 이미지url불러오기 * testDB 수정 * enum추가 * style : 코드 정리 * style : 코드 스타일 변경 * feat : enum값에 따른 출력변경기능 * test : html화면 테스트 * 불필요코드 삭제 * 불필요 코드 삭제 * style : 필요없는 import 삭제 * 불필요파일 삭제 * 불필요파일 삭제 * feat : 경매중인 물품 리스트출력(사진) * fix : 버킷명 변경 * feat : 페이지네이션 구현 * feat : 상태별 페이지변환 구현 * feat : 경매아이템 상태별 보기 * fix : 페이지네이션버그 수정 * feat : 페이지네이션버튼 동작 구현 * feat : 상품 리스트관련 * feat: modal, index header, footer 수정 #45 * feat : Login, Join Link 추가 * feat : footer 링크 추가 및 Project 정보 추가 * 불필요 코드 정리 및 테스트파일 정리 * feat : Header수정, 및 Bootstrap파일 변경을 위해서 Bootstrap 직접 static에서 가져오도록 변경, 관리자 계정 쿼리 추가 * test : 일단 실패 안나게 수정.. * 삭제하면 안되는 파일 Revert * favicon Rollback * feat : 관리자 UI작업중 * style : footer size 변경 * feat : 로그아웃 li 추가, 로그인시 사용자 닉네임과 포인트 출력 추가 * style : UI Header, 관리자 컷 * feat : 메인페이지 UI - 경매품 이미지 출력 및 Detail페이지로 이동 할 수 있게 a태그 설정. - 출력할 물품이 없는 경우에 맞는 Block추가 - More 버튼 이벤트 추가 - Vanila Javascript Function 생성 및 인자값에 따라 다르게 가져 올 수 있도록 생성. * tempSave * feat : 상세보기 * Merge Dev Branch And Conflict Resolve --------- Co-authored-by: bongsh0112 Co-authored-by: donsonioc2010 --- .../auction/controller/PictureController.java | 78 ++++++---- .../api/auction/service/PictureService.java | 5 + .../controller/PaymentController.java | 52 +++---- .../request/PostCreatePaymentRequest.java | 2 + .../server/api/user/service/UserService.java | 4 + Api/src/main/resources/static/css/add.css | 33 +++++ Api/src/main/resources/static/css/add2.css | 65 ++++++++ Api/src/main/resources/static/css/detail.css | 139 ++++++++++++++---- Api/src/main/resources/static/css/index.css | 11 ++ .../main/resources/templates/imageList.html | 2 + Api/src/main/resources/templates/modal.html | 44 ++++++ .../templates/pictures/createPictureForm.html | 34 ++--- .../templates/pictures/pictureDetail.html | 51 +++++++ .../server/domain/domains/dto/PictureDTO.java | 2 + .../server/domain/domains/items/Picture.java | 13 +- .../domain/domains/items/PictureInfo.java | 1 + .../domains/repository/PictureRepository.java | 1 - .../domain/domains/user/entity/User.java | 9 ++ .../user/repository/UserRepository.java | 2 +- Domain/src/main/resources/data.sql | 6 +- 20 files changed, 449 insertions(+), 105 deletions(-) create mode 100644 Api/src/main/resources/static/css/add2.css create mode 100644 Api/src/main/resources/templates/modal.html create mode 100644 Api/src/main/resources/templates/pictures/pictureDetail.html diff --git a/Api/src/main/java/picasso/server/api/auction/controller/PictureController.java b/Api/src/main/java/picasso/server/api/auction/controller/PictureController.java index 06cd0232..f7d96804 100644 --- a/Api/src/main/java/picasso/server/api/auction/controller/PictureController.java +++ b/Api/src/main/java/picasso/server/api/auction/controller/PictureController.java @@ -1,25 +1,28 @@ package picasso.server.api.auction.controller; +import jakarta.servlet.http.HttpSession; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import picasso.server.api.auction.service.PictureService; +import picasso.server.api.user.service.UserService; import picasso.server.common.util.NaverObjectStorageUsageType; import picasso.server.common.util.NaverObjectStorageUtil; import picasso.server.domain.domains.dto.PictureDTO; +import picasso.server.domain.domains.dto.UserDTO; import picasso.server.domain.domains.items.Picture; import picasso.server.domain.domains.items.PictureInfo; import picasso.server.domain.domains.items.PictureStatus; +import picasso.server.domain.domains.user.entity.User; +import picasso.server.domain.domains.user.repository.UserRepository; import java.util.ArrayList; import java.util.List; +import java.util.Optional; @Slf4j @@ -29,6 +32,7 @@ public class PictureController { private final PictureService pictureService; + private final UserService userService; private final NaverObjectStorageUtil naverObjectStorageUtil; @GetMapping("/new") public String createForm(Model model) { @@ -37,29 +41,41 @@ public String createForm(Model model) { } @PostMapping - public String add(PictureDTO dto, MultipartFile imageFile, Model model) { - Picture picture = new Picture(); - picture.setPictureId(dto.getPictureId()); - picture.setPictureName(dto.getPictureName()); - picture.setPainterName(dto.getPainterName()); - picture.setSize(dto.getSize()); - picture.setDetails(dto.getDetails()); - picture.setStartingPrice(dto.getStartingPrice()); - picture.setIncrementAmount(dto.getIncrementAmount()); - picture.setBidStartDate(dto.getBidStartDate()); - //희망 경매일자 + 7일 - picture.setBidEndDate(dto.getBidStartDate().plusDays(7)); - - List imageUrls = new ArrayList<>(); - if (imageFile != null && !imageFile.isEmpty()) { - String imageUrl = naverObjectStorageUtil.storageFileUpload(NaverObjectStorageUsageType.PAINT, imageFile); - picture.setImgUrl(imageUrl); - imageUrls.add(imageUrl); - model.addAttribute("imageUrls", imageUrls); - model.addAttribute("imgURL", imageUrl); + public String add(PictureDTO requestDto,Model model, HttpSession session) { + + User sessionUser = (User) session.getAttribute("loginUser"); + if (sessionUser == null) { + return "redirect:/auth/login"; //로그인 페이지로 } - pictureService.saveItem(picture); //- 이 부분은 필요에 따라 주석처리 + userService.findById(sessionUser.getId()).ifPresent(user -> { + Picture picture = new Picture(); + picture.setPictureId(requestDto.getPictureId()); + picture.setPictureName(requestDto.getPictureName()); + picture.setPainterName(requestDto.getPainterName()); + picture.setSize(requestDto.getSize()); + picture.setDetails(requestDto.getDetails()); + picture.setStartingPrice(requestDto.getStartingPrice()); + picture.setIncrementAmount(requestDto.getIncrementAmount()); + picture.setBidStartDate(requestDto.getBidStartDate()); + + + //희망 경매일자 + 7일 + picture.setBidEndDate(requestDto.getBidStartDate().plusDays(7)); + + List imageUrls = new ArrayList<>(); + if ( requestDto.getImageFile() != null && !requestDto.getImageFile().isEmpty()) { + String imageUrl = naverObjectStorageUtil.storageFileUpload(NaverObjectStorageUsageType.PAINT, requestDto.getImageFile()); + picture.setImgUrl(imageUrl); + imageUrls.add(imageUrl); + model.addAttribute("imageUrls", imageUrls); + model.addAttribute("imgURL", imageUrl); + log.error("Image URL : " + imageUrl); + } + + picture.setUser(user); + pictureService.saveItem(picture); //- 이 부분은 필요에 따라 주석처리 + }); return "redirect:/pictures/list?page=0&pageSize=10&status=BIDDING"; } @@ -139,4 +155,16 @@ public String imgUrls(Model model, return "imageList"; } + @GetMapping("/{id}") + public String viewPictureDetail(@PathVariable Long id, Model model) { + Optional pictureOptional = pictureService.getPictureById(id); + + if(pictureOptional.isPresent()) { + Picture picture = pictureOptional.get(); + model.addAttribute("picture", picture); + return "pictures/pictureDetail"; + } else { + return "error"; + } + } } diff --git a/Api/src/main/java/picasso/server/api/auction/service/PictureService.java b/Api/src/main/java/picasso/server/api/auction/service/PictureService.java index eab2e5e1..a38173d1 100644 --- a/Api/src/main/java/picasso/server/api/auction/service/PictureService.java +++ b/Api/src/main/java/picasso/server/api/auction/service/PictureService.java @@ -144,6 +144,7 @@ public Page preparePictureInfoPage(int page, int pageSize, PictureS private PictureInfo mapToPictureInfo(Picture picture) { PictureInfo pictureInfo = new PictureInfo(); + pictureInfo.setId((picture.getPictureId())); pictureInfo.setImageUrl(picture.getImgUrl()); pictureInfo.setDetails(picture.getDetails()); pictureInfo.setPictureName(picture.getPictureName()); @@ -154,4 +155,8 @@ private PictureInfo mapToPictureInfo(Picture picture) { return pictureInfo; } + public Optional getPictureById(Long id) { + return pictureRepository.findById(id); + } + } diff --git a/Api/src/main/java/picasso/server/api/exchange/controller/PaymentController.java b/Api/src/main/java/picasso/server/api/exchange/controller/PaymentController.java index a6a8bd1e..e56acc2f 100644 --- a/Api/src/main/java/picasso/server/api/exchange/controller/PaymentController.java +++ b/Api/src/main/java/picasso/server/api/exchange/controller/PaymentController.java @@ -20,30 +20,30 @@ @RequiredArgsConstructor @Controller public class PaymentController { - - private final PaymentService paymentService; - private final UserService userService; - - @GetMapping("/payment") - public String paymentForm() { - return "payment/payment"; - } - - @GetMapping("/success") - public String paymentSuccess() { - return "exchange/success"; - } - - @GetMapping("/failed") - public String paymentFailed() { - return "exchange/failed"; - } - - @ResponseBody - @PostMapping("/payment") - public void createPayment(@RequestBody PostCreatePaymentRequest body) { - paymentService.savePaymentHistory(body); - Optional user = userService.findUserById(body.getUserId()); - user.ifPresent(u -> u.updatePoint(body.getPaidAmount())); - } + + private final PaymentService paymentService; + private final UserService userService; + + @GetMapping("/payment") + public String paymentForm() { + return "payment/payment"; + } + + @GetMapping("/success") + public String paymentSuccess() { + return "exchange/success"; + } + + @GetMapping("/failed") + public String paymentFailed() { + return "exchange/failed"; + } + + @ResponseBody + @PostMapping("/payment") + public void createPayment(@RequestBody PostCreatePaymentRequest body) { + paymentService.savePaymentHistory(body); + Optional user = userService.findUserById(body.getUserId()); + user.ifPresent(u -> u.updatePoint(body.getPaidAmount())); + } } \ No newline at end of file diff --git a/Api/src/main/java/picasso/server/api/exchange/model/request/PostCreatePaymentRequest.java b/Api/src/main/java/picasso/server/api/exchange/model/request/PostCreatePaymentRequest.java index 99a021e7..07365b16 100644 --- a/Api/src/main/java/picasso/server/api/exchange/model/request/PostCreatePaymentRequest.java +++ b/Api/src/main/java/picasso/server/api/exchange/model/request/PostCreatePaymentRequest.java @@ -2,9 +2,11 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.ToString; @Getter @NoArgsConstructor +@ToString public class PostCreatePaymentRequest { private Boolean payResult; private Long userId; diff --git a/Api/src/main/java/picasso/server/api/user/service/UserService.java b/Api/src/main/java/picasso/server/api/user/service/UserService.java index 9070a67d..193957b8 100644 --- a/Api/src/main/java/picasso/server/api/user/service/UserService.java +++ b/Api/src/main/java/picasso/server/api/user/service/UserService.java @@ -72,4 +72,8 @@ public void deleteUserById(Long id) { public Optional findUserById(Long id) { return userRepository.findById(id); } + + public Optional findById(Long userId) { + return userRepository.findById(userId); + } } diff --git a/Api/src/main/resources/static/css/add.css b/Api/src/main/resources/static/css/add.css index 44e4e7f6..6c12ae4b 100644 --- a/Api/src/main/resources/static/css/add.css +++ b/Api/src/main/resources/static/css/add.css @@ -34,7 +34,40 @@ form { } .section { + background-color: #ffffff; margin-bottom: 20px; width: 100%; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + box-sizing: border-box; +} +/*.section {*/ +/* padding: 20px;*/ +/* border-radius: 10px;*/ +/* max-width: 80%;*/ +/* width: 100%;*/ +/*}*/ + + +.section button { + position: relative; + left: 70px; + padding: 10px 20px; + font-size: 16px; + background-color: #337ab7; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + display: flex; +} + + +.section-container { + display: flex; + justify-content: center; + align-items: center; + height: 850px; + background-color: #f0f0f0; + padding: 20px; box-sizing: border-box; } \ No newline at end of file diff --git a/Api/src/main/resources/static/css/add2.css b/Api/src/main/resources/static/css/add2.css new file mode 100644 index 00000000..5dc85c5f --- /dev/null +++ b/Api/src/main/resources/static/css/add2.css @@ -0,0 +1,65 @@ +/* styles.css */ + +.section-container { + display: flex; + justify-content: center; /* Center content horizontally */ + align-items: center; + height: 100vh; + background-color: #f0f0f0; + padding: 20px; /* Add padding for spacing */ + box-sizing: border-box; /* Include padding in element's total width and height */ +} + +.section { + background-color: #ffffff; + padding: 20px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + max-width: 80%; + width: 100%; +} + +.section h4 { + margin-bottom: 10px; + font-size: 1.2em; +} + +.section label { + display: block; + margin-bottom: 5px; +} + +.section input[type="text"], +.section input[type="number"], +.section textarea { + width: calc(100% - 16px); /* Adjusted: Considering padding and border */ + padding: 8px; + margin-bottom: 10px; + border: 1px solid #ccc; + border-radius: 4px; + box-sizing: border-box; +} + +.section input[type="date"] { + padding: 8px; + margin-bottom: 10px; +} + +.section button { + padding: 10px 20px; + font-size: 16px; + background-color: #337ab7; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; +} + +.section button:hover { + background-color: #286090; +} + +.fixed-textarea { + resize: none; + height: 100px; +} diff --git a/Api/src/main/resources/static/css/detail.css b/Api/src/main/resources/static/css/detail.css index f26b75a3..2ed18ba7 100644 --- a/Api/src/main/resources/static/css/detail.css +++ b/Api/src/main/resources/static/css/detail.css @@ -1,40 +1,129 @@ -body { - font-family: Arial, sans-serif; - padding: 20px; +/*body {*/ +/* font-family: Arial, sans-serif;*/ +/* padding: 20px;*/ +/*}*/ + +/*h1 {*/ +/* color: blue;*/ +/*}*/ + +/*table {*/ +/* width: 100%;*/ +/* border-collapse: collapse;*/ +/* margin-top: 20px;*/ +/*}*/ + +/*th, td {*/ +/* border: 1px solid black;*/ +/* padding: 10px;*/ +/*}*/ + +/*th {*/ +/* background-color: #f0f0f0;*/ +/* font-weight: bold;*/ +/*}*/ + +/*td {*/ +/* text-align: left;*/ +/*}*/ + +/*button {*/ +/* padding: 10px 20px;*/ +/* background-color: #008CBA;*/ +/* color: white;*/ +/* border: none;*/ +/* cursor: pointer;*/ +/*}*/ + +/*button:hover {*/ +/* background-color: #005f6b;*/ +/*}*/ + +.picture-details { + display: flex; + align-items: center; } -h1 { - color: blue; +.picture-img { + border: 2px solid #DB8681; /* 테두리 스타일 및 색상 설정 */ + border-radius: 10px; /* 테두리 둥글기 설정 */ } -table { - width: 100%; - border-collapse: collapse; - margin-top: 20px; +.picture-details img { + margin-right: 10px; /* Adjust margin as needed */ } -th, td { - border: 1px solid black; - padding: 10px; +.details-info { + float: right; + font-family: 'Kranky', sans-serif; /* Kranky 폰트 적용 */ } -th { - background-color: #f0f0f0; - font-weight: bold; +.details-info .text { + font-family: 'Noto Sans Kannada', sans-serif; } -td { - text-align: left; +.details-box { + padding: 20px; /* Padding inside the box */ + border-radius: 10px; /* 테두리 둥글기 설정 */ + color: #99F54D; + text-shadow: 4px 4px 10px rgba(219, 134, 129, 0.9); + box-shadow: 0px 0px 10px rgba(219, 134, 129, 86); + font-size: 31px; } -button { - padding: 10px 20px; - background-color: #008CBA; - color: white; - border: none; - cursor: pointer; +.details-box .btn { + position: absolute; + bottom: 40px; + right: 900px; + width: 110px; + height: 50px; + font-size: 30px; + color: #99F54D; + box-shadow: 0px 0px 10px rgba(219, 134, 129, 86); + + background-color: #761766; + z-index: 2; } -button:hover { - background-color: #005f6b; +/* Optional: Adjust margin between the box and other elements */ +.details-box + * { + margin-top: 20px; } + +.kuro { + width: 300px; + position: absolute; + left: 450px; + top: 680px; +} + +.kuro2 { + width: 200px; + position: absolute; + left: 900px; + top: 100px; +} + +.sina { + width: 300px; + position: absolute; + left: 400px; + top : 100px; +} +.frame { + position: absolute; + top: 100px; + left: 480px; + width: 630px; /* Adjust this as needed */ + height: 850px; /* Adjust this as needed */ +} + +.emphasis { + width: 300px; + height: 200px; + position: absolute; + right: 291px; + bottom: 130px; + /*z-index: 2;*/ +} + diff --git a/Api/src/main/resources/static/css/index.css b/Api/src/main/resources/static/css/index.css index 83fef7ed..caf57ec9 100644 --- a/Api/src/main/resources/static/css/index.css +++ b/Api/src/main/resources/static/css/index.css @@ -23,6 +23,17 @@ swiper-slide.no-pictures{ align-items: center; } +swiper-slide.no-pictures{ + width:936px; + height:600px; + text-align: center; + font-size: 18px; + background: #fff; + display: flex; + justify-content: center; + align-items: center; +} + swiper-slide div.box { width: 100%; height: 100%; diff --git a/Api/src/main/resources/templates/imageList.html b/Api/src/main/resources/templates/imageList.html index 10a6598b..f8262116 100644 --- a/Api/src/main/resources/templates/imageList.html +++ b/Api/src/main/resources/templates/imageList.html @@ -75,8 +75,10 @@
+ Picture +

Details:

diff --git a/Api/src/main/resources/templates/modal.html b/Api/src/main/resources/templates/modal.html new file mode 100644 index 00000000..6b023b0a --- /dev/null +++ b/Api/src/main/resources/templates/modal.html @@ -0,0 +1,44 @@ + + +
+ + + + + +
+ + + + + + + \ No newline at end of file diff --git a/Api/src/main/resources/templates/pictures/createPictureForm.html b/Api/src/main/resources/templates/pictures/createPictureForm.html index 10de416e..0506fee6 100644 --- a/Api/src/main/resources/templates/pictures/createPictureForm.html +++ b/Api/src/main/resources/templates/pictures/createPictureForm.html @@ -1,5 +1,6 @@ - + Create Picture @@ -13,7 +14,7 @@
-
+

사진 선택

사진 선택
- +
-
-
+ +

그림 정보 입력

-
+


-
+


-
+


-
-
+


-
+


-
+


- +

- -
+
- +
+
diff --git a/Api/src/main/resources/templates/pictures/pictureDetail.html b/Api/src/main/resources/templates/pictures/pictureDetail.html new file mode 100644 index 00000000..20f53406 --- /dev/null +++ b/Api/src/main/resources/templates/pictures/pictureDetail.html @@ -0,0 +1,51 @@ + + +
+ + + + + +
+
+ Picture + + + + + +
+
+

+

+

+

+

+ +

+

+

+

+

+

+

+ +
+
+
+

Picture not found.

+
+
+
+


+
+ + + diff --git a/Domain/src/main/java/picasso/server/domain/domains/dto/PictureDTO.java b/Domain/src/main/java/picasso/server/domain/domains/dto/PictureDTO.java index 566247e5..3827d00d 100644 --- a/Domain/src/main/java/picasso/server/domain/domains/dto/PictureDTO.java +++ b/Domain/src/main/java/picasso/server/domain/domains/dto/PictureDTO.java @@ -2,6 +2,7 @@ import lombok.Getter; import lombok.Setter; +import org.springframework.web.multipart.MultipartFile; import java.time.LocalDate; @@ -16,6 +17,7 @@ public class PictureDTO { private String size; //그림 사이즈 private LocalDate bidStartDate; private String imgUrl; //그림 url + private MultipartFile imageFile; } diff --git a/Domain/src/main/java/picasso/server/domain/domains/items/Picture.java b/Domain/src/main/java/picasso/server/domain/domains/items/Picture.java index 60f6e719..35502471 100644 --- a/Domain/src/main/java/picasso/server/domain/domains/items/Picture.java +++ b/Domain/src/main/java/picasso/server/domain/domains/items/Picture.java @@ -1,17 +1,11 @@ package picasso.server.domain.domains.items; -import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.Lob; -import jakarta.persistence.Table; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import picasso.server.domain.domains.user.entity.User; import java.time.LocalDate; @@ -59,4 +53,7 @@ public class Picture { @NotNull private LocalDate bidEndDate; // 경매 종료일 + @ManyToOne + @JoinColumn(name = "id") + private User user; } diff --git a/Domain/src/main/java/picasso/server/domain/domains/items/PictureInfo.java b/Domain/src/main/java/picasso/server/domain/domains/items/PictureInfo.java index acbcd549..f63af0a9 100644 --- a/Domain/src/main/java/picasso/server/domain/domains/items/PictureInfo.java +++ b/Domain/src/main/java/picasso/server/domain/domains/items/PictureInfo.java @@ -8,6 +8,7 @@ @Getter @Setter public class PictureInfo { + private Long id; private String imageUrl; private String details; private String pictureName; diff --git a/Domain/src/main/java/picasso/server/domain/domains/repository/PictureRepository.java b/Domain/src/main/java/picasso/server/domain/domains/repository/PictureRepository.java index b37a1a88..52771b31 100644 --- a/Domain/src/main/java/picasso/server/domain/domains/repository/PictureRepository.java +++ b/Domain/src/main/java/picasso/server/domain/domains/repository/PictureRepository.java @@ -18,7 +18,6 @@ public interface PictureRepository extends JpaRepository{ List findAllByPictureStatusOrderByBidStartDateAsc(PictureStatus status); Page findAllByPictureStatusOrderByBidStartDateAsc(PictureStatus status, Pageable pageable); -// Page findAllByPictureStatusOrderByBidEndDateAsc(PictureStatus status, Pageable pageable); Optional findByPictureIdAndPictureStatus(Long id, PictureStatus status); } diff --git a/Domain/src/main/java/picasso/server/domain/domains/user/entity/User.java b/Domain/src/main/java/picasso/server/domain/domains/user/entity/User.java index c860942c..690a083f 100644 --- a/Domain/src/main/java/picasso/server/domain/domains/user/entity/User.java +++ b/Domain/src/main/java/picasso/server/domain/domains/user/entity/User.java @@ -4,8 +4,10 @@ import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; import jakarta.persistence.OneToOne; import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; @@ -14,11 +16,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import picasso.server.domain.domains.items.Picture; import picasso.server.domain.domains.user.type.LoginType; import picasso.server.domain.domains.user.type.UserRole; import picasso.server.domain.domains.user.type.UserStatus; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import static jakarta.persistence.GenerationType.IDENTITY; import static picasso.server.domain.domains.user.type.LoginType.DEFAULT; @@ -88,8 +93,12 @@ public class User { @NotNull @Builder.Default private LocalDateTime loginAt = LocalDateTime.now(); + + @OneToMany(mappedBy = "user", fetch = FetchType.LAZY) + private List pictures = new ArrayList<>(); public void updatePoint(Long point) { this.point += point; } + } diff --git a/Domain/src/main/java/picasso/server/domain/domains/user/repository/UserRepository.java b/Domain/src/main/java/picasso/server/domain/domains/user/repository/UserRepository.java index 609b391a..6fd4522a 100644 --- a/Domain/src/main/java/picasso/server/domain/domains/user/repository/UserRepository.java +++ b/Domain/src/main/java/picasso/server/domain/domains/user/repository/UserRepository.java @@ -8,10 +8,10 @@ import java.util.Optional; public interface UserRepository extends JpaRepository { + Optional findByNickName(String nickname); List findByUserRole(UserRole userRole); - Optional findByNickName(String nickname); Optional findByEmail(String email); diff --git a/Domain/src/main/resources/data.sql b/Domain/src/main/resources/data.sql index e0f45714..b4f76d83 100644 --- a/Domain/src/main/resources/data.sql +++ b/Domain/src/main/resources/data.sql @@ -9,17 +9,19 @@ values ('dddd', 'a','b','c','d'); insert into t_test(name, param1,param2,param3,param4) values ('ffff', 'a','b','c','d'); --- 테스트용 데이터 + insert into tbl_picture(picture_id, increment_amount, starting_price, bid_start_date, bid_end_date, details, img_url, painter_name, picture_name, picture_status, size) values (1, 10, 1000, '2023-09-22', '2023-09-29', 'test1', 'local/paint/d5fdd501-8251-4082-9cc6-f1a65e5ad0a9.jpg', '안유진', '안유진', 'BIDDING' ,'800x600'); insert into tbl_picture(picture_id, increment_amount, starting_price, bid_start_date, bid_end_date, details, img_url, painter_name, picture_name, picture_status, size) values (2, 20, 2000, '2023-09-21', '2023-09-28', 'test2', 'local/paint/6b075c7b-7149-4ecd-8b0a-ac71bb316e4d.jpeg', '은채', '은채', 'SUCCESS_BID','800x600'); insert into tbl_picture(picture_id, increment_amount, starting_price, bid_start_date, bid_end_date, details, img_url, painter_name, picture_name, picture_status, size) - values (3, 30, 3000, '2023-09-20', '2023-09-27', 'test3', 'local/paint/b6025492-6291-4ae2-916d-00981db26ed2.jpeg', '카리나', '카리나','BIDDING' ,'800x600'); + values (3, 30, 3000, '2023-09-20', '2023-09-27', 'test3', 'local/paint/28d5faf0-f59e-4a46-ae37-0ee6c7297cf0.jpeg', '카리나', '카리나','BIDDING' ,'800x600'); insert into tbl_picture(picture_id, increment_amount, starting_price, bid_start_date, bid_end_date, details, img_url, painter_name, picture_name, picture_status, size) values (4, 40, 4000, '2023-09-19', '2023-09-26', 'test4', 'local/paint/bf50117d-e28a-4393-8bc4-2fefa7220718.jpeg', '한소희', '한소희','SUCCESS_BID' ,'800x600'); insert into tbl_picture(picture_id, increment_amount, starting_price, bid_start_date, bid_end_date, details, img_url, painter_name, picture_name, picture_status, size) values (5, 50, 5000, '2023-09-28', '2023-10-03', 'test5', 'local/paint/bf50117d-e28a-4393-8bc4-2fefa7220718.jpeg', '한소희', '한소희','BEFORE_APPROVE' ,'800x600'); +insert into tbl_picture(picture_id, increment_amount, starting_price, bid_start_date, bid_end_date, details, img_url, painter_name, picture_name, picture_status, size) +values (6, 60, 6000, '2023-09-28', '2023-10-03', 'test5', 'local/paint/a459f188-89d5-4922-9aff-bd216e63790d.JPG', '고양이', '고양이','BIDDING' ,'800x600'); insert into tbl_user (email, password, nick_name, point, login_type, user_status, user_role, created_at, updated_at, login_at) values ('admin@test.com', '1111', '꽌리자', 300, 'DEFAULT', 'SUSPENSION', 'ADMIN', '2023-09-20 10:00:00', '2023-08-22 12:00:00', '2023-08-22 12:00:00');