-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from imdangg/feat/fix
인사이트 API 수정
- Loading branch information
Showing
22 changed files
with
258 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...ava/com/project/imdang/insight/service/domain/dto/insight/list/InsightSimpleResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.project.imdang.insight.service.domain.dto.insight.list; | ||
|
||
import com.project.imdang.insight.service.domain.valueobject.Address; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.UUID; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class InsightSimpleResponse { | ||
private UUID insightId; | ||
private Integer recommendedCount; | ||
private Address address; | ||
private String title; | ||
} |
24 changes: 24 additions & 0 deletions
24
...project/imdang/insight/service/domain/dto/insight/list/ListMyInsightCreatedByMeQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.project.imdang.insight.service.domain.dto.insight.list; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.UUID; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class ListMyInsightCreatedByMeQuery { | ||
// extends PagingQuery { | ||
// @Setter | ||
private UUID memberId; | ||
|
||
private Integer pageNumber; | ||
private Integer pageSize; | ||
private String direction; | ||
private String[] properties; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 15 additions & 29 deletions
44
...va/com/project/imdang/insight/service/domain/handler/ExchangeRequestMemberCouponSaga.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,51 @@ | ||
package com.project.imdang.insight.service.domain.handler; | ||
|
||
import com.project.imdang.domain.event.EmptyEvent; | ||
import com.project.imdang.domain.message.MemberCouponPendingUpdatedResponseMessage; | ||
import com.project.imdang.domain.valueobject.ExchangeRequestId; | ||
import com.project.imdang.insight.service.domain.ExchangeDomainService; | ||
import com.project.imdang.insight.service.domain.entity.ExchangeRequest; | ||
import com.project.imdang.insight.service.domain.event.ExchangeRequestCreatedEvent; | ||
import com.project.imdang.insight.service.domain.exception.ExchangeDomainException; | ||
import com.project.imdang.insight.service.domain.exception.ExchangeRequestNotFoundException; | ||
import com.project.imdang.insight.service.domain.ports.output.repository.ExchangeRequestRepository; | ||
import com.project.imdang.insight.service.domain.exception.InsightApplicationServiceException; | ||
import com.project.imdang.saga.SagaStep; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static com.project.imdang.domain.exception.ErrorCode.EXCHANGE_REQUEST_FAILED; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Component | ||
public class ExchangeRequestMemberCouponSaga implements SagaStep<MemberCouponPendingUpdatedResponseMessage, ExchangeRequestCreatedEvent, EmptyEvent> { | ||
public class ExchangeRequestMemberCouponSaga implements SagaStep<MemberCouponPendingUpdatedResponseMessage, ExchangeRequestCreatedEvent> { | ||
// request exchange using coupon | ||
// init exchange_request → memberCoupon "pending" → save exchange_request | ||
|
||
private final ExchangeDomainService exchangeDomainService; | ||
private final ExchangeRequestRepository exchangeRequestRepository; | ||
|
||
// private final EventPublisher eventPublisher; | ||
private final ExchangeRequestHelper exchangeRequestHelper; | ||
|
||
// memberCoupon "PENDING" 처리 완료 | ||
@Override | ||
public ExchangeRequestCreatedEvent process(MemberCouponPendingUpdatedResponseMessage response) { | ||
|
||
ExchangeRequestId exchangeRequestId = new ExchangeRequestId(response.getExchangeRequestId()); | ||
ExchangeRequest exchangeRequest = exchangeRequestRepository.findById(exchangeRequestId) | ||
.orElseThrow(() -> new ExchangeRequestNotFoundException(exchangeRequestId)); | ||
log.info("MemberCoupon[id: {}] updated as PENDING.", exchangeRequest.getMemberCouponId()); | ||
ExchangeRequest exchangeRequest = exchangeRequestHelper.get(exchangeRequestId); | ||
log.info("MemberCoupon[id: {}] status updated as PENDING.", exchangeRequest.getMemberCouponId()); | ||
|
||
ExchangeRequestCreatedEvent exchangeRequestCreatedEvent = exchangeDomainService.completeCheckCoupon(exchangeRequest); | ||
save(exchangeRequestCreatedEvent.getExchangeRequest()); | ||
exchangeRequestHelper.save(exchangeRequestCreatedEvent.getExchangeRequest()); | ||
// eventPublisher.publish(exchangeRequestCreatedEvent); | ||
return exchangeRequestCreatedEvent; | ||
} | ||
|
||
// memberCoupon "PENDING" 처리 실패 | ||
@Override | ||
public EmptyEvent rollback(MemberCouponPendingUpdatedResponseMessage response) { | ||
ExchangeRequestId exchangeRequestId = new ExchangeRequestId(response.getExchangeRequestId()); | ||
// TODO - 로그 | ||
log.info("Failed!"); | ||
// TODO - CHECK : 삭제 처리 | ||
exchangeRequestRepository.deleteById(exchangeRequestId); | ||
return EmptyEvent.INSTANCE; | ||
} | ||
public void rollback(MemberCouponPendingUpdatedResponseMessage response) { | ||
|
||
throw new InsightApplicationServiceException(EXCHANGE_REQUEST_FAILED); | ||
|
||
private ExchangeRequest save(ExchangeRequest exchangeRequest) { | ||
ExchangeRequest savedExchangeRequest = exchangeRequestRepository.save(exchangeRequest); | ||
if(savedExchangeRequest == null) { | ||
String errorMessage = "Could not save ExchangeRequest!"; | ||
log.error(errorMessage); | ||
throw new ExchangeDomainException(errorMessage); | ||
} | ||
log.info("ExchangeRequest[id: {}] is saved.", savedExchangeRequest.getId().getValue()); | ||
return savedExchangeRequest; | ||
// 삭제 처리 | ||
// ExchangeRequestId exchangeRequestId = new ExchangeRequestId(response.getExchangeRequestId()); | ||
// exchangeRequestHelper.delete(exchangeRequestId); | ||
// return EmptyEvent.INSTANCE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.