Эх сурвалжийг харах

热度算法优化和一些杂碎

nnkwrik 6 жил өмнө
parent
commit
d1e007859f

+ 1 - 0
common/src/main/java/io/github/nnkwrik/common/dto/Response.java

@@ -20,6 +20,7 @@ public class Response<T> {
     public static final int OPEN_ID_IS_EMPTY = 4001;
     public static final int COMMENT_INFO_INCOMPLETE = 4002;
     public static final int POST_INFO_INCOMPLETE = 4003;
+    public static final int SELLER_AND_GOODS_IS_NOT_MATCH = 4004;
 
     //user
     public static final int USER_IS_NOT_EXIST = 3001;

+ 3 - 3
goods-service/src/main/java/io/github/nnkwrik/goodsservice/dao/GoodsMapper.java

@@ -16,10 +16,10 @@ public interface GoodsMapper {
 
     /**
      * 热度算法
-     * Score = (1*click + 10 * want) /e^ (day/10)
-     * = (1*click + 10 * want) / e^((T(now) - T *  10^-7 )
+     * Score = (1*click + 10 * want + 500) /e^ (day/10)
+     * = (1*click + 10 * want + 500) / e^((T(now) - T *  10^-7 )
      */
-    String popular_score = "(1 * browse_count + 10 * want_count) / exp((now() - last_edit) * POW(10, -7))";
+    String popular_score = "(1 * browse_count + 10 * want_count + 500) / exp((now() - last_edit) * POW(10, -7))";
 
 
     /**

+ 3 - 3
goods-service/src/main/java/io/github/nnkwrik/goodsservice/dao/SearchMapper.java

@@ -15,10 +15,10 @@ public interface SearchMapper {
 
     /**
      * 热度算法
-     * Score = (1*click + 10 * want) /e^ (day/10)
-     * = (1*click + 10 * want) / e^((T(now) - T *  10^-7 )
+     * Score = (1*click + 10 * want + 500) /e^ (day/10)
+     * = (1*click + 10 * want + 500) / e^((T(now) - T *  10^-7 )
      */
-    String popular_score = "(1 * browse_count + 10 * want_count) / exp((now() - last_edit) * POW(10, -7))";
+    String popular_score = "(1 * browse_count + 10 * want_count + 500) / exp((now() - last_edit) * POW(10, -7))";
 
 
     @Select("select keyword\n" +

+ 0 - 1
user-service/src/main/java/io/github/nnkwrik/userservice/mq/RegisterStreamReceiver.java

@@ -29,7 +29,6 @@ public class RegisterStreamReceiver {
 
         log.info("从 [ auth-service ] 收到 [ 用户注册 ]的消息");
         log.info("新用户:用户名 = [{}],城市 = [{}]", user.getNickName(), user.getCity());
-        //TODO 先确认用户是否存在
         userService.register(user);
     }
 }

+ 0 - 140
user-service/src/main/java/io/github/nnkwrik/userservice/util/Response.java

@@ -1,140 +0,0 @@
-package io.github.nnkwrik.userservice.util;
-
-/**
- * @author nnkwrik
- * @date 18/11/11 16:42
- */
-public class Response<T> {
-    /**
-     * 服务器响应数据
-     */
-    private T payload;
-
-    /**
-     * 请求是否成功
-     */
-    private boolean success;
-
-    /**
-     * 错误信息
-     */
-    private String msg;
-
-    /**
-     * 状态码
-     */
-    private int code = -1;
-
-    /**
-     * 服务器响应时间
-     */
-    private long timestamp;
-
-    public Response() {
-        this.timestamp = System.currentTimeMillis() / 1000;
-    }
-
-    public Response(boolean success) {
-        this.timestamp = System.currentTimeMillis() / 1000;
-        this.success = success;
-    }
-
-    public Response(boolean success, T payload) {
-        this.timestamp = System.currentTimeMillis() / 1000;
-        this.success = success;
-        this.payload = payload;
-    }
-
-    public Response(boolean success, T payload, int code) {
-        this.timestamp = System.currentTimeMillis() / 1000;
-        this.success = success;
-        this.payload = payload;
-        this.code = code;
-    }
-
-    public Response(boolean success, String msg) {
-        this.timestamp = System.currentTimeMillis() / 1000;
-        this.success = success;
-        this.msg = msg;
-    }
-
-    public Response(boolean success, String msg, int code) {
-        this.timestamp = System.currentTimeMillis() / 1000;
-        this.success = success;
-        this.msg = msg;
-        this.code = code;
-    }
-
-    public T getPayload() {
-        return payload;
-    }
-
-    public void setPayload(T payload) {
-        this.payload = payload;
-    }
-
-    public boolean isSuccess() {
-        return success;
-    }
-
-    public void setSuccess(boolean success) {
-        this.success = success;
-    }
-
-    public String getMsg() {
-        return msg;
-    }
-
-    public void setMsg(String msg) {
-        this.msg = msg;
-    }
-
-    public int getCode() {
-        return code;
-    }
-
-    public void setCode(int code) {
-        this.code = code;
-    }
-
-    public long getTimestamp() {
-        return timestamp;
-    }
-
-    public void setTimestamp(long timestamp) {
-        this.timestamp = timestamp;
-    }
-
-    public static Response ok() {
-        return new Response(true);
-    }
-
-    public static <T> Response ok(T payload) {
-        return new Response(true, payload);
-    }
-
-    public static <T> Response ok(int code) {
-        return new Response(true, null, code);
-    }
-
-    public static <T> Response ok(T payload, int code) {
-        return new Response(true, payload, code);
-    }
-
-    public static Response fail() {
-        return new Response(false);
-    }
-
-    public static Response fail(String msg) {
-        return new Response(false, msg);
-    }
-
-    public static Response fail(int code) {
-        return new Response(false, null, code);
-    }
-
-    public static Response fail(int code, String msg) {
-        return new Response(false, msg, code);
-    }
-
-}

+ 29 - 29
wx-front/pages/post/post.js

@@ -79,37 +79,37 @@ Page({
   },
   uploadFile(url, i) {
     let that = this;
-    // wx.uploadFile({
-    //   url: '	https://sm.ms/api/upload',
-    //   filePath: url,
-    //   name: 'smfile',
-    //   success(res) {
-    //     const data = JSON.parse(res.data);
-
-    //     console.log(data)
-    //     if (data.code == 'success') {
-    //       console.log("图片上传成功, " + data.data.url)
-    //       that.data.imgList[i] = data.data.url
-    //       that.setData({
-    //         imgList: that.data.imgList
-    //       })
-    //       // that.onLoad();
-
-    //     } else if (data.code == 'error' && data.msg == 'File is too large.') {
-    //       console.log("上传失败,图片太大")
-    //       that.compressImg(url, i)
-    //     }
-    //   }
-    // })
+    wx.uploadFile({
+      url: '	https://sm.ms/api/upload',
+      filePath: url,
+      name: 'smfile',
+      success(res) {
+        const data = JSON.parse(res.data);
+
+        console.log(data)
+        if (data.code == 'success') {
+          console.log("图片上传成功, " + data.data.url)
+          that.data.imgList[i] = data.data.url
+          that.setData({
+            imgList: that.data.imgList
+          })
+          // that.onLoad();
+
+        } else if (data.code == 'error' && data.msg == 'File is too large.') {
+          console.log("上传失败,图片太大")
+          that.compressImg(url, i)
+        }
+      }
+    })
 
     //模拟上传
-    setTimeout(function goback() {
-      console.log("图片上传成功, " + url)
-      that.data.imgList[i] = url
-      that.setData({
-        imgList: that.data.imgList
-      })
-    }, 2000)
+    // setTimeout(function goback() {
+    //   console.log("图片上传成功, " + url)
+    //   that.data.imgList[i] = url
+    //   that.setData({
+    //     imgList: that.data.imgList
+    //   })
+    // }, 2000)
 
   },
   compressImg(url, i) {

+ 1 - 1
wx-front/pages/post/post.wxss

@@ -119,7 +119,7 @@ margin-right:20rpx;
 
 
 background:#fff;
-border:1rpx solid #eee;
+border:1rpx solid #ddd;
 
 margin-bottom:30rpx;
 

+ 9 - 7
wx-front/pages/ucenter/index/index.wxml

@@ -46,21 +46,23 @@
       </navigator>
     </view>
 
-    <view class="item">
-      <navigator url="../address/address" class="a">
-        <text class="icon map"></text>
-        <text class="txt">地址管理</text>
+        <view class="item ">
+      <navigator url="/pages/ucenter/order/order" class="a">
+        <text class="icon order"></text>
+        <text class="txt">我的订单</text>
       </navigator>
     </view>
 
     <view class="item item-bottom">
-      <navigator url="/pages/ucenter/order/order" class="a">
-        <text class="icon order"></text>
-        <text class="txt">我订单</text>
+      <navigator url="../address/address" class="a">
+        <text class="icon map"></text>
+        <text class="txt">地址管理</text>
       </navigator>
     </view>
 
 
+
+
     <view class="item item-bottom">
       <navigator url="/pages/ucenter/about/about" class="a">
         <text class="icon embarrass"></text>