This repository has been archived by the owner on Sep 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #190 from intellibucket/feature/exhange-service
Feature/exhange service
- Loading branch information
Showing
50 changed files
with
752 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
56 changes: 56 additions & 0 deletions
56
...ain/java/com/intellibucket/onnetwork/exchange/dataaccess/model/entity/CurrencyEntity.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,56 @@ | ||
package com.intellibucket.onnetwork.exchange.dataaccess.model.entity; | ||
|
||
import az.rock.lib.domain.BaseEntity; | ||
import az.rock.lib.valueObject.CurrencyCode; | ||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
import org.hibernate.Hibernate; | ||
|
||
import java.util.Objects; | ||
|
||
@Entity(name = "CurrencyEntity") | ||
@Table(name = "currency", schema = "exchange", indexes = { | ||
@Index(name = "currency_code_index", columnList = "code", unique = true) | ||
}) | ||
@Getter | ||
@Setter | ||
@ToString | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CurrencyEntity extends BaseEntity { | ||
|
||
@Enumerated(EnumType.STRING) | ||
@NotNull | ||
private CurrencyCode code; | ||
|
||
@Column(name = "symbol", nullable = false, updatable = false) | ||
private String symbol; | ||
|
||
@Column(name = "name", nullable = false, updatable = false) | ||
private String name; | ||
|
||
@Column(name = "symbol_native") | ||
private String symbolNative; | ||
|
||
@Column(name = "decimal_digits", nullable = false) | ||
private String decimalDigits; | ||
|
||
@Column(name = "rounding", nullable = false) | ||
private String rounding; | ||
|
||
@Column(name = "name_plural") | ||
private String namePlural; | ||
|
||
@Column(name = "type") | ||
private String type; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; | ||
CurrencyEntity that = (CurrencyEntity) o; | ||
return getUuid() != null && Objects.equals(getUuid(), that.getUuid()); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...ain/java/com/intellibucket/onnetwork/exchange/dataaccess/model/entity/ExchangeEntity.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,27 @@ | ||
package com.intellibucket.onnetwork.exchange.dataaccess.model.entity; | ||
|
||
import az.rock.lib.domain.BaseEntity; | ||
import az.rock.lib.valueObject.CurrencyCode; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDateTime; | ||
|
||
@Entity(name = "ExchangeEntity") | ||
@Table(name = "exchanges", schema = "exchange") | ||
@Getter | ||
@Setter | ||
@ToString | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ExchangeEntity extends BaseEntity { | ||
@Column(name = "fetch_date", nullable = false, columnDefinition = "TIMESTAMP") | ||
private LocalDateTime fetchDate; | ||
@Enumerated(EnumType.STRING) | ||
private CurrencyCode baseCurrency; | ||
@Enumerated(EnumType.STRING) | ||
private CurrencyCode targetCurrency; | ||
@Column(name = "rate", nullable = false) | ||
private BigDecimal rate; | ||
} |
17 changes: 17 additions & 0 deletions
17
...ice/src/main/java/com/intellibucket/onnetwork/exchange/domain/core/root/CurrencyRoot.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,17 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.core.root; | ||
|
||
import az.rock.lib.domain.AggregateRoot; | ||
import az.rock.lib.domain.id.exchange.CurrencyID; | ||
import az.rock.lib.valueObject.CurrencyCode; | ||
|
||
|
||
public class CurrencyRoot extends AggregateRoot<CurrencyID> { | ||
private CurrencyCode code; | ||
private String symbol; | ||
private String name; | ||
private String symbolNative; | ||
private String decimalDigits; | ||
private String rounding; | ||
private String namePlural; | ||
private String type; | ||
} |
15 changes: 15 additions & 0 deletions
15
...ice/src/main/java/com/intellibucket/onnetwork/exchange/domain/core/root/ExchangeRoot.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,15 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.core.root; | ||
|
||
import az.rock.lib.domain.AggregateRoot; | ||
import az.rock.lib.domain.id.exchange.ExchangeID; | ||
import az.rock.lib.valueObject.CurrencyCode; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDateTime; | ||
|
||
public class ExchangeRoot extends AggregateRoot<ExchangeID> { | ||
private LocalDateTime fetchDate; | ||
private CurrencyCode baseCurrency; | ||
private CurrencyCode targetCurrency; | ||
private BigDecimal rate; | ||
} |
14 changes: 14 additions & 0 deletions
14
...ain/java/com/intellibucket/onnetwork/exchange/domain/presentation/config/AsyncConfig.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,14 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.config; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
|
||
@Configuration | ||
@EnableAsync | ||
@Slf4j | ||
public class AsyncConfig { | ||
{ | ||
log.info("AsyncConfig initialized"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...java/com/intellibucket/onnetwork/exchange/domain/presentation/config/SchedulerConfig.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,14 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.config; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
@Configuration | ||
@EnableScheduling | ||
@Slf4j | ||
public class SchedulerConfig { | ||
{ | ||
log.info("SchedulerConfig initialized"); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...om/intellibucket/onnetwork/exchange/domain/presentation/dto/api/request/package-info.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 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.dto.api.request; |
1 change: 1 addition & 0 deletions
1
...m/intellibucket/onnetwork/exchange/domain/presentation/dto/api/response/package-info.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 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.dto.api.response; |
32 changes: 32 additions & 0 deletions
32
...ntellibucket/onnetwork/exchange/domain/presentation/dto/feign/response/ExchangeRates.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,32 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.dto.feign.response; | ||
|
||
import az.rock.lib.valueObject.CurrencyCode; | ||
import lombok.Data; | ||
import lombok.ToString; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
|
||
@Data | ||
@ToString | ||
public class ExchangeRates { | ||
private Map<CurrencyCode, BigDecimal> data; | ||
|
||
public ExchangeRates() { | ||
this.data = new HashMap<>(); | ||
} | ||
|
||
public static ExchangeRates of() { | ||
return new ExchangeRates(); | ||
} | ||
|
||
public void addCurrencyRate(CurrencyCode currencyCode, BigDecimal rate) { | ||
this.data.put(currencyCode, rate); | ||
} | ||
|
||
public void addCurrencyRate(String currencyCode, BigDecimal rate) { | ||
this.addCurrencyRate(CurrencyCode.valueOf(currencyCode.toUpperCase()), rate); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...ibucket/onnetwork/exchange/domain/presentation/lib/aspect/annotations/JExecutionTime.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,9 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.lib.aspect.annotations; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({java.lang.annotation.ElementType.METHOD}) | ||
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME) | ||
public @interface JExecutionTime { | ||
} |
30 changes: 30 additions & 0 deletions
30
...llibucket/onnetwork/exchange/domain/presentation/lib/aspect/impl/ExecutionTimeAspect.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,30 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.lib.aspect.impl; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Aspect | ||
@Component | ||
@Slf4j | ||
public class ExecutionTimeAspect { | ||
|
||
@Around("@annotation(com.intellibucket.onnetwork.exchange.domain.presentation.lib.aspect.annotations.JExecutionTime)") | ||
public Object logExecutionTime(ProceedingJoinPoint proceedingJoinPoint) { | ||
log.info("Execution time aspect is called for {}", proceedingJoinPoint.getSignature().getName()); | ||
long start = System.currentTimeMillis(); | ||
Object proceed = null; | ||
try { | ||
proceed = proceedingJoinPoint.proceed(); | ||
} catch (Throwable throwable) { | ||
log.error("Error in execution time aspect for {}, {}", throwable, proceedingJoinPoint.getSignature().getName()); | ||
} | ||
long executionTime = System.currentTimeMillis() - start; | ||
log.info("{} executed in {} ms", proceedingJoinPoint.getSignature().getName(), executionTime); | ||
log.info("Execution time aspect is completed for {}", proceedingJoinPoint.getSignature().getName()); | ||
return proceed; | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...ava/com/intellibucket/onnetwork/exchange/domain/presentation/lib/aspect/package-info.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 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.lib.aspect; |
1 change: 1 addition & 0 deletions
1
.../main/java/com/intellibucket/onnetwork/exchange/domain/presentation/lib/package-info.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 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.lib; |
4 changes: 4 additions & 0 deletions
4
...onnetwork/exchange/domain/presentation/mapper/abstracts/AbstractCurrencyDomainMapper.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,4 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.mapper.abstracts; | ||
|
||
public abstract class AbstractCurrencyDomainMapper { | ||
} |
4 changes: 4 additions & 0 deletions
4
...onnetwork/exchange/domain/presentation/mapper/abstracts/AbstractExchangeDomainMapper.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,4 @@ | ||
package com.intellibucket.onnetwork.exchange.domain.presentation.mapper.abstracts; | ||
|
||
public abstract class AbstractExchangeDomainMapper { | ||
} |
Oops, something went wrong.