ソースを参照

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

Junling Bu 6 年 前
コミット
1f7f63136b

ファイルの差分が大きいため隠しています
+ 243 - 0
doc/api.md


+ 7 - 10
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxTopicController.java

@@ -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);
     }
 }

+ 2 - 2
litemall-wx/pages/topic/topic.js

@@ -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();

+ 3 - 3
litemall-wx/pages/topicDetail/topicDetail.js

@@ -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 - 5
renard-wx/pages/topic/topic.js

@@ -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();

+ 0 - 1
renard-wx/pages/topic/topic.wxml

@@ -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}}">

+ 1 - 1
renard-wx/pages/topicDetail/topicDetail.js

@@ -43,7 +43,7 @@ Page({
     }).then(function(res) {
       if (res.errno === 0) {
         that.setData({
-          topicList: res.data
+          topicList: res.data.list
         });
       }
     });