Commit 1f7f6313 authored by Junling Bu's avatar Junling Bu
Browse files

chore[litemall-wx, litemall-wx-api]: 专题API调整及文档

parent bb120ca4
......@@ -481,6 +481,249 @@ API应该存在版本控制,以保证兼容性。
### 2.18 专题服务
#### 2.18.1 专题列表
应用场景
访问专题列表信息
接口链接
GET /wx/topic/list
请求参数
page: 请求页码
limit: 每一页数量
sort: 排序字段
order: 升序降序
响应内容
{
"errno": 0,
"data": {
"total": 20,
"pages": 2,
"limit": 10,
"page": 1,
"list": [
{
"id": 264,
"title": "设计师们推荐的应季好物",
"subtitle": "原创设计春款系列上新",
"price": 29.90,
"readCount": "77.7k",
"picUrl": "https://yanxuan.nosdn.127.net/14918201901050274.jpg"
},
{
"id": 266,
"title": "一条丝巾就能提升时髦度",
"subtitle": "不知道大家对去年G20时,严选与国礼制造商一起推出的《凤凰于飞》等几款丝巾是否还...",
"price": 0.00,
"readCount": "35.0k",
"picUrl": "https://yanxuan.nosdn.127.net/14919007135160213.jpg"
},
{
"id": 268,
"title": "米饭好吃的秘诀:会呼吸的锅",
"subtitle": "今年1月份,我们联系到了日本伊贺地区的长谷园,那里有着180年伊贺烧历史的窑厂。...",
"price": 0.00,
"readCount": "33.3k",
"picUrl": "https://yanxuan.nosdn.127.net/14920623353130483.jpg"
},
{
"id": 271,
"title": "选式新懒人",
"subtitle": "懒出格调,懒出好生活。",
"price": 15.00,
"readCount": "57.7k",
"picUrl": "https://yanxuan.nosdn.127.net/14924199099661697.jpg"
},
{
"id": 272,
"title": "料理也要精细简单",
"subtitle": "享受天然的味道,日子每天都好新鲜",
"price": 69.00,
"readCount": "125.6k",
"picUrl": "https://yanxuan.nosdn.127.net/14925200530030186.jpg"
},
{
"id": 274,
"title": "没有软木拖,怎么过夏天",
"subtitle": "刚入四月,杭州的气温就已升高至30度。店庆时买了软木拖的用户,陆续发回评价说,很...",
"price": 0.00,
"readCount": "46.4k",
"picUrl": "https://yanxuan.nosdn.127.net/14925822213780237.jpg"
},
{
"id": 277,
"title": "治愈生活的满怀柔软",
"subtitle": "太鼓抱枕的上架历程,是从失踪开始的。由于表面的绒感,最初它被安排在秋冬季上架。某...",
"price": 0.00,
"readCount": "19.6k",
"picUrl": "https://yanxuan.nosdn.127.net/14926737925770587.jpg"
},
{
"id": 281,
"title": "条纹新风尚",
"subtitle": "经典百搭,时尚线条",
"price": 29.00,
"readCount": "76.5k",
"picUrl": "https://yanxuan.nosdn.127.net/14926859849200826.jpg"
},
{
"id": 282,
"title": "成就一室笋香",
"subtitle": "三石哥办公室常备小食推荐",
"price": 12.00,
"readCount": "40.9k",
"picUrl": "https://yanxuan.nosdn.127.net/14927695046601069.jpg"
},
{
"id": 283,
"title": "孩子成长中少不了的一双鞋",
"subtitle": "说起毛毛虫鞋,好处实在太多了,作为一个2岁孩子的宝妈选品员,按捺不住想告诉大家,...",
"price": 0.00,
"readCount": "42.5k",
"picUrl": "https://yanxuan.nosdn.127.net/14927748974441080.jpg"
}
]
},
"errmsg": "成功"
}
错误码
#### 2.18.2 专题详情
应用场景
单个专题详情信息
接口链接
GET /wx/topic/detail
请求参数
id: 专题ID,例如 id=264
响应内容
{
"errno": 0,
"data": {
"topic": {
"id": 264,
"title": "设计师们推荐的应季好物",
"subtitle": "原创设计春款系列上新",
"price": 29.90,
"readCount": "77.7k",
"picUrl": "https://yanxuan.nosdn.127.net/14918201901050274.jpg",
"sortOrder": 0,
"goods": [],
"addTime": "2018-02-01 00:00:00",
"updateTime": "2018-02-01 00:00:00",
"deleted": false,
"content": ""
},
"goods": []
},
"errmsg": "成功"
}
错误码
#### 2.18.3 专题推荐
应用场景
基于某个专题推荐其他专题
接口链接
GET /wx/topic/related
请求参数
id: 专题ID,例如 id=264
响应内容
{
"errno": 0,
"data": {
"total": 19,
"pages": 5,
"limit": 4,
"page": 1,
"list": [
{
"id": 266,
"title": "一条丝巾就能提升时髦度",
"subtitle": "不知道大家对去年G20时,严选与国礼制造商一起推出的《凤凰于飞》等几款丝巾是否还...",
"price": 0.00,
"readCount": "35.0k",
"picUrl": "https://yanxuan.nosdn.127.net/14919007135160213.jpg",
"sortOrder": 0,
"goods": [],
"addTime": "2018-02-01 00:00:00",
"updateTime": "2018-02-01 00:00:00",
"deleted": false,
"content": "\u003cimg src\u003d\"//yanxuan.nosdn.127.net/75c55a13fde5eb2bc2dd6813b4c565cc.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/e27e1de2b271a28a21c10213b9df7e95.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/9d413d1d28f753cb19096b533d53418d.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/64b0f2f350969e9818a3b6c43c217325.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/a668e6ae7f1fa45565c1eac221787570.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/0d4004e19728f2707f08f4be79bbc774.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/79ee021bbe97de7ecda691de6787241f.jpg\"\u003e"
},
{
"id": 268,
"title": "米饭好吃的秘诀:会呼吸的锅",
"subtitle": "今年1月份,我们联系到了日本伊贺地区的长谷园,那里有着180年伊贺烧历史的窑厂。...",
"price": 0.00,
"readCount": "33.3k",
"picUrl": "https://yanxuan.nosdn.127.net/14920623353130483.jpg",
"sortOrder": 0,
"goods": [],
"addTime": "2018-02-01 00:00:00",
"updateTime": "2018-02-01 00:00:00",
"deleted": false,
"content": "\u003cimg src\u003d\"//yanxuan.nosdn.127.net/75c55a13fde5eb2bc2dd6813b4c565cc.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/e27e1de2b271a28a21c10213b9df7e95.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/9d413d1d28f753cb19096b533d53418d.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/64b0f2f350969e9818a3b6c43c217325.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/a668e6ae7f1fa45565c1eac221787570.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/0d4004e19728f2707f08f4be79bbc774.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/79ee021bbe97de7ecda691de6787241f.jpg\"\u003e"
},
{
"id": 271,
"title": "选式新懒人",
"subtitle": "懒出格调,懒出好生活。",
"price": 15.00,
"readCount": "57.7k",
"picUrl": "https://yanxuan.nosdn.127.net/14924199099661697.jpg",
"sortOrder": 0,
"goods": [],
"addTime": "2018-02-01 00:00:00",
"updateTime": "2018-02-01 00:00:00",
"deleted": false,
"content": "\u003cimg src\u003d\"//yanxuan.nosdn.127.net/75c55a13fde5eb2bc2dd6813b4c565cc.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/e27e1de2b271a28a21c10213b9df7e95.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/9d413d1d28f753cb19096b533d53418d.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/64b0f2f350969e9818a3b6c43c217325.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/a668e6ae7f1fa45565c1eac221787570.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/0d4004e19728f2707f08f4be79bbc774.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/79ee021bbe97de7ecda691de6787241f.jpg\"\u003e"
},
{
"id": 272,
"title": "料理也要精细简单",
"subtitle": "享受天然的味道,日子每天都好新鲜",
"price": 69.00,
"readCount": "125.6k",
"picUrl": "https://yanxuan.nosdn.127.net/14925200530030186.jpg",
"sortOrder": 0,
"goods": [],
"addTime": "2018-02-01 00:00:00",
"updateTime": "2018-02-01 00:00:00",
"deleted": false,
"content": "\u003cimg src\u003d\"//yanxuan.nosdn.127.net/75c55a13fde5eb2bc2dd6813b4c565cc.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/e27e1de2b271a28a21c10213b9df7e95.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/9d413d1d28f753cb19096b533d53418d.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/64b0f2f350969e9818a3b6c43c217325.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/a668e6ae7f1fa45565c1eac221787570.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/0d4004e19728f2707f08f4be79bbc774.jpg\"\u003e\n \u003cimg src\u003d\"//yanxuan.nosdn.127.net/79ee021bbe97de7ecda691de6787241f.jpg\"\u003e"
}
]
},
"errmsg": "成功"
}
### 2.19 对象存储服务
......
......@@ -49,11 +49,7 @@ public class WxTopicController {
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallTopic> topicList = topicService.queryList(page, limit, sort, order);
int total = topicService.queryTotal();
Map<String, Object> data = new HashMap<String, Object>();
data.put("data", topicList);
data.put("count", total);
return ResponseUtil.ok(data);
return ResponseUtil.okList(topicList);
}
/**
......@@ -64,17 +60,18 @@ public class WxTopicController {
*/
@GetMapping("detail")
public Object detail(@NotNull Integer id) {
Map<String, Object> data = new HashMap<>();
LitemallTopic topic = topicService.findById(id);
data.put("topic", topic);
List<LitemallGoods> goods = new ArrayList<>();
for (Integer i : topic.getGoods()) {
LitemallGoods good = goodsService.findByIdVO(i);
if (null != good)
goods.add(good);
}
data.put("goods", goods);
return ResponseUtil.ok(data);
Map<String, Object> entity = new HashMap<String, Object>();
entity.put("topic", topic);
entity.put("goods", goods);
return ResponseUtil.ok(entity);
}
/**
......@@ -86,6 +83,6 @@ public class WxTopicController {
@GetMapping("related")
public Object related(@NotNull Integer id) {
List<LitemallTopic> topicRelatedList = topicService.queryRelatedList(id, 0, 4);
return ResponseUtil.ok(topicRelatedList);
return ResponseUtil.okList(topicRelatedList);
}
}
\ No newline at end of file
......@@ -63,9 +63,9 @@ Page({
that.setData({
scrollTop: 0,
topicList: res.data.data,
topicList: res.data.list,
showPage: true,
count: res.data.count
count: res.data.total
});
}
wx.hideToast();
......
......@@ -37,7 +37,7 @@ Page({
}).then(function(res) {
if (res.errno === 0) {
that.setData({
topicList: res.data
topicList: res.data.list
});
}
});
......@@ -53,8 +53,8 @@ Page({
}).then(function(res) {
if (res.errno === 0) {
that.setData({
commentList: res.data.data,
commentCount: res.data.count
commentList: res.data.list,
commentCount: res.data.total
});
}
});
......
......@@ -5,7 +5,7 @@ Page({
data: {
topicList: [],
page: 1,
size: 10,
limit: 10,
count: 0,
scrollTop: 0,
showPage: false
......@@ -28,7 +28,7 @@ Page({
},
nextPage: function(event) {
var that = this;
if (this.data.page > that.data.count / that.data.size) {
if (this.data.page > that.data.count / that.data.limit) {
return true;
}
......@@ -65,15 +65,15 @@ Page({
util.request(api.TopicList, {
page: that.data.page,
size: that.data.size
limit: that.data.limit
}).then(function(res) {
if (res.errno === 0) {
that.setData({
scrollTop: 0,
topicList: res.data.data,
topicList: res.data.list,
showPage: true,
count: res.data.count
count: res.data.total
});
}
wx.hideToast();
......
......@@ -5,7 +5,6 @@
<view class="info">
<text class="title">{{item.title}}</text>
<text class="desc">{{item.subtitle}}</text>
<!-- <text class="price">{{item.price}}元起</text> -->
</view>
</navigator>
<view class="page" wx:if="{{showPage}}">
......
......@@ -43,7 +43,7 @@ Page({
}).then(function(res) {
if (res.errno === 0) {
that.setData({
topicList: res.data
topicList: res.data.list
});
}
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment