Skip to content
Merged

Dev #124

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI/CD Deploy and Start services

run-name: Deploy to ECR and Start services by ${{github.actor}}
run-name: Deploy and Start services by ${{github.actor}}

on:
push:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cleanengine.coin.configuration.bootstrap;

import com.cleanengine.coin.order.domain.Asset;
import com.cleanengine.coin.order.adapter.out.persistentce.wallet.WalletExternalRepository;
import com.cleanengine.coin.order.adapter.out.persistentce.wallet.OrderWalletRepository;
import com.cleanengine.coin.order.adapter.out.persistentce.asset.AssetRepository;
import com.cleanengine.coin.user.domain.Account;
import com.cleanengine.coin.user.domain.User;
Expand All @@ -24,7 +24,7 @@
public class DBInitRunner implements CommandLineRunner {
private final AccountRepository accountRepository;
private final UserRepository userRepository;
private final WalletExternalRepository walletExternalRepository;
private final OrderWalletRepository orderWalletRepository;
private final AssetRepository assetRepository;

@Transactional
Expand Down Expand Up @@ -58,7 +58,7 @@ protected void initSellBotData(){
wallet2.setTicker("TRUMP");
wallet2.setAccountId(account.getId());
wallet2.setSize(500_000_000.0);
walletExternalRepository.saveAll(List.of(wallet, wallet2));
orderWalletRepository.saveAll(List.of(wallet, wallet2));
}

@Transactional
Expand All @@ -80,7 +80,7 @@ protected void initBuyBotData() {
wallet2.setTicker("TRUMP");
wallet2.setAccountId(account.getId());
wallet2.setSize(0.0);
walletExternalRepository.saveAll(List.of(wallet, wallet2));
orderWalletRepository.saveAll(List.of(wallet, wallet2));
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SpringOrderCreatedAddQueueHandler {
private final WaitingOrdersManager waitingOrdersManager;
private final ApplicationEventPublisher applicationEventPublisher;

@TransactionalEventListener(OrderCreated.class)
@TransactionalEventListener
public void handleOrderCreated(OrderCreated event) {
Order order = event.order();
WaitingOrders waitingOrders = waitingOrdersManager.getWaitingOrders(order.getTicker());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class SpringOrderCreatedUpdateOrderBookHandler {
private final UpdateOrderBookUsecase updateOrderBookUsecase;

@TransactionalEventListener(OrderCreated.class)
@TransactionalEventListener
public void handleOrderCreated(OrderCreated event) {
updateOrderBookUsecase.updateOrderBookOnNewOrder(event.order());
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.util.Optional;

public interface AccountExternalRepository extends CrudRepository<Account, Integer> {
// TODO null 대처 해야
public interface OrderAccountRepository extends CrudRepository<Account, Integer> {
Optional<Account> findByUserId(Integer userId);
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import com.cleanengine.coin.user.domain.Wallet;
import org.springframework.data.repository.CrudRepository;

public interface WalletExternalRepository extends CrudRepository<Wallet, Long>, WalletExternalRepositoryCustom {
public interface OrderWalletRepository extends CrudRepository<Wallet, Long>, OrderWalletRepositoryCustom {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

import java.util.Optional;

public interface WalletExternalRepositoryCustom {
public interface OrderWalletRepositoryCustom {
Optional<Wallet> findWalletBy(Integer userId, String ticker);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Repository
@Transactional
@RequiredArgsConstructor
public class WalletExternalRepositoryCustomImpl implements WalletExternalRepositoryCustom {
public class OrderWalletRepositoryCustomImpl implements OrderWalletRepositoryCustom {
private final EntityManager em;

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.cleanengine.coin.order.application.dto.OrderCommand;
import com.cleanengine.coin.order.application.dto.OrderInfo;
import com.cleanengine.coin.order.application.strategy.CreateOrderStrategy;
import jakarta.validation.Valid;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.ConstraintViolationException;
import jakarta.validation.Validator;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
Expand All @@ -12,6 +14,7 @@

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

import static com.cleanengine.coin.common.CommonValues.BUY_ORDER_BOT_ID;
import static com.cleanengine.coin.common.CommonValues.SELL_ORDER_BOT_ID;
Expand All @@ -21,9 +24,11 @@
@Validated
public class OrderService {
private final List<CreateOrderStrategy<?, ?>> createOrderStrategies;
private final Validator validator;

@Transactional
public OrderInfo<?> createOrder(@Valid OrderCommand.CreateOrder createOrder){
public OrderInfo<?> createOrder(OrderCommand.CreateOrder createOrder){
validateCreateOrder(createOrder);
CreateOrderStrategy<?, ?> createOrderStrategy = createOrderStrategies.stream()
.filter(strategy -> strategy.supports(createOrder.isBuyOrder())).findFirst().orElseThrow();

Expand All @@ -39,4 +44,12 @@ public OrderInfo<?> createOrderWithBot(String ticker, Boolean isBuyOrder, Double

return createOrder(createOrder);
}

protected void validateCreateOrder(OrderCommand.CreateOrder createOrder) {
Set<ConstraintViolation<OrderCommand.CreateOrder>> violations = validator.validate(createOrder);

if (!violations.isEmpty()) {
throw new ConstraintViolationException(violations);
}
}
}

This file was deleted.

This file was deleted.

Loading