Merge branch 'main' of http://192.168.2.166:3180/OMC/ems_backend
This commit is contained in:
Binary file not shown.
@@ -27,9 +27,9 @@ func Setup(router *gin.Engine) {
|
|||||||
// 系统可暴露的配置信息
|
// 系统可暴露的配置信息
|
||||||
indexGroup.GET("/sys-conf", controller.NewCommont.SysConfig)
|
indexGroup.GET("/sys-conf", controller.NewCommont.SysConfig)
|
||||||
// 系统使用文档转存
|
// 系统使用文档转存
|
||||||
indexGroup.POST("/help-doc",
|
indexGroup.POST("/helpDoc",
|
||||||
middleware.PreAuthorize(nil),
|
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,
|
controller.NewCommont.HelpDoc,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -56,11 +56,11 @@ func Setup(router *gin.Engine) {
|
|||||||
indexGroup.GET("/getInfo", middleware.PreAuthorize(nil), controller.NewAccount.Info)
|
indexGroup.GET("/getInfo", middleware.PreAuthorize(nil), controller.NewAccount.Info)
|
||||||
indexGroup.GET("/getRouters", middleware.PreAuthorize(nil), controller.NewAccount.Router)
|
indexGroup.GET("/getRouters", middleware.PreAuthorize(nil), controller.NewAccount.Router)
|
||||||
indexGroup.POST("/logout",
|
indexGroup.POST("/logout",
|
||||||
// middleware.RateLimit(middleware.LimitOption{
|
middleware.RateLimit(middleware.LimitOption{
|
||||||
// Time: 300,
|
Time: 300,
|
||||||
// Count: 5,
|
Count: 5,
|
||||||
// Type: middleware.LIMIT_IP,
|
Type: middleware.LIMIT_IP,
|
||||||
// }),
|
}),
|
||||||
controller.NewAccount.Logout,
|
controller.NewAccount.Logout,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ func (s *CommontController) SysConfig(c *gin.Context) {
|
|||||||
|
|
||||||
// 转存帮助文档
|
// 转存帮助文档
|
||||||
//
|
//
|
||||||
// POST /help-doc
|
// POST /helpDoc
|
||||||
func (s *CommontController) HelpDoc(c *gin.Context) {
|
func (s *CommontController) HelpDoc(c *gin.Context) {
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
var body struct {
|
var body struct {
|
||||||
@@ -105,8 +105,6 @@ func (s *CommontController) HelpDoc(c *gin.Context) {
|
|||||||
newFile := fmt.Sprintf("%s/helpDoc/%s_doc.pdf", dir, lang)
|
newFile := fmt.Sprintf("%s/helpDoc/%s_doc.pdf", dir, lang)
|
||||||
fmt.Println(newFile)
|
fmt.Println(newFile)
|
||||||
|
|
||||||
// dst := ""
|
|
||||||
|
|
||||||
err = file.CopyUploadFile(body.UploadPath, newFile)
|
err = file.CopyUploadFile(body.UploadPath, newFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, err.Error()))
|
c.JSON(400, result.CodeMsg(400, err.Error()))
|
||||||
|
|||||||
68
src/modules/network_element/controller/ne_action.go
Normal file
68
src/modules/network_element/controller/ne_action.go
Normal file
@@ -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)))
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ func (s *NeInfoController) NeTypeAndID(c *gin.Context) {
|
|||||||
|
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(neInfo))
|
c.JSON(200, result.OkData(neInfo))
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func (s *UDMAuthController) Info(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ func (s *UDMAuthController) Add(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ func (s *UDMAuthController) Adds(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ func (s *UDMAuthController) Edit(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ func (s *UDMAuthController) Remove(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ func (s *UDMAuthController) Removes(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +414,7 @@ func (s *UDMAuthController) Import(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ func (s *UDMSubController) Info(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ func (s *UDMSubController) Add(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ func (s *UDMSubController) Adds(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ func (s *UDMSubController) Edit(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +344,7 @@ func (s *UDMSubController) Remove(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ func (s *UDMSubController) Removes(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ func (s *UDMSubController) Import(c *gin.Context) {
|
|||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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鉴权用户信息
|
// UDM鉴权用户信息
|
||||||
udmAuthGroup := neGroup.Group("/udm/auth")
|
udmAuthGroup := neGroup.Group("/udm/auth")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,10 +40,8 @@ func (r *UDMAuthImpl) authDataByRedis(imsi, neID string) []model.UDMAuth {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
status := "0"
|
status := "1" // 默认给1
|
||||||
if _, ok := m["auth_success"]; ok {
|
|
||||||
status = "1"
|
|
||||||
}
|
|
||||||
amf := ""
|
amf := ""
|
||||||
if v, ok := m["amf"]; ok {
|
if v, ok := m["amf"]; ok {
|
||||||
amf = strings.Replace(v, "\r\n", "", 1)
|
amf = strings.Replace(v, "\r\n", "", 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user