Parcourir la source

第三方商品服务-增加查询时,随机排序盐

sunxbiao il y a 6 mois
Parent
commit
bdbdebb504

+ 8 - 0
commons-pojo/src/main/java/com/bjtdba/entity/thirdPartyWares/ThirdPartyGoods.java

@@ -19,6 +19,7 @@ public class ThirdPartyGoods implements Serializable {
19 19
      * 1:淘宝。2:京东。3:拼多多
20 20
      */
21 21
     private Integer type;
22
+    private Integer salt;
22 23
 
23 24
 
24 25
 
@@ -55,5 +56,12 @@ public class ThirdPartyGoods implements Serializable {
55 56
         this.type = type;
56 57
     }
57 58
 
59
+    public Integer getSalt() {
60
+        return salt;
61
+    }
62
+
63
+    public void setSalt(Integer salt) {
64
+        this.salt = salt;
65
+    }
58 66
 }
59 67
 

+ 3 - 0
thirdPartyWares_service/src/main/java/com/bjtdba/thirdPartWares/service/impl/TaobaoServiceImpl.java

@@ -78,6 +78,9 @@ public class TaobaoServiceImpl implements TaobaoService {
78 78
         if(cid!=null&&!cid.equals("")){
79 79
             thirdPartyGoods.setCid(Integer.parseInt(cid));
80 80
         }
81
+        long timestamp = System.currentTimeMillis();
82
+        Integer salt = (int) (timestamp / 100000);
83
+        thirdPartyGoods.setSalt(salt);
81 84
         List<ThirdPartyGoods> thirdPartyGoodsList=thirdPartyGoodsDao.queryAllByLimit(thirdPartyGoods);
82 85
         List<Object> list=new ArrayList<Object>();
83 86
         for (int i = 0; i < thirdPartyGoodsList.size(); i++) {

+ 1 - 2
thirdPartyWares_service/src/main/resources/mapper/ThirdPartyGoodsDao.xml

@@ -33,9 +33,8 @@
33 33
             <if test="cid != null">
34 34
                 and cid = #{cid}
35 35
             </if>
36
-
37
-
38 36
         </where>
37
+        ORDER BY RAND(#{salt}) desc
39 38
     </select>
40 39
 
41 40
     <!--统计总行数-->