xuzhiheng 4 rokov pred
rodič
commit
cba4fe8150

+ 2 - 1
api/v1/projects.go

@@ -93,6 +93,7 @@ func getProjectDetail(c *gin.Context) {
 //调用日志
 func callLog(c *gin.Context) {
 	appID := c.PostForm("app_id")
+	productId := c.PostForm("product_id")
 	startTime := c.PostForm("start_time")
 	endTime := c.PostForm("end_time")
 	datas := []map[string]interface{}{}
@@ -103,7 +104,7 @@ func callLog(c *gin.Context) {
 		"endTime":   endTime,
 	}
 	global.Logger.Info("api callLog:", zap.Any("param:", p))
-	datas, err = service.CallLog(appID, startTime, endTime)
+	datas, err = service.CallLog(appID, productId, startTime, endTime)
 	if err == nil {
 		response.FailWithDetailed(response.SUCCESS, datas, "OK", c)
 	} else {

+ 8 - 4
service/callLog.go

@@ -1,15 +1,15 @@
 package service
 
 import (
-	"log"
 	"sfis/db"
 	"sfis/model"
 	"sfis/utils"
+	"strconv"
 	"strings"
 	"time"
 )
 
-func CallLog(appid, startTime, endTime string) ([]map[string]interface{}, error) {
+func CallLog(appid, productId, startTime, endTime string) ([]map[string]interface{}, error) {
 	key := []string{}
 	param := []interface{}{}
 	datas := []map[string]interface{}{}
@@ -24,10 +24,14 @@ func CallLog(appid, startTime, endTime string) ([]map[string]interface{}, error)
 		key = append(key, "create_at <= ?")
 		param = append(param, time.Now().Local().Format("2006-01-02 15:04:05"))
 	}
+	if productId != "" {
+		productIds, _ := strconv.Atoi(productId)
+		key = append(key, "product_id = ?")
+		param = append(param, productIds)
+	}
 	whereSql := strings.Join(key, " and ")
-	log.Println("whereSql", whereSql)
 	userCallRecord := []model.UserCallRecord{}
-	err := db.GetSFISDB().Where(whereSql, param...).Where("app_id = ? ", appid).Find(&userCallRecord).Error
+	err := db.GetSFISDB().Where(whereSql, param...).Where("app_id = ? ", appid).Order("create_at desc").Find(&userCallRecord).Error
 	if err != nil {
 		return nil, err
 	} else {

+ 3 - 1
static/templates/callLog.html

@@ -46,9 +46,11 @@
 
         var appid = GetQueryString("appId");
         var key = GetQueryString("key");
+        var product_id = GetQueryString("product_id");
         
         var param = {
-            "app_id": appid
+            "app_id": appid,
+            "product_id":product_id
         };
         var url = "/sfis/api/v1/callLog";
         var rType = "post";

+ 3 - 54
static/templates/login.html

@@ -161,8 +161,7 @@
                 success: function (r) {
                     if (r.code === 0) {
                         var str = "";
-                        console.log(r.data)
-                        if (r.data.length != 0) {
+                        if (r.data) {
                             $(".nodata").html("");
                             $(".userProductDiv").show();
                             $(".userProTbody").html("");
@@ -194,6 +193,7 @@
                                 if (item.cost_model == 0) {
                                     str += "<a href=\"/page/userRecharge?appId=" + appId + "\"  >剩余量充值</a>"
                                 }
+                                str += "<a href=\"/page/callLogPage?appId=" + appId + "&key=" + key + "&product_id=" + item.product_id +  "\"  >调用记录</a>";
                                 str += "<a onclick=\"myFunction('" + appId + "','" + key + "','" + item.product_id + "')\"  href='javascript:void(0);' style='pointer:hand;'>并发测试</a>"
                                 // else {
                                 //
@@ -234,58 +234,7 @@
                     async: false,
                     data: param,
                     success: function (r) {
-                        if (r.code === 0) {
-                            var str = "";
-                            console.log(r.data)
-                            if (r.data.length != 0) {
-                                $(".nodata").html("");
-                                $(".userProductDiv").show();
-                                $(".userProTbody").html("");
-                                for (var i = 0; i < r.data.length; i++) {
-                                    var item = r.data[i];
-                                    str += "<tr>";
-                                    str += "<td>" + (i + 1) + "</td>";
-                                    str += "<td>" + item.product_id + "</td>";
-                                    str += "<td>" + item.app_id + "</td>";
-                                    str += "<td>" + item.left_num + "</td>";
-                                    if (item.cost_model == 0) {
-                                        str += "<td>扣量</td>";
-                                    } else {
-                                        str += "<td>扣余额</td>";
-                                    }
-                                    if (item.interface_status == 0) {
-                                        str += "<td>开启</td>";
-                                    } else {
-                                        str += "<td>关闭</td>";
-                                    }
-                                    str += "<td>" + item.call_times_limit_day + "</td>";
-                                    str += "<td>" + item.data_num_limit_one_times + "</td>";
-                                    if (item.product_id === 1000 || item.product_id === 1001) {
-                                        str += "<td class='handle' style='width: 100px ;'><a href=\"/page/projectListPage?appId=" + appId + "&key=" + key + "\" >测试接口</a>";
-                                    } else {
-                                        str += "<td class='handle' style='width: 100px;'><a href=\"/page/projectListDetail?appId=" + appId + "&key=" + key + "\"  >测试接口</a>";
-                                    }
-                                    if (item.cost_model == 0) {
-                                        str += "<a href=\"/page/userRecharge?appId=" + appId + "\"  >剩余量充值</a>"
-                                    }
-                                    str += "<a href=\"/page/callLogPage?appId=" + appId + "&key=" + key + "\"  >调用记录</a>";
-                                    str += "<a onclick=\"myFunction('" + appId + "','" + key + "','" + item.product_id + "')\"  href='javascript:void(0);' style='pointer:hand;'>并发测试</a>"
-                                    // else {
-                                    //
-                                    // }
-                                    str += "</td>";
-                                    str += "</tr>";
-                                }
-                                // console.log(str);
-                                let trBody = $(str);
-                                $(".userProTbody").append(trBody);
-                            } else {
-                                $(".userProductDiv").hide();
-                            }
-
-                        } else {
-                            $(".userProductList").html(r.msg);
-                        }
+                        alert(JSON.stringify(r))
                     }
                 })