美文网首页
新api接口

新api接口

作者: wkf14435 | 来源:发表于2017-10-03 22:47 被阅读0次

api的采用 jwt 鉴权方式,登录成功后后台返回 token,后面的请求一律带上 Authorization 头

短信验证码登录

  • 获取验证码: POST /api/sms/code
    {"username":"13812345678"}
  • 登录:POST /api/users/login2
    {"username":"13812345678",
    "code":"7986"}

用户管理 User

  • 注册新用户
POST /api/users/
{
    "username": "18612345678",
    "nickname":  "黄小姐"
}
  • 更新用户信息
PUT /api/users/:userId
{
    "username": "18612345678",
    "profile": {
      "name": "黄先生"
    }
}

车型库 Auto

GET /api/autos/brands 获得品牌款型数据
GET /api/autos/models?brand=奥迪&&series=A6 获取车型年款信息,这里每个车型都有_id

用户车辆 Userauto:

  • 添加新车,username和autoId是必须的。api返回包含userautoId的新车的完整信息
POST /api/userautos
{
  "username" : "13587451247",
  "autoId" : "sdgwexccvsda214x",   //从/api/autos/models获取的车型记录的_id
  "licence" : "沪CZ1039"
}
  • 获取当前登录用户的所有车辆
     GET   /api/userautos 
  • 更新车辆信息,可以更新字段如下:
    username: String, // 用户名 (手机号)
    licence: String, // 车牌号
    autoId: String // 车型的_id
PUT   /api/userautos/:userauto_Id 
  • 设置车辆为默认车辆:
PUT   /api/userautos/:userauto_Id 
{
   "current" : "1"
}
  • 删除用户的车
DELETE /api/userautos/:userauto_id

项目 Item

  • 获取项目及其工时费,参数是当前车辆userautoId,公里数mileage
GET /api/items/recommend?userautoId=xxxxxxx&mileage=50000

返回一个包含所有项目信息对象的数组,项目对象如下:

{
    'id': 'oil',         // 项目的id
    'item': '机油', // 项目的名称
    ‘type’: by,    // 项目的类别(保养by,维修wx,钣喷bp,美容mr)
    'cate': 'engine',  //项目的子类别
    'period': 5000, // 多少公里需要做此项目
    'manhour' : 40, //工时费
    ‘recommend’ : 1,  // 是否推荐,1表示推荐,0不推荐
    ’amount' : 4.5  //  需要的数量
}

订单 Order

  • (下单用接口)获取下单车辆的所有项目的配件,参数userautoId是下单车辆的_id
GET /api/parts/match?userautoId=xxxxxxx
  • 创建订单
POST /api/orders
{
    "mileage" : 74000,
    "worker" : "HEfCLj4sNsXussA3b",
    "reserveTime" : "2016-01-27 10:00:00",
    "userautoId" : "dsXmgLJppEQCSCoy9",    // 下单车辆 userauto 的 _id
    "message" : "",
    "charge":  260,
    "details" : [ {
            "partId" : "ZT46M8M9jGYQ6ENan",  // 配件的 _id
            "partBrand" : "壳牌",
            "partModel" : "黄喜力HX5 SN级 10W-40 ",
            "unitPrice" : 34,
            "amt" : 4,
            "manhour" : 40,
            "item" : "oil"
        }]
}
  • 删除订单
    DELETE /api/orders/:order_id
  • 更新订单,字段都是可选
POST /api/orders/:order_id
{
    "mileage" : 74000,
    "reserveTime" : "2016-01-27 10:00:00",
    "message" : "",
    "status" : 3,
    "charge":  260,
    "details" : [ {
            "partId" : "ZT46M8M9jGYQ6ENan",  // 配件的 _id
            "partBrand" : "壳牌",
            "partModel" : "黄喜力HX5 SN级 10W-40 ",
            "unitPrice" : 34,
            "amt" : 4,
            "manhour" : 40,
            "item" : "oil"
        }]
}

施工单位 Worker

  • 获取列表
    GET /api/factory/workers

相关文章

网友评论

      本文标题:新api接口

      本文链接:https://www.haomeiwen.com/subject/yvsfyxtx.html