mini项目后台接口文档

Posted AlexP5

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mini项目后台接口文档相关的知识,希望对你有一定的参考价值。

说明

1. returnCode和returnMessage返回值说明

returnCodereturnMessage含义
0OK返回成功
1000PARAM_ERROR参数错误:仔细校验请求包参数是否完整,参数名称、参数类型、参数值是否正确
1001DB_QUERY_ERROR数据库查询异常 
2000USER_EXISTS注册失败,该用户已存在
2001USER_NOT_FOUND登录失败,该用户不存在
3000NO_CREDIT取消/删除活动失败,用户信用分不够
3001FULL_HC_ERROR参加活动失败,人数已满
3002DEADLINE_ERROR参加活动失败,该活动已截止
3003ACT_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 注册

  • 参数
参数名称是否必须参数类型备注
userNamestring微信自动拉取
portraitstring微信自动拉取
creditScoreint系统自动生成
  • 请求包

    "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 登录

  • 参数
参数名称是否必须参数类型备注
userIdint 
  • 请求包

    "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 修改用户信息

  • 参数
参数名称是否必须参数类型备注
userIdint 
ageint 
heightint 
weightint 
bgstring 
signaturestring 
  • 请求包

    "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查找信息

  • 参数
参数名称是否必须参数类型备注
userIdint 
  • 请求包

    "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 添加活动

  • 参数
参数名称是否必须参数类型备注
initiatorIdint活动发起人Id
sportIdint活动类型,'跑步','健身','游泳','乒乓球','羽毛球','网球','足球','篮球'对应id序号1~8
titlestring活动名称
contentstring活动内容
picturestring图片url

releaseTime

long调用当前接口的系统时间戳
blockingTimelongreleaseTime+用户选择的活动时长
longitudestring经度(地图获取)
latitudestring纬度(地图获取)
addressstring地址(地图获取)
maxNumOfMemberint最大参与人数
state1活动状态,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.需要将活动申请相关信息一并删除

参数名称是否必须参数类型备注
activityIdint活动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 参加活动

  • 参数
参数名称是否必须参数类型备注
participantIdint活动参与者Id
activityIdint活动Id
participateDatetimestring活动参与时间
  • 请求包

    "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信用分

参数名称是否必须参数类型备注
activityIdint活动Id
participantIdint活动参与者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,需要从活动参加表中进行计算参与该活动的人数,后面凡是涉及返回活动信息的都是这样

参数名称是否必须参数类型备注
stateint活动状态
  • 请求包

    "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获取活动

参数名称是否必须参数类型备注
initiatorIdint活动发起人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获取活动

参数名称是否必须参数类型备注
participantIdint活动参与人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的活动

参数名称是否必须参数类型备注
sportIdint活动类型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.距离为两个经纬度的在地球上的直线距离

参数名称是否必须参数类型备注
longitudestring用户所在经度
latitudestring用户所在纬度
  • 请求包

    "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获取活动

参数名称是否必须参数类型备注
activityIdint活动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%进行模糊匹配

参数名称是否必须参数类型备注
titlestring活动标题
  • 请求包

    "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项目后台接口文档的主要内容,如果未能解决你的问题,请参考以下文章

基于layui的开源项目LAYUI MINI后台模板

后台接口文档示例

vue 项目接口管理

Vue.js 项目接口管理

SpringBoot18 SwaggerAPI接口文档生成WireMock模拟后台数据

ng中用$http接后台接口的异步坑