Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyuung committed Sep 11, 2024
2 parents 7ae8728 + f1b759d commit a44d8f0
Show file tree
Hide file tree
Showing 67 changed files with 1,575 additions and 304 deletions.
7 changes: 5 additions & 2 deletions db/src/main/java/db/domain/fault/FaultEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
@AllArgsConstructor
public class FaultEntity extends BaseEntity {

private LocalDateTime guaranteeAt;

@Column(length = 200, nullable = false)
private String description;

@Column(nullable = false)
private Boolean approval;

private LocalDateTime registeredAt;

@Column(nullable = false)
private Long receivingId;

Expand Down
2 changes: 2 additions & 0 deletions db/src/main/java/db/domain/fault/FaultRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

public interface FaultRepository extends JpaRepository<FaultEntity, Long> {

boolean existsByReceivingId(Long receivingId);

}
1 change: 1 addition & 0 deletions db/src/main/java/db/domain/goods/GoodsRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ public interface GoodsRepository extends JpaRepository<GoodsEntity,Long> {

List<GoodsEntity> findAllByShippingIdOrderByIdDesc(Long takeBackId);

List<GoodsEntity> findAllByStatusOrderByIdDesc(GoodsStatus status);
}
4 changes: 4 additions & 0 deletions db/src/main/java/db/domain/image/ImageRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public interface ImageRepository extends JpaRepository<ImageEntity,Long> {

Optional<ImageEntity> findFirstByIdOrderByIdDesc(Long imageId);

List<ImageEntity> findAllByImageMappingIdOrderByImageMappingId(Long id);

Optional<ImageEntity> findFirstByImageMappingIdOrderByIdDesc(Long imageMappingId);

}
34 changes: 34 additions & 0 deletions db/src/main/java/db/domain/store/GoodsLedgerEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package db.domain.store;

import db.domain.store.enums.StoreLocation;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "goods_ledger")
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GoodsLedgerEntity {

@Id
private Long goodsId;

@Enumerated(EnumType.STRING)
@Column(length = 50,columnDefinition = "VARCHAR(50)")
private StoreLocation location;

@Column(nullable = false)
private LocalDateTime storedDate;

}
9 changes: 9 additions & 0 deletions db/src/main/java/db/domain/store/GoodsLedgerRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package db.domain.store;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface GoodsLedgerRepository extends JpaRepository<GoodsLedgerEntity,Long> {

}
19 changes: 19 additions & 0 deletions db/src/main/java/db/domain/store/enums/StoreLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package db.domain.store.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum StoreLocation {

S1( "서울"),
S2( "부산"),
S3("대구"),
S4( "대전"),
S5( "목포"),
;

private final String location;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package db.domain.usedgoods;

import db.domain.usedgoods.enums.UsedGoodsStatus;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -15,6 +16,7 @@ public class EntitySearchCondition {

private Long usedGoodsId;
private String keyword;
private UsedGoodsStatus status;
private int minPrice;
private Integer maxPrice;
private LocalDateTime startDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public List<UsedGoodsEntity> usedGoodsSearchBy(EntitySearchCondition condition)
loeEndDate(condition.getEndDate()), // endDate 이전 날짜로 조회 진행함
ltUsedGoodsId(condition.getUsedGoodsId()), // cursor 방식 적용
isNotUnregistered(),
isUserId(condition.getUserId())
isUserId(condition.getUserId()),
filterBy(condition.getStatus()) // 파라미터로 받은 status로 필터링
)
.orderBy(getOrderSpecifier(condition.getPage().getSort()).stream()
.toArray(size -> new OrderSpecifier[size]))
Expand Down Expand Up @@ -85,4 +86,9 @@ private BooleanExpression isUserId(Long userId) {
return userId != null ? usedGoodsEntity.userId.eq(userId) : null;
}

private BooleanExpression filterBy(UsedGoodsStatus status) {
return status != null ? usedGoodsEntity.status.eq(status)
: usedGoodsEntity.status.ne(UsedGoodsStatus.UNREGISTERED);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ public enum UsedGoodsStatus {

REGISTERED(1, "중고 물품 등록", "판매 중인 중고 물품입니다."),
UNREGISTERED(2, "중고 물품 취소", "판매 취소된 중고 물품입니다."),
DEALING(3, "중고 거래 중", "현재 거래 중인 중고 물품입니다."),
DEAL(4, "중고 거래 확정", "거래가 확정된 중고 물품입니다."),
REMITTANCE(5, "송금 확인", "송금이 확인되었습니다."),
ASSIGNMENT(6, "물건 확인", "물건이 확인되었습니다."),
SOLD(7, "중고 거래 완료", "중고 물품 거래가 완료되었습니다.")
;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package db.domain.usedgoodsorder;

import db.common.BaseEntity;
import db.domain.usedgoodsorder.enums.UsedGoodsOrderStatus;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
Expand All @@ -25,11 +22,10 @@ public class UsedGoodsOrderEntity extends BaseEntity {


@Column(nullable = false)
private Long userId; // 구매자 ID
private Long buyerId; // 구매자 ID

@Enumerated(EnumType.STRING)
@Column(nullable = false, length = 50,columnDefinition = "VARCHAR(50)")
private UsedGoodsOrderStatus status;
@Column(nullable = false)
private Long sellerId; // 판매자 ID

private LocalDateTime createdAt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ public interface UsedGoodsOrderRepository extends JpaRepository<UsedGoodsOrderEn

List<UsedGoodsOrderEntity> findAllByUsedGoodsId(Long usedGoodsId);

List<UsedGoodsOrderEntity> findAllBySellerId(Long userId);

List<UsedGoodsOrderEntity> findAllByBuyerId(Long userId);

Optional<UsedGoodsOrderEntity> findFirstById(Long usedGoodsOrderId);

Optional<UsedGoodsOrderEntity> findByUsedGoodsIdAndUserId(Long usedGoodsId, Long userId);
Optional<UsedGoodsOrderEntity> findByUsedGoodsIdAndBuyerId(Long usedGoodsId, Long buyerId);

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package delivery.common.exception;

import delivery.common.error.ImageErrorCode;
import delivery.common.exception.image.ImageNotFoundException;
import delivery.common.exception.image.ImageStorageException;
import global.api.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
@Order(value = Integer.MIN_VALUE)
public class ImageExceptionHandler {

@ExceptionHandler(value = ImageStorageException.class)
public ResponseEntity<Api<Object>> imageException(ImageStorageException e) {
log.info("", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Api.ERROR(ImageErrorCode.IMAGE_STORAGE_ERROR));
}

@ExceptionHandler(value = ImageNotFoundException.class)
public ResponseEntity<Api<Object>> imageException(ImageNotFoundException e) {
log.info("", e);
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(Api.ERROR(ImageErrorCode.IMAGE_NOT_FOUND));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package delivery.common.exception.image;

import global.errorcode.ErrorCodeIfs;

public interface ApiExceptionIfs {

ErrorCodeIfs getErrorCodeIfs();

String getDescription();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package delivery.common.exception.image;

import global.errorcode.ErrorCodeIfs;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

@Getter
@ResponseStatus(HttpStatus.NOT_FOUND)
public class ImageNotFoundException extends RuntimeException implements ApiExceptionIfs {

private final ErrorCodeIfs errorCodeIfs;
private final String description;

public ImageNotFoundException(ErrorCodeIfs errorCodeIfs) {
super(errorCodeIfs.getDescription());
this.errorCodeIfs = errorCodeIfs;
this.description = errorCodeIfs.getDescription();
}

public ImageNotFoundException(ErrorCodeIfs errorCodeIfs, String errorDescription) {
this.errorCodeIfs = errorCodeIfs;
this.description = errorDescription;
}

public ImageNotFoundException(ErrorCodeIfs errorCodeIfs, Throwable throwable) {
super(throwable);
this.errorCodeIfs = errorCodeIfs;
this.description = errorCodeIfs.getDescription();
}

public ImageNotFoundException(ErrorCodeIfs errorCodeIfs, Throwable throwable,
String errorDescription) {
super(throwable);
this.errorCodeIfs = errorCodeIfs;
this.description = errorDescription;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package delivery.common.exception.image;

import global.errorcode.ErrorCodeIfs;
import lombok.Getter;

@Getter
public class ImageStorageException extends RuntimeException implements ApiExceptionIfs {

private final ErrorCodeIfs errorCodeIfs;
private final String description;

public ImageStorageException(ErrorCodeIfs errorCodeIfs) {
super(errorCodeIfs.getDescription());
this.errorCodeIfs = errorCodeIfs;
this.description = errorCodeIfs.getDescription();
}

public ImageStorageException(ErrorCodeIfs errorCodeIfs, String errorDescription) {
this.errorCodeIfs = errorCodeIfs;
this.description = errorDescription;
}

public ImageStorageException(ErrorCodeIfs errorCodeIfs, Throwable throwable) {
super(throwable);
this.errorCodeIfs = errorCodeIfs;
this.description = errorCodeIfs.getDescription();
}

public ImageStorageException(ErrorCodeIfs errorCodeIfs, Throwable throwable,
String errorDescription) {
super(throwable);
this.errorCodeIfs = errorCodeIfs;
this.description = errorDescription;
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
package delivery.domain.image.converter;

import db.domain.image.ImageEntity;
import db.domain.imagemapping.ImageMappingEntity;
import delivery.domain.goods.controller.model.ImageSet;
import delivery.domain.image.service.ImageMappingService;
import global.annotation.Converter;
import java.util.List;
import lombok.RequiredArgsConstructor;

@Converter
@RequiredArgsConstructor
public class ImageConverter {

private final ImageMappingService imageMappingService;

public List<ImageSet> toImageSetList(List<ImageEntity> imageEntityList) {
return imageEntityList.stream().map(imageEntity -> {
return toImageSet(imageEntity);
}).toList();
}

public ImageSet toImageSet(ImageEntity imageEntity) {
ImageMappingEntity imageMappingEntity = imageMappingService.getImageMappingBy(
imageEntity.getImageMappingId());
return ImageSet.builder()
.imageId(imageEntity.getId())
.caption(imageEntity.getCaption())
.kind(imageMappingEntity.getKind())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package delivery.domain.image.service;

import db.domain.imagemapping.ImageMappingEntity;
import db.domain.imagemapping.ImageMappingRepository;
import delivery.common.error.ImageErrorCode;
import delivery.common.exception.image.ImageNotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ImageMappingService {

private final ImageMappingRepository imageMappingRepository;

public ImageMappingEntity getImageMappingBy(Long imageMappingId) {
return imageMappingRepository.findById(imageMappingId)
.orElseThrow(() -> new ImageNotFoundException(ImageErrorCode.IMAGE_NOT_FOUND));
}
}
Loading

0 comments on commit a44d8f0

Please sign in to comment.