DanceGradeV2 is the back end of an academic research project on dance grading based on motion sensors and artificial intelligence.
Represents the information of a student and their dance rating.
id: Long- The ID of the data in the database.studentId: Long- The student ID of the student.name: String- The name of the student.actions: Integer[]- The order of actions (the index of the first dance action is 0).scores: Double[]: - The score of each dance action.scoreAvg: Double- The average score of all acions.
{
"id": 1,
"studentId": 19532801,
"name": "Student Name 1",
"actions": [0, 1, 2, 1, 2, 4, 3],
"scores": [98.285001, 92.104919, 94.184573, 91.501711, 96.171609],
"scoreAvg": 94.449563
}The data returned by the server after receiving an HTTP request.
code: Integer- The status code. Used to indicate success or failure of the operation.message: String- Additional message of the operation.data: Object (nullable)- The data requested by the client, or the details of an error. Can be any type.
{
"code": 200,
"message": "OK",
"data": 38101472
}{
"code": 201,
"message": "Data created",
"data": null
}{
"code": 404,
"message": "The resource you requested was not found on this server",
"data": null
}{
"code": 40003,
"message": "Content-Type 'application/octet-stream' is not supported",
"data": null
}{
"code": 40005,
"message": "'name' cannot be empty",
"data": "org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public org.springframework.http.ResponseEntity<?> vip.floatationdevice.dancegrade.controller.DataWriteController.insertData(vip.floatationdevice.dancegrade.data.DanceData) with 6 errors: ..."
}Stores the result in a search. Returned as CommonMappedResult's 'data' field during search operations.
result: List<DanceData>- The paged list of DanceData objects (max 10 objects per page)total: Integer- The total number of the data that matches the search criteria
{
"result": [
{
"id": 2,
"studentId": 19532802,
"name": "Rain Silves",
"actions": [0, 1, 2, 3, 4],
"scores": [100.0 ,100.0, 100.0, 100.0, 100.0],
"scoreAvg": 100.0
}
],
"total": 1
}Default bind address: 0.0.0.0:60080
GET /api/dataCount
{
"code": 200,
"message": "OK",
"data": 3
}GET /api/data?page={}
Query parameters:
page: Integer, required
Request: GET /api/data?page=0
Response:
{
"code": 200,
"message": "OK",
"data": [
{
"id": 0,
"studentId": 19532801,
"name": "Student Name 1",
"actions": [0, 1, 2, 1, 2, 4, 3],
"scores": [98.285001, 92.104919, 94.184573, 91.501711, 96.171609],
"scoreAvg": 94.449563
},
{
"id": 2,
"studentId": 19532802,
"name": "Rain Silves",
"actions": [0, 1, 2, 3, 4],
"scores": [100.0 ,100.0, 100.0, 100.0, 100.0],
"scoreAvg": 100.0
},
{
"id": 5,
"studentId": 19532805,
"name": "Nixuelle",
"actions": [4, 1, 4, 2, 3, 1, 2, 3, 2],
"scores": [82.180572, 80.471065, 78.587753, 88.67142, 83.160093],
"scoreAvg": 82.6141806
}
]
}GET /api/data?page={}&studentId={}&name={}
Query parameters:
page: Integer, requiredstudentId: Integer, optional*name: String, optional*
*Provide at least 1 search criteria
Request: GET /api/data?page=0&name=den
Response:
{
"code": 200,
"message": "OK",
"data": {
"result": [
{
"id": 0,
"studentId": 19532801,
"name": "Student Name 1",
"actions": [0, 1, 2, 1, 2, 4, 3],
"scores": [98.285001, 92.104919, 94.184573, 91.501711, 96.171609],
"scoreAvg": 94.449563
}
],
"total": 1
}
}GET /api/data/{id}
URL parameters:
id: Integer, required
Request: GET /api/data/5
Response:
{
"code": 200,
"message": "OK",
"data": {
"id": 5,
"studentId": 19532805,
"name": "Nixuelle",
"actions": [4, 1, 4, 2, 3, 1, 2, 3, 2],
"scores": [82.180572, 80.471065, 78.587753, 88.67142, 83.160093],
"scoreAvg": 82.6141806
}
}POST /api/data
JSON parameters:
studentId: Integer, requiredname: String, requiredscores: Double[], requiredscoreAvg: Double, requiredactions: Integer[], required
{
"code": 201,
"message": "Data created",
"data": null
}DELETE /api/data/{id}
URL parameters:
id: Integer, required
Request: DELETE /api/data/1
Response:
{
"code": 200,
"message": "Data deleted",
"data": null
}The default configuration doesn't meet everyone's needs. This example shows how to change the binding port to 8080, change the URL, username & password of the MySQL connection, and turn on verbose logging of MyBatis.
- Create a new file named
application.ymlunder the working directory (usually the same location as the runnable jar file). - Write these lines:
server:
port: 8080
spring:
datasource:
url: "jdbc:mysql://node0.example.org:3306/myDatabase?user=admin&password=111111"
mybatis:
configuration:
log-impl: "org.apache.ibatis.logging.stdout.StdOutImpl"- Start the program and see the results.