From 823f470769bfab5e9630874ed763f1d556a70766 Mon Sep 17 00:00:00 2001 From: hydrationn <suhwaparkk1031@gmail.com> Date: Wed, 8 May 2024 09:08:08 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20#89=20PointDetail=20=ED=94=84?= =?UTF-8?q?=EB=A1=A0=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/UserPointDetailApiClient.java | 34 ++++++++++++++ .../pointdetail/model/dto/PointDetailDto.java | 23 ++++++++++ .../request/CreatePointDetailRequest.java | 41 +++++++++++++++++ .../model/response/PointDetailResponse.java | 29 ++++++++++++ .../service/UserPointDetailService.java | 46 +++++++++++++++++++ 5 files changed, 173 insertions(+) create mode 100644 src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java create mode 100644 src/main/java/com/t3t/frontserver/pointdetail/model/dto/PointDetailDto.java create mode 100644 src/main/java/com/t3t/frontserver/pointdetail/model/request/CreatePointDetailRequest.java create mode 100644 src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java create mode 100644 src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java diff --git a/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java b/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java new file mode 100644 index 0000000..b12db35 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java @@ -0,0 +1,34 @@ +package com.t3t.frontserver.pointdetail.client; + +import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 포인트 사용/적립 내역 API 호출을 위한 Feign Client + * @author hydraitonn(박수화) + */ +@FeignClient(name = "UserPointDetailApiClient", url = "${t3t.feignClient.url}") +public interface UserPointDetailApiClient { + + /** + * 회원의 모든 포인트 상세 내역 조회 API 호출 + * @param memberId 회원 ID + * @author hydrationn(박수화) + */ + @GetMapping("/t3t/bookstore/members/point-details") + public ResponseEntity<List<PointDetailResponse>> getPointDetailList(@PathVariable("memberId") Long memberId); + + /** + * 회원의 포인트 타입에 따른 포인트 사용/적립 내역 조회 API 호출 + * @param memberId 회원 ID + * @param pointDetailType 조회할 포인트 타입(사용/적립) + * @author hydrationn(박수화) + */ + @GetMapping("/t3t/bookstore/members/point-details") + public ResponseEntity<List<PointDetailResponse>> getPointDetailByPointDetailType(@PathVariable("members") Long memberId, + @RequestParam String pointDetailType); +} diff --git a/src/main/java/com/t3t/frontserver/pointdetail/model/dto/PointDetailDto.java b/src/main/java/com/t3t/frontserver/pointdetail/model/dto/PointDetailDto.java new file mode 100644 index 0000000..fa48139 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/pointdetail/model/dto/PointDetailDto.java @@ -0,0 +1,23 @@ +package com.t3t.frontserver.pointdetail.model.dto; + +import com.t3t.frontserver.member.model.dto.MemberDto; +import lombok.Builder; +import lombok.Getter; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * PointDetail Entity에 대한 DTO 클래스 + * @author hydrationn(박수화) + */ +@Getter +@Builder +public class PointDetailDto { + private Long pointDetailId; + private MemberDto member; + private String content; + private String pointDetailType; + private LocalDateTime pointDetailDate; + private BigDecimal pointAmount; +} diff --git a/src/main/java/com/t3t/frontserver/pointdetail/model/request/CreatePointDetailRequest.java b/src/main/java/com/t3t/frontserver/pointdetail/model/request/CreatePointDetailRequest.java new file mode 100644 index 0000000..08c70f3 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/pointdetail/model/request/CreatePointDetailRequest.java @@ -0,0 +1,41 @@ +package com.t3t.frontserver.pointdetail.model.request; + +import lombok.*; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 포인트 사용/정립 내역 생성 정보를 담기 위한 클래스 + * @author hydrationn(박수화) + */ +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ToString +@Setter +public class CreatePointDetailRequest { + + // 포인트 상세 내용 + @NotBlank(message = "포인트 상세 내용이 누락되었습니다.") + private String content; + + // 포인트 사용/적립 구분 + @NotBlank(message = "포인트 사용/적립 구분이 명시되지 않았습니다.") + @Pattern(regexp = "^(사용|적립)$", message = "포인트 상세 유형은'사용' 또는'적립'만 가능합니다.") + private String pointDetailType; + + // 사용/적립 내역 일자 + @NotNull(message = "포인트 사용/적립 일자가 누락되었습니다.") + @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") + private LocalDateTime pointDetailDate; + + // 포인트 양 + @NotNull(message = "포인트 양이 누락되었습니다.") + private BigDecimal pointAmount; +} diff --git a/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java b/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java new file mode 100644 index 0000000..79c8988 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java @@ -0,0 +1,29 @@ +package com.t3t.frontserver.pointdetail.model.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 회원 포인트 사용/적립 내역 조회 요청을 성공적으로 처리한 경우 응답 정보를 담기 위한 클래스 + * @author hydrationn(박수화) + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PointDetailResponse { + + private String content; + + private String pointDetailType; + + private LocalDateTime pointDetailDate; + + private BigDecimal pointAmount; +} + diff --git a/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java b/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java new file mode 100644 index 0000000..45e5b5a --- /dev/null +++ b/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java @@ -0,0 +1,46 @@ +package com.t3t.frontserver.pointdetail.service; + +import com.t3t.frontserver.pointdetail.client.UserPointDetailApiClient; +import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +@Slf4j +@Service +@RequiredArgsConstructor +public class UserPointDetailService { + + private final UserPointDetailApiClient userPointDetailApiClient; + + /** + * 특정 회원의 모든 포인트 상세 내역 조회 API 호출 + * @param memberId 회원 ID + * @return 등록된 포인트 내역이 없으면 204(NO_CONTENT) 상태와 메시지 반환, + * 내역이 있으면 해당 내역을 포함한 200(OK) 상태 반환 + * + * @author hydrationn(박수화) + */ + public List<PointDetailResponse> getPointDetailList(@PathVariable("memberId") Long memberId) { + return userPointDetailApiClient.getPointDetailList(memberId).getBody(); + } + + /** + * 특정 회원의 포인트 타입에 따른 포인트 상세 내역 조회 API 호출 + * @param memberId 회원 ID + * @param pointDetailType 조회할 포인트 타입(사용/적립) + * @return 해당 포인트 상세 내역을 포함한 200(OK) 상태 반환 + * + * @author hydrationn(박수화) + */ + public List<PointDetailResponse> getPointDetailByPointDetailType(@PathVariable("memberId") Long memberId, + @RequestParam String pointDetailType) { + return userPointDetailApiClient.getPointDetailByPointDetailType(memberId, pointDetailType).getBody(); + } + +} + From 4ea78c8f70ab2181c6e107c48a4a7a85bb83217d Mon Sep 17 00:00:00 2001 From: hydrationn <suhwaparkk1031@gmail.com> Date: Sat, 11 May 2024 00:53:43 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20#89=20PointDetail=20=ED=94=84?= =?UTF-8?q?=EB=A1=A0=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/UserPointDetailApiClient.java | 20 ++++---- .../controller/UserPointDetailController.java | 40 ++++++++++++++++ .../pointdetail/model/dto/PointDetailDto.java | 7 +-- .../request/CreatePointDetailRequest.java | 2 +- .../model/response/PointDetailResponse.java | 4 +- .../service/UserPointDetailService.java | 42 +++++++++-------- .../main/pointdetails/pointdetail.html | 47 +++++++++++++++++++ 7 files changed, 125 insertions(+), 37 deletions(-) create mode 100644 src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java create mode 100644 src/main/resources/templates/main/pointdetails/pointdetail.html diff --git a/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java b/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java index b12db35..372fa0a 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java @@ -5,6 +5,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import javax.ws.rs.Path; import java.util.List; /** @@ -14,21 +15,18 @@ @FeignClient(name = "UserPointDetailApiClient", url = "${t3t.feignClient.url}") public interface UserPointDetailApiClient { - /** - * 회원의 모든 포인트 상세 내역 조회 API 호출 - * @param memberId 회원 ID - * @author hydrationn(박수화) - */ - @GetMapping("/t3t/bookstore/members/point-details") - public ResponseEntity<List<PointDetailResponse>> getPointDetailList(@PathVariable("memberId") Long memberId); +/** + * 회원의 모든 포인트 상세 내역 조회 API 호출 + * @author hydrationn(박수화) + */ +/*@GetMapping("/t3t/bookstore/members/point-details") +public ResponseEntity<List<PointDetailResponse>> getPointDetailList();*/ /** * 회원의 포인트 타입에 따른 포인트 사용/적립 내역 조회 API 호출 - * @param memberId 회원 ID * @param pointDetailType 조회할 포인트 타입(사용/적립) * @author hydrationn(박수화) */ @GetMapping("/t3t/bookstore/members/point-details") - public ResponseEntity<List<PointDetailResponse>> getPointDetailByPointDetailType(@PathVariable("members") Long memberId, - @RequestParam String pointDetailType); -} + public ResponseEntity<List<PointDetailResponse>> getPointDetailByPointDetailType(@RequestParam String pointDetailType); +} \ No newline at end of file diff --git a/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java b/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java new file mode 100644 index 0000000..4752e70 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java @@ -0,0 +1,40 @@ +package com.t3t.frontserver.pointdetail.controller; + +import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; +import com.t3t.frontserver.pointdetail.service.UserPointDetailService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +@Controller +@RequiredArgsConstructor +public class UserPointDetailController { + + private final UserPointDetailService userPointDetailService; + + /** + * 회원 포인트 사용/적립 내역 페이지 뷰 반환 + * @return 포인트 사용/적립 내역 뷰 + * @author hydrationn(박수화) + */ + @GetMapping("/member/point-details") + public String pointDetailView(Model model, @Valid @ModelAttribute String pointDetailType) { + +/*if(!SecurityContextUtils.isLoggedIn()){ +return "redirect:/login"; +}*/ + +// Long memberId = SecurityContextUtils.getMemberId(); + + +// List<PointDetailResponse> pointDetails = userPointDetailService.getPointDetailByPointDetailType(pointDetailType); + +// model.addAttribute("pointDetails", userPointDetailService.getPointDetailByPointDetailType(pointDetailType)); + + return "main/pointdetails/pointdetail"; + } +} diff --git a/src/main/java/com/t3t/frontserver/pointdetail/model/dto/PointDetailDto.java b/src/main/java/com/t3t/frontserver/pointdetail/model/dto/PointDetailDto.java index fa48139..fd4b1d1 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/model/dto/PointDetailDto.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/model/dto/PointDetailDto.java @@ -1,8 +1,7 @@ package com.t3t.frontserver.pointdetail.model.dto; import com.t3t.frontserver.member.model.dto.MemberDto; -import lombok.Builder; -import lombok.Getter; +import lombok.*; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -13,6 +12,8 @@ */ @Getter @Builder +@NoArgsConstructor +@AllArgsConstructor public class PointDetailDto { private Long pointDetailId; private MemberDto member; @@ -20,4 +21,4 @@ public class PointDetailDto { private String pointDetailType; private LocalDateTime pointDetailDate; private BigDecimal pointAmount; -} +} \ No newline at end of file diff --git a/src/main/java/com/t3t/frontserver/pointdetail/model/request/CreatePointDetailRequest.java b/src/main/java/com/t3t/frontserver/pointdetail/model/request/CreatePointDetailRequest.java index 08c70f3..8d4d273 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/model/request/CreatePointDetailRequest.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/model/request/CreatePointDetailRequest.java @@ -38,4 +38,4 @@ public class CreatePointDetailRequest { // 포인트 양 @NotNull(message = "포인트 양이 누락되었습니다.") private BigDecimal pointAmount; -} +} \ No newline at end of file diff --git a/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java b/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java index 79c8988..ae9a0b9 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java @@ -1,5 +1,6 @@ package com.t3t.frontserver.pointdetail.model.response; +import com.t3t.frontserver.pointdetail.model.dto.PointDetailDto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -25,5 +26,4 @@ public class PointDetailResponse { private LocalDateTime pointDetailDate; private BigDecimal pointAmount; -} - +} \ No newline at end of file diff --git a/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java b/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java index 45e5b5a..2ead274 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java @@ -5,8 +5,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -17,30 +15,34 @@ public class UserPointDetailService { private final UserPointDetailApiClient userPointDetailApiClient; - /** - * 특정 회원의 모든 포인트 상세 내역 조회 API 호출 - * @param memberId 회원 ID - * @return 등록된 포인트 내역이 없으면 204(NO_CONTENT) 상태와 메시지 반환, - * 내역이 있으면 해당 내역을 포함한 200(OK) 상태 반환 - * - * @author hydrationn(박수화) - */ - public List<PointDetailResponse> getPointDetailList(@PathVariable("memberId") Long memberId) { - return userPointDetailApiClient.getPointDetailList(memberId).getBody(); - } +/** + * 특정 회원의 모든 포인트 상세 내역 조회 API 호출 + // * @param memberId 회원 ID + * @return 등록된 포인트 내역이 없으면 204(NO_CONTENT) 상태와 메시지 반환, + * 내역이 있으면 해당 내역을 포함한 200(OK) 상태 반환 + * + * @author hydrationn(박수화) + */ +/* public List<PointDetailResponse> getPointDetailList() { +return userPointDetailApiClient.getPointDetailList().getBody(); +}*/ /** * 특정 회원의 포인트 타입에 따른 포인트 상세 내역 조회 API 호출 - * @param memberId 회원 ID + * // * @param memberId 회원 ID + * + // * @param memberId * @param pointDetailType 조회할 포인트 타입(사용/적립) * @return 해당 포인트 상세 내역을 포함한 200(OK) 상태 반환 - * * @author hydrationn(박수화) */ - public List<PointDetailResponse> getPointDetailByPointDetailType(@PathVariable("memberId") Long memberId, - @RequestParam String pointDetailType) { - return userPointDetailApiClient.getPointDetailByPointDetailType(memberId, pointDetailType).getBody(); - } + public List<PointDetailResponse> getPointDetailByPointDetailType(String pointDetailType) { + List<PointDetailResponse> pointDetailResponseList; -} +/*if(pointDetailType == null) +userPointDetailApiClient.getPointDetailList().getBody();*/ + + return userPointDetailApiClient.getPointDetailByPointDetailType(pointDetailType).getBody(); + } +} \ No newline at end of file diff --git a/src/main/resources/templates/main/pointdetails/pointdetail.html b/src/main/resources/templates/main/pointdetails/pointdetail.html new file mode 100644 index 0000000..33f960d --- /dev/null +++ b/src/main/resources/templates/main/pointdetails/pointdetail.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<html xmlns:th="http://www.thymeleaf.org" + xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout(categoryList)" + xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5" + layout:decorate="main/layout/layout"> + +<th:block layout:fragment="content"> + <div class="container"> + <div class="row justify-content-center"> + <div class="col-md-10"> + <h2 class="text-center mb-5">회원 포인트 내역 조회</h2> + <div class="d-flex justify-content-end mb-3"> + <a href="/member/point-details" class="btn btn-primary mx-1">전체</a> + <a href="/member/point-details?pointDetailType=used" class="btn btn-primary mx-1">사용</a> + <a href="/member/point-details?pointDetailType=saved" class="btn btn-primary mx-1">적립</a> + </div> + <div class="text-center mb-5"> + <table id="pointDetailTable" class="table table-bordered table-striped centered-table"> + <thread> + <tr> + <td>No</td> + <td>날짜</td> + <td>포인트</td> + <td>구분</td> + <td>내용</td> + </tr> + </thread> + <tbody> + <!-- Thymeleaf를 사용하여 반복문 처리 --> + <tr th:each="pointDetail : ${pointDetails}"> + <td th:text="${pointDetail.count}"></td> + <td th:text="${pointDetail.pointDetailDate}"></td> + <td th:text="${pointDetail.pointAmount}"></td> + <td th:text="${pointDetail.pointDetailType}"></td> + <td th:text="${pointDetail.content}"></td> + </tr> + </tbody> + + </table> + <a href="/member/" class="btn btn-secondary">메인 화면 바로가기</a> + <p></p> + </div> + </div> + </div> + </div> +</th:block> +</html> \ No newline at end of file From 530dc9c0c9c60189011047848b979ff1831d46b5 Mon Sep 17 00:00:00 2001 From: hydrationn <suhwaparkk1031@gmail.com> Date: Sun, 12 May 2024 22:46:00 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20#89=20PointDetail=20=ED=94=84?= =?UTF-8?q?=EB=A1=A0=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserPointDetailController.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java b/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java index 4752e70..b4ef83e 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java @@ -1,5 +1,6 @@ package com.t3t.frontserver.pointdetail.controller; +import com.t3t.frontserver.auth.util.SecurityContextUtils; import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; import com.t3t.frontserver.pointdetail.service.UserPointDetailService; import lombok.RequiredArgsConstructor; @@ -24,16 +25,16 @@ public class UserPointDetailController { @GetMapping("/member/point-details") public String pointDetailView(Model model, @Valid @ModelAttribute String pointDetailType) { -/*if(!SecurityContextUtils.isLoggedIn()){ -return "redirect:/login"; -}*/ + if(!SecurityContextUtils.isLoggedIn()){ + return "redirect:/login"; + } // Long memberId = SecurityContextUtils.getMemberId(); // List<PointDetailResponse> pointDetails = userPointDetailService.getPointDetailByPointDetailType(pointDetailType); -// model.addAttribute("pointDetails", userPointDetailService.getPointDetailByPointDetailType(pointDetailType)); + model.addAttribute("pointDetails", userPointDetailService.getPointDetailByPointDetailType(pointDetailType)); return "main/pointdetails/pointdetail"; } From 636d57523735a01ac19fdf891faf85b733ca95e3 Mon Sep 17 00:00:00 2001 From: hydrationn <suhwaparkk1031@gmail.com> Date: Mon, 13 May 2024 03:09:11 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20#89=20=ED=9A=8C=EC=9B=90=20?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=82=AC=EC=9A=A9/=EC=A0=81?= =?UTF-8?q?=EB=A6=BD=20=EB=82=B4=EC=97=AD=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/UserPointDetailApiClient.java | 11 +---- .../controller/UserPointDetailController.java | 30 ++++++++---- .../model/response/PointDetailResponse.java | 1 - .../service/UserPointDetailService.java | 48 ------------------- .../main/pointdetails/pointdetail.html | 15 +++--- 5 files changed, 33 insertions(+), 72 deletions(-) delete mode 100644 src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java diff --git a/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java b/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java index 372fa0a..ce02744 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/client/UserPointDetailApiClient.java @@ -1,11 +1,11 @@ package com.t3t.frontserver.pointdetail.client; +import com.t3t.frontserver.model.response.BaseResponse; import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import javax.ws.rs.Path; import java.util.List; /** @@ -15,18 +15,11 @@ @FeignClient(name = "UserPointDetailApiClient", url = "${t3t.feignClient.url}") public interface UserPointDetailApiClient { -/** - * 회원의 모든 포인트 상세 내역 조회 API 호출 - * @author hydrationn(박수화) - */ -/*@GetMapping("/t3t/bookstore/members/point-details") -public ResponseEntity<List<PointDetailResponse>> getPointDetailList();*/ - /** * 회원의 포인트 타입에 따른 포인트 사용/적립 내역 조회 API 호출 * @param pointDetailType 조회할 포인트 타입(사용/적립) * @author hydrationn(박수화) */ @GetMapping("/t3t/bookstore/members/point-details") - public ResponseEntity<List<PointDetailResponse>> getPointDetailByPointDetailType(@RequestParam String pointDetailType); + public ResponseEntity<BaseResponse<List<PointDetailResponse>>> getPointDetailByPointDetailType(@RequestParam(name = "pointDetailType", required = false) String pointDetailType); } \ No newline at end of file diff --git a/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java b/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java index b4ef83e..c2c2a7c 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/controller/UserPointDetailController.java @@ -1,21 +1,24 @@ package com.t3t.frontserver.pointdetail.controller; import com.t3t.frontserver.auth.util.SecurityContextUtils; +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.pointdetail.client.UserPointDetailApiClient; import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; -import com.t3t.frontserver.pointdetail.service.UserPointDetailService; import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; @Controller @RequiredArgsConstructor public class UserPointDetailController { - - private final UserPointDetailService userPointDetailService; + private final UserPointDetailApiClient userPointDetailApiClient; /** * 회원 포인트 사용/적립 내역 페이지 뷰 반환 @@ -23,18 +26,29 @@ public class UserPointDetailController { * @author hydrationn(박수화) */ @GetMapping("/member/point-details") - public String pointDetailView(Model model, @Valid @ModelAttribute String pointDetailType) { + public String pointDetailView(Model model, @Valid @RequestParam(value = "pointDetailType", required = false) String pointDetailType) { + // 로그인 정보가 없으면 로그인 페이지로 이동 if(!SecurityContextUtils.isLoggedIn()){ - return "redirect:/login"; + return "redirect:/login"; } -// Long memberId = SecurityContextUtils.getMemberId(); + ResponseEntity<BaseResponse<List<PointDetailResponse>>> response = userPointDetailApiClient.getPointDetailByPointDetailType(pointDetailType); // 모든 내역을 가져오는 API 호출 + List<PointDetailResponse> pointDetails; -// List<PointDetailResponse> pointDetails = userPointDetailService.getPointDetailByPointDetailType(pointDetailType); + if (pointDetailType == null) { + // parameter가 null인 경우 모든 내역 반환 + pointDetails = Objects.requireNonNull(response.getBody()).getData(); + } else { + // pointDetailType(used, saved)에 해당하는 내역만 반환 + pointDetails = Objects.requireNonNull(response.getBody()).getData() + .stream() + .filter(pointDetail -> pointDetail.getPointDetailType().equals(pointDetailType)) + .collect(Collectors.toList()); + } - model.addAttribute("pointDetails", userPointDetailService.getPointDetailByPointDetailType(pointDetailType)); + model.addAttribute("pointDetails", pointDetails); return "main/pointdetails/pointdetail"; } diff --git a/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java b/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java index ae9a0b9..04143e0 100644 --- a/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java +++ b/src/main/java/com/t3t/frontserver/pointdetail/model/response/PointDetailResponse.java @@ -1,6 +1,5 @@ package com.t3t.frontserver.pointdetail.model.response; -import com.t3t.frontserver.pointdetail.model.dto.PointDetailDto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java b/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java deleted file mode 100644 index 2ead274..0000000 --- a/src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.t3t.frontserver.pointdetail.service; - -import com.t3t.frontserver.pointdetail.client.UserPointDetailApiClient; -import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Slf4j -@Service -@RequiredArgsConstructor -public class UserPointDetailService { - - private final UserPointDetailApiClient userPointDetailApiClient; - -/** - * 특정 회원의 모든 포인트 상세 내역 조회 API 호출 - // * @param memberId 회원 ID - * @return 등록된 포인트 내역이 없으면 204(NO_CONTENT) 상태와 메시지 반환, - * 내역이 있으면 해당 내역을 포함한 200(OK) 상태 반환 - * - * @author hydrationn(박수화) - */ -/* public List<PointDetailResponse> getPointDetailList() { -return userPointDetailApiClient.getPointDetailList().getBody(); -}*/ - - /** - * 특정 회원의 포인트 타입에 따른 포인트 상세 내역 조회 API 호출 - * // * @param memberId 회원 ID - * - // * @param memberId - * @param pointDetailType 조회할 포인트 타입(사용/적립) - * @return 해당 포인트 상세 내역을 포함한 200(OK) 상태 반환 - * @author hydrationn(박수화) - */ - public List<PointDetailResponse> getPointDetailByPointDetailType(String pointDetailType) { - List<PointDetailResponse> pointDetailResponseList; - -/*if(pointDetailType == null) -userPointDetailApiClient.getPointDetailList().getBody();*/ - - return userPointDetailApiClient.getPointDetailByPointDetailType(pointDetailType).getBody(); - } - -} \ No newline at end of file diff --git a/src/main/resources/templates/main/pointdetails/pointdetail.html b/src/main/resources/templates/main/pointdetails/pointdetail.html index 33f960d..f7f3fb7 100644 --- a/src/main/resources/templates/main/pointdetails/pointdetail.html +++ b/src/main/resources/templates/main/pointdetails/pointdetail.html @@ -19,7 +19,7 @@ <h2 class="text-center mb-5">회원 포인트 내역 조회</h2> <thread> <tr> <td>No</td> - <td>날짜</td> + <td>날짜 및 시간</td> <td>포인트</td> <td>구분</td> <td>내용</td> @@ -27,17 +27,20 @@ <h2 class="text-center mb-5">회원 포인트 내역 조회</h2> </thread> <tbody> <!-- Thymeleaf를 사용하여 반복문 처리 --> - <tr th:each="pointDetail : ${pointDetails}"> - <td th:text="${pointDetail.count}"></td> - <td th:text="${pointDetail.pointDetailDate}"></td> + <tr th:each="pointDetail, no : ${pointDetails}"> + <td th:text="${no.index + 1}"></td> + <td th:text="${#temporals.format(pointDetail.pointDetailDate, 'yyyy-MM-dd HH:mm:ss')}"></td> <td th:text="${pointDetail.pointAmount}"></td> - <td th:text="${pointDetail.pointDetailType}"></td> + <td th:switch="${pointDetail.pointDetailType}"> + <span th:case="used" th:text="사용"></span> + <span th:case="saved" th:text="적립"></span> + </td> <td th:text="${pointDetail.content}"></td> </tr> </tbody> </table> - <a href="/member/" class="btn btn-secondary">메인 화면 바로가기</a> + <a href="/" class="btn btn-secondary">메인 화면 바로가기</a> <p></p> </div> </div>