Code Monkey home page Code Monkey logo

natlexservice's Introduction

NatlexService

Test task for backend developer by Natlex.

Features:

  • Async Importing .XLS files;
  • Async Exporting .XLS files;
  • REST Endpoint API.

API

Example API Request and Response:

All requests must have an authorization token in the header. 'Authorization' : 'token'

GET http://localhost:8080/api/sections - Get a list of all Sections.
Json Response for api/sections [ { "name": "Section 1", "geologicalClasses": [ { "name": "Geo Class 11", "code": "GC11" }, { "name": "Geo Class 12", "code": "GC12" } ] }, { "name": "Section 2", "geologicalClasses": [ { "name": "Geo Class 21", "code": "GC21" }, { "name": "Geo Class 22", "code": "GC22" } ] } }
GET http://localhost:8080/api/sections/by-code?code=<code> - Get a list of all Sections that have geologicalClasses with the specified code. 
`code` - specified code. Required field.
Json Response for api/sections/by-code?code=GCN2 [ { "name": "Section N", "geologicalClasses": [ { "name": "Geo Class N1", "code": "GCN1" }, { "name": "Geo Class N2", "code": "GCN2" }, { "name": "Geo Class NM", "code": "GCNM" } ] } }
POST http://localhost:8080/api/import/ - POST request with .xls file. Returns ID of the Async Job and launches importing .xls file.
Content-Type : multipart/form-data;
Json Response for POST api/import { "id": 1 }
GET http://localhost:8080/api/import/{id} - returns result of importing by Job ID ("DONE", "IN_PROGRESS", "ERROR")
Json Response for api/import/{id} { "id": 1, "type": "DONE" }
GET http://localhost:8080/api/export/ - returns ID of the Async Job and launches exporting .xls file.
Json Response for api/api/export { "id": 2, "type": "IN_PROGRESS" }
GET http://localhost:8080/api/export/{id} - returns status progress of exporting by Job ID ("DONE", "IN_PROGRESS", "ERROR")
Json Response for api/export/{id} { "id": 1, "type": "DONE" }
GET http://localhost:8080/api/export/file/{id} - returns a file by Job ID (throw an exception with status 424(Failed Dependency) if exporting is in process or 404(Not Found) if Async Job was not launched)

Structure of file for importing and exporting: img.png

HOW TO RUN:

  1. Clone this project;
  2. Open/Import project in IDEA;
  3. Create 'natlexservice' MySQL database for runtime;
  4. Select 'NatlexServiceApplication' in Run/Debug Configurations and run.

If your IDE didn't generate it on its own when importing the project create SpringBoot run configuration manually: runconfiguration.png com.prototype.natlexservice.NatlexServiceApplication

Settings

Many settings, including database data, authorization token, can be found in application.properties for runtime

natlexservice's People

Contributors

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