文章目录
1. 微信登录
1.1 用户登陆
接口说明
微信登录,获取用户信息。
前端收集到用户登陆产生的临时code,后台通过此码可以向微信 jscode2session 接口请求到用户的唯一标志openid。获得openid后,若该用户是新用户,则将其信息存储进用户表。并向前端返回openid。
后续前端发起的端口请求,均需要通过openid来区分当前用户。
GET / login HTTP1.1
Content-Type: application/x-www-form-urlencoded
请求参数
字段 | 属性 | 说明 |
---|---|---|
code | string | 微信登陆时产生的临时标识码。 |
返回结果
返回数据:
[
{
"openid": integer, // 用户标识
},...
]
返回信息:
成功时:
HTTP/1.1 200 OK
失败时(例子):
HTTP/1.1 403 Forbidden
Content-Type: application/x-www-form-urlencoded
{"message" : "登录失败"}
2. 衣橱模块
2.1 衣物信息显示
接口说明
获取数据库中当前用户的所有衣物信息。
GET / closet HTTP1.1
Content-Type: application/x-www-form-urlencoded
请求参数
字段 | 属性 | 说明 |
---|---|---|
openid | integer | 当前微信用户标识 |
返回结果
返回数据:
[
{
"cloid": integer, // 衣物id
"tgR": integer, // 目标RGB值
"tgG": integer,
"tgB": integer,
"code": integer, //色彩码,1-26
"inR": integer, //原始RGB值
"inG": integer,
"inB": integer,
"type": integer, //衣物属性:种类 1短袖 2长袖 3毛衣 4棉服 5夹克 6西装外套 7连衣裙 8半身裙 9裤子
"clothlength": integer, //衣物属性:长度 1短 2中 3长
"tightness": integer, //衣物属性:松紧 1紧 2宽
"thi": integer, //衣物属性:薄厚 1薄 2中 3厚
"picurl": string(url) //图片地址
},...
]
返回信息:
成功时:
HTTP/1.1 200 OK
失败时(例子):
HTTP/1.1 403 Forbidden
Content-Type: application/x-www-form-urlencoded
{"message" : "获取衣物信息失败"}
2.2 衣物预览
接口说明
用户添加衣物,在选择衣物属性时,下方预览对应衣物图片。
GET / preview HTTP1.1
Content-Type: application/x-www-form-urlencoded
请求参数
字段 | 属性 | 说明 |
---|---|---|
openid | integer | 用户标识 |
type | integer | 衣物属性:种类 |
clothlength | integer | 属性:长度 |
tightness | integer | 属性:松紧 |
thi | integer | 属性:薄厚 |
返回结果
返回数据:
{
"picurl": string(url), //图片地址
"inR": integer, //原始RGB值
"inG": integer,
"inB": integer
}
返回信息:
成功时:
HTTP/1.1 200 OK
失败时(例子):
HTTP/1.1 403 Forbidden
Content-Type: application/x-www-form-urlencoded
{"message" : "预览失败"}
2.3 衣物添加
接口说明
用户修改/添加衣物信息。若为修改已存在衣物,则仅更新该衣物的信息。若添加新衣物,则向该用户衣橱中增加该件衣物。
POST / add HTTP1.1
Content-Type: x-www-form-urlencoded
请求参数
字段 | 属性 | 说明 |
---|---|---|
openid | integer | 用户标识 |
tgR | integer | 目标R值 |
tgG | integer | 目标G值 |
tgB | integer | 目标B值 |
colortype | integer | 颜色种类(1:non 2:warm 3:cold) |
code | integer | 色彩码(1-26) |
type | integer | 衣物属性:种类 |
clothlength | integer | 属性:长度 |
tightness | integer | 属性:松紧 |
thi | integer | 属性:薄厚 |
返回结果
后端操作结束返回信息(无数据返回)。
成功时:
HTTP/1.1 200 OK
失败时(例子):
HTTP/1.1 403 Forbidden
Content-Type: x-www-form-urlencoded
{"message" : "添加失败"}
2.4 衣物删除
接口说明
用户删除已有的一件衣物。
POST / delete HTTP1.1
Content-Type: application/x-www-form-urlencoded
请求参数
字段 | 属性 | 说明 |
---|---|---|
openid | integer | 用户标识 |
cloid | integer | 衣物id |
返回结果
后端操作结束返回信息(无数据返回):
成功时:
HTTP/1.1 200 OK
失败时(例子):
HTTP/1.1 403 Forbidden
Content-Type: application/x-www-form-urlencoded//
{"message" : "删除失败"}
3.穿搭模块
3.1 显示推荐穿搭
接口说明
根据用户拥有的衣物,推荐搭配方案。
GET / fashion HTTP1.1
Content-Type: application/x-www-form-urlencoded
请求参数
字段 | 属性 | 说明 |
---|---|---|
openid | integer | 用户标识 |
weather | integer | 当日温度 |
返回结果
返回数据:
[
{
"wholeType": integer, //1:上下衣 2:裙子 3:外套+上下衣 4:裙子+外套
"label": string, //风格标签
"tips": string, //穿搭建议
"upperCloth": { "inR": integer, //原始RGB值
"inG": integer,
"inB": integer,
"tgR": integer, //目标RGB值
"tgG": integer,
"tgB": integer,
"picurl": string(url) //图片地址
},
"downCloth": { "inR": integer,
"inG": integer,
"inB": integer,
"tgR": integer,
"tgG": integer,
"tgB": integer,
"picurl": string(url)
},
"outerCloth": { "inR": integer,
"inG": integer,
"inB": integer,
"tgR": integer,
"tgG": integer,
"tgB": integer,
"picurl": string(url)
},
"dress": { "inR": integer,
"inG": integer,
"inB": integer,
"tgR": integer,
"tgG": integer,
"tgB": integer,
"picurl": string(url)
},
},...
]
返回信息:
成功时:
HTTP/1.1 200 OK
失败时(例子):
HTTP/1.1 403 Forbidden
Content-Type: application/x-www-form-urlencoded
{"message" : "获取穿搭失败"}
3.2 获取用户评价
接口说明
获取并储存前端传回的用户对搭配的满意程度评价。
POST / comment HTTP1.1
Content-Type: application/x-www-form-urlencoded
请求参数
字段 | 属性 | 说明 |
---|---|---|
weather | integer | 温度 |
label | string | 穿搭标签 |
score | integer | 评分 |
返回结果
返回信息:
成功时:
HTTP/1.1 200 OK
失败时(例子):
HTTP/1.1 403 Forbidden
Content-Type: application/x-www-form-urlencoded
{"message" : "未收到评价"}
4. 天气模块
4.1 获取天气信息
接口说明
从“易源数据”获取天气信息。
GET / weather HTTP1.1
Content-Type: application/json
请求参数
参考易源提供的API
数据库与算法部分的数据对接
说明
从数据库获取当前用户所有衣物的信息,然后处理为算法模块需要的格式,通过传参的形式传给算法。
算法执行后返回搭配结果。
传给算法
数据格式
[
{
"cloid": integer, // 衣物id
"code": integer, //色彩码,1-26
"colortype":integer,//颜色种类 颜色种类:1:non 2:warm 3:cold)
"type": integer, //衣物属性:种类 1短袖 2长袖 3毛衣 4棉服 5夹克 6西装外套 7连衣裙 8半身裙 9裤子
"clothlength": integer, //衣物属性:长度 1短 2中 3长
"tightness": integer, //衣物属性:松紧 1紧 2宽
"thi": integer //衣物属性:薄厚 1薄 2中 3厚
},...
]
算法传回
选取的衣物信息格式
[
{//workdtata, sportdata, datedata
"cloid":integer, //衣物id
"type": integer, //衣物属性:种类 1短袖 2长袖 3毛衣 4棉服 5夹克 6西装外套 7连衣裙 8半身裙 9裤子
"clothlength": integer, //衣物属性:长度 1短 2中 3长
"tightness": integer, //衣物属性:松紧 1紧 2宽
"thi": integer, //衣物属性:薄厚 1薄 2中 3厚
"code": integer //色彩码,1-26
},...
]
tips信息格式:
[
{//workdtips, sporttips, datetips
"style": integer, // 标签:1工作 2约会 3运动
"tips": string //小贴士内容
},...
]