Parcourir la source

查询ip功能添加

maker il y a 3 ans
Parent
commit
9fc48a20a3

+ 36 - 0
api/v1/log/loging.go

@@ -158,6 +158,42 @@ func (s *ApiLoging) GetIpLogList(c *gin.Context) {
 	}
 }
 
+// @Tags loging
+// @Summary 获取某天具体ip
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body log2.IpLog true "获取ip"
+// @Success 200 {object} response.Response{data=log2.IpResponse} "获取iplog列表"
+// @Router /loging/getIp [post]
+func (s *ApiLoging) GetIp(c *gin.Context) {
+	var ip log2.IpLogResponse
+	_ = c.ShouldBindJSON(&ip)
+	if ip.GameId == 0 {
+		response.FailWithMessage("游戏id不能为空", c)
+		return
+	}
+	if ip.PcCode == "" {
+		response.FailWithMessage("租机编号不能为空", c)
+		return
+	}
+	if ip.CreateDate == ""{
+		response.FailWithMessage("创建日期不能为空", c)
+		return
+	}
+	list, total, err := ServiceIpLog.GetIp(ip)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+		}, "获取成功", c)
+	}
+}
+
+
 
 // @Tags loging
 // @Summary 获取统计节点log

+ 5 - 0
model/log/log_ip.go

@@ -32,6 +32,11 @@ type IpLogResponse struct {
 	CountDistinctIp	int	`json:"count_distinct_ip"`
 }
 
+type QueryIpList struct {
+	Ip     		string  `json:"ip"`	//模拟器ip
+}
+
+
 func (IpLog) TableName() string {
 	return "ip_log"
 }

+ 2 - 0
model/typeManage/responsiblePerson.go

@@ -14,6 +14,8 @@ type ResponsiblePerson struct {
 	GameCounts        int64     `json:"game_counts"`
 	Custodians		  string	`json:"custodians"`
 	Remark            string    `json:"remark"`
+	StartTime		  int64		`json:"start_time"`
+	Url				  string	`json:"url"`
 	State             int8      `json:"state"`
 	PushStatus		  int8		`json:"push_status"`
 	CreateTime        LocalTime `gorm:"column:create_time;" json:"createTime"`

+ 1 - 0
router/log/loging.go

@@ -29,6 +29,7 @@ func (e *LogingRouter) InitLogingRouter(Router *gin.RouterGroup) {
 		excelRouter.POST("computerRateExport", logApi.ComputerRateExport)
 		excelRouter.POST("computerSevenRate", logApi.ComputerSevenRate)
 		excelRouter.POST("getIpLogList", logApi.GetIpLogList)	//获取ip日志列表
+		excelRouter.POST("getIp", logApi.GetIp)	//获取ip
 
 	}
 }

+ 14 - 2
service/log/log_ip.go

@@ -47,8 +47,10 @@ func (s *ServiceIpLog) GetIpLogList(api log.IpLogRequest, info request.PageInfo,
 			var OrderStr string
 			// 设置有效排序key 防止sql注入
 			// 感谢 Tom4t0 提交漏洞信息
-			orderMap := make(map[string]bool, 1)
+			orderMap := make(map[string]bool, 3)
 			orderMap["game_id"] = true
+			orderMap["count_distinct_ip"] = true
+			orderMap["count_total"] = true
 			if orderMap[order] {
 				if desc {
 					OrderStr = order + " desc"
@@ -70,4 +72,14 @@ func (s *ServiceIpLog) GetIpLogList(api log.IpLogRequest, info request.PageInfo,
 		apiList[i].CreateDate = apiList[i].CreateDate[:10]
 	}
 	return apiList, total, err
-}
+}
+
+func (s *ServiceIpLog) GetIp(iplog log.IpLogResponse) (list interface{}, total int64, err error) {
+	var ipList []log.QueryIpList
+	iplog.CreateDate = time.Now().Format("2006-01-02")
+	db := global.GVA_DB.Model(&log.IpLog{}).Distinct("ip").Where("game_id = ? and pc_code = ? and create_date = ?", iplog.GameId, iplog.PcCode, iplog.CreateDate)
+	//db.Group("ip").Count(&total)
+	err = db.Find(&ipList).Count(&total).Error
+	return ipList, total, err
+}
+