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

사용하지 않는 초기데이터 세팅 제거 #714

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
51cdc82
comment: #617 불필요한 todo 삭제 (#618)
kwonyj1022 Oct 11, 2023
29d58db
cd: #619 운영 서버 배포 스크립트에 무중단 배포 적용 (#624)
kwonyj1022 Oct 12, 2023
fdcaeb2
feat: #603 경매 상세 조회 시 경매글을 찾을 수 없을 때만 404를 보내도록 수정 (#604)
kwonyj1022 Oct 12, 2023
fe25e4a
fix: 메시지 전송 시 작성자 이미지가 전송되도록 수정 (#634)
swonny Oct 12, 2023
c2ab4b3
!hotfix: actuator 관련 변수 추가 (#636)
kwonyj1022 Oct 12, 2023
08c40c9
fix: actuator 변수 설정 (#638)
kwonyj1022 Oct 12, 2023
282e9a6
refactor: #605 경매 목록 조회 시 마감된 경매의 정렬 순서를 후순위로 변경 (#608)
apptie Oct 13, 2023
874913e
refactor: #613 경매 등록 시 경매 마감 시간 제한 변경 (#620)
apptie Oct 13, 2023
2958fe9
refactor: #609 소셜 로그인 시 최초 로그인(회원가입)한 회원인지 여부 반환 (#612)
apptie Oct 13, 2023
0d78095
feat: #585 상호 평가 반영 스케줄링 (#602)
kwonyj1022 Oct 13, 2023
7143025
refactor: #625 회원 탈퇴 시 소셜 로그인 방식을 DB에서 조회하도록 변경 (#626)
apptie Oct 13, 2023
3ff04a4
feat: #587 Q&A 알림 기능 구현 (#614)
swonny Oct 13, 2023
149a646
refactor: #649 Auction 관련 인프라 리펙토링 (#651)
apptie Oct 14, 2023
d0ce0d5
refactor: #648 Category 관련 인프라 리펙토링 (#650)
apptie Oct 14, 2023
3160e7d
refactor: #645 Authentication 관련 인프라 리펙토링 (#647)
apptie Oct 14, 2023
455e3ab
refactor: #655 User 관련 인프라 리팩토링 (#661)
kwonyj1022 Oct 14, 2023
b386153
refactor: #656 ChatRoom 관련 인프라 리팩토링 (#663)
kwonyj1022 Oct 14, 2023
3f63037
refactor: #658 Region 관련 인프라 리팩토링 (#665)
kwonyj1022 Oct 14, 2023
34aa5fa
refactor: #657 Review 관련 인프라 리팩토링 (#664)
kwonyj1022 Oct 14, 2023
a45c7d2
refactor: #659 입찰 목록 조회 API 명세 변경에 따른 수정 (#667)
JJ503 Oct 14, 2023
d9a3026
refactor: #660 Q&A 목록 조회 API 명세 변경에 따른 수정 (#669)
JJ503 Oct 14, 2023
d516c37
fix: #680 신규 회원가입이 안되는 버그 수정 (#681)
apptie Oct 15, 2023
7d1f855
refactor: #670 Image 관련 인프라 리팩토링 (#678)
JJ503 Oct 15, 2023
57026a2
refactor: #671 Bid 관련 인프라 리팩토링 (#684)
JJ503 Oct 15, 2023
ca3b225
refactor: #672 Report 관련 인프라 리팩토링 (#685)
JJ503 Oct 15, 2023
6351bee
refactor: #673 Q&A 관련 인프라 리팩토링 (#686)
JJ503 Oct 15, 2023
d139814
feat: #687 닉네임 수정 시 중복 예외 처리 추가 (#688)
JJ503 Oct 15, 2023
fa8e296
refactor: #689 Message 인프라 리팩토링 (#694)
swonny Oct 15, 2023
a58f961
refactor: #692 경매 상세 조회 시 로그인한 사용자가 해당 경매의 최고 입찰자인지 여부를 반환하도록 응답 형식 변…
apptie Oct 15, 2023
7507116
refactor: #690 Device 인프라 리팩토링 (#696)
swonny Oct 15, 2023
d8096cf
refactor: #697 질문과 답변 조회 시 삭제된 답변은 보이지 않도록 수정 (#698)
JJ503 Oct 15, 2023
937b365
fix: 답변이 null인 경우에 대한 처리 추가 (#700)
JJ503 Oct 16, 2023
1952051
feat: #573 탈퇴 시 사용자 닉네임 랜덤 값으로 수정 (#606)
JJ503 Oct 16, 2023
ec335a1
fix: #701 답변 삭제 시 다시 답변을 달지 못하는 문제 해결 (#704)
JJ503 Oct 17, 2023
87e42e1
fix: flyway 스크립트 문제 해결 (#706)
JJ503 Oct 17, 2023
55c844b
feat: #705 경매 관련 탈퇴 로직 추가 (#710)
JJ503 Oct 18, 2023
3647925
remove: 사용하지 않는 초기데이터 세팅 제거
kwonyj1022 Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
65 changes: 57 additions & 8 deletions backend/ddang/script/prod-deploy-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,66 @@ ABSPATH=$(readlink -f $0) # /home/ubuntu/prod-deploy-script.sh
ABSDIR=$(dirname $ABSPATH) # /home/ubuntu
APPNAME="ddang-0.0.1-SNAPSHOT"
APPDIR=${ABSDIR}/${APPNAME} # /home/ubuntu/ddang-0.0.1-SNAPSHOT
PORT_A=8080
PORT_B=8081
DEFAULT_ACTUATOR_PORT=3000
ANOTHER_ACTUATOR_PORT=3001

echo "구동중인 애플리케이션을 확인합니다."
if curl -s "http://localhost:${PORT_A}" > /dev/null
then
green_port=${PORT_B}
blue_port=${PORT_A}
else
green_port=${PORT_A}
blue_port=${PORT_B}
fi

CURRENT_PID=$(pgrep -f ${APPNAME}.jar) # ddang-0.0.1-SNAPSHOT.jar
if curl -s "http://localhost:${green_port}" > /dev/null
then
echo "그린 서버가 이미 동작 중입니다."
exit 255
fi

if [ ! -z ${CURRENT_PID} ]; then
echo "기존 애플리케이션이 실행중이므로 종료합니다."
kill -15 ${CURRENT_PID}
sleep 5
if curl -s "http://localhost:${DEFAULT_ACTUATOR_PORT}" > /dev/null
then
actuator_port=${ANOTHER_ACTUATOR_PORT}
else
actuator_port=${DEFAULT_ACTUATOR_PORT}
fi

echo "애플리케이션을 실행합니다."
echo "그린 서버를 실행합니다. port number: ${green_port}"

nohup java -jar ${ABSDIR}/${APPNAME}.jar --server.port=${green_port} --spring.profiles.active=prod --management.server.port=${actuator_port} 1>> prod.log 2>> prod_error.log & # /home/ubuntu/ddang-0.0.1-SNAPSHOT.jar

for retry_count in $(seq 10)
do
if curl -s "http://localhost:${green_port}" > /dev/null
then
echo "Health check success ✅ port number: ${green_port}"
break
fi

if [ $retry_count -eq 10 ]
then
echo "Health check failed ❌ port number: ${green_port}"
exit 1
fi

nohup java -jar ${ABSDIR}/${APPNAME}.jar --spring.profiles.active=prod 1>> prod.log 2>> prod_error.log & # /home/ubuntu/ddang-0.0.1-SNAPSHOT.jar
echo "서버가 아직 실행되지 않았습니다... 시도 횟수: ${retry_count}"
sleep 10
done

echo "set \$service_port ${green_port};" | sudo tee /etc/nginx/conf.d/service-port.inc
echo "set \$actuator_port ${actuator_port};" | sudo tee /etc/nginx/conf.d/actuator-port.inc
sudo systemctl restart nginx

echo "블루 서버를 종료합니다. port number: ${blue_port}"
fuser -s -k ${blue_port}/tcp

if curl -s "http://localhost:${blue_port}" > /dev/null
then
echo "블루 서버가 아직 종료되지 않았습니다... 시도 횟수: ${blue_port}"
sleep 10
else
echo "블루 서버가 종료되었습니다. port number: ${blue_port}"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,39 @@
import com.ddang.ddang.auction.application.exception.AuctionNotFoundException;
import com.ddang.ddang.auction.application.exception.UserForbiddenException;
import com.ddang.ddang.auction.domain.Auction;
import com.ddang.ddang.auction.infrastructure.persistence.JpaAuctionRepository;
import com.ddang.ddang.auction.domain.repository.AuctionRepository;
import com.ddang.ddang.auction.presentation.dto.request.ReadAuctionSearchCondition;
import com.ddang.ddang.category.application.exception.CategoryNotFoundException;
import com.ddang.ddang.category.domain.Category;
import com.ddang.ddang.category.infrastructure.persistence.JpaCategoryRepository;
import com.ddang.ddang.category.domain.repository.CategoryRepository;
import com.ddang.ddang.image.domain.AuctionImage;
import com.ddang.ddang.image.domain.StoreImageProcessor;
import com.ddang.ddang.image.domain.dto.StoreImageDto;
import com.ddang.ddang.region.application.exception.RegionNotFoundException;
import com.ddang.ddang.region.domain.AuctionRegion;
import com.ddang.ddang.region.domain.Region;
import com.ddang.ddang.region.infrastructure.persistence.JpaRegionRepository;
import com.ddang.ddang.region.domain.repository.RegionRepository;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
import com.ddang.ddang.user.domain.User;
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository;
import java.time.LocalDateTime;
import java.util.List;
import com.ddang.ddang.user.domain.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class AuctionService {

private final JpaUserRepository userRepository;
private final JpaAuctionRepository auctionRepository;
private final JpaRegionRepository regionRepository;
private final JpaCategoryRepository categoryRepository;
private final UserRepository userRepository;
private final AuctionRepository auctionRepository;
private final RegionRepository regionRepository;
private final CategoryRepository categoryRepository;
private final StoreImageProcessor imageProcessor;

@Transactional
Expand Down Expand Up @@ -79,7 +80,7 @@ private void validateAuctionRegions(final List<Region> thirdRegions) {
}

public ReadAuctionDto readByAuctionId(final Long auctionId) {
final Auction findAuction = auctionRepository.findAuctionById(auctionId)
final Auction findAuction = auctionRepository.findTotalAuctionById(auctionId)
.orElseThrow(() -> new AuctionNotFoundException(
"지정한 아이디에 대한 경매를 찾을 수 없습니다."
));
Expand All @@ -91,8 +92,8 @@ public ReadAuctionsDto readAllByCondition(
final Pageable pageable,
final ReadAuctionSearchCondition readAuctionSearchCondition) {
final Slice<Auction> auctions = auctionRepository.findAuctionsAllByCondition(
pageable,
readAuctionSearchCondition
readAuctionSearchCondition,
pageable
);

return ReadAuctionsDto.of(auctions, LocalDateTime.now());
Expand All @@ -112,7 +113,7 @@ public ReadAuctionsDto readAllByBidderId(final Long userId, final Pageable pagea

@Transactional
public void deleteByAuctionId(final Long auctionId, final Long userId) {
final Auction auction = auctionRepository.findAuctionById(auctionId)
final Auction auction = auctionRepository.findTotalAuctionById(auctionId)
.orElseThrow(() -> new AuctionNotFoundException(
"지정한 아이디에 대한 경매를 찾을 수 없습니다."
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public record ReadAuctionDto(
String sellerName,
double sellerReliability,
boolean isSellerDeleted,
AuctionStatus auctionStatus
AuctionStatus auctionStatus,
Long lastBidderId
) {

public static ReadAuctionDto of(final Auction auction, final LocalDateTime targetTime) {
Expand All @@ -53,7 +54,8 @@ public static ReadAuctionDto of(final Auction auction, final LocalDateTime targe
auction.getSeller().getName(),
auction.getSeller().getReliability().getValue(),
auction.getSeller().isDeleted(),
auction.findAuctionStatus(targetTime)
auction.findAuctionStatus(targetTime),
convertLastBidderId(auction)
);
}

Expand All @@ -79,4 +81,12 @@ private static List<ReadRegionsDto> convertReadRegionsDto(final Auction auction)
.map(ReadRegionsDto::from)
.toList();
}

private static Long convertLastBidderId(final Auction auction) {
if (auction.getLastBid() == null) {
return null;
}

return auction.getLastBid().getBidder().getId();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.ddang.ddang.auction.application.dto;

public record ReadChatRoomDto(Long id, boolean isChatParticipant) {

public static ReadChatRoomDto CANNOT_CHAT_DTO = new ReadChatRoomDto(null, false);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ddang.ddang.auction.configuration.validator;

import jakarta.validation.Constraint;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = ClosingTimeValidator.class)
public @interface ClosingTimeLimit {

String message() default "마감 시간은 현재 일자로부터 최대 30일까지 설정할 수 있습니다.";

Class[] groups() default {};

Class[] payload() default {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.ddang.ddang.auction.configuration.validator;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class ClosingTimeValidator implements ConstraintValidator<ClosingTimeLimit, LocalDateTime> {

private static final int MAXIMUM_CLOSING_TIME_DAYS = 30;

@Override
public boolean isValid(final LocalDateTime target, final ConstraintValidatorContext context) {
if (target == null) {
return false;
}

final long days = ChronoUnit.DAYS.between(LocalDateTime.now(), target);

return days <= MAXIMUM_CLOSING_TIME_DAYS;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ddang.ddang.auction.infrastructure.persistence.dto;
package com.ddang.ddang.auction.domain.dto;

import com.ddang.ddang.auction.domain.Auction;
import com.ddang.ddang.image.domain.AuctionImage;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ddang.ddang.auction.domain.repository;

import com.ddang.ddang.auction.domain.dto.AuctionAndImageDto;
import java.util.Optional;

public interface AuctionAndImageRepository {

Optional<AuctionAndImageDto> findDtoByAuctionId(final Long auctionId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.ddang.ddang.auction.domain.repository;

import com.ddang.ddang.auction.domain.Auction;
import com.ddang.ddang.auction.presentation.dto.request.ReadAuctionSearchCondition;

import java.time.LocalDateTime;
import java.util.Optional;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;

public interface AuctionRepository {

Auction save(final Auction auction);

boolean existsById(final Long id);

Optional<Auction> findTotalAuctionById(final Long id);

Optional<Auction> findPureAuctionById(final Long id);

Slice<Auction> findAuctionsAllByCondition(
final ReadAuctionSearchCondition readAuctionSearchCondition,
final Pageable pageable
);

Slice<Auction> findAuctionsAllByUserId(final Long userId, final Pageable pageable);

Slice<Auction> findAuctionsAllByBidderId(final Long bidderId, final Pageable pageable);

boolean existsBySellerIdAndAuctionStatusIsOngoing(final Long userId, final LocalDateTime now);

boolean existsLastBidByUserIdAndAuctionStatusIsOngoing(final Long userId, final LocalDateTime now);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.ddang.ddang.auction.infrastructure.persistence;

import com.ddang.ddang.auction.domain.Auction;
import com.ddang.ddang.auction.domain.repository.AuctionRepository;
import com.ddang.ddang.auction.presentation.dto.request.ReadAuctionSearchCondition;

import java.time.LocalDateTime;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class AuctionRepositoryImpl implements AuctionRepository {

private final JpaAuctionRepository jpaAuctionRepository;
private final QuerydslAuctionRepository querydslAuctionRepository;

@Override
public Auction save(final Auction auction) {
return jpaAuctionRepository.save(auction);
}

@Override
public boolean existsById(final Long id) {
return jpaAuctionRepository.existsById(id);
}

@Override
public Optional<Auction> findTotalAuctionById(final Long id) {
return jpaAuctionRepository.findTotalAuctionById(id);
}

@Override
public Optional<Auction> findPureAuctionById(final Long id) {
return jpaAuctionRepository.findPureAuctionById(id);
}

@Override
public Slice<Auction> findAuctionsAllByCondition(
final ReadAuctionSearchCondition readAuctionSearchCondition,
final Pageable pageable
) {
return querydslAuctionRepository.findAuctionsAllByCondition(readAuctionSearchCondition, pageable);
}

@Override
public Slice<Auction> findAuctionsAllByUserId(final Long userId, final Pageable pageable) {
return querydslAuctionRepository.findAuctionsAllByUserId(userId, pageable);
}

@Override
public Slice<Auction> findAuctionsAllByBidderId(final Long bidderId, final Pageable pageable) {
return querydslAuctionRepository.findAuctionsAllByBidderId(bidderId, pageable);
}

@Override
public boolean existsBySellerIdAndAuctionStatusIsOngoing(final Long userId, final LocalDateTime now) {
return jpaAuctionRepository.existsBySellerIdAndDeletedIsFalseAndClosingTimeGreaterThanEqual(userId, now);
}

@Override
public boolean existsLastBidByUserIdAndAuctionStatusIsOngoing(final Long userId, final LocalDateTime now) {
return jpaAuctionRepository.existsByLastBidBidderIdAndDeletedIsFalseAndClosingTimeGreaterThanEqual(
userId,
now
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,38 @@

import com.ddang.ddang.auction.domain.Auction;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.time.LocalDateTime;
import java.util.Optional;

public interface JpaAuctionRepository extends JpaRepository<Auction, Long>, QuerydslAuctionRepository, QuerydslAuctionAndImageRepository {
public interface JpaAuctionRepository extends JpaRepository<Auction, Long> {

Optional<Auction> findByIdAndDeletedIsFalse(final Long id);
@Query("""
SELECT a
FROM Auction a
LEFT JOIN FETCH a.auctionRegions ar
LEFT JOIN FETCh ar.thirdRegion tr
LEFT JOIN FETCH tr.firstRegion
LEFT JOIN FETCH tr.secondRegion
LEFT JOIN FETCH a.lastBid
JOIN FETCH a.subCategory sc
JOIN FETCH sc.mainCategory
JOIN FETCH a.seller
WHERE a.deleted = false AND a.id = :id
""")
Optional<Auction> findTotalAuctionById(final Long id);

@Query("SELECT a FROM Auction a WHERE a.deleted = false AND a.id = :id")
Optional<Auction> findPureAuctionById(final Long id);

boolean existsBySellerIdAndDeletedIsFalseAndClosingTimeGreaterThanEqual(
final Long userId,
final LocalDateTime now
);

boolean existsByLastBidBidderIdAndDeletedIsFalseAndClosingTimeGreaterThanEqual(
final Long userId,
final LocalDateTime now
);
}
Loading
Loading