Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.5.1^2
zouap 3 years ago
parent
commit
24d8164170
1 changed files with 12 additions and 2 deletions
  1. +12
    -2
      routers/repo/user_data_analysis.go

+ 12
- 2
routers/repo/user_data_analysis.go View File

@@ -290,7 +290,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e
xlsx.SetActiveSheet(index)
filename := sheetName + "_" + ctx.Tr("user.static."+tableName) + ".xlsx"
if tableName == "" {
filename = sheetName + "_" + startTime.Add(8*60*60*1000).Format("20060102") + "_" + endTime.Add(8*60*60*1000).Format("20060102") + ".xlsx"
filename = sheetName + "_" + getTimeFileName(startTime) + "_" + getTimeFileName(endTime) + ".xlsx"
}
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename))
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
@@ -312,7 +312,17 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e
}
ctx.JSON(http.StatusOK, mapInterface)
}

}
func getTimeFileName(t time.Time) string {
month := fmt.Sprint(t.Month())
if t.Month() < 10 {
month = "0" + month
}
day := fmt.Sprint(t.Day())
if t.Day() < 10 {
day = "0" + day
}
return fmt.Sprint(t.Year()) + month + day
}

func QueryRankingList(ctx *context.Context) {


Loading…
Cancel
Save