Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Latest commit

 

History

History
executable file
·
38 lines (26 loc) · 2.38 KB

README.md

File metadata and controls

executable file
·
38 lines (26 loc) · 2.38 KB

FPT Librarian Module - API part (Legacy)

Build Status

Basic Design

  • We expose REST API at web server side so that multiple client can consume our's API.
  • Advantage of this design is that can scale to large size of our project grow up.
  • Disavantage the complexcity when implement is higher than monolothich application.

Details Design

package Responsibility
com.fpt.edu.controllers Store all of controller
com.fpt.edu.services contain all of services class that help us do our business logic
com.fpt.edu.repositories contain all of our repository (DAO) that allow us to manipulate with Database
com.fpt.edu.entities contain all of our entity or Domain object
_.config, _.common Contain Spring config and some common function
com.fpt.edu.app contain application app that will help to start the server

Development Guide

1. Defing a controller

  1. Anotation to define this java class will be a controller. So that client can request to this class method if do the request mapping.

  2. Define Swagger docs, using @ApiOperation and @ApiResponses to declare the information about the. If you start serser then you can see the swagger docs at SWAGGER_UI (note that start your local server before you click on this link, Start server by run Application.java)

  3. Define and do mapping: Using anotation @RequestMapping mean that you tell spring that hey Spring I declarce a url that can do some thine awesome please expose it to client can access to it. For example:

    @RequestMapping(value = "/test", method = RequestMethod.GET, produces = "application/json")
    

    This will map the /test path to current running web app with method GET and return type is application/json. You can test it by run postman via this link : http://localhost:9090/users/test