feat: trace 模块路由多语言
This commit is contained in:
@@ -6,9 +6,11 @@ import (
|
|||||||
|
|
||||||
"ems.agt/src/framework/cmd"
|
"ems.agt/src/framework/cmd"
|
||||||
"ems.agt/src/framework/config"
|
"ems.agt/src/framework/config"
|
||||||
|
"ems.agt/src/framework/i18n"
|
||||||
|
"ems.agt/src/framework/utils/ctx"
|
||||||
"ems.agt/src/framework/utils/ssh"
|
"ems.agt/src/framework/utils/ssh"
|
||||||
"ems.agt/src/framework/vo/result"
|
"ems.agt/src/framework/vo/result"
|
||||||
netElementService "ems.agt/src/modules/net_element/service"
|
netElementService "ems.agt/src/modules/network_element/service"
|
||||||
traceService "ems.agt/src/modules/trace/service"
|
traceService "ems.agt/src/modules/trace/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gin-gonic/gin/binding"
|
"github.com/gin-gonic/gin/binding"
|
||||||
@@ -34,6 +36,7 @@ type TcpdumpController struct {
|
|||||||
//
|
//
|
||||||
// POST /ne
|
// POST /ne
|
||||||
func (s *TcpdumpController) NeTask(c *gin.Context) {
|
func (s *TcpdumpController) NeTask(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
var body struct {
|
var body struct {
|
||||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||||
@@ -43,7 +46,7 @@ func (s *TcpdumpController) NeTask(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +54,7 @@ func (s *TcpdumpController) NeTask(c *gin.Context) {
|
|||||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||||
if neInfo.NeId != body.NeId {
|
if neInfo.NeId != body.NeId {
|
||||||
// 找不到 %s %s 对应网元信息
|
// 找不到 %s %s 对应网元信息
|
||||||
msg := fmt.Sprintf("Cannot find %s %s network element information.", body.NeType, body.NeId)
|
msg := i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||||
c.JSON(200, result.ErrMsg(msg))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -79,6 +82,7 @@ func (s *TcpdumpController) NeTask(c *gin.Context) {
|
|||||||
//
|
//
|
||||||
// POST /download
|
// POST /download
|
||||||
func (s *TcpdumpController) Download(c *gin.Context) {
|
func (s *TcpdumpController) Download(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
var body struct {
|
var body struct {
|
||||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||||
@@ -86,7 +90,7 @@ func (s *TcpdumpController) Download(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +98,7 @@ func (s *TcpdumpController) Download(c *gin.Context) {
|
|||||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||||
if neInfo.NeId != body.NeId {
|
if neInfo.NeId != body.NeId {
|
||||||
// 找不到 %s %s 对应网元信息
|
// 找不到 %s %s 对应网元信息
|
||||||
msg := fmt.Sprintf("Cannot find %s %s network element information.", body.NeType, body.NeId)
|
msg := i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||||
c.JSON(200, result.ErrMsg(msg))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -114,6 +118,7 @@ func (s *TcpdumpController) Download(c *gin.Context) {
|
|||||||
//
|
//
|
||||||
// POST /neUPF
|
// POST /neUPF
|
||||||
func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
var body struct {
|
var body struct {
|
||||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||||
@@ -123,14 +128,14 @@ func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查网元信息
|
// 检查网元信息
|
||||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||||
if neInfo.NeId != body.NeId {
|
if neInfo.NeId != body.NeId {
|
||||||
msg := fmt.Sprintf("找不到 %s %s 对应网元信息", body.NeType, body.NeId)
|
msg := i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||||
c.JSON(200, result.ErrMsg(msg))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,18 +5,18 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
netElementService "ems.agt/src/modules/net_element/service"
|
neService "ems.agt/src/modules/network_element/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 实例化服务层 TcpdumpImpl 结构体
|
// 实例化服务层 TcpdumpImpl 结构体
|
||||||
var NewTcpdumpImpl = &TcpdumpImpl{
|
var NewTcpdumpImpl = &TcpdumpImpl{
|
||||||
neInfoService: netElementService.NewNeInfoImpl,
|
neInfoService: neService.NewNeInfoImpl,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通用请求 服务层处理
|
// 通用请求 服务层处理
|
||||||
type TcpdumpImpl struct {
|
type TcpdumpImpl struct {
|
||||||
// 网元信息服务
|
// 网元信息服务
|
||||||
neInfoService netElementService.INeInfo
|
neInfoService neService.INeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// UPFTelnetStart UPF进行telnet抓包
|
// UPFTelnetStart UPF进行telnet抓包
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ func Setup(router *gin.Engine) {
|
|||||||
{
|
{
|
||||||
tcpdumpGroup.POST("/ne",
|
tcpdumpGroup.POST("/ne",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
controller.NewTcpdump.NeTask,
|
controller.NewTcpdump.NeTask,
|
||||||
)
|
)
|
||||||
tcpdumpGroup.POST("/neUPF",
|
tcpdumpGroup.POST("/neUPF",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
controller.NewTcpdump.NeUPFTask,
|
controller.NewTcpdump.NeUPFTask,
|
||||||
)
|
)
|
||||||
tcpdumpGroup.POST("/download",
|
tcpdumpGroup.POST("/download",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_IMPORT)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_IMPORT)),
|
||||||
controller.NewTcpdump.Download,
|
controller.NewTcpdump.Download,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user