diff --git a/features/cm/param.go b/features/cm/param.go
index 74089cd..2a68a87 100644
--- a/features/cm/param.go
+++ b/features/cm/param.go
@@ -46,7 +46,7 @@ func GetParamConfigFromNF(w http.ResponseWriter, r *http.Request) {
restHostPort := fmt.Sprintf("http://127.0.0.1:%d", config.GetYamlConfig().Rest[0].Port)
getNeInfoPattern := fmt.Sprintf(config.DefaultUriPrefix+"/databaseManagement/v1/%s/ne_info", config.GetYamlConfig().Database.Name)
getNeInfoURI := restHostPort + getNeInfoPattern
- neId := services.GetUriParamString(r, "ne_id", ",", true, false)
+ neId := services.GetUriParamString(r, "ne_id", ",", true, true)
if neId == "" {
getNeInfoURI = getNeInfoURI + fmt.Sprintf("?WHERE=status='0'+and+ne_type='%s'", neType)
} else {
diff --git a/features/state/getstate.go b/features/state/getstate.go
index 1b1b2a3..786c76e 100644
--- a/features/state/getstate.go
+++ b/features/state/getstate.go
@@ -733,7 +733,7 @@ func GetStateFromNF(w http.ResponseWriter, r *http.Request) {
getNeInfoPattern := fmt.Sprintf(config.DefaultUriPrefix+"/databaseManagement/v1/elementType/%s/objectType/ne_info",
config.GetYamlConfig().Database.Name)
getNeInfoURI := restHostPort + getNeInfoPattern
- neId := services.GetUriParamString(r, "ne_id", ",", true, false)
+ neId := services.GetUriParamString(r, "ne_id", ",", true, true)
if neId == "" {
getNeInfoURI = getNeInfoURI + fmt.Sprintf("?WHERE=status='0'+and+ne_type='%s'", neType)
} else {
diff --git a/restagent/etc/restconf.yaml b/restagent/etc/restconf.yaml
index 6ffcf47..dd08a52 100644
--- a/restagent/etc/restconf.yaml
+++ b/restagent/etc/restconf.yaml
@@ -37,12 +37,15 @@ webServer:
database:
type: mysql
user: root
- password: "1000omc@kp!"
- host: "192.168.2.219"
- port: 33066
- name: omc_db
+ # password: "1000omc@kp!"
+ # host: "192.168.2.219"
+ # port: 33066
+ # name: omc_db
backup: d:/local.git/ems.agt/restagent/database
-
+ password: "root@1234"
+ host: "192.168.2.152"
+ port: 3306
+ name: "omc_db"
# Redis 缓存数据,数据源声明全小写
redis:
dataSource:
diff --git a/restagent/restagent.go b/restagent/restagent.go
index 25d5503..540f782 100644
--- a/restagent/restagent.go
+++ b/restagent/restagent.go
@@ -19,6 +19,7 @@ import (
"ems.agt/lib/routes"
"ems.agt/restagent/config"
"ems.agt/src"
+ "ems.agt/src/framework/middleware"
libSession "ems.agt/src/lib_features/session"
"github.com/gin-gonic/gin"
)
@@ -73,7 +74,8 @@ func HttpListen(addr string, router http.Handler) {
}
}
-func HttpListenTLS(addr, certFile, keyFile string, router http.Handler) {
+func HttpListenTLS(addr, caFile, certFile, keyFile string, router http.Handler) {
+ HttpListenConfigTLS(addr, caFile, certFile, keyFile, router)
err := http.ListenAndServeTLS(addr, certFile, keyFile, router)
if err != nil {
fmt.Println("ListenAndServeTLS err:", err)
@@ -92,6 +94,7 @@ func HttpListenConfigTLS(addr, caFile, certFile, keyFile string, router http.Han
// 创建自定义的TLS配置
tlsConfig := &tls.Config{
+ MinVersion: 1,
ClientCAs: caCertPool,
ClientAuth: tls.RequireAndVerifyClientCert,
}
@@ -110,7 +113,8 @@ func HttpListenConfigTLS(addr, caFile, certFile, keyFile string, router http.Han
}
}
-func HttpListenWebServerTLS(addr, certFile, keyFile string) {
+func HttpListenWebServerTLS(addr, caFile, certFile, keyFile string) {
+ HttpListenConfigTLS(addr, caFile, certFile, keyFile, nil)
err := http.ListenAndServeTLS(addr, certFile, keyFile, nil)
if err != nil {
fmt.Println("ListenAndServeTLS err:", err)
@@ -173,6 +177,7 @@ func main() {
// 默认路由组
defaultUriGroup := app.Group(config.DefaultUriPrefix)
+ defaultUriGroup.Use(middleware.PreAuthorize(nil))
defaultUriGroup.Use(libSession.SessionHeader())
defaultUriGroup.Any("/*any", gin.WrapH(routes.NewRouter()))
// 可配置前缀路由组
@@ -188,7 +193,7 @@ func main() {
if rest.IPv4 != "" {
listen := rest.IPv4 + ":" + strconv.Itoa(int(rest.Port))
if strings.ToLower(rest.Scheme) == "https" {
- go HttpListenTLS(listen, rest.CertFile, rest.KeyFile, app)
+ go HttpListenTLS(listen, rest.CaFile, rest.CertFile, rest.KeyFile, app)
} else {
go HttpListen(listen, app)
}
@@ -198,7 +203,7 @@ func main() {
if rest.IPv6 != "" {
listenv6 := "[" + rest.IPv6 + "]" + ":" + strconv.Itoa(int(rest.Port))
if strings.ToLower(rest.Scheme) == "https" {
- go HttpListenTLS(listenv6, rest.CertFile, rest.KeyFile, app)
+ go HttpListenTLS(listenv6, rest.CaFile, rest.CertFile, rest.KeyFile, app)
} else {
go HttpListen(listenv6, app)
}
@@ -210,7 +215,7 @@ func main() {
http.Handle("/", fs)
for _, listen := range conf.WebServer.Listen {
if strings.ToLower(listen.Scheme) == "https" {
- go HttpListenWebServerTLS(listen.Addr, listen.CertFile, listen.KeyFile)
+ go HttpListenWebServerTLS(listen.Addr, listen.CaFile, listen.CertFile, listen.KeyFile)
} else {
go HttpListenWebServer(listen.Addr)
}
diff --git a/src/framework/utils/file/file.go b/src/framework/utils/file/file.go
index 831250e..77d25a8 100644
--- a/src/framework/utils/file/file.go
+++ b/src/framework/utils/file/file.go
@@ -2,7 +2,9 @@ package file
import (
"fmt"
+ "io"
"mime/multipart"
+ "os"
"path"
"path/filepath"
"strconv"
@@ -295,6 +297,43 @@ func ChunkMergeFile(identifier, originalFileName, subPath string) (string, error
return filepath.ToSlash(urlPath), nil
}
+// CopyUploadFile 将上传文件资源转移新目录
+//
+// filePath 上传得到的文件路径 /upload....
+// dst 新文件路径 /a/xx.pdf
+func CopyUploadFile(filePath, dst string) error {
+ srcPath := ParseUploadFilePath(filePath)
+ src, err := os.Open(srcPath)
+ if err != nil {
+ return err
+ }
+ defer src.Close()
+
+ if err := os.MkdirAll(filepath.Dir(dst), 0750); err != nil {
+ return err
+ }
+
+ // 如果目标文件已经存在,先将目标文件重命名
+ if _, err := os.Stat(dst); err == nil {
+ ext := filepath.Ext(dst)
+ name := dst[0 : len(dst)-len(ext)]
+ newName := fmt.Sprintf("%s-%s%s", name, time.Now().Format("20060102_150405"), ext)
+ err := os.Rename(dst, newName)
+ if err != nil {
+ return err
+ }
+ }
+
+ out, err := os.Create(dst)
+ if err != nil {
+ return err
+ }
+ defer out.Close()
+
+ _, err = io.Copy(out, src)
+ return err
+}
+
// ParseUploadFileDir 得到上传资源目录
//
// subPath 子路径,默认 UploadSubPath.DEFAULT
@@ -304,7 +343,7 @@ func ParseUploadFileDir(subPath string) string {
return filepath.Join(dir, filePath)
}
-// ParseUploadFilePath 本地资源路径
+// ParseUploadFilePath 上传资源本地绝对资源路径
//
// filePath 上传文件路径
func ParseUploadFilePath(filePath string) string {
diff --git a/src/modules/common/common.go b/src/modules/common/common.go
index 70af591..a78c831 100644
--- a/src/modules/common/common.go
+++ b/src/modules/common/common.go
@@ -3,6 +3,7 @@ package common
import (
"ems.agt/src/framework/logger"
"ems.agt/src/framework/middleware"
+ "ems.agt/src/framework/middleware/collectlogs"
"ems.agt/src/modules/common/controller"
"github.com/gin-gonic/gin"
@@ -25,6 +26,12 @@ func Setup(router *gin.Engine) {
// 系统可暴露的配置信息
indexGroup.GET("/sys-conf", controller.NewCommont.SysConfig)
+ // 系统使用文档转存
+ indexGroup.POST("/helpDoc",
+ middleware.PreAuthorize(nil),
+ collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.helpDoc", collectlogs.BUSINESS_TYPE_UPDATE)),
+ controller.NewCommont.HelpDoc,
+ )
// 验证码操作处理
indexGroup.GET("/captchaImage",
@@ -49,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 4ba3776..c7329cf 100644
--- a/src/modules/common/controller/common.go
+++ b/src/modules/common/controller/common.go
@@ -1,11 +1,18 @@
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/vo/result"
commonService "ems.agt/src/modules/common/service"
"github.com/gin-gonic/gin"
+ "github.com/gin-gonic/gin/binding"
)
// 实例化控制层 CommontController 结构体
@@ -69,3 +76,41 @@ func (s *CommontController) SysConfig(c *gin.Context) {
c.JSON(200, result.OkData(data))
}
+
+// 转存帮助文档
+//
+// POST /helpDoc
+func (s *CommontController) HelpDoc(c *gin.Context) {
+ language := ctx.AcceptLanguage(c)
+ var body struct {
+ UploadPath string `json:"uploadPath" binding:"required"`
+ Language string `json:"language" binding:"required"`
+ }
+ if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
+ c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
+ return
+ }
+
+ // 取语言前缀
+ lang := strings.SplitN(body.Language, "_", 2)[0]
+
+ // 默认静态资源
+ static := config.Get("staticFile.default").(map[string]any)
+ dir, err := filepath.Abs(static["dir"].(string))
+ if err != nil {
+ c.JSON(400, result.CodeMsg(400, err.Error()))
+ return
+ }
+
+ newFile := fmt.Sprintf("%s/helpDoc/%s_doc.pdf", dir, lang)
+ fmt.Println(newFile)
+
+ err = file.CopyUploadFile(body.UploadPath, newFile)
+ if err != nil {
+ c.JSON(400, result.CodeMsg(400, err.Error()))
+ return
+ }
+
+ urlPath := strings.Replace(newFile, dir, static["prefix"].(string), 1)
+ c.JSON(200, result.OkData(filepath.ToSlash(urlPath)))
+}
diff --git a/src/modules/common/service/commont.impl.go b/src/modules/common/service/commont.impl.go
index 3756a16..56a5da0 100644
--- a/src/modules/common/service/commont.impl.go
+++ b/src/modules/common/service/commont.impl.go
@@ -41,5 +41,11 @@ func (s *CommontImpl) SystemConfigInfo() map[string]string {
// 获取登录界面背景
loginBackground := s.sysConfigService.SelectConfigValueByKey("sys.loginBackground")
infoMap["loginBackground"] = loginBackground
+ // 系统设置-官网网址
+ officialUrl := s.sysConfigService.SelectConfigValueByKey("sys.officialUrl")
+ infoMap["officialUrl"] = officialUrl
+ // 系统设置-系统使用文档
+ helpDoc := s.sysConfigService.SelectConfigValueByKey("sys.helpDoc")
+ infoMap["helpDoc"] = helpDoc
return infoMap
}
diff --git a/src/modules/monitor/controller/sys_user_online.go b/src/modules/monitor/controller/sys_user_online.go
index 1c9232c..cbd7690 100644
--- a/src/modules/monitor/controller/sys_user_online.go
+++ b/src/modules/monitor/controller/sys_user_online.go
@@ -34,6 +34,7 @@ type SysUserOnlineController struct {
//
// GET /list
func (s *SysUserOnlineController) List(c *gin.Context) {
+ language := ctx.AcceptLanguage(c)
ipaddr := c.Query("ipaddr")
userName := c.Query("userName")
@@ -69,6 +70,7 @@ func (s *SysUserOnlineController) List(c *gin.Context) {
onlineUser := s.sysUserOnlineService.LoginUserToUserOnline(loginUser)
if onlineUser.TokenID != "" {
+ onlineUser.LoginLocation = i18n.TKey(language, onlineUser.LoginLocation)
userOnlines = append(userOnlines, onlineUser)
}
}
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 0000000..f001b63
--- /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 07ca0d1..d8f8a7c 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 a3e5596..d1acc52 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 dce7063..df73862 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 de36190..bcb385b 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 378200a..ed7cc4a 100644
--- a/src/modules/network_element/service/udm_auth.impl.go
+++ b/src/modules/network_element/service/udm_auth.impl.go
@@ -23,7 +23,8 @@ type UDMAuthImpl struct {
// authDataByRedis UDM鉴权用户
func (r *UDMAuthImpl) authDataByRedis(imsi, neID string) []model.UDMAuth {
arr := []model.UDMAuth{}
- ausfArr, err := redis.GetKeys("udmuser", fmt.Sprintf("ausf:%s", imsi))
+ key := fmt.Sprintf("ausf:%s", imsi)
+ ausfArr, err := redis.GetKeys("udmuser", key)
if err != nil {
return arr
}
@@ -39,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)
@@ -166,11 +165,12 @@ func (r *UDMAuthImpl) Delete(neID, imsi string) int64 {
// Insert UDM鉴权用户-删除范围
func (r *UDMAuthImpl) Deletes(neID, imsi, num string) int64 {
- prefix := imsi[:len(imsi)-len(num)]
- // keys udm-sd:4600001000004*
+ prefix := imsi[:len(imsi)-len(num)-1]
+ // 直接删除前缀的记录
+ r.udmAuthRepository.DeletePrefixImsi(neID, prefix)
+ // keys ausf:4600001000004*
authArr := r.authDataByRedis(prefix+"*", neID)
if len(authArr) > 0 {
- r.udmAuthRepository.DeletePrefixImsi(neID, prefix)
return r.udmAuthRepository.Inserts(authArr)
}
return 0
diff --git a/src/modules/network_element/service/udm_sub.impl.go b/src/modules/network_element/service/udm_sub.impl.go
index e730e01..617a0a3 100644
--- a/src/modules/network_element/service/udm_sub.impl.go
+++ b/src/modules/network_element/service/udm_sub.impl.go
@@ -23,7 +23,8 @@ type UDMSubImpl struct {
// subDataByRedis UDM签约用户
func (r *UDMSubImpl) subDataByRedis(imsi, neID string) []model.UDMSub {
arr := []model.UDMSub{}
- udmsdArr, err := redis.GetKeys("udmuser", fmt.Sprintf("udm-sd:%s", imsi))
+ key := fmt.Sprintf("udm-sd:%s", imsi)
+ udmsdArr, err := redis.GetKeys("udmuser", key)
if err != nil {
return arr
}
@@ -180,11 +181,12 @@ func (r *UDMSubImpl) Delete(neID, imsi string) int64 {
// Insert UDM签约用户-删除范围
func (r *UDMSubImpl) Deletes(neID, imsi, num string) int64 {
- prefix := imsi[:len(imsi)-len(num)]
+ prefix := imsi[:len(imsi)-len(num)-1]
+ // 直接删除前缀的记录
+ r.udmSubRepository.DeletePrefixImsi(neID, prefix)
// keys udm-sd:4600001000004*
authArr := r.subDataByRedis(prefix+"*", neID)
if len(authArr) > 0 {
- r.udmSubRepository.DeletePrefixImsi(neID, prefix)
return r.udmSubRepository.Inserts(authArr)
}
return 0
diff --git a/src/modules/system/controller/sys_user.go b/src/modules/system/controller/sys_user.go
index f656f23..6bf77cd 100644
--- a/src/modules/system/controller/sys_user.go
+++ b/src/modules/system/controller/sys_user.go
@@ -759,7 +759,7 @@ func (s *SysUserController) ImportData(c *gin.Context) {
message = strings.Join(append([]string{msg}, failureMsgArr...), "
")
} else {
// 恭喜您,数据已全部导入成功!共 %d 条,数据如下:
- msg := i18n.TTemplate(language, "user.import.successTip", map[string]any{"num": failureNum})
+ msg := i18n.TTemplate(language, "user.import.successTip", map[string]any{"num": successNum})
message = strings.Join(append([]string{msg}, successMsgArr...), "
")
}
diff --git a/src/modules/trace/service/tcpdump.impl.go b/src/modules/trace/service/tcpdump.impl.go
index 78f1259..6b8c005 100644
--- a/src/modules/trace/service/tcpdump.impl.go
+++ b/src/modules/trace/service/tcpdump.impl.go
@@ -1,7 +1,7 @@
package service
import (
- fmt "fmt"
+ "fmt"
"net"
"time"