|
|
@@ -1,6 +1,8 @@
|
|
|
package log
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
+ "github.com/xuri/excelize/v2"
|
|
|
"go.uber.org/zap"
|
|
|
"log-server/global"
|
|
|
"log-server/model/log"
|
|
|
@@ -76,12 +78,11 @@ func (s *ServiceIpLog) GetIpLogList(api log.IpLogRequest, info request.PageInfo,
|
|
|
}
|
|
|
|
|
|
//根据gameId获取ip
|
|
|
-func (s *ServiceIpLog) GetGameIpList(api log.IpLogRequest, info request.PageInfo, order string, desc bool) (list interface{}, total int64, err error) {
|
|
|
+func (s *ServiceIpLog) GetGameIpList(api log.IpLogRequest, info request.PageInfo, order string, desc bool) (apiList []log.GameIpResponse, total int64, err error) {
|
|
|
limit := info.PageSize
|
|
|
offset := info.PageSize * (info.Page - 1)
|
|
|
db := global.GVA_DB.Model(&log.IpLog{})
|
|
|
|
|
|
- var apiList []log.GameIpResponse
|
|
|
startDate := time.Now().Format("2006-01-02")
|
|
|
endDate := time.Now().Format("2006-01-02")
|
|
|
if len(api.Date) == 2 {
|
|
|
@@ -161,3 +162,28 @@ func (s *ServiceIpLog) GetGameIp(ip log.GameIpResponse) (list interface{}, total
|
|
|
err = db.Order("count desc").Find(&ipList).Error
|
|
|
return ipList, total, err
|
|
|
}
|
|
|
+
|
|
|
+//获取gameIP列表
|
|
|
+func (s *ServiceIpLog) GameIpListExcel(infoList []log.GameIpResponse, filePath string) error {
|
|
|
+ excel := excelize.NewFile()
|
|
|
+ excel.SetSheetRow("Sheet1", "A1", &[]string{
|
|
|
+ "游戏id",
|
|
|
+ "上报ip次数",
|
|
|
+ "任务完成",
|
|
|
+ "成功ip次数",
|
|
|
+ "ip个数",
|
|
|
+ "日期"})
|
|
|
+ for i, statisticsLog := range infoList {
|
|
|
+ axis := fmt.Sprintf("A%d", i+2)
|
|
|
+ excel.SetSheetRow("Sheet1", axis, &[]interface{}{
|
|
|
+ statisticsLog.GameId,
|
|
|
+ statisticsLog.CountTotal,
|
|
|
+ statisticsLog.TaskCount,
|
|
|
+ statisticsLog.SuccessIp,
|
|
|
+ statisticsLog.CountDistinctIp,
|
|
|
+ statisticsLog.CreateDate[:10],
|
|
|
+ })
|
|
|
+ }
|
|
|
+ err := excel.SaveAs(filePath)
|
|
|
+ return err
|
|
|
+}
|