diff --git a/config/locales/i18n_data.xlsx b/config/locales/i18n_data.xlsx index 93ee11ec..b44b2862 100644 Binary files a/config/locales/i18n_data.xlsx and b/config/locales/i18n_data.xlsx differ diff --git a/src/modules/common/common.go b/src/modules/common/common.go index 071fca52..a78c8310 100644 --- a/src/modules/common/common.go +++ b/src/modules/common/common.go @@ -27,9 +27,9 @@ func Setup(router *gin.Engine) { // 系统可暴露的配置信息 indexGroup.GET("/sys-conf", controller.NewCommont.SysConfig) // 系统使用文档转存 - indexGroup.POST("/help-doc", + indexGroup.POST("/helpDoc", middleware.PreAuthorize(nil), - collectlogs.OperateLog(collectlogs.OptionNew("系统使用文档", collectlogs.BUSINESS_TYPE_UPDATE)), + collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.helpDoc", collectlogs.BUSINESS_TYPE_UPDATE)), controller.NewCommont.HelpDoc, ) @@ -56,11 +56,11 @@ func Setup(router *gin.Engine) { indexGroup.GET("/getInfo", middleware.PreAuthorize(nil), controller.NewAccount.Info) indexGroup.GET("/getRouters", middleware.PreAuthorize(nil), controller.NewAccount.Router) indexGroup.POST("/logout", - // middleware.RateLimit(middleware.LimitOption{ - // Time: 300, - // Count: 5, - // Type: middleware.LIMIT_IP, - // }), + middleware.RateLimit(middleware.LimitOption{ + Time: 300, + Count: 5, + Type: middleware.LIMIT_IP, + }), controller.NewAccount.Logout, ) } diff --git a/src/modules/common/controller/common.go b/src/modules/common/controller/common.go index 097e5297..c7329cfa 100644 --- a/src/modules/common/controller/common.go +++ b/src/modules/common/controller/common.go @@ -79,7 +79,7 @@ func (s *CommontController) SysConfig(c *gin.Context) { // 转存帮助文档 // -// POST /help-doc +// POST /helpDoc func (s *CommontController) HelpDoc(c *gin.Context) { language := ctx.AcceptLanguage(c) var body struct { @@ -105,8 +105,6 @@ func (s *CommontController) HelpDoc(c *gin.Context) { newFile := fmt.Sprintf("%s/helpDoc/%s_doc.pdf", dir, lang) fmt.Println(newFile) - // dst := "" - err = file.CopyUploadFile(body.UploadPath, newFile) if err != nil { c.JSON(400, result.CodeMsg(400, err.Error())) diff --git a/src/modules/network_element/controller/ne_action.go b/src/modules/network_element/controller/ne_action.go new file mode 100644 index 00000000..f001b631 --- /dev/null +++ b/src/modules/network_element/controller/ne_action.go @@ -0,0 +1,68 @@ +package controller + +import ( + "fmt" + "path/filepath" + "strings" + + "ems.agt/src/framework/config" + "ems.agt/src/framework/i18n" + "ems.agt/src/framework/utils/ctx" + "ems.agt/src/framework/utils/file" + "ems.agt/src/framework/utils/ssh" + "ems.agt/src/framework/vo/result" + neService "ems.agt/src/modules/network_element/service" + "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" +) + +// 实例化控制层 NeActionController 结构体 +var NewNeAction = &NeActionController{ + neInfoService: neService.NewNeInfoImpl, +} + +// 网元处理请求 +// +// PATH / +type NeActionController struct { + // 网元信息服务 + neInfoService neService.INeInfo +} + +// 发送文件到网元端 +// +// POST /pushFile +func (s *NeActionController) PushFile(c *gin.Context) { + language := ctx.AcceptLanguage(c) + var body struct { + NeType string `json:"neType" binding:"required"` + NeID string `json:"neId" binding:"required"` + UploadPath string `json:"uploadPath" binding:"required"` + } + if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil { + c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) + return + } + + // 查询网元获取IP + neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeID) + if neInfo.NeId != body.NeID || neInfo.IP == "" { + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) + return + } + + // 本地文件 + localPath := file.ParseUploadFilePath(body.UploadPath) + nePath := config.Get("mml.upload").(string) + // 复制到远程 + err := ssh.FileSCPLocalToNe(neInfo.IP, localPath, nePath) + if err != nil { + c.JSON(200, result.ErrMsg(err.Error())) + return + } + + // 网元端文件路径 + fileName := localPath[strings.LastIndex(localPath, "/")+1:] + neFilePath := fmt.Sprintf("%s/%s", nePath, fileName) + c.JSON(200, result.OkData(filepath.ToSlash(neFilePath))) +} diff --git a/src/modules/network_element/controller/ne_info.go b/src/modules/network_element/controller/ne_info.go index 07ca0d12..d8f8a7c8 100644 --- a/src/modules/network_element/controller/ne_info.go +++ b/src/modules/network_element/controller/ne_info.go @@ -35,7 +35,7 @@ func (s *NeInfoController) NeTypeAndID(c *gin.Context) { neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } c.JSON(200, result.OkData(neInfo)) diff --git a/src/modules/network_element/controller/udm_auth.go b/src/modules/network_element/controller/udm_auth.go index a3e55965..d1acc52e 100644 --- a/src/modules/network_element/controller/udm_auth.go +++ b/src/modules/network_element/controller/udm_auth.go @@ -76,7 +76,7 @@ func (s *UDMAuthController) Info(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -134,7 +134,7 @@ func (s *UDMAuthController) Add(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -177,7 +177,7 @@ func (s *UDMAuthController) Adds(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -219,7 +219,7 @@ func (s *UDMAuthController) Edit(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -268,7 +268,7 @@ func (s *UDMAuthController) Remove(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -305,7 +305,7 @@ func (s *UDMAuthController) Removes(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -414,7 +414,7 @@ func (s *UDMAuthController) Import(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } diff --git a/src/modules/network_element/controller/udm_sub.go b/src/modules/network_element/controller/udm_sub.go index dce70634..df738622 100644 --- a/src/modules/network_element/controller/udm_sub.go +++ b/src/modules/network_element/controller/udm_sub.go @@ -77,7 +77,7 @@ func (s *UDMSubController) Info(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -158,7 +158,7 @@ func (s *UDMSubController) Add(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -206,7 +206,7 @@ func (s *UDMSubController) Adds(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -253,7 +253,7 @@ func (s *UDMSubController) Edit(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -344,7 +344,7 @@ func (s *UDMSubController) Remove(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -381,7 +381,7 @@ func (s *UDMSubController) Removes(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } @@ -492,7 +492,7 @@ func (s *UDMSubController) Import(c *gin.Context) { // 查询网元获取IP neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId) if neInfo.NeId != neId || neInfo.IP == "" { - c.JSON(200, result.OkData(i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) return } diff --git a/src/modules/network_element/network_element.go b/src/modules/network_element/network_element.go index de361903..bcb385b5 100644 --- a/src/modules/network_element/network_element.go +++ b/src/modules/network_element/network_element.go @@ -22,6 +22,17 @@ func Setup(router *gin.Engine) { ) } + // 网元处理 + neActionGroup := neGroup.Group("/action") + { + // 发送文件到网元服务器 + neActionGroup.POST("/pushFile", + middleware.PreAuthorize(nil), + collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neAction", collectlogs.BUSINESS_TYPE_IMPORT)), + controller.NewNeAction.PushFile, + ) + } + // UDM鉴权用户信息 udmAuthGroup := neGroup.Group("/udm/auth") { diff --git a/src/modules/network_element/service/udm_auth.impl.go b/src/modules/network_element/service/udm_auth.impl.go index 7d6cd519..ed7cc4ab 100644 --- a/src/modules/network_element/service/udm_auth.impl.go +++ b/src/modules/network_element/service/udm_auth.impl.go @@ -40,10 +40,8 @@ func (r *UDMAuthImpl) authDataByRedis(imsi, neID string) []model.UDMAuth { continue } - status := "0" - if _, ok := m["auth_success"]; ok { - status = "1" - } + status := "1" // 默认给1 + amf := "" if v, ok := m["amf"]; ok { amf = strings.Replace(v, "\r\n", "", 1)