Skip to content

REST API

Jack Sun edited this page Jan 16, 2017 · 9 revisions

前台轮播api

调用方式:

POST      : '/getBanner'
Response  : Array
structure :
  +  type        :   carousel(轮播)
  +  image_url   :   banner图片路径
  +  upload_time :   上传时间(时间戳)
  +  status      :   图片状态(NEW,DELETE)

前台头部广告图片api

调用方式:

POST      : '/getHeadBanner'
Response  : JSON
structure :
  +  type        :   headBanner(轮播)
  +  image_url   :   banner图片路径
  +  upload_time :   上传时间(时间戳)
  +  status      :   图片状态(NEW,DELETE)

前台注册接口

调用方式:

POST      : '/doregister'
Response  : {error_msg: [], info: "", result: "success", code: ""}

状态码 | 状态值
------|-------------
2000  | 注册成功
2001  | 用户已存在
2002  | 服务器错误

params :
  +  email       :   邮箱地址当做用户名
  +  password    :   注册密码

前台登录接口

调用方式:

POST      : '/dologin'
Response  :  Response  : {error_msg: [], info: user, result: "success", code: ""}

 状态码 | 状态值
 ------|-------------
 1000  | 登录成功
 1001  | 账号或密码错误
 1002  | 服务器错误

USE       : <%= user% >  <%= status%>
USER structure:
  +   name: String
  +   password: String
  +   mobile: String
  +   nick_name: String
  +   level: String
  +   levelName: String
  +   userType: String
  +   registerTime: Number
params :
  +  name       :    即为邮箱地址
  +  password    :   注册密码

首页类目接口

调用方式:

URL      : '/'
Response  : categories []
USE       : <%= categories% >  PS(forEach)
categories structure:
  +   firstCategory: String,
  +   secondCategory: [{secondTitle:String,thirdTitle:[]}]
  firstCategory: 一级类目
  secondTitle  : 二级类目(多个)
  thirdTitle   : 三级类目(多个)

首页最热标签接口

调用方式:

URL      : '/'
Response  : hotLabels []
USE       : <%= hotLabels% >  PS(forEach)
categories structure:
  +   label_name: String,
  +   color_name: String,
  +   belong_category:String,
  +   add_time:Number

保存为新增类目接口

返回状态码

状态码 状态值
200 保存类目成功
400 缺失(未找到)参数,保存失败
500 服务器错误

End Point:

curl -H "Content-Type: application/json \
               -X POST -d '{"firstCategory":"1","secondCategory":"2","thirdCategory":"3","addBy":"admin","status":"NEW"}' \
               http://<host>/admin/uploadTemporary

Response Success

{
    "error_msg": [],
    "info": {
        "firstCategory": "123",
        "secondCategory": "456",
        "thirdCategory": "567",
        "upload_time": "1477933258",
        "status": "NEW"
    },
    "result": "success",
    "code": "200"
}

Response Failed

{
    "error_msg": [
        "FORMAT ERROR"
    ],
    "info": "",
    "result": "fail",
    "code": "400"
}

Response Failed

{
    "error_msg": [
        "INTERNAL SERVER ERROR"
    ],
    "info": "",
    "result": "fail",
    "code": "500"
}

点击上传产品页面,上部导航栏接口

返回状态码

状态码 状态值
200 保存类目成功
400 缺失(未找到)参数,保存失败
500 服务器错误

End Point:

curl -H "Content-Type: application/json \
               -X POST -d '[{"firstCategory":"1","secondCategory":"2","thirdCategory":"3","addBy":"admin","status":"NEW"},{"firstCategory":"1","secondCategory":"2","thirdCategory":"3","addBy":"admin","status":"NEW"}]' \
               http://<host>/admin/uploadProductsDetail

Return Render Page:

    http://<host>/admin/upload-products-detail

Calling

    <%= info.categories%>
     <%= info.product_specification%>
    <%= status%>

Response Success

{
    "error_msg": [

    ],
    "info":{
               categories: [
                   {
                       firstCategory: 'test111',
                       secondCategory: 'test2222',
                       thirdCategory: 'test33333',
                       addBy: undefined,
                       status: 'NEW'
                   },
                   {
                       firstCategory: 'test222',
                       secondCategory: 'test2222',
                       thirdCategory: 'test33333',
                       addBy: undefined,
                       status: 'NEW'
                   }
               ],
               product_specification: [    //产品的所有规格
                   {
                       _id: 581b71ad5852754becc801f6,
                       material: [         //材料
                           Object
                       ],
                       Color: [            //颜色
                           Object
                       ],
                       pattern: [          //模式
                           Object
                       ],
                       features: [         //特征
                           Object
                       ],
                       hardOrSoft: [       //柔软度
                           Object
                       ],
                       type: [             //类型
                           Object
                       ],
                       compatibility: [    //兼容性
                           Object
                       ]
                   }
               ]
           }
    "result": "success",
    "code": "200",
    "username": "admin"
}

