Code Monkey home page Code Monkey logo

accountservice's Introduction

Spring Boot Account Maintanence Service

Account Maintanence Service developed under Java / Maven / Spring Boot (version 2.6.3)

How to Run

This application is packaged as a jar which has Tomcat embedded. No Tomcat or JBoss installation is necessary. You run it using the java -jar command.

  • Clone/fork this repository
  • Make sure you are using JDK 11 and Maven 3.x.
  • This project is embedded with H2 DB
  • You can build the project and run the tests by running mvn clean package
  • Once successfully built, you can run the service by one of these two methods:
        java -jar -Dspring.profiles.active=dev target/AccountService-0.0.1-SNAPSHOT
or
        mvn spring-boot:run -Drun.arguments="spring.profiles.active=dev"

How to navigate to log path

  • Check the logs @ c:/temp/logs/fss/application.log to make sure no exceptions are thrown

Once the application runs you should see something like this

2017-08-29 17:31:23.091  INFO 19387 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8090 (http)
2017-08-29 17:31:23.097  INFO 19387 --- [           main] com.fss.example.Application        : Started Application in 22.285 seconds (JVM running for 23.032)

Create a customer resource

POST http://localhost:8080/customer/add
Accept: application/json
Content-Type: application/json

{
    "customerID": "arasu.dhanush",
    "customerName": "Thirunavukkarasu",
    "customerPhone" : "123456789",
    "customerEmail" : "[email protected]"
}

RESPONSE: HTTP 200 (OK)
{
    "id": "arasu.dhanush",
    "customerName": "Thirunavukkarasu",
    "customerPhone": "123456789",
    "customerEmail": "[email protected],
    "dateOpened": "04/20/2022",
    "dateClosed": null
}

To list all the account holder

GET http://localhost:8080/account/list


RESPONSE: HTTP 200 (OK)
[
    {
        "id": "rfL2I37j",
        "customers": {
            "id": "arasu.dhanush",
            "customerName": "Thirunavukkarasu",
            "customerPhone": "123456789",
            "customerEmail": "[email protected]",
            "dateOpened": "04/20/2022",
            "dateClosed": null
        },
        "dateOpened": "2022-04-20",
        "dateClosed": null,
        "minimumBalance": 5000.00,
        "currentBalance": 5000.00
    },
    {
        "id": "qlP8uhzC",
        "customers": {
            "id": "arasu.nilan",
            "customerName": "Thirunavukkarasu",
            "customerPhone": "123456789",
            "customerEmail": "[email protected]",
            "dateOpened": "04/20/2022",
            "dateClosed": null
        },
        "dateOpened": "2022-04-20",
        "dateClosed": null,
        "minimumBalance": 5000.00,
        "currentBalance": 5000.00
    }
]

Credit / Debit Service [ ../debit or ../credit ]

POST http://localhost:8080/transaction/debit
Accept: application/json
Content-Type: application/json

{
    "accountID": "EOaLJdsH",
    "transactionType": "CREDIT",
    "transactionAmount" : "500",
    "transactionNotes" : "to Arasu"
}

RESPONSE: HTTP 200 (OK)
"Transaction completed"

To list all the transaction

GET http://localhost:8080/transaction/list


RESPONSE: HTTP 200 (OK)
[
    {
        "id": 1,
        "accounts": {
            "id": "dPgWZPxe",
            "customers": {
                "id": "arasu.nilan",
                "customerName": "Thirunavukkarasu",
                "customerPhone": "123456789",
                "customerEmail": "[email protected]",
                "dateOpened": "04/20/2022",
                "dateClosed": null
            },
            "dateOpened": "2022-04-20",
            "dateClosed": null,
            "minimumBalance": 5000.00,
            "currentBalance": 17500.00
        },
        "transactionDate": "04/20/2022",
        "transactionTypes": {
            "id": 1,
            "transactionType": "CREDIT"
        },
        "transactionAmount": 12500.00,
        "transactionNotes": "Get Amount",
        "balance": 17500.00
    }
]

To Get Balance

GET http://localhost:8080/account/balance
Accept: application/json
Content-Type: application/json

{
    "accountID" : "rfL2I37j"
}

RESPONSE: HTTP 200 (OK)
Your Account Balance : 5000.00

To close the account

PUT http://localhost:8080/account/close
Accept: application/json
Content-Type: application/json

{
    "accountID" : "rfL2I37j"
}

RESPONSE: HTTP 200 (OK)
"Account has been closed"

Insufficient Fund Test

POST http://localhost:8080/transaction/debit
Accept: application/json
Content-Type: application/json

{
    "accountID": "71ersIUN",
    "transactionType": "DEBIT",
    "transactionAmount" : "12000",
    "transactionNotes" : "Get Amount"
}

RESPONSE: HTTP 200 (OK)
"In sufficient balance : Overdraw with minimum balance"

Debit / Credit transaction after closing account

POST http://localhost:8080/transaction/debit
Accept: application/json
Content-Type: application/json

{
    "accountID": "71ersIUN",
    "transactionType": "CREDIT",
    "transactionAmount" : "500",
    "transactionNotes" : "to Arasu"
}

RESPONSE: HTTP 200 (OK)
"Account has been closed so you can't do the transaction"

accountservice's People

Contributors

thiru-apps avatar

Stargazers

 avatar

Watchers

 avatar

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.