The backend of 9PM Online Teaming Platform
9PM Online Teaming Platform——Fronted
This project is the backend of the 9PM Online Teaming Platform for Unicode Hackathon. 9PM Online Teaming Platform aims to facilitate game teaming for international students from China in this self-quarantine period and further.
Installation guide:
https://www.runoob.com/mysql/mysql-install.html
Establish develop environment data
create table room
(
id int auto_increment
primary key,
date_time varchar(255) null,
game_name varchar(255) null,
max_number int null,
host_id int not null,
members_id varchar(255) null
);
INSERT INTO unicodesc.room (id, date_time, game_name, max_number, host_id, members_id) VALUES (1, '2020-9-5-20-00', 'lol', 5, 1, '2,3');
INSERT INTO unicodesc.room (id, date_time, game_name, max_number, host_id, members_id) VALUES (2, '2020-1-1-0-0', 'pubg', 4, 2, null);
INSERT INTO unicodesc.room (id, date_time, game_name, max_number, host_id, members_id) VALUES (3, '2020-02-1420-10', 'lol', 5, 1, null);
create table user
(
id bigint auto_increment
primary key,
email varchar(64) null,
password varchar(255) collate utf8mb4_bin null,
name varchar(32) null,
my_teams varchar(255) collate utf8mb4_bin null,
joined_teams varchar(255) null,
sex int null,
roles varchar(255) null
);
INSERT INTO unicodesc.user (id, email, password, name, my_teams, joined_teams, sex, roles) VALUES (1, 'abc@ucsd.edu', 'sss', 'Yui', '1,3', null, 0, null);
INSERT INTO unicodesc.user (id, email, password, name, my_teams, joined_teams, sex, roles) VALUES (2, 'yyu@ucsd.edu', 'sss', 'Yukino', '2', '1', 2, null);
INSERT INTO unicodesc.user (id, email, password, name, my_teams, joined_teams, sex, roles) VALUES (3, 'zzd@ucsd.edu', '123', 'zzd', null, '1', 0, null);
Clone the repo
https://github.com/wfy0425/Unicode-Hackathon-backend.git
Package the Application
Run it
GET /login
Type | Name | Description | Schema |
---|---|---|---|
Query | email required |
登录邮箱 | string |
Query | password required |
登录密码 | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
400 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "Login success",
"data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTkzMDk5NzgsInVzZXJuYW1lIjoiMTIzQGdtYWlsLmNvbSJ9.0i4g4K5IcOY5h2q9xYuYtG_sbkjkc5LwEilz9KM_YvQ"
}
{
"code": 400,
"msg": "username or password wrong",
"data": null
}
POST /register
Type | Name | Description | Schema | Default |
---|---|---|---|---|
Query | email required |
用户邮箱 | string | |
Query | name required |
姓名 | string | |
Query | password required |
密码 | string | |
Query | sex optional |
性别 | integer (int32) | 0 |
HTTP Code | Description | Schema |
---|---|---|
201 | Created | ResponseBean |
400 | Unauthorized | ResponseBean |
{
"code": 201,
"msg": "user registered",
"data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTkzMTM0ODUsInVzZXJuYW1lIjoiYWJjQHVjc2QuZWR1In0.RrPSAM0iJi7GFAMMTgLbLZHPwjPdglmF5cHrWSTV3ug"
}
{
"code": 400,
"msg": "username already exist",
"data": null
}
GET /users
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | No Content |
403 | Forbidden | No Content |
404 | Not Found | No Content |
GET /users/{id}
Type | Name | Description | Schema |
---|---|---|---|
Path | id required |
用户Id | integer (int32) |
Header | Authorization required |
token | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | |
401 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "OK",
"data": [
{
"id": 1,
"email": "123@gmail.com",
"password": "123",
"name": "Adam",
"myTeams": "1",
"joinedTeams": "2",
"sex": 1,
"roles": null
},
...
]
}
{
"code": 401,
"msg": "The current Subject is not authenticated. Access denied.",
"data": null
}
PUT /users/{id}
Type | Name | Description | Schema | Default |
---|---|---|---|---|
Path | id required |
用户Id | integer (int32) | |
Query | name optional |
姓名 | string | |
Query | password optional |
密码 | string | |
Query | sex optional |
性别 | integer (int32) | 0 |
Header | Authorization required |
token | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "OK",
"data": {
"id": 17,
"email": null,
"password": null,
"name": "Yukinoshita Yukino",
"myTeams": null,
"joinedTeams": null,
"sex": 0,
"roles": null
}
}
{
"code": 401,
"msg": "The current Subject is not authenticated. Access denied.",
"data": null
}
只能更新自己
PUT /users/{teamId}/{userId}
Type | Name | Description | Schema |
---|---|---|---|
Path | teamId required |
队伍Id | integer (int32) |
Path | userId required |
用户Id | integer (int32) |
Header | Authorization required |
token | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "OK",
"data": 1
}
{
"code": 401,
"msg": "Unauthorized",
"data": null
}
DELETE /users/{teamId}/{userId}
Type | Name | Description | Schema |
---|---|---|---|
Path | teamId required |
队伍Id | integer (int32) |
Path | userId required |
用户Id | integer (int32) |
Header | Authorization required |
token | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "OK",
"data": 1
}
POST /rooms
Type | Name | Description | Schema |
---|---|---|---|
Query | gameName required |
游戏名字 | string |
Query | hostId required |
房主Id | integer (int32) |
Query | maxNumber required |
队伍最大人数 | integer (int32) |
Query | date required |
游戏日期 | string |
Query | time required |
游戏时间 | string |
Header | Authorization required |
token | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | ResponseBean |
{
"code": 201,
"msg": "CREATED",
"data": {
"id": 8,
"dateTime": "2222",
"gameName": "123",
"maxNumber": 4,
"hostId": 17,
"membersId": null
}
}
GET /rooms
Type | Name | Description | Schema |
---|---|---|---|
Header | Authorization required |
token | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "OK",
"data": [
{
"id": 1,
"dateTime": "2020-9-5-20-00",
"gameName": "lol",
"maxNumber": 5,
"hostId": 1,
"membersId": "17,17"
},
...
]
}
GET /rooms/host/{id}
Type | Name | Description | Schema |
---|---|---|---|
Path | id required |
房主Id | integer (int32) |
Header | Authorization required |
token | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "OK",
"data": [
{
"id": 1,
"dateTime": "2020-9-5-20-00",
"gameName": "lol",
"maxNumber": 5,
"hostId": 1,
"membersId": "17,17"
}
]
}
GET /rooms/{id}
Type | Name | Description | Schema |
---|---|---|---|
Path | id required |
队伍Id | integer (int32) |
Header | Authorization required |
token | string |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "OK",
"data": {
"id": 1,
"dateTime": "2020-9-5-20-00",
"gameName": "lol",
"maxNumber": 5,
"hostId": 1,
"membersId": "17"
}
}
DELETE /rooms/{id}
Type | Name | Description | Schema |
---|---|---|---|
Path | id required |
队伍Id | integer (int32) |
401 | Unauthorized | ResponseBean |
HTTP Code | Description | Schema |
---|---|---|
200 | OK | ResponseBean |
401 | Unauthorized | ResponseBean |
{
"code": 200,
"msg": "OK",
"data": 1
}
只能删除以自己为房主的房间
This project is licensed under the MIT License - see the LICENSE file for details
《深入浅出Spring Boot 2.x》 (杨开振)