Giter Club home page Giter Club logo

spring-boot-transactions's Introduction

Spring boot transactions - Приложение для иллюстрации декларативного и программного управления транзакциями в экосистеме Spring

Это pet-проект, который показывает как имитировать перевод денег со счета на счет в виде транзакции с разной реализацией.

Стек технологий

  • Java 11
  • Spring Boot
  • Spring Data JPA (+EntityManager)
  • Spring Web
  • Spring Transactional (+TransactionManager, TransactionTemplate)
  • Lombok
  • MapStruct
  • Swagger (OpenAPI 3.0)
  • H2 database
  • Gradle
  • Docker
  • Log4JDBC

H2 database configuration

Приложение использует базу данных H2 In Memory, а консоль находится по адресу http://localhost:8080/transactions-app/h2-console. URL-адрес jdbc должен быть следующим: jdbc:h2:mem:transaction-system. Имя пользователя — «sa», пароль отсутствует.

В ресурсах добавлен data.sql файл для заполнения данных.

INSERT INTO account (balance, name) VALUES (200,  'Alexander');
INSERT INTO account (balance, name) VALUES (200,  'Petr');

Сборка приложения

Необходимо:

  1. Java 11+
  2. Docker

Через jar-файл

# Склонировать проект к себе
git clone https://github.com/devalurum/messenger-system.git
# загружает gradle wrapper
gradlew wrapper
# сборка проекта
gradlew clean build 
# запуск Spring сервиса
java -jar build/libs/spring-boot-transactions.jar 

Через docker

# Склонировать проект к себе
git clone https://github.com/devalurum/messenger-system.git
# загружает gradle wrapper
gradlew wrapper
# сборка проекта
gradlew clean build 
# сборка образа  
docker build -t spring-boot-transactions .
# запуск docker-контейнера
docker run -d -p 127.0.0.1:8080:8080 --name spring-boot-transactions spring-boot-transactions

OpenAPI описание

  1. Откройте адрес в браузере http://localhost:8080/transactions-app/swagger-ui
  2. Ознакомтесь с endpoint'ами и схемами запросов.
  3. Попробовать отправить запросы из Swagger-UI.
  • Поле id при post запросе игнорируются, т.к генерируются на стороне сервера.

Пример curl-запроса

curl -X 'POST' \
'http://localhost:8080/transactions-app/api/v1/services/declarative/transfer' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"fromId": 1,
"toId": 2,
"amount": 100
}'

Endpoints

Image Alt

Схемы данных

Image Alt

Todo:

  • Написать голую реализацию перевода через транзакцию на JDBC.
  • Дописать тесты как будет время для всех слоёв и модулей.

spring-boot-transactions's People

Contributors

devalurum avatar

Watchers

 avatar

spring-boot-transactions's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.