Skip to content

REST service where TL equivalents of currencies are kept with Parity codes and some transactions can be made.

Notifications You must be signed in to change notification settings

muhammedalikocabey/Spring-Boot-Rest-Service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EN

Spring Boot Rest service for parity data

Spring Boot REST service, which contains parity data where TL equivalents of currencies are kept together with the Parity code and the day it belongs, and enables certain operations on this parity data.


  • A method was used to calculate the ratio of two currency units to each other, and this method was included in the Controller Class with the Dependency Injection Pattern.
  • For yield change method calculation, 3 different functions were defined and these functions were implemented and used with the Strategy Pattern.
  • The Factory Pattern was used to select this 3 yield change method calculation more effectively than the request parameter to the service.
  • When unwanted situations occur in the requests sent by the user, the control of these situations was made with Controller Advice Annotation as Global Exception Handling. Each undesirable situation that occurred was handled separately.
  • Factory Pattern changed to be applied with Enum data type.
  • Separately handled Exceptions were defined by a function for each Exception in the RestErrorHandler defined by @ControllerAdvice Annotation. These functions were divided into 2 different functions according to their Http Status, and instead of giving Exceptions as a value to a function for each Exception collectively, 2 separate functions were given parameters collectively.
  • XMLParser Service was created in order to log parity data in XML format published on the TCMB website on a daily basis in the database.
    • Case 1: This service is called in SpringBootApplication.run() method to run when REST Service is run. Commit for Detail.
    • Case 2 : When the user makes a GET request, XMLParser runs within the request. Commit for Detail
  • Cron Scheduler was added to keep the data up-to-date as the data was updated daily at the market closing (17.00).

 

Requests within the service:

  • GET:
    • 127.0.0.1:8080/   List All Data
    • 127.0.0.1:8080/2020-11-21/   List data on the requested date
    • 127.0.0.1:8080/2020-11-21/USDTRY   List the data in the requested date and parity code
    • 127.0.0.1:8080/2020-11-21/2020-11-25/USDTRY   List data between two requested dates and in the parity code
    • 127.0.0.1:8080/2020-11-21/2020-11-25/USDTRY/absolute   Calculate and list the data between the two requested dates and in the parity code according to the desired return exchange method.
    • 127.0.0.1:8080/dailyparity Scrap daily updated data from the TCMB website.
  • POST:
    • 127.0.0.1:8080/   Check the data sent without distinguishing the day and save all to the database
    • 127.0.0.1:8080/2020-11-21   Check the data of the day sent according to its parameter and save all to the database

   

TR

Parity verileri için Spring Boot Rest servisi

Para birimlerinin TL karşılıklarının, Parite kodu ve ait olduğu gün ile birlikte tutulduğu parite verilerini içeren Spring Boot REST hizmeti, bu parite verileri üzerinde belirli işlemlerin yapılmasını sağlar.


  • İki para biriminin birbirine oranını hesaplamak için bir metod kullanıldı ve bu yöntem Bağımlılık Enjeksiyoni Pattern'i ile Controller Sınıfına dahil edildi.
  • Getiri değişim yöntemi hesaplaması için 3 farklı fonksiyon tanımlandı ve bu fonksiyonlar Strateji Pattern'i ile uygulandı ve kullanıldı.
  • Bu 3 getiri değişim metodu hesaplamasını hizmet içerisinde request parametresinden daha etkin bir şekilde seçmek için Fabrika Pattern'i kullanıldı.
  • Kullanıcı tarafından gönderilen request'lerde istenmeyen durumlar oluştuğunda bu durumların kontrolü Global Exception Handler ile ve Global Advice Annotation ile yapıldı. Ortaya çıkan her istenmeyen durum ayrı ayrı ele alındı.
  • Factory Pattern'i Enum veri tipi ile uygulanacak şekilde değiştirildi.
  • Ayrı ayrı olarak ele alınan Exception'lar @ControllerAdvice Annotation'ı ile tanımlanan RestErrorHandler içerisinde her Exception için bir fonksiyon tanımlanmış şekildeydi. Bu fonksiyonlar Http Status'lerine göre 2 ayrı fonksiyona ayrıldı ve Exception'lar value şeklinde toplu olarak her Exception için bir fonksiyona parametre olarak verilmek yerine 2 ayrı fonksiyona toplu olarak parametre verildi.
  • Günlük olarak TCMB sitesinde yayınlanan XML formatındaki parite verilerini veritabanına günlük olarak kaydedebilmek için XMLParser Service'i oluşturuldu.
    • Durum 1: Bu hizmetin REST servis çalıştığında çalışması için SpringBootApplication.run() metodunda çalıştırılır. Detay için Commit
    • Durum 2 :XMLParser kullanıcı GET istek attığında bu istek içerisinde çalışır. Detay için Commit
  • Veriler piyasaların kapanışında(17.00) günlük olarak yenilendiğinden verileri güncel tutmak için Cron Scheduler eklendi.

 

Servis içerisindeki istekler:

  • GET:
    • 127.0.0.1:8080/   Tüm verileri Listele
    • 127.0.0.1:8080/2020-11-21/   İstenen tarihteki verileri listele
    • 127.0.0.1:8080/2020-11-21/USDTRY   İstenen tarihteki ve parite kodundaki verileri listele
    • 127.0.0.1:8080/2020-11-21/2020-11-25/USDTRY   İstenen iki tarih arasındaki ve parite kodundaki verileri listele
    • 127.0.0.1:8080/2020-11-21/2020-11-25/USDTRY/absolute   İstenen iki tarih arasındaki ve parite kodundaki verileri istenen getiri değişim metoduna göre hesapla ve listele
    • 127.0.0.1:8080/dailyparity Günlük güncel verileri TCMB sitesinden kazı.
  • POST:
    • 127.0.0.1:8080/   Gönderilen verileri gün ayırt etmeden kontrol edip veri tabanına kaydet
    • 127.0.0.1:8080/2020-11-21   Gönderilen güne ait verileri parametresine göre kontrol edip veri tabanına kaydet

About

REST service where TL equivalents of currencies are kept with Parity codes and some transactions can be made.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages