Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feign통신연결 및 프론트 요구사항 반영 #26

Merged
merged 25 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f55c375
:pencil2: Question 엔티티 productName 추가 #LF1-602 #LF1-603
qwerty1434 Dec 6, 2023
1a9b26e
:pencil2: 가게목록 조회 시 좋아요 여부 정보 추가
qwerty1434 Dec 6, 2023
907e9f8
:pencil2: 일부 가게정보 출력 시 주소 추가
qwerty1434 Dec 6, 2023
ce23585
:recycle: 정적 팩토리 메서드 적용
qwerty1434 Dec 6, 2023
d9963e5
:pencil2: 다른 MS의 subscriptionId가 String으로 변경됨
qwerty1434 Dec 6, 2023
3fb440c
:pencil2: 요구사항 변경 - 가게 정보 조회 시 구독상품 아이디 전달
qwerty1434 Dec 6, 2023
ba9b72a
:green_heart: bus-refresh를 위한 의존성 추가 [팀 전체]
qwerty1434 Dec 7, 2023
12dd9ba
:green_heart: kafka-stream 의존성 추가 취소 [팀 전체]
qwerty1434 Dec 7, 2023
32d0377
:pencil2: 본인 비밀글이 아닐 시 제목과 내용을 노출하지 않도록 변경
qwerty1434 Dec 7, 2023
0e9bc9a
:pencil2: 비회원(userId가 null일 수 있다) 접속에 대한 처리
qwerty1434 Dec 7, 2023
11cbbbe
:pencil2: 다른 MS의 변수 타입 변경에 따른 수정
qwerty1434 Dec 7, 2023
2d22174
:ambulance: 최소주문금액 삭제
qwerty1434 Dec 7, 2023
75dd6ee
:green_heart: kafka 의존성 추가
qwerty1434 Dec 7, 2023
dc705a3
:pencil2: 결제페이지 쿠폰 조회 시 사용여부도 함께 반환 [요구사항 추가]
qwerty1434 Dec 8, 2023
389c9c8
:sparkles: 사용 가능한 구폰 개수 API
qwerty1434 Dec 8, 2023
c2cb193
:pencil2: 쿠폰 개수 요청 시 Response객체로 감싸지 않고 반환
qwerty1434 Dec 8, 2023
63b597a
:sparkles: Product서버와의 통신 설정
qwerty1434 Dec 8, 2023
61fbd00
:bulb: TODO 추가
qwerty1434 Dec 8, 2023
6959375
:white_check_mark: 가게 아이디 요청 테스트
qwerty1434 Dec 8, 2023
5736998
:truck: Dto 위치 변경
qwerty1434 Dec 8, 2023
d1b2bd8
:pencil2: data.sql 삭제 및 gitignore 추가
qwerty1434 Dec 8, 2023
8423c2a
:green_heart: yml파일 생성
qwerty1434 Dec 8, 2023
f2d2297
:pencil2: feign통신에 공통 Dto 사용
qwerty1434 Dec 8, 2023
cfd4521
:pencil2: crossorigin, requestmapping 제거
qwerty1434 Dec 8, 2023
a80146e
:sparkles: 테스트 컨테이너 추가
qwerty1434 Dec 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
data.sql

### STS ###
.apt_generated
Expand Down
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation "org.springframework.cloud:spring-cloud-starter-bus-kafka"
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'

runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
Expand All @@ -57,7 +59,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation("it.ozimov:embedded-redis:0.7.2")

implementation group: 'io.github.lotteon-maven', name: 'blooming-blooms-utils', version: '0.1.0-alpha1'
// testContainers
testImplementation "org.junit.jupiter:junit-jupiter:5.8.1"
testImplementation "org.testcontainers:junit-jupiter:1.16.3"

implementation group: 'io.github.lotteon-maven', name: 'blooming-blooms-utils', version: '25041622'
}

