Code Monkey home page Code Monkey logo

springbooteducationsystem's Introduction

Spring Boot Education System

License: GPL v3 Build Status CodeFactor

Education System based on SpringBoot and REST

Table of Contents

1. Development

1.1 Prerequisites

  1. Maven
  2. JDK-8(not compatible with JDK-9)

1.2 Configuration

  1. Create Database

      $ mysql -uroot -p 12345
      $ create database EAS
  2. Edit application.yml to set your database name, username and password.

    spring:
      datasource:
        url: jdbc:mysql://localhost:3306/EAS
        username: root
        password: 123456
  3. Start server

     $ mvn spring-boot:run
    

    Then open the address http://localhost:8080 to open the HAL browser.

    332DE30D-8F1F-428B-B736-5BCBE38669E6

  4. Or you can use the command below to package the application into jar

    $ mvn package
    $ java -jar *.jar # run the application

2. Techneques Stacks

  • SpringBoot
  • JPA Hibernate
  • Spring Data
  • Spring Security

3. API documentation

3.1 Summary

This project use well formatted HAL JSON as response, you can quickly understand them with HAL browser.

There are 5 root resources in current api version, all of this resource support below actions:

  • GET: get REST resouce.

    • Paging: request a page of resource.
    • Sorting: sort the resource with some of it's properties.
  • POST: create a new REST resource.

  • PATCH: update an existent REST resource with some resouce properties

  • DELETE: delete an existent REST resource.

  1. exams{?page,size,sort}

    This api exposed all the exams.

  2. marks{?page,size,sort}

    This api exposed all the marks.

  3. users{?page,size,sort}

    This api exposed all the users.

  4. resources{?page,size,sort}

    This api exposed all the course resource.

  5. courses{?page,size,sort}

    This api exposed all the course.

3.2 Example Usages

Take users resource as an example:

  1. GET all the users

    GET http://localhost:8080/users
  2. GET user by id

    GET http://localhost:8080/users/58
  3. GET with sorting

    Ascending with email

    GET http://localhost:8080/users?sort=email

    Decending with email:

    GET http://localhost:8080/users?sort=-email
  4. GET with paging

    pagespecify the page number. size specify the number of resource in one page.

    GET http://localhost:8080/users?page=0&size=10
  5. GET with search parameter

    Not all the resource support search parameters:

    GET http://localhost:8080/users/search/[email protected]

    To find out all avaliable search parameter under users resource:

    GET http://localhost:8080/users/search/

    The response body should be:

    {
      "_links": {
        "findByEmail": {
          "href": "http://69.171.71.251:8080/users/search/findByEmail{?email}",
          "templated": true
        },
        "self": {
          "href": "http://69.171.71.251:8080/users/search/"
        }
      }
    }
  6. GET subresource

    get user with id 58's learning courses:

    GET http://localhost:8080/users/58/learning
  7. Create user

    POST http://localhost:8080/api/users

    Body

    {
        "email": "[email protected]",
        "password": "$2a$10$x0Qw0EdwJTNnY9DF8xNYfebahJ./8vEOkd0b8sacHJhSVcrnK50t.",
        "firstName": "test",
        "lastName": "test",
        "phone": "12345678901",
        "roles": [
            {
                "name": "ROLE_TEACHER"
            },
            {
                "name": "ROLE_USER"
            }
        ]
    }
  8. Update user

    Update user with id 58

    PATCH http://localhost:8080/api/users/58

    Body

    {
        "phone": "10086"
    }
  9. Delete a user

    DELETE http://localhost:8080/users/58
  10. ==Update Subresource==

Add a course with id 59 to user with id 58's learning courses:

$ curl -i -X PUT -d "http://localhost:8080/courses/59"
  -H "Content-Type:text/uri-list" http://localhost:8080/users/58/learning

3.3 API Security

There are 3 levels of users in this application: Admin > Teacher > User

Admin was granted authority to access all api, while Teacher and User only have limited access. Here's a table to demonstrate the auchorities:

"" denotes full authorities: create, update, delete, query all or single REST resource.

Resource Admin Teacher User
users Get/Query single/all User Get himself
exams
resources
courses
marks Get himself

LICENSE

GPL V3 License: GPL v3

springbooteducationsystem's People

Contributors

peng-ym avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

springbooteducationsystem's Issues

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.