# chat-room-api **Repository Path**: pony177/chat-room ## Basic Information - **Project Name**: chat-room-api - **Description**: 聊天室后端接口。就是后端 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-08-22 - **Last Updated**: 2023-09-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README --- title: 聊天室 v1.0.0 language_tabs: - shell: Shell - http: HTTP - javascript: JavaScript - ruby: Ruby - python: Python - php: PHP - java: Java - go: Go toc_footers: [] includes: [] search: true code_clipboard: true highlight_theme: darkula headingLevel: 2 generator: "@tarslib/widdershins v4.0.17" --- # 聊天室 > v1.0.0 Base URLs: # h5/用户登录注册 ## POST h5登录 POST /h5/user/login > Body 请求参数 ```json { "username": "admin", "password": "123456" } ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |token|header|string| 否 |none| |body|body|object| 否 |none| |» username|body|string| 是 |none| |» password|body|string| 是 |none| > 返回示例 > 成功 ```json { "data": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NGUyZTUzNTYxYTI1YTMwZGI3NjdhNDAiLCJ1c2VybmFtZSI6ImFkbWluIiwicGFzc3dvcmQiOiIxMjM0NTYiLCJyb2xlIjowLCJfX3YiOjAsImNyZWF0ZWRBdCI6IjIwMjMtMDgtMjFUMDQ6MTY6NTMuNzY1WiIsInVwZGF0ZWRBdCI6IjIwMjMtMDgtMjFUMDQ6MTY6NTMuNzY1WiIsImlhdCI6MTY5MjU5MTQ4MX0.JCPnY99Sjgdii4-1Ezg4Js_9kxbt3bbrWeq2Nfodqx0", "_id": "64e2e53561a25a30db767a40", "username": "admin", "role": 0, "__v": 0, "createdAt": "2023-08-21T04:16:53.765Z", "updatedAt": "2023-08-21T04:16:53.765Z" }, "msg": "success", "code": 200 } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|Inline| ### 返回数据结构 状态码 **200** |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |» data|object|true|none||none| |»» token|string|true|none||none| |»» _id|string|true|none||none| |»» username|string|true|none||none| |»» role|integer|true|none||none| |»» __v|integer|true|none||none| |»» createdAt|string|true|none||none| |»» updatedAt|string|true|none||none| |» msg|string|true|none||none| |» code|integer|true|none||none| ## POST h5注册 POST /h5/user/reg > Body 请求参数 ```json { "username": "admin", "password": "123456" } ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |token|header|string| 否 |none| |body|body|object| 否 |none| |» username|body|string| 是 |none| |» password|body|string| 是 |none| > 返回示例 > 成功 ```json { "data": [ { "username": "admin1", "password": "123456", "role": 0, "_id": "64e2e5bdf2dc01079367511e", "__v": 0, "createdAt": "2023-08-21T04:19:09.838Z", "updatedAt": "2023-08-21T04:19:09.838Z" } ], "msg": "注册成功", "code": 200 } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|Inline| ### 返回数据结构 状态码 **200** |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |» data|[object]|true|none||none| |»» username|string|false|none||none| |»» password|string|false|none||none| |»» role|integer|false|none||none| |»» _id|string|false|none||none| |»» __v|integer|false|none||none| |»» createdAt|string|false|none||none| |»» updatedAt|string|false|none||none| |» msg|string|true|none||none| |» code|integer|true|none||none| # h5/商页 ## GET 获取商页 GET /h5/merchant ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |token|header|string| 否 |none| > 返回示例 > 成功 ```json { "data": [ { "_id": "64e2f2047eddc55db967892c", "user": "64e2e53561a25a30db767a40", "merchant": { "_id": "64e2ee287afb0737f092ff9b", "userId": "64e2e53561a25a30db767a40", "name": "小蓝的商页", "customer": "64e2e53561a25a30db767a40" }, "__v": 0, "createdAt": "2023-08-21T05:11:32.043Z", "updatedAt": "2023-08-21T05:11:32.043Z" } ], "msg": "success", "code": 200 } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|Inline| ### 返回数据结构 状态码 **200** |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |» data|[object]|true|none||none| |»» _id|string|false|none||none| |»» user|string|false|none||none| |»» merchant|object|false|none||none| |»»» _id|string|true|none||none| |»»» user|string|true|none||none| |»»» activationCode|string|true|none||none| |»»» name|string|true|none||none| |»»» icon|string|true|none||none| |»»» customer|string|true|none||none| |»»» __v|integer|true|none||none| |»»» createdAt|string|true|none||none| |»»» updatedAt|string|true|none||none| |»» __v|integer|false|none||none| |»» createdAt|string|false|none||none| |»» updatedAt|string|false|none||none| |» msg|string|true|none||none| |» code|integer|true|none||none| ## POST 加入商页 POST /h5/merchant > Body 请求参数 ```json { "merchant": "64e2ee287afb0737f092ff9b" } ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |token|header|string| 否 |none| |body|body|object| 否 |none| |» merchant|body|string| 是 |none| > 返回示例 > 成功 ```json { "data": [ { "user": "64e2e53561a25a30db767a40", "merchant": "64e2ee287afb0737f092ff9b", "_id": "64e2f2047eddc55db967892c", "__v": 0, "createdAt": "2023-08-21T05:11:32.043Z", "updatedAt": "2023-08-21T05:11:32.043Z" } ], "msg": "success", "code": 200 } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|Inline| ### 返回数据结构 状态码 **200** |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |» data|[object]|true|none||none| |»» _id|string|false|none||none| |»» __v|integer|false|none||none| |»» createdAt|string|false|none||none| |»» updatedAt|string|false|none||none| |»» user|string|false|none||none| |»» merchant|string|false|none||none| |» msg|string|true|none||none| |» code|integer|true|none||none| ## POST 创建商页 POST /h5/merchant/createMerchant > Body 请求参数 ```json { "activationCode": "asdasad", "name": "小蓝的商页1", "icon": "https://www.somode.com/uploadimg/image/20230129/20230129150835_59024.jpg", "customer": "64e2e53561a25a30db767a40" } ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |token|header|string| 否 |none| |body|body|object| 否 |none| |» activationCode|body|string| 是 |none| |» name|body|string| 是 |none| |» icon|body|string| 是 |none| |» customer|body|string| 是 |none| > 返回示例 > 成功 ```json { "data": [ { "user": "64e2e53561a25a30db767a40", "activationCode": "asdasad", "name": "小蓝的商页1", "icon": "https://www.somode.com/uploadimg/image/20230129/20230129150835_59024.jpg", "customer": "64e2e53561a25a30db767a40", "_id": "64e2f4773f81c20a68e41abc", "__v": 0, "createdAt": "2023-08-21T05:21:59.172Z", "updatedAt": "2023-08-21T05:21:59.172Z" } ], "msg": "success", "code": 200 } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|Inline| ### 返回数据结构 状态码 **200** |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |» activationCode|string|true|none||none| |» name|string|true|none||none| |» icon|string|true|none||none| |» customer|string|true|none||none| |» data|[object]|true|none||none| |»» user|string|false|none||none| |»» activationCode|string|false|none||none| |»» name|string|false|none||none| |»» icon|string|false|none||none| |»» customer|string|false|none||none| |»» _id|string|false|none||none| |»» __v|integer|false|none||none| |»» createdAt|string|false|none||none| |»» updatedAt|string|false|none||none| |» msg|string|true|none||none| |» code|integer|true|none||none| # h5/群聊 ## POST 获取群聊 POST /h5/group/getGroup 里面有一个state字段,0表示未加入群,1表示已经加入群了,可以点进去聊天 > Body 请求参数 ```json { "merchant": "64e2f4773f81c20a68e41abc" } ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |token|header|string| 否 |none| |body|body|object| 否 |none| |» merchant|body|string| 是 |none| > 返回示例 > 成功 ```json { "data": [ { "state": 1, "_id": "64e313309054f1bdf19707c1", "user": "64e2e53561a25a30db767a40", "merchant": "64e2f4773f81c20a68e41abc", "name": "小黑子的世界", "icon": "https://www.somode.com/uploadimg/image/20230129/20230129150835_59024.jpg", "__v": 0, "createdAt": "2023-08-21T07:33:04.305Z", "updatedAt": "2023-08-21T07:33:04.305Z" }, { "state": 1, "_id": "64e313ab46b6b56336dc06ab", "user": "64e2e53561a25a30db767a40", "merchant": "64e2f4773f81c20a68e41abc", "name": "小黑子的世界2群", "icon": "https://www.somode.com/uploadimg/image/20230129/20230129150835_59024.jpg", "__v": 0, "createdAt": "2023-08-21T07:35:07.499Z", "updatedAt": "2023-08-21T07:35:07.499Z" } ], "msg": "success", "code": 200 } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|Inline| ### 返回数据结构 状态码 **200** |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |» data|[object]|true|none||none| |»» state|integer|true|none||none| |»» _id|string|true|none||none| |»» user|string|true|none||none| |»» merchant|string|true|none||none| |»» name|string|true|none||none| |»» icon|string|true|none||none| |»» __v|integer|true|none||none| |»» createdAt|string|true|none||none| |»» updatedAt|string|true|none||none| |» msg|string|true|none||none| |» code|integer|true|none||none| ## POST 创建群聊 POST /h5/group 这个接口只有商页创建人可以使用。 > Body 请求参数 ```json { "merchant": "64e2f4773f81c20a68e41abc", "name": "小黑子的世界", "icon": "https://www.somode.com/uploadimg/image/20230129/20230129150835_59024.jpg" } ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |token|header|string| 否 |none| |body|body|object| 否 |none| |» merchant|body|string| 是 |none| |» name|body|string| 是 |none| |» icon|body|string| 是 |none| > 返回示例 > 成功 ```json { "data": { "user": "64e2e53561a25a30db767a40", "merchant": "64e2f4773f81c20a68e41abc", "name": "小黑子的世界2群", "icon": "https://www.somode.com/uploadimg/image/20230129/20230129150835_59024.jpg", "_id": "64e313ab46b6b56336dc06ab", "__v": 0, "createdAt": "2023-08-21T07:35:07.499Z", "updatedAt": "2023-08-21T07:35:07.499Z" }, "msg": "success", "code": 200 } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|Inline| ### 返回数据结构 状态码 **200** |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |» data|object|true|none||none| |»» user|string|true|none||none| |»» merchant|string|true|none||none| |»» name|string|true|none||none| |»» icon|string|true|none||none| |»» _id|string|true|none||none| |»» __v|integer|true|none||none| |»» createdAt|string|true|none||none| |»» updatedAt|string|true|none||none| |» msg|string|true|none||none| |» code|integer|true|none||none| # 公共接口 ## POST 文件上传 POST /upload > Body 请求参数 ```yaml file: file://C:\Users\17748\Pictures\584_2023011331303489.png ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |token|header|string| 否 |none| |body|body|object| 否 |none| |» file|body|string(binary)| 否 |none| > 返回示例 > 成功 ```json { "data": "/upload/20230821/7e23cd7207e15d29589565701.png", "msg": "success", "code": 200 } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|成功|Inline| ### 返回数据结构 状态码 **200** |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |» data|string|true|none||none| |» msg|string|true|none||none| |» code|integer|true|none||none| # 数据模型