Переглянути джерело

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

sunxbiao 6 місяців тому
батько
коміт
bdbdebb504

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

@@ -19,6 +19,7 @@ public class ThirdPartyGoods implements Serializable {
19
      * 1:淘宝。2:京东。3:拼多多
19
      * 1:淘宝。2:京东。3:拼多多
20
      */
20
      */
21
     private Integer type;
21
     private Integer type;
22
+    private Integer salt;
22
 
23
 
23
 
24
 
24
 
25
 
@@ -55,5 +56,12 @@ public class ThirdPartyGoods implements Serializable {
55
         this.type = type;
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
         if(cid!=null&&!cid.equals("")){
78
         if(cid!=null&&!cid.equals("")){
79
             thirdPartyGoods.setCid(Integer.parseInt(cid));
79
             thirdPartyGoods.setCid(Integer.parseInt(cid));
80
         }
80
         }
81
+        long timestamp = System.currentTimeMillis();
82
+        Integer salt = (int) (timestamp / 100000);
83
+        thirdPartyGoods.setSalt(salt);
81
         List<ThirdPartyGoods> thirdPartyGoodsList=thirdPartyGoodsDao.queryAllByLimit(thirdPartyGoods);
84
         List<ThirdPartyGoods> thirdPartyGoodsList=thirdPartyGoodsDao.queryAllByLimit(thirdPartyGoods);
82
         List<Object> list=new ArrayList<Object>();
85
         List<Object> list=new ArrayList<Object>();
83
         for (int i = 0; i < thirdPartyGoodsList.size(); i++) {
86
         for (int i = 0; i < thirdPartyGoodsList.size(); i++) {

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

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