Giter VIP home page Giter VIP logo

zhiboapp's Introduction

zhiboapp

CI Status

  • Build Status
  • codecov.io

Goal

  • Expose REST Service based on Apache + Tomcat + Spring MVC + JPA + Hibernate + PostgreSQL

How to build the code?

  1. Get the code from Github
  2. Make sure you have installed gradle 3.1
  3. cd /path/to/zhiboapp
  4. gradle war #This task will build the java code and generate war which can be deployed to servlet container.

Artifact Version

Test Environment configuration:

Download Tomcat and PostgreSQL to your local machine. Check the versions in above sections.

How to test?

If you want to test zhiboapp, you have prepare PostgreSQL and Tomcat.

Test way 1: based on PostgreSQL and standalone Tomcat.

  1. gradle war #This task wll generate war to /path/to/zhiboapp/build/libs/zhiboapp.war
  2. Copy that war to /webapps/
  3. Start tomcat: cd /bin, then ./startup.sh or .\startup.bat
  4. The tomcat will listen on port 8080 of localhost (127.0.0.1).
  5. Then you have to prepare a REST client
  1. In REST client, fill in the HTTP method, URL, headers, and send your request.
  • For querying data, use HTTP method -- GET, headers -- Accept:application/json.
  • For create/modify operation, use HTTP method -- POST, headers -- Content-Type: application/json, Accept:application/json
  • For delete operation, use HTTP method -- DELETE, headrs -- Content-Type: application/json

Test way 2: based on PostgreSQL and embedded Tomcat. (Without install tomcat)

  1. This way is similar with way 1. But it doesn't require you to install tomcat.
  2. Be sure your PostgreSQL service is up. Then run gradle tomcatRun in Terminal. Then the embedded tomcat will also start on 127.0.0.1:8080.
  3. Note: must run gradle tomcatRun at Terminal. Run it in IntelliJ may not work.

Some request and response example:

Collection query:

  • Request:
HTTP Method: GET
URL: http://127.0.0.1:8080/zhiboapp/api/account
  • Response:
  • Response HTTP status: 200(OK)
  • Response Body:
   {
      "resources":
      [
          {
              "phoneNumber": "123456789",
              "name": "jack",
              "id": 1
          }
      ]
   }

One instance query

  • Request:
HTTP Method: GET
URL: http://127.0.0.1:8080/zhiboapp/api/account/1
  • Response:
  • Response HTTP status: 200(OK)
  • Response Body:
    {
       "phoneNumber": "123456789",
       "name": "jack",
       "id": 1
    }

Create operation

  • Request: + Request method, url, headers
HTTP Method: POST
URL: http://127.0.0.1:8080/zhiboapp/api/account
Headers: Content-Type:application/json
+ Request body:
{
"name":"Hello",
"phoneNumber":"123"
}
  • Response: + Response status: 200(OK) (Need change to 201) + Response Body:
    {
       "phoneNumber": "123",
       "name": "Hello",
       "id": 2
    }

Modify operation

  • Request:
  • Request method, url, headers
HTTP Method: POST
URL: http://127.0.0.1:8080/zhiboapp/api/account/2
Headers: Content-Type:application/json
  • Request body:
{
"name":"World",
"phoneNumber":"246"
}
  • Response:
  • Response status: 204(No Content)
  • Response Body: No response body.

Delete operation

  • Request:
  • Request method, url, headers
HTTP Method: DELETE
URL: http://127.0.0.1:8080/zhiboapp/api/account/2
Headers: Content-Type:application/json
  • Request body: No Need Request body.
  • Response:
  • Response status: 204(No Content)
  • Response Body: No response body.

Done features.

  1. User can do collection query to fetch all.
  2. User can do single instance query.
  3. User can do create, modify, delete operation.
  4. User can do collection with filter (Just like where clause of sql.)

Request Examples:

  1. http://127.0.0.1:8080/zhiboapp/api/account?filter=id>1 and id<4
  2. http://127.0.0.1:8080/zhiboapp/api/account?filter=id=gt=1;id=lt=4

Done infrastructure

  1. Tomcat + Spring + JPA + Hibernate + PostgreSQL
  2. CI based on Travis is done.
  3. Integration test based on HSQL is done.

Backlog

  1. CI setup (0)
  2. Basic Paging, Fields (always return all fields), Filter, OrderBy, Dot notation/reference/support?
  3. Adanced query features: @count...Or not support, keep REST API simple.
  4. Not reuturn null value. to save the network data of customers phone.
  5. Select expected fields. Maybe not a issue. First step, can be return all fields.
  6. Embedded support.
  7. HATEOAS.
  8. Architecture: RQL + JPA&JPQL (based o hiberate)?
  9. API spec finalize
  10. User Login, session manage, security impl investigation and impl
  11. Interact with Shipin Cloud? Should we?
  12. Admin access, UI (WEB and App)?
  13. Doc about Usage. For frontend developer.
  14. JPA based on Hibernate. Can be final solution? Final solution always mixed solution, since no one solution is perfect.

zhiboapp's People

Contributors

lianwaiyuchanchan avatar jicahoo avatar

Watchers

nicholas_wei 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.