Student-Management-System-Backend

command module
v0.0.0-...-9ec1373 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2018 License: MIT Imports: 2 Imported by: 0

README

Student Management

Quick Start

$ git clone https://github.com/Triple-Z/Student-Management-System-Backend.git
$ cd Student-Management-System-Backend/
$ go run main.go

需要更改本地数据库配置信息,位于 app/mysql.go:10。 配置格式(若数据库用户名为 root,数据库密码为 password,数据库地址为 127.0.0.1,数据库端口为 3306 ):

root:password@tcp(127.0.0.1:3306)/?parseTime=true&charset=utf8

API Reference

API Root: http://localhost:3000

Students
获取所有学生信息
GET /api/v1/students
Response
Status: 200 OK
{
    "count": 3,
    "data": [
        {
            "Id": {
                "Int64": 3,
                "Valid": true
            },
            "Number": {
                "String": "161540121",
                "Valid": true
            },
            "Name": {
                "String": "赵祯真",
                "Valid": true
            },
            "Department_id": {
                "Int64": 1,
                "Valid": true
            },
            "Department_name": {
                "String": "计算机科学与技术学院",
                "Valid": true
            },
            "Create_date": "2018-06-09T15:01:04Z",
            "Last_updated": "2018-06-09T15:00:58Z"
        },
        {
            "Id": {
                "Int64": 7,
                "Valid": true
            },
            "Number": {
                "String": "161540110",
                "Valid": true
            },
            "Name": {
                "String": "lewis",
                "Valid": true
            },
            "Department_id": {
                "Int64": 1,
                "Valid": true
            },
            "Department_name": {
                "String": "计算机科学与技术学院",
                "Valid": true
            },
            "Create_date": "2018-06-09T15:01:04Z",
            "Last_updated": "2018-06-09T19:32:49Z"
        },
        {
            "Id": {
                "Int64": 10,
                "Valid": true
            },
            "Number": {
                "String": "161540119",
                "Valid": true
            },
            "Name": {
                "String": "斳森",
                "Valid": true
            },
            "Department_id": {
                "Int64": 1,
                "Valid": true
            },
            "Department_name": {
                "String": "计算机科学与技术学院",
                "Valid": true
            },
            "Create_date": "2018-06-09T15:01:04Z",
            "Last_updated": "2018-06-09T15:00:58Z"
        }
    ],
    "status": "ok"
}
新建学生
POST /api/v1/students
Parameters
Name Type Description
number string 学号
name string 姓名
department_id int 学院 ID
Response
Status: 200 OK
{
    "new_id": 13,
    "status": "ok"
}
获取某个学生信息
GET /api/v1/students/:id
Response
Status: 200 OK
{
    "data": {
        "Id": {
            "Int64": 3,
            "Valid": true
        },
        "Number": {
            "String": "161540121",
            "Valid": true
        },
        "Name": {
            "String": "赵祯真",
            "Valid": true
        },
        "Department_id": {
            "Int64": 1,
            "Valid": true
        },
        "Department_name": {
            "String": "计算机科学与技术学院",
            "Valid": true
        },
        "Create_date": "2018-06-09T15:01:04Z",
        "Last_updated": "2018-06-09T15:00:58Z"
    },
    "status": "ok"
}
更新某个学生信息
PUT /api/v1/students/:id
Parameters
Name Type Description
number string 学号
name string 姓名
department_id int 学院 ID
Response
Status: 200 OK
{
    "status": "ok",
    "updated_id": "13"
}
删除某个学生
DELETE /api/v1/students/:id
Response

删除成功返回 204

Status: 204 No Content

删除失败则返回 404

Status: 404 Not Found
{
    "message": "Cannot find this student by id: 13",
    "rows_affected": null,
    "status": "failed"
}
Departments
获取所有学院信息
GET /api/v1/departments
Response
Status: 200 OK
{
    "count": 3,
    "data": [
        {
            "Id": {
                "Int64": 1,
                "Valid": true
            },
            "Name": {
                "String": "计算机科学与技术学院",
                "Valid": true
            },
            "Create_date": "2018-06-09T14:47:53Z",
            "Last_updated": "2018-06-09T14:58:24Z"
        },
        {
            "Id": {
                "Int64": 2,
                "Valid": true
            },
            "Name": {
                "String": "航空宇航学院",
                "Valid": true
            },
            "Create_date": "2018-06-09T14:56:12Z",
            "Last_updated": "2018-06-09T14:56:12Z"
        },
        {
            "Id": {
                "Int64": 3,
                "Valid": true
            },
            "Name": {
                "String": "自动化学院",
                "Valid": true
            },
            "Create_date": "2018-06-09T18:46:52Z",
            "Last_updated": "2018-06-09T20:18:24Z"
        }
    ],
    "status": "ok"
}
新建学院
POST /api/v1/departments
Parameters
Name Type Description
name string 学院名
Response
Status: 200 OK
{
    "new_id": 5,
    "status": "ok"
}
获取某个学院信息
GET /api/v1/departments/:id
Response
Status: 200 OK
{
    "data": {
        "Id": {
            "Int64": 5,
            "Valid": true
        },
        "Name": {
            "String": "人工智能学院",
            "Valid": true
        },
        "Create_date": "2018-06-09T21:16:15Z",
        "Last_updated": "2018-06-09T21:16:15Z"
    },
    "status": "ok"
}
更新某个学院信息
PUT /api/v1/departments/:id
Parameters
Name Type Description
name string 学院名
Response
Status: 200 OK
{
    "status": "ok",
    "updated_id": "5"
}
删除某个学院
DELETE /api/v1/departments/:id
Response

删除成功返回 204

Status: 204 No Content

删除失败则返回 404

Status: 404 Not Found
{
    "message": "Cannot find this department by id: 5",
    "rows_affected": null,
    "status": "failed"
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL