Solution for task 5 on Spring Boot https://t.me/try2py/197

Overview

IouRestService (Spring Boot Application)

Решение задачи 5 https://t.me/try2py/197

Условие задачи: Четверо соседей по комнате имеют привычку занимать деньги друг у друга, но им трудно вспомнить, кто кому должен и сколько. Ваша задача состоит в том, чтобы реализовать простой > API (желательно следовать принципу REST, если знакомы с ним), который создаёт долговые расписки в виде POST-запросов и может предоставлять информацию о долгах с помощью GET-запросов.

REST API

Список пользователей

request:

GET http://localhost:8080/api/v1/user
request body: empty

output:

{
    "users": [
        {
            "id": 1,
            "name": "Andrey"
        },
        {
            "id": 2,
            "name": "Timofei"
        },
        {
            "id": 3,
            "name": "Jimmy"
        }
    ]
}

Список долговых расписок

request:

GET http://localhost:8080/api/v1/iou
request body: empty

output:

{
    "notes": [
        {
            "id": 1,
            "lender": {
                "id": 1,
                "name": "Andrey"
            },
            "borrower": {
                "id": 2,
                "name": "Timofei"
            },
            "amount": 100.0
        },
        {
            "id": 2,
            "lender": {
                "id": 1,
                "name": "Andrey"
            },
            "borrower": {
                "id": 2,
                "name": "Timofei"
            },
            "amount": 120.5
        },
        {
            "id": 3,
            "lender": {
                "id": 1,
                "name": "Andrey"
            },
            "borrower": {
                "id": 2,
                "name": "Timofei"
            },
            "amount": 13.5
        }
    ]
}

Список просуммированных долговых расписок

request

GET http://localhost:8080/api/v1/iou/summed
request body: empty

output:

{
    "notes": [
        {
            "lender": {
                "id": 1,
                "name": "Andrey"
            },
            "borrower": {
                "id": 2,
                "name": "Timofei"
            },
            "amount": 234.0
        }
    ]
}

Добавить пользователя

request:

POST http://localhost:8080/api/v1/user
request body: { "name": "Jimmy" }

output:

{
    "id": 3,
    "name": "Jimmy"
}

Добавить долговую расписку

request:

POST http://localhost:8080/api/v1/iou
request body: {
    "lender": 1,
    "borrower": 2,
    "amount": 13.50
}

output:

{
    "id": 3,
    "lender": {
        "id": 1,
        "name": "Andrey"
    },
    "borrower": {
        "id": 2,
        "name": "Timofei"
    },
    "amount": 13.5
}

Удалить пользователя

request:

DELETE http://localhost:8080/api/v1/user
request body: { "id": 3 }

output:

{
    "message": "success"
}

Удалить долговую расписку

request:

DELETE http://localhost:8080/api/v1/iou
request body: { "id": 3 }

output:

{
    "message": "success"
}
You might also like...
Push notification application using One Signal + Spring Boot + Kotlin

Spring Boot push notification system using One Signal This project was created to demonstrate a simple application built with Kotlin + Spring Boot inc

Kotlin Based Spring Boot ETL project
Kotlin Based Spring Boot ETL project

Adverity ETL REST API (AERA) A simple ETL Spring Boot application with H2. This API provides the following basics functionalities: Endpoint that retur

Spring Boot Webflux RDBMS Sample App

R2DBC Spring Boot Webflux Sample Project generate schema (DDL script) h2-console (Web based database management console) WebFlux and r2dbc is not supp

GraphQL for Java with Spring Boot made easy.

GraphQL for Java with Spring Boot made easy.

Spring boot admin server for android

spring-boot-admin-server 어드민 서버 그래들 implementation("org.springframework.boot:spring-boot-starter-security:2.5.6") // https://mvnrepository.com/artifac

API Rest With Kotlin And Spring Boot

##API REST WITH KOTLIN AND SPRING BOOT GET Url: http://localhost:8080/customers Response (Status Code: 200 Ok) { "_embedded": { "customer

Créer un microservice avec Spring Boot et Kotlin
Créer un microservice avec Spring Boot et Kotlin

🚀 Créer un microservice avec Spring Boot et Kotlin Ce dépôt contient les slides et la démo du talk "créer un microservice avec Spring Boot et Kotlin"

A generic library for quick development in Spring Boot using Java Generics.
A generic library for quick development in Spring Boot using Java Generics.

slinky Now in Kotlin! A generic library for quick development in Spring Boot using Java Generics. Why "slinky"? A slinky is a precompressed helical sp

Cloud Bowl Sample - Kotlin Spring Boot

Cloud Bowl Sample - Kotlin Spring Boot To make changes, edit the src/main/kotlin/hello/KotlinApplication.kt file. Run Locally: ./mvnw spring-boot:run

Comments
Owner
Fomin Sergei
Fomin Sergei
Spring-graphql-getting-started - Spring for GraphQL provides support for Spring applications built on GraphQL Java

Getting Started with GraphQL and Spring Boot Spring for GraphQL provides support

Shinya 0 Feb 2, 2022
Spring Boot Example with Kotlin and Domain Driven Design

Spring Boot Kotlin Domain Driven Design Example Just an example project where ddd is implemented with some other great patterns and architecture from

Fernando Guevara Sanchez 16 Jun 29, 2022
A sample skeleton backend app built using Spring Boot kotlin, Expedia Kotlin Graphql, Reactive Web that can be deployed to Google App Engine Flexible environmennt

spring-kotlin-gql-gae This is a sample skeleton of a backend app that was built using: Spring Boot(Kotlin) Reactive Web Sprinng Data R2DBC with MYSQL

Dario Mungoi 7 Sep 17, 2022
Sample Social Login Project of Spring Boot and Kotlin

Sample-Spring-Boot-Social-Kotlin Sample Social Login Project of Spring Boot and Kotlin dependencies dependencies { implementation("org.springframewor

Seokhyun 2 Oct 11, 2021
This repository demonstrates how Kotlin can simplify Spring Boot configuration properties file mapping

Kotlin spring-boot nested config props This repository demonstrates how Kotlin can simplify Spring Boot configuration properties file mapping @Constru

Maksim Kostromin 1 Oct 11, 2021
My personal template for a Spring Boot REST reactive webapp

My personal spring boot kotlin reactive template Features Spring Security implementation with JWT access and refresh token MongoDB database Project Co

Dušan 2 Dec 1, 2021
Generated with spring boot kotlin starter kit

Kotlin backend Generated with spring boot kotlin starter kit The idea is to: Get a microservice written in kotlin for managing users and roles. To be

Oriol Subirana 1 Oct 19, 2021
The Okila server project uses the Spring boot framework and uses the Kotlin language

Okila-Server The Okila server project uses the Spring boot framework and uses the Kotlin language Format Response //The response successfully format

Nankai 1 Oct 25, 2021
An application that simulate the Swedish Transport Agency, implemented with Spring Boot, Kotlin and GraphQL

graphql-kotlin-spring-server An application that simulate the Swedish Transport Agency, implemented with Spring Boot, Kotlin and GraphQL Running the s

null 0 Oct 31, 2021
API for a library using Kotlin, Spring-boot and covered by test

Library API This API is to create Books and be able to borrow from them I'm using: Spring Boot version 2.5.6 Kotlin 1.5.31 Java 11 I'm implementing us

Daniel Queiroz 1 Nov 5, 2021