Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #190 from intellibucket/feature/exhange-service
Browse files Browse the repository at this point in the history
Feature/exhange service
  • Loading branch information
l00pss authored Mar 20, 2024
2 parents d61d4e8 + 22a7dba commit 1476486
Show file tree
Hide file tree
Showing 50 changed files with 752 additions and 25 deletions.
1 change: 1 addition & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.intellibucket.onnetwork.company.dataAccess.command.model.entity.vacancy;

import az.rock.lib.domain.BaseEntity;
import az.rock.lib.valueObject.Currency;
import az.rock.lib.valueObject.CurrencyCode;
import az.rock.lib.valueObject.vacancy.Payment;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
Expand All @@ -25,7 +25,7 @@ public class VacancySalaryEntity extends BaseEntity {
private Boolean hasSalary;

@Column(name = "currency")
private Currency currency;
private CurrencyCode currencyCode;

@Column(name = "start_amount")
private BigDecimal startAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import az.rock.lib.domain.AggregateRoot;
import az.rock.lib.domain.id.vacancy.VacancyID;
import az.rock.lib.domain.id.vacancy.VacancySalaryID;
import az.rock.lib.valueObject.Currency;
import az.rock.lib.valueObject.CurrencyCode;
import az.rock.lib.valueObject.vacancy.Payment;
import lombok.Builder;
import lombok.Getter;
import lombok.experimental.SuperBuilder;

import java.math.BigDecimal;

Expand All @@ -18,7 +17,7 @@ public class VacancySalaryRoot extends AggregateRoot<VacancySalaryID> {

private Boolean hasSalary;

private Currency currency;
private CurrencyCode currencyCode;

private BigDecimal startAmount;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.intellibucket.onnetwork.company.domain.presentation.command.dto.request.vacancy;

import az.rock.lib.valueObject.Currency;
import az.rock.lib.valueObject.CurrencyCode;
import az.rock.lib.valueObject.vacancy.Payment;
import lombok.AllArgsConstructor;
import lombok.Data;
Expand All @@ -14,7 +14,7 @@
public class VacancySalaryCommand {
private Boolean hasSalary;

private Currency currency;
private CurrencyCode currencyCode;

private BigDecimal startAmount;

Expand Down
41 changes: 41 additions & 0 deletions exchange-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
<groupId>com.intellibucket.onnetwork.exchange</groupId>
<artifactId>exchange-service</artifactId>


<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>com.intellibucket.lib.fj</groupId>
<artifactId>ib-data-access</artifactId>
Expand Down Expand Up @@ -81,8 +87,15 @@
<artifactId>grpc-client-spring-boot-starter</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.intellibucket.lib</groupId>
<artifactId>ib-auth-proto</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>


<build>
<extensions>
<extension>
Expand All @@ -92,6 +105,34 @@
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.4.3</version>
<configuration>
<changeLogFile>src/main/resources/db/changelog-master.xml</changeLogFile>
</configuration>
<executions>
<execution>
<goals>
<goal>diff</goal>
<goal>update</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.6.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

@EnableDiscoveryClient
@SpringBootApplication
@EnableFeignClients
@EntityScan(basePackages = "com/intellibucket/onnetwork/exchange/dataaccess/model/entity")
public class ExchangeServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ExchangeServiceApplication.class, args);
Expand Down
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());
}

}
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;
}
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;
}
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;
}
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");
}
}
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");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package com.intellibucket.onnetwork.exchange.domain.presentation.dto.api.request;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package com.intellibucket.onnetwork.exchange.domain.presentation.dto.api.response;
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);
}
}
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 {
}
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;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package com.intellibucket.onnetwork.exchange.domain.presentation.lib.aspect;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package com.intellibucket.onnetwork.exchange.domain.presentation.lib;
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 {
}
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 {
}
Loading

0 comments on commit 1476486

Please sign in to comment.