Skip to content

Commit

Permalink
fix: 충돌 해결 #225
Browse files Browse the repository at this point in the history
  • Loading branch information
jjt4515 committed Nov 19, 2024
2 parents b963a70 + e9b2a7e commit 4edc909
Show file tree
Hide file tree
Showing 54 changed files with 756 additions and 163 deletions.
546 changes: 542 additions & 4 deletions README.md

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ dependencies {
implementation(platform("software.amazon.awssdk:bom:2.27.21"))
implementation("software.amazon.awssdk:s3")

implementation platform("io.awspring.cloud:spring-cloud-aws-dependencies:3.0.1")
implementation 'io.awspring.cloud:spring-cloud-aws-starter-sqs'

// 아임포트 및 아임포트 웹훅
implementation 'com.github.iamport:iamport-rest-client-java:0.2.23'

Expand Down
Binary file added docs/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/cart-erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deploy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/domae.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/farm-domain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/farm-erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/goal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/grak.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/member-erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/naver-ocr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/payment-process.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/product-domain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/product-erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/slack-monitoring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/wishlist-erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
import poomasi.domain.reservation.entity.Reservation;
import poomasi.domain.reservation.service.ReservationService;
import poomasi.global.error.ApplicationException;
import poomasi.global.error.BusinessError;
import poomasi.global.error.BusinessException;
import poomasi.payment.entity.Payment;
import poomasi.payment.util.PaymentUtil;

import java.math.BigDecimal;

import static poomasi.domain.reservation.entity.ReservationStatus.CANCELED;
import static poomasi.domain.reservation.entity.ReservationStatus.PENDING;
import static poomasi.global.error.ApplicationError.PAYMENT_CHECKSUM_EXCESSIVE_REFUND_AMOUNT;

@Service
Expand All @@ -39,6 +42,13 @@ public FarmCancelResponse cancel(FarmCancelRequest farmCancelRequest){
Long reservationId = farmCancelRequest.reservationId();
Reservation reservation = reservationService.getReservation(reservationId);
BigDecimal cancelAmount = reservationService.calculateRefundAmount(reservation);


//1.1 펜딩 상태가 아니라면
if(reservation.getStatus()!=PENDING){
throw new BusinessException(BusinessError.RESERVATION_CANCELLATION_PERIOD_EXPIRED);
}

//2. farmaftersales 만들기
FarmAfterSales farmAfterSales = FarmAfterSales
.builder()
Expand All @@ -62,8 +72,6 @@ public FarmCancelResponse cancel(FarmCancelRequest farmCancelRequest){
}




@Description("security context에서 member 객체 가져오는 메서드")
private Member getMember() {
Authentication authentication = SecurityContextHolder
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/poomasi/domain/auth/config/CorsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public CorsConfigurationSource corsConfigurationSource() {
config.setAllowedOrigins(Arrays.asList(
"https://localhost:3000",
"https://poomasi.shop",
"https://*.poomasi.shop"
"https://*.poomasi.shop",
"http://*.poomasi.shop",
"http://localhost:3000",
"https://test.poomasi.shop:3000"
));

config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
Expand Down
38 changes: 32 additions & 6 deletions src/main/java/poomasi/domain/auth/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter;
Expand Down Expand Up @@ -50,6 +51,12 @@ public class SecurityConfig {
@Autowired
private OAuth2UserDetailServiceImpl oAuth2UserDetailServiceImpl;

@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return web -> web.ignoring()
.requestMatchers("/error", "/favicon.ico");
}

@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception {
return configuration.getAuthenticationManager();
Expand Down Expand Up @@ -88,6 +95,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.requestMatchers("/oauth2/authentication/kakao").authenticated()
.requestMatchers("api/orders/**").authenticated()
.requestMatchers(HttpMethod.POST, "api/logout").authenticated()
.requestMatchers(HttpMethod.POST, "api/payments/**").authenticated()
.requestMatchers(HttpMethod.POST, "api/aftersales/**").authenticated()


//진택 api
.requestMatchers(HttpMethod.POST, "/api/reissue").authenticated()
Expand Down Expand Up @@ -122,12 +132,28 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti


//풍헌 api
.requestMatchers("/api/cart/**").authenticated()
.requestMatchers("/api/categories").authenticated()
.requestMatchers("/api/reviews/**").authenticated()
.requestMatchers("/api/products/**").authenticated()
.requestMatchers("/api/store/**").authenticated()

.requestMatchers(HttpMethod.GET, "/api/cart/**").authenticated() // GET 요청에 대해 인증 필요
.requestMatchers(HttpMethod.POST, "/api/cart/**").authenticated() // POST 요청에 대해 인증 필요
.requestMatchers(HttpMethod.PUT, "/api/cart/**").authenticated() // PUT 요청에 대해 인증 필요
.requestMatchers(HttpMethod.DELETE, "/api/cart/**").authenticated() // DELETE 요청에 대해 인증 필요

// /api/categories/** 경로에 대한 인증 요구
.requestMatchers(HttpMethod.POST, "/api/categories/**").authenticated() // POST 요청에 대해 인증 필요
.requestMatchers(HttpMethod.PUT, "/api/categories/**").authenticated() // PUT 요청에 대해 인증 필요
.requestMatchers(HttpMethod.DELETE, "/api/categories/**").authenticated() // DELETE 요청에 대해 인증 필요

// /api/reviews/** 경로에 대한 인증 요구
.requestMatchers(HttpMethod.PUT, "/api/reviews/**").authenticated() // PUT 요청에 대해 인증 필요
.requestMatchers(HttpMethod.DELETE, "/api/reviews/**").authenticated() // DELETE 요청에 대해 인증 필요

// /api/products/** 경로에 대한 인증 요구
.requestMatchers(HttpMethod.POST, "/api/products/**").authenticated() // POST 요청에 대해 인증 필요
.requestMatchers(HttpMethod.PUT, "/api/products/**").authenticated() // PUT 요청에 대해 인증 필요
.requestMatchers(HttpMethod.DELETE, "/api/products/**").authenticated() // DELETE 요청에 대해 인증 필요

// /api/stores/** 경로에 대한 인증 요구
.requestMatchers(HttpMethod.POST, "/api/stores/**").authenticated() // POST 요청에 대해 인증 필요
.requestMatchers(HttpMethod.PUT, "/api/stores/**").authenticated() // PUT 요청에 대해 인증 필요

.anyRequest().permitAll()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseCookie;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
Expand Down Expand Up @@ -67,7 +68,7 @@ protected void successfulAuthentication(HttpServletRequest request, HttpServletR
String refreshToken = jwtUtil.generateRefreshTokenById(memberId);

log.info("username password 기반 로그인 성공 . cookie에 토큰을 넣어 발급합니다.");
response.addCookie(createCookie("refresh", refreshToken));
createCookie("refresh", refreshToken, response);
response.setStatus(HttpStatus.OK.value());

refreshTokenWhitelistService.putRefreshToken(refreshToken, memberId);
Expand All @@ -82,12 +83,16 @@ protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServle
response.setStatus(401);
}

private Cookie createCookie(String key, String value) {
Cookie cookie = new Cookie(key, value);
cookie.setMaxAge(24*60*60);
cookie.setHttpOnly(true);
cookie.setDomain("https://poomasi.shop");
return cookie;
private void createCookie(String key, String value, HttpServletResponse response){
ResponseCookie cookie = ResponseCookie.from(key, value)
.path("/")
.sameSite("None")
.httpOnly(true)
.secure(true)
.domain("poomasi.shop")
.maxAge(60*60*24*7)
.build();
response.addHeader("Set-Cookie", cookie.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseCookie;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -42,26 +43,24 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
String accessToken = jwtUtil.generateAccessTokenById(memberId);
String refreshToken = jwtUtil.generateRefreshTokenById(memberId);

response.addCookie(createCookie("refresh", refreshToken));
createCookie("refresh", refreshToken, response);
response.setStatus(HttpStatus.OK.value());

//refresh token db에 저장

refreshTokenWhitelistService.putRefreshToken(refreshToken, memberId);
response.sendRedirect("https://poomasi.shop/callback/kakao"+"?access=" + accessToken);
}

private Cookie createCookie(String key, String value) {

Cookie cookie = new Cookie(key, value);
cookie.setMaxAge(60*60*60);
cookie.setSecure(true);
cookie.setPath("/");
cookie.setHttpOnly(true);
cookie.setDomain("https://poomasi.shop");


return cookie;
private void createCookie(String key, String value, HttpServletResponse response){
ResponseCookie cookie = ResponseCookie.from(key, value)
.path("/")
.sameSite("None")
.httpOnly(true)
.secure(true)
.domain("poomasi.shop")
.maxAge(60*60*24*7)
.build();
response.addHeader("Set-Cookie", cookie.toString());
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/poomasi/domain/farm/controller/FarmController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ public ResponseEntity<FarmDetailResponse> getFarmDetail(@PathVariable Long farmI
return ResponseEntity.ok(farmPlatformService.getFarmDetailByFarmId(farmId));
}

@GetMapping("Farm 다건 조회")
@Description("Farm 카테고리로 조회")
@GetMapping("/category/{categoryId}")
public ResponseEntity<?> getFarmListByCategory(@PathVariable Long categoryId, Pageable pageable) {
return ResponseEntity.ok(farmPlatformService.getFarmListByCategory(categoryId, pageable));
}

@Description("Farm 다건 조회")
@GetMapping("")
public ResponseEntity<?> getFarmList(Pageable pageable) {
return ResponseEntity.ok(farmPlatformService.getFarmList(pageable));
}

@GetMapping("byFarmer/{farmerId}")
@GetMapping("/byFarmer/{farmerId}")
public ResponseEntity<?> getFarmsByFarmerId(@PathVariable Long farmerId) {
return ResponseEntity.ok(farmPlatformService.getFarmsByFarmerId(farmerId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.stereotype.Repository;
import poomasi.domain.farm.entity.Farm;

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

Expand All @@ -20,4 +21,6 @@ public interface FarmRepository extends JpaRepository<Farm, Long> {
Optional<Farm> findByIdAndDeletedAtIsNull(Long id);

List<Farm> findAllByOwnerIdAndDeletedAtIsNull(Long farmerId);

Page<Farm> findByCategoryIdAndDeletedAtIsNull(Long categoryId, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.query.JpaEntityGraph;
import org.springframework.stereotype.Service;
import poomasi.domain.farm._schedule.dto.FarmScheduleResponse;
import poomasi.domain.farm._schedule.service.FarmScheduleService;
Expand Down Expand Up @@ -44,4 +45,10 @@ public List<FarmResponse> getFarmsByFarmerId(Long farmerId) {
.map(FarmResponse::fromEntity)
.collect(Collectors.toList());
}

public List<FarmResponse> getFarmListByCategory(Long categoryId, Pageable pageable) {
return farmService.getFarmListByCategory(categoryId, pageable).stream()
.map(FarmResponse::fromEntity)
.collect(Collectors.toList());
}
}
7 changes: 7 additions & 0 deletions src/main/java/poomasi/domain/farm/service/FarmService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import poomasi.global.error.BusinessError;
import poomasi.global.error.BusinessException;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -49,4 +50,10 @@ public void delete(Farm farm) {
farm.delete();
farmRepository.save(farm);
}

public Collection<Farm> getFarmListByCategory(Long categoryId, Pageable pageable) {
return farmRepository.findByCategoryIdAndDeletedAtIsNull(categoryId, pageable)
.stream()
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ public ResponseEntity<Void> recoverImage(@AuthenticationPrincipal UserDetailsImp
}


}
}
3 changes: 2 additions & 1 deletion src/main/java/poomasi/domain/image/service/ImageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ public ImageResponse saveImage(Long memberId, ImageRequest imageRequest) {
.map(existingImage -> recoverImageOrThrow(existingImage, imageRequest))
.orElseGet(() -> imageRequest.toEntity(imageRequest));

image = imageRepository.save(image);
imageLink(image);

return ImageResponse.fromEntity(imageRepository.save(image));
return ImageResponse.fromEntity(image);
}

// 이미지 주인이 맞는지 검증
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public class OrderController {

@GetMapping("")
@Secured({"ROLE_CUSTOMER", "ROLE_FARMER"})
public ResponseEntity<?> getAllOrders(@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size) {
List<OrderResponse> orders = orderService.getOrders(page, size);
public ResponseEntity<?> getAllOrders() {
List<OrderResponse> orders = orderService.getOrders();
return ResponseEntity.ok(orders);
}

Expand Down
22 changes: 22 additions & 0 deletions src/main/java/poomasi/domain/order/entity/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jdk.jfr.Timestamp;
import lombok.Builder;
import lombok.Getter;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.UpdateTimestamp;
Expand All @@ -17,6 +18,9 @@
import java.util.ArrayList;
import java.util.List;

import static poomasi.payment.entity.PaymentStatus.PAYMENT_COMPLETE;
import static poomasi.payment.entity.PaymentStatus.PAYMENT_DECLINED;

@Entity
@Table(name = "product_order")
@Getter
Expand All @@ -43,6 +47,9 @@ public class Order {
@UpdateTimestamp
private LocalDateTime updateAt = LocalDateTime.now();

@Comment("예약 취소 일자")
private LocalDateTime canceledAt;

@Column(name = "deleted_at")
@Timestamp
private LocalDateTime deletedAt;
Expand Down Expand Up @@ -109,4 +116,19 @@ public void setPayment(Payment payment){
this.payment=payment;
payment.setOrder(this);
}

public void setPaymentComplete(){
this.payment.setPaymentStatus(PAYMENT_COMPLETE);
}

public void cancel(){
this.payment.setPaymentStatus(PAYMENT_DECLINED);
this.canceledAt = LocalDateTime.now();
}


public void setImpUid(String impUid){
this.payment.setImpUid(impUid);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
public interface OrderRepository extends JpaRepository<Order, Long> {
Optional<Order> findByMerchantUid(String merchantUid);
Page<Order> findById(Long id, Pageable pageable);
Page<Order> findByMemberId(Long memberId, Pageable pageable);
List<Order> findByMemberId(Long memberId);
//Page<Order> findByMemberId(Long memberId, Pageable pageable);

@Query("SELECT o FROM Order o WHERE o.updateAt BETWEEN :startDate AND :endDate")
List<Order> findAllByUpdateAtBetween(@Param("startDate") LocalDateTime startDate,
Expand All @@ -42,5 +43,4 @@ Page<CategoryMonthlySalesResponse> findCategoryMonthlySales(
@Param("endDate") LocalDateTime endDate,
Pageable pageable
);

}
Loading

0 comments on commit 4edc909

Please sign in to comment.