Response Failed

{
    "error_msg": [
        "FORMAT ERROR"
    ],
    "info": {
    categories:[],
    product_specification:[]
    },
    "result": "fail",
    "code": "400",
    "username":"admin"
}

Response Failed

{
    "error_msg": [
        "INTERNAL SERVER ERROR"
    ],
    "info": {
      categories:[],
      product_specification:[]
    },
    "result": "fail",
    "code": "500",
    "username":"admin"
}

修改产品增量价格

HTTP状态码 状态值
200 保存增量价格
401 缺失(未找到)参数,保存失败
500 服务器错误

Create delta price

END PONIT: curl -x POST /delta-price

payload:{
     "delta_price":10,
     "update_time":1741314181
}

Resonse Success:

{
  "succeed": true,
  "msg": "success"
}

Resonse Fail:

Invalid Param Request

{
  "succeed": false,
  "msg": "Invalid Param Request"
}

Internal Server Error

{
  "succeed": false,
  "msg": "Internal Server Error"
}

Update delta price

END PONIT: curl -x PUT /delta-price 
payload:{
     "id":"585a9be4980dfc787af86eb0",
     "delta_price":10,
     "update_time":1741314181
}

Resonse Success:

{
  "succeed": true,
  "msg": "success"
}

Resonse Fail:

Invalid Param Request

{
  "succeed": false,
  "msg": "Invalid Param Request"
}

Internal Server Error

{
  "succeed": false,
  "msg": "Internal Server Error"
}

添加运费模板接口

保存运费模板国家

Options:

  • 请求路径 : /admin/fee-express-country
  • 请求方法 : POST
  • 请求参数体

小包请求参数(Body):

{
    "country_name":["china","jack","test"],
    "registered_fee" : 5,
    "expected_delivery" : "1~2",
    "free_ship" : {
        "fee_quantity" : 1.5,
        "fee_status" : true
    },
    "transport_fees" : [ 
        {
            "transport_fee" : 10
        }
    ]
}

普快/特快请求参数(Body):

{
    "country_name":["america"],
    "registered_fee" : 5,
    "expected_delivery" : "1~2",
    "free_ship" : {
        "fee_quantity" : 1.5,
        "fee_status" : true
    },
     "transport_fees": [{
        "transport_default_quantity":"0~4.9",    
        "transport_default_fee":10,              
        "transport_add_quantity":2,              
        "transport_add_fee":5                               
    },{
        "transport_default_quantity":"4.9~20",   
        "transport_default_fee":10,             
        "transport_add_quantity":2,             
        "transport_add_fee":5                           
    }]
}
  • 添加成功
{
  "succeed": true,
  "msg": {
    "countryId": "587c9bd6c59b0a37ca23f766"
  }
}
  • 添加失败
{
  "succeed": true,
  "msg":"internal error"
}

保存运费模板(小包,普快,特快)

Options:

  • 请求路径 : /admin/fee-template
  • 请求方法 : POST
  • 请求参数体 EM: POST{{local}}:3000/admin/fee-express 小包(Body)
{
    "type": "Parcel",                           //小包(Parcel) 普快(Orindary) 特快(Express)
    "country": ["587c8ec123d20b0fb90677ca",
               "587c8ec123d20b0fb90677cb"]      //模板国家ID
}
  • 添加成功
{
  "succeed": true,
  "msg": "add success"
}
  • 添加失败
{
  "succeed": false,
  "msg": "internal error"
}

获取运费模板接口

Options:

  • 请求路径 : /admin/fee-express
  • 请求方法 : GET
  • 请求参数 : type (?type=Parsel) EM: GET{{local}}:3000/admin/fee-express type为空获取所有
  • 获取成功
{
  "succeed": true,
  "msg": [
    {
      "_id": "587c97fb69c2f92b9bccd615",
      "type": "Parsel",
      "discount": 10,
      "fuel_cost": 20,
      "__v": 0,
      "country": [
        {
          "_id": "587c9bd6c59b0a37ca23f766",
          "registered_fee": 5,
          "expected_delivery": "1~2",
          "__v": 0,
          "free_ship": {
            "fee_quantity": 1.5,
            "fee_status": true
          },
          "transport_fees": [
            {
              "transport_fee": 10,
              "_id": "587c9bd6c59b0a37ca23f767"
            }
          ],
          "country_name": [
            "china",
            "jack",
            "test"
          ]
        },
        null
      ]
    }
  ]
}
  • 获取失败
{
  "succeed": false,
  "msg": "internal error"
}

