feat: 更新多个模块以支持新的数据结构和日志格式

This commit is contained in:
TsMask
2025-02-20 10:08:27 +08:00
parent 045a2b6b01
commit f3c33b31ac
272 changed files with 13246 additions and 15885 deletions

View File

@@ -7,8 +7,8 @@ import (
"be.ems/src/framework/i18n"
"be.ems/src/framework/logger"
"be.ems/src/framework/utils/ctx"
"be.ems/src/framework/vo/result"
"be.ems/src/framework/reqctx"
"be.ems/src/framework/resp"
neService "be.ems/src/modules/network_element/service"
"github.com/gin-gonic/gin"
@@ -21,17 +21,17 @@ import (
// @Tags ws
// @Accept json
// @Produce json
// @Param neType query string true "NE Type" Enums(IMS,AMF,AUSF,UDM,SMF,PCF,NSSF,NRF,UPF,MME,CBC,OMC,SGWC)
// @Param neType query string true "NE Type" Enums(IMS,AMF,AUSF,UDM,SMF,PCF,NSSF,NRF,UPF,MME,CBC,OMC,SGWC,SMSC)
// @Param neId query string true "NE ID" default(001)
// @Param cols query number false "Terminal line characters" default(120)
// @Param rows query number false "Terminal display lines" default(40)
// @Param access_token query string true "Authorization"
// @Param access_token query string true "Authorization tokens are used when it is inconvenient to pass parameters through the header."
// @Success 200 {object} object "Response Results"
// @Summary (ws://) Terminal Interactive File Content Viewing
// @Description (ws://) Terminal Interactive File Content Viewing
// @Router /ws/view [get]
func (s *WSController) ShellView(c *gin.Context) {
language := ctx.AcceptLanguage(c)
language := reqctx.AcceptLanguage(c)
var query struct {
NeType string `form:"neType" binding:"required"` // 网元类型
NeId string `form:"neId" binding:"required"` // 网元标识id
@@ -39,7 +39,7 @@ func (s *WSController) ShellView(c *gin.Context) {
Rows int `form:"rows"` // 终端显示行数
}
if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
if query.Cols < 120 || query.Cols > 400 {
@@ -50,23 +50,23 @@ func (s *WSController) ShellView(c *gin.Context) {
}
// 登录用户信息
loginUser, err := ctx.LoginUser(c)
loginUser, err := reqctx.LoginUser(c)
if err != nil {
c.JSON(401, result.CodeMsg(401, i18n.TKey(language, err.Error())))
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error())))
return
}
// 网元主机的SSH客户端
sshClient, err := neService.NewNeInfo.NeRunSSHClient(query.NeType, query.NeId)
if err != nil {
c.JSON(200, result.ErrMsg(err.Error()))
c.JSON(200, resp.ErrMsg(err.Error()))
return
}
defer sshClient.Close()
// ssh连接会话
clientSession, err := sshClient.NewClientSession(query.Cols, query.Rows)
if err != nil {
c.JSON(200, result.ErrMsg("neinfo ssh client session new err"))
c.JSON(200, resp.ErrMsg("neinfo ssh client session new err"))
return
}
defer clientSession.Close()
@@ -78,7 +78,7 @@ func (s *WSController) ShellView(c *gin.Context) {
}
defer wsConn.Close()
wsClient := s.wsService.ClientCreate(loginUser.UserID, nil, wsConn, clientSession)
wsClient := s.wsService.ClientCreate(loginUser.UserId, nil, wsConn, clientSession)
go s.wsService.ClientWriteListen(wsClient)
go s.wsService.ClientReadListen(wsClient, s.wsReceiveService.ShellView)
@@ -95,7 +95,7 @@ func (s *WSController) ShellView(c *gin.Context) {
outputByte := clientSession.Read()
if len(outputByte) > 0 {
outputStr := string(outputByte)
msgByte, _ := json.Marshal(result.Ok(map[string]any{
msgByte, _ := json.Marshal(resp.Ok(map[string]any{
"requestId": fmt.Sprintf("view_%d", ms.UnixMilli()),
"data": outputStr,
}))
@@ -103,7 +103,7 @@ func (s *WSController) ShellView(c *gin.Context) {
}
case <-wsClient.StopChan: // 等待停止信号
s.wsService.ClientClose(wsClient.ID)
logger.Infof("ws Stop Client UID %s", wsClient.BindUid)
logger.Infof("ws Stop Client UID %d", wsClient.BindUid)
return
}
}