项目作者: wfy0425

项目描述 :
The backend of 9PM Online Teaming Platform
高级语言: Java
项目地址: git://github.com/wfy0425/9PM-backend.git
创建时间: 2020-09-04T16:41:21Z
项目社区:https://github.com/wfy0425/9PM-backend

开源协议:MIT License

下载


9PM Online Teaming Platform -backend

About The Project

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.

Built With

Quick Start

Prerequisites

  • MySQL

Installation guide:

  1. https://www.runoob.com/mysql/mysql-install.html

Establish develop environment data

  1. create table room
  2. (
  3. id int auto_increment
  4. primary key,
  5. date_time varchar(255) null,
  6. game_name varchar(255) null,
  7. max_number int null,
  8. host_id int not null,
  9. members_id varchar(255) null
  10. );
  11. 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');
  12. 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);
  13. 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);
  14. create table user
  15. (
  16. id bigint auto_increment
  17. primary key,
  18. email varchar(64) null,
  19. password varchar(255) collate utf8mb4_bin null,
  20. name varchar(32) null,
  21. my_teams varchar(255) collate utf8mb4_bin null,
  22. joined_teams varchar(255) null,
  23. sex int null,
  24. roles varchar(255) null
  25. );
  26. 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);
  27. 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);
  28. 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);

Installation

  1. Clone the repo

    1. https://github.com/wfy0425/Unicode-Hackathon-backend.git
  2. Package the Application

  3. Run it

APIs

登陆

  1. GET /login

Parameters

Type Name Description Schema
Query email
required
登录邮箱 string
Query password
required
登录密码 string

Responses

HTTP Code Description Schema
200 OK ResponseBean
400 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "Login success",
  4. "data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTkzMDk5NzgsInVzZXJuYW1lIjoiMTIzQGdtYWlsLmNvbSJ9.0i4g4K5IcOY5h2q9xYuYtG_sbkjkc5LwEilz9KM_YvQ"
  5. }
  1. {
  2. "code": 400,
  3. "msg": "username or password wrong",
  4. "data": null
  5. }

注册

  1. POST /register

Parameters

Type Name Description Schema Default
Query email
required
用户邮箱 string
Query name
required
姓名 string
Query password
required
密码 string
Query sex
optional
性别 integer (int32) 0

Responses

HTTP Code Description Schema
201 Created ResponseBean
400 Unauthorized ResponseBean
  1. {
  2. "code": 201,
  3. "msg": "user registered",
  4. "data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTkzMTM0ODUsInVzZXJuYW1lIjoiYWJjQHVjc2QuZWR1In0.RrPSAM0iJi7GFAMMTgLbLZHPwjPdglmF5cHrWSTV3ug"
  5. }
  1. {
  2. "code": 400,
  3. "msg": "username already exist",
  4. "data": null
  5. }

获取用户列表

  1. GET /users

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized No Content
403 Forbidden No Content
404 Not Found No Content

通过用户id获取用户信息

  1. GET /users/{id}

Parameters

Type Name Description Schema
Path id
required
用户Id integer (int32)
Header Authorization
required
token string

Responses

HTTP Code Description Schema
200 OK
401 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "OK",
  4. "data": [
  5. {
  6. "id": 1,
  7. "email": "123@gmail.com",
  8. "password": "123",
  9. "name": "Adam",
  10. "myTeams": "1",
  11. "joinedTeams": "2",
  12. "sex": 1,
  13. "roles": null
  14. },
  15. ...
  16. ]
  17. }
  1. {
  2. "code": 401,
  3. "msg": "The current Subject is not authenticated. Access denied.",
  4. "data": null
  5. }

更新用户详细信息

  1. PUT /users/{id}

Parameters

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

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "OK",
  4. "data": {
  5. "id": 17,
  6. "email": null,
  7. "password": null,
  8. "name": "Yukinoshita Yukino",
  9. "myTeams": null,
  10. "joinedTeams": null,
  11. "sex": 0,
  12. "roles": null
  13. }
  14. }
  1. {
  2. "code": 401,
  3. "msg": "The current Subject is not authenticated. Access denied.",
  4. "data": null
  5. }

Security

只能更新自己

将用户加入队伍

  1. PUT /users/{teamId}/{userId}

Parameters

Type Name Description Schema
Path teamId
required
队伍Id integer (int32)
Path userId
required
用户Id integer (int32)
Header Authorization
required
token string

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "OK",
  4. "data": 1
  5. }
  1. {
  2. "code": 401,
  3. "msg": "Unauthorized",
  4. "data": null
  5. }

从队伍中删除用户

  1. DELETE /users/{teamId}/{userId}

Parameters

Type Name Description Schema
Path teamId
required
队伍Id integer (int32)
Path userId
required
用户Id integer (int32)
Header Authorization
required
token string

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "OK",
  4. "data": 1
  5. }

创建队伍

  1. POST /rooms

Parameters

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

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized ResponseBean
  1. {
  2. "code": 201,
  3. "msg": "CREATED",
  4. "data": {
  5. "id": 8,
  6. "dateTime": "2222",
  7. "gameName": "123",
  8. "maxNumber": 4,
  9. "hostId": 17,
  10. "membersId": null
  11. }
  12. }

Security

只能创建以自己为房主的房间

获取队伍列表

  1. GET /rooms

Parameters

Type Name Description Schema
Header Authorization
required
token string

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "OK",
  4. "data": [
  5. {
  6. "id": 1,
  7. "dateTime": "2020-9-5-20-00",
  8. "gameName": "lol",
  9. "maxNumber": 5,
  10. "hostId": 1,
  11. "membersId": "17,17"
  12. },
  13. ...
  14. ]
  15. }

通过房主id获取队伍信息

  1. GET /rooms/host/{id}

Parameters

Type Name Description Schema
Path id
required
房主Id integer (int32)
Header Authorization
required
token string

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "OK",
  4. "data": [
  5. {
  6. "id": 1,
  7. "dateTime": "2020-9-5-20-00",
  8. "gameName": "lol",
  9. "maxNumber": 5,
  10. "hostId": 1,
  11. "membersId": "17,17"
  12. }
  13. ]
  14. }

通过队伍id获取队伍信息

  1. GET /rooms/{id}

Parameters

Type Name Description Schema
Path id
required
队伍Id integer (int32)
Header Authorization
required
token string

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "OK",
  4. "data": {
  5. "id": 1,
  6. "dateTime": "2020-9-5-20-00",
  7. "gameName": "lol",
  8. "maxNumber": 5,
  9. "hostId": 1,
  10. "membersId": "17"
  11. }
  12. }

通过队伍id删除队伍

  1. DELETE /rooms/{id}

Parameters

Type Name Description Schema
Path id
required
队伍Id integer (int32)
401 Unauthorized ResponseBean

Responses

HTTP Code Description Schema
200 OK ResponseBean
401 Unauthorized ResponseBean
  1. {
  2. "code": 200,
  3. "msg": "OK",
  4. "data": 1
  5. }

Security

只能删除以自己为房主的房间

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

《深入浅出Spring Boot 2.x》 (杨开振)

Shiro + JWT + Spring Boot Restful 简易教程

使用Swagger2Markup实现API文档的静态部署