运费模板国家接口

Options:

  • 请求路径 : /admin/country
  • 请求方法 : GET
  • 请求参数 type /status
  • 状态 status(true)代表已经被添加,false代表未被添加过
  • 请求类型 (小包:parcel 普快:ordinary 特快:express)

EM:

  • GET {{local}}:3000/admin/country?type=express&status=true
{
  "succeed": true,
  "msg": {
    "templates": [
      {
        "_id": "587c898084b844fe9c015a44",
        "type": "Parcel",
        "discount": 10,
        "fuel_cost": 100,
        "__v": 0,
        "country": [
          {
            "registered_fee": 5,
            "expected_delivery": "1~2",
            "_id": "587c898084b844fe9c015a45",
            "free_ship": {
              "fee_quantity": 1.5,
              "fee_status": true
            },
            "transport_fees": [
              {
                "transport_fee": 10,
                "_id": "587c898084b844fe9c015a46"
              }
            ],
            "country_name": [
              "china"
            ]
          }
        ]
      },
      {
        "_id": "587c89a284b844fe9c015a47",
        "type": "Parcel",
        "discount": 10,
        "fuel_cost": 100,
        "__v": 0,
        "country": [
          {
            "registered_fee": 5,
            "expected_delivery": "1~2",
            "_id": "587c89a284b844fe9c015a4e",
            "free_ship": {
              "fee_quantity": 1.5,
              "fee_status": true
            },
            "transport_fees": [
              {
                "transport_fee": 10,
                "_id": "587c89a284b844fe9c015a4f"
              }
            ],
            "country_name": [
              "china"
            ]
          },
          {
            "registered_fee": 5,
            "expected_delivery": "1~2",
            "_id": "587c89a284b844fe9c015a4c",
            "free_ship": {
              "fee_quantity": 1.5,
              "fee_status": true
            },
            "transport_fees": [
              {
                "transport_fee": 10,
                "_id": "587c89a284b844fe9c015a4d"
              }
            ],
            "country_name": [
              "china"
            ]
          },
          {
            "registered_fee": 5,
            "expected_delivery": "1~2",
            "_id": "587c89a284b844fe9c015a4a",
            "free_ship": {
              "fee_quantity": 1.5,
              "fee_status": true
            },
            "transport_fees": [
              {
                "transport_fee": 10,
                "_id": "587c89a284b844fe9c015a4b"
              }
            ],
            "country_name": [
              "china"
            ]
          },
          {
            "registered_fee": 5,
            "expected_delivery": "1~2",
            "_id": "587c89a284b844fe9c015a48",
            "free_ship": {
              "fee_quantity": 1.5,
              "fee_status": true
            },
            "transport_fees": [
              {
                "transport_fee": 10,
                "_id": "587c89a284b844fe9c015a49"
              }
            ],
            "country_name": [
              "china"
            ]
          }
        ]
      }
    ]
  }
}
  • GET {{local}}:3000/admin/country?type=express(status默认返回为false)
{
  "succeed": true,
  "msg": [
    {
      "_id": "587bacac1344177a6fd45665",
      "country_en_name": "Philippines",
      "country_area": "",
      "country_status": false,
      "country_code": "PH"
    },
    {
      "_id": "587bacac1344177a6fd45664",
      "country_en_name": "Singapore",
      "country_area": "",
      "country_status": false,
      "country_code": "SG"
    }
    ········
]

获取失败

{
  "succeed": false,
  "msg": "internal error"
}

Options:

  • 请求路径 : /admin/country
  • 请求方法 : PUT
  • 请求参数 type /code
  • 请求类型 (小包:parcel 普快:ordinary 特快:express)
  • 请求体 {"type":"express","code":["MO","BN","MY"]}

EM:

  • PUT {{local}}:3000/admin/country

Body

{
   "type":"express",
   "code":["MO","BN","MY"]
}

修改成功

{
  "succeed": true,
  "msg": "ok"
}

修改失败

{
  "succeed": false,
  "msg": "internal error"
}

Clone this wiki locally