Просмотр исходного кода

修改日志列表代码结构

maker лет назад: 3
Родитель
Сommit
2cc95b1546
8 измененных файлов с 105 добавлено и 65 удалено
  1. 1 0
      api/v1/log/enter.go
  2. 79 0
      api/v1/log/log_ip.go
  3. 0 62
      api/v1/log/loging.go
  4. 3 0
      initialize/router.go
  5. 1 0
      router/enter.go
  6. 21 0
      router/log/log_ip.go
  7. 0 2
      router/log/loging.go
  8. 0 1
      service/log/log_ip.go

+ 1 - 0
api/v1/log/enter.go

@@ -9,6 +9,7 @@ type GroupLog struct {
 	ApiEnvLog
 	ApiLoging
 	ApiComputer
+	ApiIpLog
 }
 
 var (

+ 79 - 0
api/v1/log/log_ip.go

@@ -0,0 +1,79 @@
+package log
+
+import (
+	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
+	"log-server/global"
+	log2 "log-server/model/log"
+	"log-server/model/log/request"
+	"log-server/model/log/response"
+	"log-server/utils"
+)
+
+type ApiIpLog struct {
+
+}
+
+// @Tags loging
+// @Summary 获取iplog
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body request.IpLogListRequest true "获取iplog"
+// @Success 200 {object} response.Response{data=log2.IpLog} "获取iplog列表"
+// @Router /loging/getIpLogList [post]
+func (s *ApiIpLog) GetIpLogList(c *gin.Context) {
+	var paramsInfo request.IpLogListRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	list, total, err := ServiceIpLog.GetIpLogList(paramsInfo.IpLogRequest, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     paramsInfo.Page,
+			PageSize: paramsInfo.PageSize,
+		}, "获取成功", c)
+	}
+}
+
+// @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 *ApiIpLog) 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)
+	}
+}

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

@@ -129,69 +129,7 @@ func (s *ApiLoging) GetReportPointsLogList(c *gin.Context) {
 	}
 }
 
-// @Tags loging
-// @Summary 获取iplog
-// @Security ApiKeyAuth
-// @accept application/json
-// @Produce application/json
-// @Param data body request.IpLogListRequest true "获取iplog"
-// @Success 200 {object} response.Response{data=log2.IpLog} "获取iplog列表"
-// @Router /loging/getIpLogList [post]
-func (s *ApiLoging) GetIpLogList(c *gin.Context) {
-	var paramsInfo request.IpLogListRequest
-	_ = c.ShouldBindJSON(&paramsInfo)
-	if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
-		response.FailWithMessage(err.Error(), c)
-		return
-	}
-	list, total, err := ServiceIpLog.GetIpLogList(paramsInfo.IpLogRequest, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
-	if err != nil {
-		global.GVA_LOG.Error("获取失败!", zap.Error(err))
-		response.FailWithMessage("获取失败", c)
-	} else {
-		response.OkWithDetailed(response.PageResult{
-			List:     list,
-			Total:    total,
-			Page:     paramsInfo.Page,
-			PageSize: paramsInfo.PageSize,
-		}, "获取成功", c)
-	}
-}
 
-// @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)
-	}
-}
 
 
 

+ 3 - 0
initialize/router.go

@@ -23,6 +23,7 @@ func Routers() *gin.Engine {
 	taskRouter := router.RouterGroupApp.Task
 	uploadFileRouter := router.RouterGroupApp.UploadFile
 
+	ipLogRouter := router.RouterGroupApp.IpLog
 	typeManageRouter := router.RouterGroupApp.TypeManage
 	rentComputerRouter := router.RouterGroupApp.RentComputer
 	dataStatisticsRouter := router.RouterGroupApp.DataStatistics
@@ -65,6 +66,8 @@ func Routers() *gin.Engine {
 		typeManageRouter.InitLoginTypeRouter(PublicGroup)         //登录类型路由
 		typeManageRouter.InitResponsiblePersonRouter(PublicGroup) //负责人路由
 		typeManageRouter.InitAccountTypeRouter(PublicGroup)       //账号类型路由
+		ipLogRouter.InitIpLogRouter(PublicGroup)				  //ip日志路由
+
 		taskRouter.InitGameTaskRouter(PublicGroup)
 		uploadFileRouter.InitUploadFileRouter(PublicGroup)
 		rentComputerRouter.InitRentComputerRouter(PublicGroup)     //租机管理

+ 1 - 0
router/enter.go

@@ -22,6 +22,7 @@ type RouterGroup struct {
 	RentComputer   rentComputer.RouterGroup
 	DataStatistics dataStatistics.RouterGroup
 	FileManager    fileManager.RouterGroup
+	IpLog 		   log.IpLogRouter
 }
 
 var RouterGroupApp = new(RouterGroup)

+ 21 - 0
router/log/log_ip.go

@@ -0,0 +1,21 @@
+package log
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "log-server/api/v1"
+)
+
+type IpLogRouter struct {
+
+}
+
+func (e *IpLogRouter) InitIpLogRouter(Router *gin.RouterGroup) {
+	ipLogRouter := Router.Group("ipLog")
+	logApi := v1.ApiGroupApp.LogApiGroup.ApiIpLog
+	{
+		ipLogRouter.POST("getIpLogList", logApi.GetIpLogList)	//获取ip日志列表
+		ipLogRouter.POST("getIp", logApi.GetIp)	//获取ip
+
+	}
+}
+

+ 0 - 2
router/log/loging.go

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

+ 0 - 1
service/log/log_ip.go

@@ -76,7 +76,6 @@ func (s *ServiceIpLog) GetIpLogList(api log.IpLogRequest, info request.PageInfo,
 
 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{}).Select("ip, COUNT(1) as count").Where("game_id = ? and pc_code = ? and create_date = ?", iplog.GameId, iplog.PcCode, iplog.CreateDate).Group("ip")
 	//db.Group("ip").Count(&total)
 	err = db.Find(&ipList).Count(&total).Error