Browse Source

:fries: 我发布的,更改部分RestURL,浏览量统计缓存

nnkwrik 6 years ago
parent
commit
b11022cb4b

+ 5 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/controller/GoodsController.java

@@ -3,6 +3,7 @@ package io.github.nnkwrik.goodsservice.controller;
 import io.github.nnkwrik.common.dto.JWTUser;
 import io.github.nnkwrik.common.dto.JWTUser;
 import io.github.nnkwrik.common.dto.Response;
 import io.github.nnkwrik.common.dto.Response;
 import io.github.nnkwrik.common.token.injection.JWT;
 import io.github.nnkwrik.common.token.injection.JWT;
+import io.github.nnkwrik.goodsservice.cache.BrowseCache;
 import io.github.nnkwrik.goodsservice.model.po.Goods;
 import io.github.nnkwrik.goodsservice.model.po.Goods;
 import io.github.nnkwrik.goodsservice.model.vo.CategoryPageVo;
 import io.github.nnkwrik.goodsservice.model.vo.CategoryPageVo;
 import io.github.nnkwrik.goodsservice.model.vo.GoodsDetailPageVo;
 import io.github.nnkwrik.goodsservice.model.vo.GoodsDetailPageVo;
@@ -36,6 +37,9 @@ public class GoodsController {
     @Autowired
     @Autowired
     private UserService userService;
     private UserService userService;
 
 
+    @Autowired
+    private BrowseCache browseCache;
+
     /**
     /**
      * 获取选定的子目录下的商品列表和同一个父目录下的兄弟目录
      * 获取选定的子目录下的商品列表和同一个父目录下的兄弟目录
      *
      *
@@ -69,6 +73,7 @@ public class GoodsController {
     public Response<GoodsDetailPageVo> getGoodsDetail(@PathVariable("goodsId") int goodsId,
     public Response<GoodsDetailPageVo> getGoodsDetail(@PathVariable("goodsId") int goodsId,
                                                       @JWT JWTUser jwtUser) {
                                                       @JWT JWTUser jwtUser) {
         //更新浏览次数
         //更新浏览次数
+        browseCache.add(goodsId);
         GoodsDetailVo goodsDetail = goodsService.getGoodsDetail(goodsId);
         GoodsDetailVo goodsDetail = goodsService.getGoodsDetail(goodsId);
         if (goodsDetail == null) {
         if (goodsDetail == null) {
             log.info("搜索goodsId = 【{}】的详情时出错", goodsId);
             log.info("搜索goodsId = 【{}】的详情时出错", goodsId);

+ 9 - 2
goods-service/src/main/java/io/github/nnkwrik/goodsservice/controller/UserController.java

@@ -43,17 +43,24 @@ public class UserController {
         return Response.ok(vo);
         return Response.ok(vo);
     }
     }
 
 
-    @GetMapping("/bought/goods")
+    @GetMapping("goods/bought")
     public Response getUserBought(@JWT(required = true) JWTUser user) {
     public Response getUserBought(@JWT(required = true) JWTUser user) {
         List<GoodsSimpleVo> vo = userService.getUserBought(user.getOpenId());
         List<GoodsSimpleVo> vo = userService.getUserBought(user.getOpenId());
         log.info("用户【{}】查询买过的商品,总数:{}", user.getNickName(), vo.size());
         log.info("用户【{}】查询买过的商品,总数:{}", user.getNickName(), vo.size());
         return Response.ok(vo);
         return Response.ok(vo);
     }
     }
 
 
-    @GetMapping("/sold/goods")
+    @GetMapping("goods/sold")
     public Response getUserSold(@JWT(required = true) JWTUser user) {
     public Response getUserSold(@JWT(required = true) JWTUser user) {
         List<GoodsSimpleVo> vo = userService.getUserSold(user.getOpenId());
         List<GoodsSimpleVo> vo = userService.getUserSold(user.getOpenId());
         log.info("用户【{}】查询卖出的商品,总数:{}", user.getNickName(), vo.size());
         log.info("用户【{}】查询卖出的商品,总数:{}", user.getNickName(), vo.size());
         return Response.ok(vo);
         return Response.ok(vo);
     }
     }
+
+    @GetMapping("goods/posted")
+    public Response getUserPosted(@JWT(required = true) JWTUser user) {
+        List<GoodsSimpleVo> vo = userService.getUserPosted(user.getOpenId());
+        log.info("用户【{}】查询发布的商品,总数:{}", user.getNickName(), vo.size());
+        return Response.ok(vo);
+    }
 }
 }

+ 8 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/dao/UserMapper.java

@@ -63,4 +63,12 @@ public interface UserMapper {
             "  and is_selling = 0\n" +
             "  and is_selling = 0\n" +
             "order by sold_time desc;")
             "order by sold_time desc;")
     List<Goods> getUserSold(@Param("seller_id") String sellerId);
     List<Goods> getUserSold(@Param("seller_id") String sellerId);
+
+    @Select("select id, name, primary_pic_url, price, last_edit\n" +
+            "from goods\n" +
+            "where seller_id = #{seller_id}\n" +
+            "  and is_selling = 1\n" +
+            "  and is_delete = 0\n" +
+            "order by last_edit desc;")
+    List<Goods> getUserPosted(@Param("seller_id") String sellerId);
 }
 }

+ 0 - 1
goods-service/src/main/java/io/github/nnkwrik/goodsservice/model/vo/inner/GoodsDetailVo.java

@@ -14,7 +14,6 @@ public class GoodsDetailVo extends GoodsSimpleVo {
     private Double market_price;
     private Double market_price;
     private Integer want_count;
     private Integer want_count;
     private Integer browse_count;
     private Integer browse_count;
-    private String last_edit;
 
 
     private Double postage;
     private Double postage;
     private String region;
     private String region;

+ 1 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/model/vo/inner/GoodsSimpleVo.java

@@ -14,4 +14,5 @@ public class GoodsSimpleVo {
     private Double price;
     private Double price;
     private Boolean is_selling;
     private Boolean is_selling;
     private String sold_time;
     private String sold_time;
+    private String last_edit;
 }
 }

+ 2 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/UserService.java

@@ -19,4 +19,6 @@ public interface UserService {
     List<GoodsSimpleVo> getUserBought(String buyerId);
     List<GoodsSimpleVo> getUserBought(String buyerId);
 
 
     List<GoodsSimpleVo> getUserSold(String sellerId);
     List<GoodsSimpleVo> getUserSold(String sellerId);
+
+    List<GoodsSimpleVo> getUserPosted(String userId);
 }
 }

+ 0 - 2
goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/impl/GoodsServiceImpl.java

@@ -40,8 +40,6 @@ public class GoodsServiceImpl implements GoodsService {
     @Autowired
     @Autowired
     private UserClient userClient;
     private UserClient userClient;
 
 
-    @Autowired
-    private OtherMapper otherMapper;
 
 
 
 
     @Override
     @Override

+ 6 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/impl/UserServiceImpl.java

@@ -54,5 +54,11 @@ public class UserServiceImpl implements UserService {
 
 
     }
     }
 
 
+    @Override
+    public List<GoodsSimpleVo> getUserPosted(String userId) {
+        List<Goods> goodsList = userMapper.getUserPosted(userId);
+        return PO2VO.convertList(PO2VO.goodsSimple,goodsList);
+    }
+
 
 
 }
 }

+ 6 - 5
goods-service/src/main/java/io/github/nnkwrik/goodsservice/util/PO2VO.java

@@ -48,6 +48,12 @@ public class PO2VO {
                 BeanUtils.copyProperties(po, vo);
                 BeanUtils.copyProperties(po, vo);
                 vo.setList_pic_url(po.getPrimaryPicUrl());
                 vo.setList_pic_url(po.getPrimaryPicUrl());
                 vo.setIs_selling(po.getIsSelling());
                 vo.setIs_selling(po.getIsSelling());
+                //Date转String
+                if (po.getLastEdit() != null) {
+                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+                    vo.setLast_edit(formatter.format(po.getLastEdit()));
+                }
+
                 if (po.getSoldTime() != null) {
                 if (po.getSoldTime() != null) {
                     SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                     SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                     vo.setSold_time(formatter.format(po.getSoldTime()));
                     vo.setSold_time(formatter.format(po.getSoldTime()));
@@ -64,11 +70,6 @@ public class PO2VO {
                 vo.setMarket_price(po.getMarketPrice());
                 vo.setMarket_price(po.getMarketPrice());
                 vo.setWant_count(po.getWantCount());
                 vo.setWant_count(po.getWantCount());
                 vo.setBrowse_count(po.getBrowseCount());
                 vo.setBrowse_count(po.getBrowseCount());
-                //Date转String
-                if (po.getLastEdit() != null) {
-                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-                    vo.setLast_edit(formatter.format(po.getLastEdit()));
-                }
 
 
                 BeanUtils.copyProperties(po, vo);
                 BeanUtils.copyProperties(po, vo);
                 return vo;
                 return vo;

+ 2 - 1
wx-front/app.json

@@ -35,7 +35,8 @@
     "pages/nav2post/nav2post",
     "pages/nav2post/nav2post",
     "pages/postCate/postCate",
     "pages/postCate/postCate",
     "pages/ucenter/bought/bought",
     "pages/ucenter/bought/bought",
-    "pages/ucenter/sold/sold"
+    "pages/ucenter/sold/sold",
+    "pages/ucenter/posted/posted"
   ],
   ],
   "window": {
   "window": {
     "backgroundTextStyle": "dark",
     "backgroundTextStyle": "dark",

+ 2 - 2
wx-front/pages/ucenter/bought/bought.js

@@ -7,7 +7,7 @@ Page({
   data: {
   data: {
     boughtList: []
     boughtList: []
   },
   },
-  getCollectList() {
+  getBoughtList() {
     let that = this;
     let that = this;
     util.request(api.BoughtList).then(function (res) {
     util.request(api.BoughtList).then(function (res) {
       if (res.errno === 0) {
       if (res.errno === 0) {
@@ -19,7 +19,7 @@ Page({
     });
     });
   },
   },
   onLoad: function (options) {
   onLoad: function (options) {
-    this.getCollectList();
+    this.getBoughtList();
   },
   },
   onReady: function () {
   onReady: function () {
 
 

+ 2 - 2
wx-front/pages/ucenter/index/index.wxml

@@ -18,9 +18,9 @@
       </navigator>
       </navigator>
     </view>
     </view>
     <view class="item">
     <view class="item">
-      <navigator url="/pages/ucenter/coupon/coupon" class="a">
+      <navigator url="{{isLogin?'/pages/ucenter/posted/posted':'/pages/auth/auth'}}" class="a">
         <text class="icon publish"></text>
         <text class="icon publish"></text>
-        <text class="txt">优惠券</text>
+        <text class="txt">我发布的</text>
       </navigator>
       </navigator>
     </view>
     </view>
     <view class="item no-border">
     <view class="item no-border">

+ 45 - 0
wx-front/pages/ucenter/posted/posted.js

@@ -0,0 +1,45 @@
+var util = require('../../../utils/util.js');
+var api = require('../../../config/api.js');
+
+var app = getApp();
+
+Page({
+  data: {
+    postedList: []
+  },
+  getPostedList() {
+    let that = this;
+    util.request(api.PostedList).then(function (res) {
+      if (res.errno === 0) {
+        console.log(res.data);
+        that.setData({
+          postedList: res.data
+        });
+      }
+    });
+  },
+  onLoad: function (options) {
+    this.getPostedList();
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+  },
+  openGoods(event) {
+    let goodsId = this.data.postedList[event.currentTarget.dataset.index].id;
+
+    wx.navigateTo({
+      url: '/pages/goods/goods?id=' + goodsId,
+    });
+  },
+
+})

+ 3 - 0
wx-front/pages/ucenter/posted/posted.json

@@ -0,0 +1,3 @@
+{
+  "navigationBarTitleText": "我发布的"
+}

+ 20 - 0
wx-front/pages/ucenter/posted/posted.wxml

@@ -0,0 +1,20 @@
+<view class="container">
+  <view class="collect-list" wx:if='{{postedList.length}}'>
+    <view class="item" bindtap="openGoods" wx:for="{{postedList}}" wx:key="{{item.id}}" data-index="{{index}}">
+      <image class="img" src="{{item.list_pic_url}}"></image>
+      <view class="info">
+        <view class="name">{{item.name}}</view>
+        <view class="subtitle">{{item.goods_brief}}</view>
+        <view class="flex">
+          <view class="price">¥{{item.price}}</view>
+          <view class='time'>最后编辑 :{{item.last_edit}}</view>
+        </view>
+      </view>
+    </view>
+  </view>
+
+  <view class="result-empty" wx:else>
+    <image class="icon" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/noSearchResult-7572a94f32.png"></image>
+    <text class="text">您还没有发布过宝贝</text>
+  </view>
+</view>

+ 104 - 0
wx-front/pages/ucenter/posted/posted.wxss

@@ -0,0 +1,104 @@
+page {
+  background: #f4f4f4;
+  min-height: 100%;
+}
+
+.container {
+  background: #f4f4f4;
+  min-height: 100%;
+}
+
+.collect-list {
+  width: 100%;
+  height: auto;
+  overflow: hidden;
+  background: #fff;
+  padding-left: 30rpx;
+  border-top: 1px solid #e1e1e1;
+}
+
+.item {
+  height: 212rpx;
+  width: 720rpx;
+  background: #fff;
+  padding: 30rpx 30rpx 30rpx 0;
+  border-bottom: 1px solid #e1e1e1;
+}
+
+.item:last-child {
+  border-bottom: 1px solid #fff;
+}
+
+.item .img {
+  float: left;
+  width: 150rpx;
+  height: 150rpx;
+}
+
+.item .info {
+  float: right;
+  width: 540rpx;
+  height: 150rpx;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  padding-left: 20rpx;
+}
+
+.item .info .name {
+  font-size: 28rpx;
+  color: #333;
+  line-height: 40rpx;
+}
+
+.item .info .subtitle {
+  margin-top: 8rpx;
+  font-size: 24rpx;
+  color: #888;
+  line-height: 40rpx;
+}
+
+.item .info .price {
+  margin-top: 8rpx;
+  font-size: 28rpx;
+  color: #f94b4b;
+  line-height: 40rpx;
+  width: 160rpx;
+}
+
+.item .info .flex {
+  display: flex;
+}
+
+.item .info .time {
+  display: flex;
+  align-items: center;
+  padding: 0 10rpx;
+  width: auto;
+  color: #999;
+  overflow: hidden;
+  font-size: 26rpx;
+  line-height: 55rpx;
+}
+
+.result-empty {
+  width: 100%;
+  height: 100%;
+  padding-top: 300rpx;
+}
+
+.result-empty .icon {
+  margin: 0 auto;
+  display: block;
+  width: 240rpx;
+  height: 240rpx;
+}
+
+.result-empty .text {
+  display: block;
+  width: 100%;
+  height: 40rpx;
+  font-size: 28rpx;
+  text-align: center;
+  color: #999;
+}

+ 2 - 2
wx-front/pages/ucenter/sold/sold.js

@@ -7,7 +7,7 @@ Page({
   data: {
   data: {
     soldList: []
     soldList: []
   },
   },
-  getCollectList() {
+  getSoldList() {
     let that = this;
     let that = this;
     util.request(api.SoldList).then(function (res) {
     util.request(api.SoldList).then(function (res) {
       if (res.errno === 0) {
       if (res.errno === 0) {
@@ -19,7 +19,7 @@ Page({
     });
     });
   },
   },
   onLoad: function (options) {
   onLoad: function (options) {
-    this.getCollectList();
+    this.getSoldList();
   },
   },
   onReady: function () {
   onReady: function () {
 
 

+ 0 - 11
zuul/src/main/resources/application.yml

@@ -58,17 +58,6 @@ zuul:
       serviceId: goods-service
       serviceId: goods-service
       strip-prefix: false
       strip-prefix: false
       sensitiveHeaders:
       sensitiveHeaders:
-    bought:
-      path: /bought/**
-      serviceId: goods-service
-      strip-prefix: false
-      sensitiveHeaders:
-    sold:
-      path: /sold/**
-      serviceId: goods-service
-      strip-prefix: false
-      sensitiveHeaders:
-