feat: 多语言处理tkey
This commit is contained in:
@@ -6,9 +6,11 @@ import (
|
||||
|
||||
"ems.agt/src/framework/cmd"
|
||||
"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/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"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
@@ -34,6 +36,7 @@ type TcpdumpController struct {
|
||||
//
|
||||
// POST /ne
|
||||
func (s *TcpdumpController) NeTask(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
@@ -43,7 +46,7 @@ func (s *TcpdumpController) NeTask(c *gin.Context) {
|
||||
}
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -51,7 +54,7 @@ func (s *TcpdumpController) NeTask(c *gin.Context) {
|
||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||
if neInfo.NeId != body.NeId {
|
||||
// 找不到 %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))
|
||||
return
|
||||
}
|
||||
@@ -79,6 +82,7 @@ func (s *TcpdumpController) NeTask(c *gin.Context) {
|
||||
//
|
||||
// POST /download
|
||||
func (s *TcpdumpController) Download(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
@@ -86,7 +90,7 @@ func (s *TcpdumpController) Download(c *gin.Context) {
|
||||
}
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,7 +98,7 @@ func (s *TcpdumpController) Download(c *gin.Context) {
|
||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||
if neInfo.NeId != body.NeId {
|
||||
// 找不到 %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))
|
||||
return
|
||||
}
|
||||
@@ -114,6 +118,7 @@ func (s *TcpdumpController) Download(c *gin.Context) {
|
||||
//
|
||||
// POST /neUPF
|
||||
func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
@@ -123,14 +128,14 @@ func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
||||
}
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查网元信息
|
||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, 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))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user