dependencyManagement {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/kr/bb/store/client/ProductFeignClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package kr.bb.store.client;

import bloomingblooms.domain.flower.FlowerDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(name = "product-service")
public interface ProductFeignClient {
@GetMapping
List<FlowerDto> getFlowers();

@GetMapping
String getProductThumbnail(@RequestParam(name="productId") Long productId);

@GetMapping
String getSubscriptionProductId(@RequestParam(name="storeId") Long storeId);
}
16 changes: 16 additions & 0 deletions src/main/java/kr/bb/store/client/StoreLikeFeignClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package kr.bb.store.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;
import java.util.Map;

@FeignClient(name = "storeLike-service")
public interface StoreLikeFeignClient {
@PostMapping
Map<Long,Boolean> getStoreLikes(@RequestHeader(value = "userId") Long userId,
List<Long> storeIds);

}
15 changes: 15 additions & 0 deletions src/main/java/kr/bb/store/client/StoreSubscriptionFeignClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package kr.bb.store.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;
import java.util.Map;

@FeignClient(name = "storeSubscription-service")
public interface StoreSubscriptionFeignClient {
@PostMapping
Map<Long,Boolean> getStoreSubscriptions(@RequestHeader(value = "userId") Long userId,
List<Long> storeIds);
}
9 changes: 9 additions & 0 deletions src/main/java/kr/bb/store/config/FeignConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.bb.store.config;

import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.stereotype.Component;

@EnableFeignClients(basePackages = "kr.bb.store")
@Component
public class FeignConfig {
}
97 changes: 0 additions & 97 deletions src/main/java/kr/bb/store/config/LocalRedisConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@CrossOrigin(origins = "*")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/stores")
public class CargoController {
private final CargoService cargoService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.bb.store.domain.cargo.controller;

import kr.bb.store.domain.cargo.controller.request.StockFeignRequest;
import bloomingblooms.domain.flower.StockChangeDto;
import kr.bb.store.domain.cargo.service.CargoService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -13,14 +13,14 @@
public class CargoFeignController {
private final CargoService cargoService;
@PutMapping("/add")
public ResponseEntity<Void> addStock(@RequestBody StockFeignRequest stockFeignRequest) {
cargoService.plusStockCount(stockFeignRequest.getStoreId(), stockFeignRequest.getFlowerId(), stockFeignRequest.getStock());
public ResponseEntity<Void> addStock(@RequestBody StockChangeDto stockChangeDto) {
cargoService.plusStockCount(stockChangeDto.getStoreId(), stockChangeDto.getFlowerId(), stockChangeDto.getStock());
return ResponseEntity.ok().build();
}

@PutMapping("/substract")
public ResponseEntity<Void> subtractStock(@RequestBody StockFeignRequest stockFeignRequest) {
cargoService.minusStockCount(stockFeignRequest.getStoreId(), stockFeignRequest.getFlowerId(), stockFeignRequest.getStock());
public ResponseEntity<Void> subtractStock(@RequestBody StockChangeDto stockChangeDto) {
cargoService.minusStockCount(stockChangeDto.getStoreId(), stockChangeDto.getFlowerId(), stockChangeDto.getStock());
return ResponseEntity.ok().build();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kr.bb.store.domain.cargo.service;


import bloomingblooms.domain.flower.FlowerDto;
import kr.bb.store.domain.cargo.controller.response.RemainingStocksResponse;
import kr.bb.store.domain.cargo.dto.FlowerDto;
import kr.bb.store.domain.cargo.dto.StockInfoDto;
import kr.bb.store.domain.cargo.dto.StockModifyDto;
import kr.bb.store.domain.cargo.entity.FlowerCargo;
Expand Down Expand Up @@ -64,10 +64,10 @@ public RemainingStocksResponse getAllStocks(Long storeId) {
@Transactional
public void createBasicCargo(Store store, List<FlowerDto> flowers) {
List<FlowerCargo> flowerCargos = flowers.stream()
.map(v -> FlowerCargo.builder()
.id(makeKeys(store.getId(), v.getFlowerId()))
.map(flowerDto -> FlowerCargo.builder()
.id(makeKeys(store.getId(), flowerDto.getFlowerId()))
.store(store)
.flowerName(v.getFlowerName())
.flowerName(flowerDto.getFlowerName())
.build()
)
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import kr.bb.store.domain.coupon.controller.request.CouponCreateRequest;
import kr.bb.store.domain.coupon.controller.request.CouponEditRequest;
import kr.bb.store.domain.coupon.controller.request.TotalAmountRequest;
import kr.bb.store.domain.coupon.controller.response.CouponsForOwnerResponse;
import kr.bb.store.domain.coupon.controller.response.CouponsForUserResponse;
import kr.bb.store.domain.coupon.service.CouponService;
Expand All @@ -11,10 +12,8 @@

import java.time.LocalDate;

@CrossOrigin(origins = "*")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/stores")
public class CouponController {
private final CouponService couponService;

Expand Down Expand Up @@ -70,16 +69,19 @@ public ResponseEntity<CouponsForUserResponse> storeCouponsForUser(@PathVariable
return ResponseEntity.ok().body(couponService.getAllStoreCouponsForUser(userId, storeId, now));
}

@GetMapping("/{storeId}/coupons/my")
@PostMapping("/{storeId}/coupons/payment")
public ResponseEntity<CouponsForUserResponse> couponsInPaymentStep(@PathVariable Long storeId,
@RequestHeader(value = "userId") Long userId) {
@RequestHeader(value = "userId") Long userId,
@RequestBody TotalAmountRequest totalAmountRequest) {

return ResponseEntity.ok().body(couponService.getAvailableCouponsInPayment(userId, storeId));
LocalDate now = LocalDate.now();
return ResponseEntity.ok().body(couponService.getAvailableCouponsInPayment(totalAmountRequest, userId, storeId, now));
}

@GetMapping("/coupons/list")
@GetMapping("/coupons/my")
public ResponseEntity<CouponsForUserResponse> myCoupons(@RequestHeader(value = "userId") Long userId) {

return ResponseEntity.ok().body(couponService.getMyValidCoupons(userId));
LocalDate now = LocalDate.now();
return ResponseEntity.ok().body(couponService.getMyValidCoupons(userId, now));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@CrossOrigin(origins = "*")
@RestController
@RequiredArgsConstructor
@RequestMapping(("/coupons"))
@RequestMapping(("stores/coupons"))
public class CouponFeignController {
private final CouponService couponService;

Expand All @@ -21,4 +21,11 @@ public ResponseEntity<Void> useCoupon(@PathVariable Long couponId, @PathVariable

return ResponseEntity.ok().build();
}

@GetMapping("/count")
public ResponseEntity<Integer> availableCouponCountOfUser(@RequestHeader(value = "userId") Long userId) {
LocalDate now = LocalDate.now();

return ResponseEntity.ok().body(couponService.getAvailableCouponCount(userId, now));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.bb.store.domain.cargo.dto;
package kr.bb.store.domain.coupon.controller.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -9,7 +9,6 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FlowerDto {
private Long flowerId;
private String flowerName;
public class TotalAmountRequest {
private Long totalAmount;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package kr.bb.store.domain.coupon.dto;

import com.querydsl.core.annotations.QueryProjection;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

@Getter
@NoArgsConstructor
public class CouponWithAvailabilityDto extends CouponDto {
private Boolean isAvailable;

@QueryProjection
public CouponWithAvailabilityDto(Long couponId, String couponName, String storeName, Long discountPrice, LocalDate endDate, Long minPrice, Boolean isAvailable) {
super(couponId, couponName, storeName, discountPrice, endDate, minPrice);
this.isAvailable = isAvailable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import kr.bb.store.domain.coupon.dto.CouponDto;
import kr.bb.store.domain.coupon.dto.CouponForOwnerDto;
import kr.bb.store.domain.coupon.dto.CouponWithAvailabilityDto;
import kr.bb.store.domain.coupon.dto.CouponWithIssueStatusDto;
import kr.bb.store.domain.coupon.entity.Coupon;
import kr.bb.store.domain.coupon.exception.CouponNotFoundException;
Expand Down Expand Up @@ -33,11 +34,16 @@ public List<CouponWithIssueStatusDto> readStoreCouponsForUser(Long userId, Long
return couponRepository.findStoreCouponsForUser(userId, storeId, now);
}

public List<CouponDto> readAvailableCouponsInStore(Long userId, Long storeId, LocalDate readDate) {
return couponRepository.findAvailableCoupons(userId, storeId, readDate);
public List<CouponWithAvailabilityDto> readAvailableCouponsInStore(Long totalAmount, Long userId, Long storeId,
LocalDate readDate) {
return couponRepository.findAvailableCoupons(totalAmount, userId, storeId, readDate);
}

public List<CouponDto> readMyValidCoupons(Long userId, LocalDate readDate) {
return couponRepository.findMyValidCoupons(userId, readDate);
}

public Integer readMyValidCouponCount(Long userId, LocalDate readDate) {
return couponRepository.findMyValidCouponCount(userId, readDate);
}
}
Loading
Loading