后端 接口

1. 微信登录

1.1 用户登陆

接口说明

微信登录,获取用户信息。
前端收集到用户登陆产生的临时code,后台通过此码可以向微信 jscode2session 接口请求到用户的唯一标志openid。获得openid后,若该用户是新用户,则将其信息存储进用户表。并向前端返回openid。
后续前端发起的端口请求,均需要通过openid来区分当前用户。

GET / login HTTP1.1
Content-Type: application/x-www-form-urlencoded

请求参数

字段属性说明
codestring微信登陆时产生的临时标识码。

返回结果

返回数据:

[
  {
    "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

请求参数

字段属性说明
openidinteger当前微信用户标识

返回结果

返回数据:

[
  {
    "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

请求参数

字段属性说明
openidinteger用户标识
typeinteger衣物属性:种类
clothlengthinteger属性:长度
tightnessinteger属性:松紧
thiinteger属性:薄厚

返回结果

返回数据:

{
    "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

请求参数

字段属性说明
openidinteger用户标识
tgRinteger目标R值
tgGinteger目标G值
tgBinteger目标B值
colortypeinteger颜色种类(1:non 2:warm 3:cold)
codeinteger色彩码(1-26)
typeinteger衣物属性:种类
clothlengthinteger属性:长度
tightnessinteger属性:松紧
thiinteger属性:薄厚

返回结果

后端操作结束返回信息(无数据返回)。

成功时:
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

请求参数

字段属性说明
openidinteger用户标识
cloidinteger衣物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

请求参数

字段属性说明
openidinteger用户标识
weatherinteger当日温度

返回结果

返回数据:

[
  {
    "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

请求参数

字段属性说明
weatherinteger温度
labelstring穿搭标签
scoreinteger评分

返回结果

返回信息:

成功时:
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	//小贴士内容
  },...
]
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值