Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rver into develop
  • Loading branch information
cogns committed Nov 4, 2024
2 parents d41df8b + 1291034 commit c131529
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 113 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/deploy_msa_k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,4 @@ jobs:
- name: eks kubectl apply
run: |
kubectl apply -f ./backend/apigateway/k8s/apigateway-depl.yml
kubectl rollout restart deployment apigateway-deployment
# openvidu
- name: eks kubectl apply
run: |
kubectl apply -f ./k8s/openvidu-depl.yml
kubectl apply -f ./k8s/openvidu-service.yml
kubectl rollout restart deployment openvidu-deployment
kubectl rollout restart deployment apigateway-deployment
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.samtuap.inong.domain.live.dto.LiveSessionRequest;
import org.samtuap.inong.domain.live.dto.LiveSessionResponse;
import org.samtuap.inong.domain.live.service.LiveService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand Down
4 changes: 4 additions & 0 deletions backend/live/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ server:
port: 0

spring:
data:
redis:
port: 6379
host: localhost
config:
activate:
on-profile: local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
import org.samtuap.inong.domain.member.dto.MemberSubscriptionListResponse;
import org.samtuap.inong.domain.member.dto.MemberSubscriptionResponse;
import org.samtuap.inong.domain.member.dto.PaymentMethodGetResponse;
import org.samtuap.inong.domain.subscription.dto.BillingKeyRegisterRequest;
import org.samtuap.inong.domain.subscription.dto.SubscribeProductRequest;
import org.samtuap.inong.domain.subscription.dto.SubscriptionGetResponse;
import org.samtuap.inong.domain.subscription.dto.SubscriptionListGetResponse;
import org.samtuap.inong.domain.subscription.dto.*;
import org.samtuap.inong.domain.subscription.service.SubscriptionService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -75,4 +73,5 @@ public ResponseEntity<Void> subscribeProduct(@Valid @RequestBody SubscribeProduc
public Optional<SubscriptionGetResponse> subscribeProduct(@PathVariable("productId") Long productId, @RequestHeader("myId") Long memberId) {
return subscriptionService.getSubscriptionByProductId(productId, memberId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void registerPaymentMethod(Long memberId, BillingKeyRegisterRequest reque
}


@Transactional
public SubscriptionListGetResponse getSubscriptionToPay() {
List<Subscription> subscriptions = subscriptionRepository.findAllByPayDate(LocalDate.now());

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

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

Expand All @@ -36,4 +37,5 @@ public interface MemberFeign {

@GetMapping(value = "/subscription/product/{productId}")
Optional<SubscriptionInfoGetResponse> getSubscriptionByProductId(@PathVariable("productId") Long productId, @RequestHeader("myId") Long memberId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class PaymentScheduler {
private final OrderService orderService;
@SchedulerLock(name = "shedLock_regular_payment", lockAtLeastFor = "1m", lockAtMostFor = "59m")
@Scheduled(cron = "0 0 13 * * *")
@Scheduled(cron = "0 0 7 * * *")
public void regularPayment() {
orderService.regularPay();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.samtuap.inong.domain.order.repository;


import org.samtuap.inong.common.exception.BaseCustomException;
import org.samtuap.inong.domain.order.dto.PackageOrderCount;
import org.samtuap.inong.domain.order.dto.PackageProductOrderResponse;
import org.samtuap.inong.domain.order.dto.SalesDataGetResponse;
import org.samtuap.inong.domain.order.dto.TopPackageResponse;
import org.samtuap.inong.domain.order.entity.Ordering;
import org.samtuap.inong.domain.receipt.entity.Receipt;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
Expand All @@ -16,6 +18,9 @@
import java.util.List;
import java.util.Optional;

import static org.samtuap.inong.common.exceptionType.OrderExceptionType.ORDER_NOT_FOUND;
import static org.samtuap.inong.common.exceptionType.ReceiptExceptionType.RECEIPT_NOT_FOUND;

public interface OrderRepository extends JpaRepository<Ordering, Long> {

@Query(value = "SELECT o.package_id FROM ordering o " +
Expand All @@ -38,4 +43,7 @@ public interface OrderRepository extends JpaRepository<Ordering, Long> {
@Query("SELECT new org.samtuap.inong.domain.order.dto.PackageOrderCount(o.packageId, COUNT(o.id)) FROM Ordering o WHERE o.farmId = :farmId AND o.createdAt >= :startAt AND o.createdAt <= :endAt GROUP BY o.packageId")
List<PackageOrderCount> findAllByFarmIdAndBetweenStartAtAndEndAt(Long farmId, LocalDateTime startAt, LocalDateTime endAt);

default Ordering findByIdOrThrow(Long id) {
return findById(id).orElseThrow(() -> new BaseCustomException(ORDER_NOT_FOUND));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,14 @@ public PaymentResponse makeOrder(Long memberId, PaymentRequest reqDto, boolean i
// 4. 최초 결제하기
String paymentId = kakaoPay(memberInfo, packageProduct, paidAmount, order);

log.info("line 150 >>>>>>>> {}", savedOrder.getId());

// 5. 영수증 만들기
makeReceipt(savedOrder, packageProduct, paidAmount, paymentId);

// 6. orderCount 증가 이벤트 발행
kafkaTemplate.send("order-count-topic", new KafkaOrderCountUpdateRequest(packageProduct.farmId(), packageProduct.id(), INCREASE));

// 7. subscription payDate 변경 TODO



// 8. 알림 발송
KafkaNotificationRequest notification = KafkaNotificationRequest.builder()
Expand Down Expand Up @@ -289,6 +288,7 @@ public void regularPay() {
}
}

@Transactional
public void makeReceipt(Ordering order, PackageProductResponse packageProduct, Long paidAmount, String paymentId) {
Long beforePrice = packageProduct.price();
Long discountPrice = beforePrice - paidAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
@SQLRestriction("deleted_at is NULL")
public class Receipt extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "order_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class ReceiptService {
private final ProductFeign productFeign;


public ReceiptInfoResponse getReceiptInfo(Long orderId) {
Ordering ordering = orderRepository.findById(orderId).orElseThrow(()-> new BaseCustomException(ORDER_NOT_FOUND));
Receipt receipt = receiptRepository.findByOrderOrThrow(ordering);
public ReceiptInfoResponse getReceiptInfo(Long receiptId) {
Receipt receipt = receiptRepository.findByIdOrThrow(receiptId);
Ordering ordering = orderRepository.findByIdOrThrow(receipt.getOrder().getId());
PackageProductResponse product = productFeign.getPackageProduct(ordering.getPackageId());
return ReceiptInfoResponse.from(receipt, product);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

import static org.samtuap.inong.common.exceptionType.ProductExceptionType.FARM_NOT_FOUND;

@Repository
public interface FarmRepository extends JpaRepository<Farm, Long> {
default Farm findByIdOrThrow(Long farmId) {
return findById(farmId).orElseThrow(() -> new BaseCustomException(FARM_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.samtuap.inong.domain.product.repository.PackageProductRepository;
import org.samtuap.inong.domain.seller.dto.FarmCategoryResponse;
import org.samtuap.inong.domain.seller.dto.SellerFarmInfoUpdateRequest;
import org.samtuap.inong.search.document.FarmDocument;
import org.samtuap.inong.search.service.FarmSearchService;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
Expand Down Expand Up @@ -191,8 +192,8 @@ public FarmCreateResponse createFarm(FarmCreateRequest request, Long sellerId) {
}

// elasticsearch✔️ : open search에 인덱싱
// FarmDocument farmDocument = FarmDocument.convertToDocument(farm);
// farmSearchService.indexFarmDocument(farmDocument);
FarmDocument farmDocument = FarmDocument.convertToDocument(farm);
farmSearchService.indexFarmDocument(farmDocument);

return FarmCreateResponse.fromEntity(farm);
}
Expand Down Expand Up @@ -229,8 +230,8 @@ public void updateFarmInfo(Long sellerId, SellerFarmInfoUpdateRequest infoUpdate
}

// elasticsearch✔️ : open search에 수정
// FarmDocument farmDocument = FarmDocument.convertToDocument(farm);
// farmSearchService.updateFarm(farmDocument);
FarmDocument farmDocument = FarmDocument.convertToDocument(farm);
farmSearchService.updateFarm(farmDocument);
}

public List<FarmCategoryResponse> getAllFarmCategories() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

import static org.samtuap.inong.common.exceptionType.ProductExceptionType.PRODUCT_NOT_FOUND;

@Repository
public interface PackageProductRepository extends JpaRepository<PackageProduct, Long> {
@Query("SELECT p FROM PackageProduct p WHERE p.id IN :ids")
List<PackageProduct> findAllByIds(@Param("ids") List<Long> ids);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.samtuap.inong.domain.product.repository.PackageProductRepository;
import org.samtuap.inong.domain.seller.entity.Seller;
import org.samtuap.inong.domain.seller.repository.SellerRepository;
import org.samtuap.inong.search.document.PackageProductDocument;
import org.samtuap.inong.search.service.PackageProductSearchService;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
Expand Down Expand Up @@ -142,8 +143,8 @@ public PackageProductCreateResponse createPackageProduct(Long sellerId, PackageP
packageProductImageService.saveImages(savedPackageProduct, imageUrls);

// elasticsearch✔️ : open search에 인덱싱
// PackageProductDocument packageProductDocument = PackageProductDocument.convertToDocument(savedPackageProduct);
// packageProductSearchService.indexProductDocument(packageProductDocument);
PackageProductDocument packageProductDocument = PackageProductDocument.convertToDocument(savedPackageProduct);
packageProductSearchService.indexProductDocument(packageProductDocument);

// 저장된 엔티티를 DTO로 반환
return PackageProductCreateResponse.fromEntity(savedPackageProduct, imageUrls);
Expand Down Expand Up @@ -174,7 +175,7 @@ public void deletePackage(Long sellerId, Long packageId) {
}

// elasticsearch✔️ : 삭제
// packageProductSearchService.deleteProduct(String.valueOf(packageId));
packageProductSearchService.deleteProduct(String.valueOf(packageId));
}

@Transactional
Expand Down Expand Up @@ -203,8 +204,8 @@ public void updatePackageProduct(Long sellerId, Long packageId, PackageProductUp
}

// elasticsearch✔️ : open search에 수정
// PackageProductDocument updateProduct = PackageProductDocument.convertToDocument(packageProduct);
// packageProductSearchService.updateProduct(updateProduct);
PackageProductDocument updateProduct = PackageProductDocument.convertToDocument(packageProduct);
packageProductSearchService.updateProduct(updateProduct);
}

// Feign 요청 용
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.samtuap.inong.domain.seller.jwt.domain.JwtToken;
import org.samtuap.inong.domain.seller.jwt.service.JwtService;
import org.samtuap.inong.domain.seller.repository.SellerRepository;
import org.samtuap.inong.search.service.FarmSearchService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import static org.samtuap.inong.common.exceptionType.SellerExceptionType.*;
Expand All @@ -35,6 +36,7 @@ public class SellerService {
private final JwtService jwtService;
private final PackageProductRepository packageProductRepository;
private final RedisTool redisUtil;
private final FarmSearchService farmSearchService;

@Transactional
public boolean verifyAuthCode(String email, String code) {
Expand Down Expand Up @@ -113,7 +115,7 @@ public void withDraw(Long sellerId, String password) {
// 농장 삭제 진행
farmRepository.delete(farm);
// elasticsearch✔️ : 삭제
// farmSearchService.deleteFarm(String.valueOf(farm.getId()));
farmSearchService.deleteFarm(String.valueOf(farm.getId()));
}

// 삭제되지 않은 패키지가 없으면 농장과 판매자 삭제 진행
Expand Down
2 changes: 1 addition & 1 deletion backend/product/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spring:
data:
redis:
port: 6379
host: 127.0.0.1
host: localhost
elasticsearch:
uris: ${SPRING_ELASTICSEARCH_URIS}
username: ${SPRING_ELASTICSEARCH_USERNAME}
Expand Down
37 changes: 13 additions & 24 deletions k8s/ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,21 @@ metadata:
name: inong-ingress
annotations:
kubernetes.io/ingress.class: nginx
# nginx.ingress.kubernetes.io/ssl-passthrough: "true"
# nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
# nginx.ingress.kubernetes.io/rewrite-target: /$1 # api-gateway에서 라우팅하므로 이부부은 주석 처리 되어야한다.
# nginx.ingress.kubernetes.io/websocket-services: "openvidu-service" # 웹소켓 지원
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
# 아래 tls 부분을 추가!
tls:
- hosts:
- "api.inong.shop"
secretName: inong-com-tls
- hosts:
- "api.inong.shop"
secretName: inong-com-tls
rules:
- host: api.inong.shop
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: apigateway-service
port:
number: 80 # 서비스 포트를 적어 줘야 한다.
- path: /openvidu
pathType: Prefix
backend:
service:
name: openvidu-service
port:
number: 4443
- host: api.inong.shop
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: apigateway-service
port:
number: 80 # 서비스 포트를 적어 줘야 한다.
43 changes: 0 additions & 43 deletions k8s/openvidu-depl.yml

This file was deleted.

Loading

0 comments on commit c131529

Please sign in to comment.