mini项目后台接口文档
Posted AlexP5
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mini项目后台接口文档相关的知识,希望对你有一定的参考价值。
说明
1. returnCode和returnMessage返回值说明
returnCode | returnMessage | 含义 |
---|---|---|
0 | OK | 返回成功 |
1000 | PARAM_ERROR | 参数错误:仔细校验请求包参数是否完整,参数名称、参数类型、参数值是否正确 |
1001 | DB_QUERY_ERROR | 数据库查询异常 |
2000 | USER_EXISTS | 注册失败,该用户已存在 |
2001 | USER_NOT_FOUND | 登录失败,该用户不存在 |
3000 | NO_CREDIT | 取消/删除活动失败,用户信用分不够 |
3001 | FULL_HC_ERROR | 参加活动失败,人数已满 |
3002 | DEADLINE_ERROR | 参加活动失败,该活动已截止 |
3003 | ACT_NOT_FOUND | 参加活动失败,该活动不存在或已被取消 |
注:当未查找到相关信息时data将不会返回任何信息,但该请求判定为成功(returnCode=0,returnMessage="OK")
2. 系统自动生成的参数不需要用户提供,但也在参数列表中列出
3. 若不特殊说明,请求方式均为 POST
4. 请求包和返回包通用格式如下
请求包:
"version": "1.0", // 版本号,固定为1.0
"timestamp": 1450936869, // 请求时间戳
"interface": // 接口详情
"interfaceName": "...", // 接口名称
"para": // 业务入参
...
返回包:
"version": "1.0", // 版本号
"timestamp": 1450936869, // 时间戳
"returnCode": 0, // 请求返回码
"returnMessage": "...", // 请求返回信息
"data": // 请求返回数据
...
一、用户接口
1. signIn 注册
- 参数
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
userName | 是 | string | 微信自动拉取 |
portrait | 是 | string | 微信自动拉取 |
creditScore | 是 | int | 系统自动生成 |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "user.signIn",
"para":
"userName": "alecpeng",
"portrait": "用户头像url",
"creditScore": 100
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
- 涉及错误码:1000 1001 2000
2. login 登录
- 参数
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
userId | 是 | int |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "user.login",
"para":
"userId": "12"
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
- 涉及错误码:1000 1001 2001
3. modifyUser 修改用户信息
- 参数
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
userId | 是 | int | |
age | 否 | int | |
height | 否 | int | |
weight | 否 | int | |
bg | 否 | string | |
signature | 否 | string |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "user.modifyUser ",
"para":
"userId": 2,
"age": 25,
"height": 175,
"weight": 65,
"bg": "SNG腾讯云",
"signature": "个性签名"
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
- 涉及错误码:1000 1001
4. getUserByUid 按用户Id查找信息
- 参数
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
userId | 是 | int |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "user.getUserByUid",
"para":
"userId": "12"
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
"user":
"userId": 12,
"userName": "alecpeng",
"portrait": "用户头像url",
"sex": 1,
"age": 25,
"height": 175,
"weight": 65,
"creditScore": 100,
"bg": "SNG腾讯云",
"signature": "这是我的个性签名"
- 涉及错误码:1000 1001
二、活动接口
1. addActivity 添加活动
- 参数
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
initiatorId | 是 | int | 活动发起人Id |
sportId | 是 | int | 活动类型,'跑步','健身','游泳','乒乓球','羽毛球','网球','足球','篮球'对应id序号1~8 |
title | 是 | string | 活动名称 |
content | 否 | string | 活动内容 |
picture | 否 | string | 图片url |
releaseTime | 是 | long | 调用当前接口的系统时间戳 |
blockingTime | 是 | long | releaseTime+用户选择的活动时长 |
longitude | 是 | string | 经度(地图获取) |
latitude | 是 | string | 纬度(地图获取) |
address | 是 | string | 地址(地图获取) |
maxNumOfMember | 是 | int | 最大参与人数 |
state | 是 | 1 | 活动状态,1:'finished',0:'underway'(默认初始状态是0) |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.addActivity",
"para":
"initiatorId": 12,//系统获取
"sportId": 2, //用户填写
"title": "约跑步", //用户填写
"content": "腾大周围,三个人", //用户选填
"picture": "图片url", //用户选填
"releaseTime": 1450936869, //活动发起时间,即前面的timestamp
"blockingTime": 145096000, //releaseTime+用户选择的活动时长
"activityLongitude": "343.343566", //地图获取
"activityLatitude": "38.123456", //地图获取
"address": "腾讯大厦", //地图获取
"maxNumOfMember": 3, //用户填写
"state": 0 //系统生成
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
- 涉及错误码:1000 1001
2. deleteActivity 删除活动
说明:1.删除已有人参与过的活动将扣除50信用分;2.需要将活动申请相关信息一并删除
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
activityId | 是 | int | 活动Id |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.deleteActivity",
"para":
"activityId": 2
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
- 涉及错误码:1000 1001 3000
3. attendActivity 参加活动
- 参数
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
participantId | 是 | int | 活动参与者Id |
activityId | 是 | int | 活动Id |
participateDatetime | 是 | string | 活动参与时间 |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.attendActivity",
"para":
"participantId": 12,//系统获取
"activityId": 2, //系统获取
"participateDatetime": 1450936869 //活动参与时间,即前面的timestamp
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
- 涉及错误码:1000 1001 3001 3002 3003
4. cancelAttendActivity 取消参加活动
说明:取消参与正在进行的活动将扣除10信用分
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
activityId | 是 | int | 活动Id |
participantId | 是 | int | 活动参与者Id |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.cancelAttendActivity",
"para":
"activityId": 2,
"participantId": 12
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
-
涉及错误码:1000 1001 3000
5. getActivityByState 按照活动状态获取活动
说明:注意返回字段takenMember,需要从活动参加表中进行计算参与该活动的人数,后面凡是涉及返回活动信息的都是这样
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
state | 是 | int | 活动状态 |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.getActivityByState",
"para":
"state": 0
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
"activities": [
"activityId": 2,
"initiatorId": 12,
"sportId": 2,
"title": "约跑步",
"content": "腾大周围,三个人",
"picture": "图片url",
"releaseTime": 1450936869,
"blockingTime": 145096000,
"activityLongitude": "343.343566",
"activityLatitude": "38.123456",
"address": "腾讯大厦",
"takenMember": 2,
"maxNumOfMember": 3,
"state": 0
,
....
,
....
]
- 涉及错误码:1000 1001
6. getActivityByIid 按照发起人Id获取活动
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
initiatorId | 是 | int | 活动发起人Id |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.getActivityByIid",
"para":
"initiatorId": 12
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
"activities": [
"activityId": 2,
"initiatorId": 12,
"sportId": 2,
"title": "约跑步",
"content": "腾大周围,三个人",
"picture": "图片url",
"releaseTime": 1450936869,
"blockingTime": 145096000,
"activityLongitude": "343.343566",
"activityLatitude": "38.123456",
"address": "腾讯大厦",
"takenMember": 2,
"maxNumOfMember": 3,
"state": 0
,
....
,
....
]
-
涉及错误码:1000 1001
7. getActivityByPid 按照参与人Id获取活动
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
participantId | 是 | int | 活动参与人Id |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.getActivityByPid",
"para":
"participantId": 12
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
"activities": [
"activityId": 2,
"initiatorId": 12,
"sportId": 2,
"title": "约跑步",
"content": "腾大周围,三个人",
"picture": "图片url",
"releaseTime": 1450936869,
"blockingTime": 145096000,
"activityLongitude": "343.343566",
"activityLatitude": "38.123456",
"address": "腾讯大厦",
"takenMember": 2,
"maxNumOfMember": 3,
"state": 0
,
....
,
....
]
- 涉及错误码:1000 1001
8. getActivityBySid 按照活动类型Id获取活动
说明:仅获取state=0的活动
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
sportId | 是 | int | 活动类型Id |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.getActivityBySid",
"para":
"sportId": 2
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
"activities": [
"activityId": 2,
"initiatorId": 12,
"sportId": 2,
"title": "约跑步",
"content": "腾大周围,三个人",
"picture": "图片url",
"releaseTime": 1450936869,
"blockingTime": 145096000,
"activityLongitude": "343.343566",
"activityLatitude": "38.123456",
"address": "腾讯大厦",
"takenMember": 2,
"maxNumOfMember": 3,
"state": 0
,
....
,
....
]
- 涉及错误码:1000 1001
9. getActivityByDis 按活动距离(由近到远)获取活动
说明:1.仅获取state=0的活动;2.距离为两个经纬度的在地球上的直线距离
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
longitude | 是 | string | 用户所在经度 |
latitude | 是 | string | 用户所在纬度 |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.getActivityByDis",
"para":
"initiatorId": 12
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
"activities": [
"activityId": 2,
"initiatorId": 12,
"sportId": 2,
"title": "约跑步",
"content": "腾大周围,三个人",
"picture": "图片url",
"releaseTime": 1450936869,
"blockingTime": 145096000,
"activityLongitude": "343.343566",
"activityLatitude": "38.123456",
"address": "腾讯大厦",
"takenMember": 2,
"maxNumOfMember": 3,
"state": 0
,
....
,
....
]
- 涉及错误码:1000 1001
10. getActivityById 按活动Id获取活动
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
activityId | 是 | int | 活动Id |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.getActivityById",
"para":
"activityId": 2
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
"activity":
"activityId": 2,
"initiatorId": 12,
"sportId": 2,
"title": "约跑步",
"content": "腾大周围,三个人",
"picture": "图片url",
"releaseTime": 1450936869,
"blockingTime": 145096000,
"activityLongitude": "343.343566",
"activityLatitude": "38.123456",
"address": "腾讯大厦",
"takenMember": 2,
"maxNumOfMember": 3,
"state": 0
- 涉及错误码:1000 1001
11. searchActivityByTitle 根据活动标题搜索活动
说明:建议采用%title%进行模糊匹配
参数名称 | 是否必须 | 参数类型 | 备注 |
---|---|---|---|
title | 是 | string | 活动标题 |
- 请求包
"version": "1.0",
"timestamp": 1450936869,
"interface":
"interfaceName": "activity.searchActivityByTitle",
"para":
"title": "跑步"
- 返回包
"version": "1.0",
"timestamp": 1450936869,
"returnCode": 0,
"returnMessage": "OK",
"data":
"activities": [
"activityId": 2,
"initiatorId": 12,
"sportId": 2,
"title": "约跑步",
"content": "腾大周围,三个人",
"picture": "图片url",
"releaseTime": 1450936869,
"blockingTime": 145096000,
"activityLongitude": "343.343566",
"activityLatitude": "38.123456",
"address": "腾讯大厦",
"takenMember": 2,
"maxNumOfMember": 3,
"state": 0
,
....
,
....
]
- 涉及错误码:1000 1001
以上是关于mini项目后台接口文档的主要内容,如果未能解决你的问题,请参考以下文章