feat: 新增跟踪任务pcap文件获取接口
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"be.ems/src/framework/i18n"
|
||||
@@ -129,3 +132,24 @@ func (s *TraceTaskController) Remove(c *gin.Context) {
|
||||
msg := i18n.TTemplate(language, "app.common.deleteSuccess", map[string]any{"num": rows})
|
||||
c.JSON(200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
// 跟踪任务文件
|
||||
//
|
||||
// GET /filePull
|
||||
func (s *TraceTaskController) FilePull(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var querys struct {
|
||||
TraceId string `form:"traceId" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
fileName := fmt.Sprintf("task_%s.pcap", querys.TraceId)
|
||||
localFilePath := filepath.Join("/tmp/omc/trace", fileName)
|
||||
if runtime.GOOS == "windows" {
|
||||
localFilePath = fmt.Sprintf("C:%s", localFilePath)
|
||||
}
|
||||
c.FileAttachment(localFilePath, fileName)
|
||||
}
|
||||
|
||||
@@ -92,6 +92,10 @@ func Setup(router *gin.Engine) {
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.task", collectlogs.BUSINESS_TYPE_DELETE)),
|
||||
controller.NewTraceTask.Remove,
|
||||
)
|
||||
taskGroup.GET("/filePull",
|
||||
middleware.PreAuthorize(nil),
|
||||
controller.NewTraceTask.FilePull,
|
||||
)
|
||||
}
|
||||
|
||||
// 跟踪数据
|
||||
|
||||
Reference in New Issue
Block a user