修复单词拼写错误的问题
This commit is contained in:
@ -47,7 +47,7 @@ func (api SessionApi) SessionPagingEndpoint(c echo.Context) error {
|
||||
if status == constant.Disconnected && len(items[i].Recording) > 0 {
|
||||
|
||||
var recording string
|
||||
if items[i].Mode == constant.Naive || items[i].Mode == constant.Terminal {
|
||||
if items[i].Mode == constant.Native || items[i].Mode == constant.Terminal {
|
||||
recording = items[i].Recording
|
||||
} else {
|
||||
recording = items[i].Recording + "/recording"
|
||||
@ -170,8 +170,8 @@ func (api SessionApi) SessionCreateEndpoint(c echo.Context) error {
|
||||
assetId := c.QueryParam("assetId")
|
||||
mode := c.QueryParam("mode")
|
||||
|
||||
if mode == constant.Naive {
|
||||
mode = constant.Naive
|
||||
if mode == constant.Native {
|
||||
mode = constant.Native
|
||||
} else {
|
||||
mode = constant.Guacd
|
||||
}
|
||||
@ -526,7 +526,7 @@ func (api SessionApi) SessionRecordingEndpoint(c echo.Context) error {
|
||||
}
|
||||
|
||||
var recording string
|
||||
if s.Mode == constant.Naive || s.Mode == constant.Terminal {
|
||||
if s.Mode == constant.Native || s.Mode == constant.Terminal {
|
||||
recording = s.Recording
|
||||
} else {
|
||||
recording = s.Recording + "/recording"
|
||||
|
@ -70,6 +70,14 @@ func (app App) InitDBData() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// 修复数据
|
||||
if err := service.AssetService.FixSshMode(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := service.SessionService.FixSshMode(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ const (
|
||||
Disconnected = "disconnected" // 会话状态:已断开连接
|
||||
|
||||
Guacd = "guacd" // 接入模式:guacd
|
||||
Naive = "naive" // 接入模式:原生
|
||||
Native = "native" // 接入模式:原生
|
||||
Terminal = "terminal" // 接入模式:终端
|
||||
|
||||
TypeUser = "user" // 普通用户
|
||||
|
@ -345,3 +345,8 @@ func (r assetRepository) FindAssetAttrMapByAssetId(c context.Context, assetId st
|
||||
}
|
||||
return attributeMap, nil
|
||||
}
|
||||
|
||||
func (r assetRepository) UpdateAttrs(c context.Context, name, value, newValue string) error {
|
||||
sql := "update asset_attributes set value = ? where name = ? and value = ?"
|
||||
return r.GetDB(c).Exec(sql, newValue, name, value).Error
|
||||
}
|
||||
|
@ -168,3 +168,8 @@ func (r sessionRepository) FindAllUnReviewed(c context.Context) (o []model.Sessi
|
||||
err = r.GetDB(c).Where("reviewed = false or reviewed is null").Find(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func (r sessionRepository) UpdateMode(c context.Context) error {
|
||||
sql := "update sessions set mode = 'native' where mode = 'naive'"
|
||||
return r.GetDB(c).Exec(sql).Error
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"next-terminal/server/constant"
|
||||
|
||||
"next-terminal/server/config"
|
||||
"next-terminal/server/env"
|
||||
@ -260,3 +261,7 @@ func (s assetService) UpdateById(id string, m echo.Map) error {
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (s assetService) FixSshMode() error {
|
||||
return repository.AssetRepository.UpdateAttrs(context.TODO(), "ssh-mode", "naive", constant.Native)
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func (service sessionService) WriteCloseMessage(ws *websocket.Conn, mode string,
|
||||
disconnect := guacd.NewInstruction("disconnect")
|
||||
_ = ws.WriteMessage(websocket.TextMessage, []byte(disconnect.String()))
|
||||
}
|
||||
case constant.Naive:
|
||||
case constant.Native:
|
||||
if ws != nil {
|
||||
msg := `0` + reason
|
||||
_ = ws.WriteMessage(websocket.TextMessage, []byte(msg))
|
||||
@ -354,3 +354,7 @@ func (service sessionService) Create(clientIp, assetId, mode string, user *model
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (service sessionService) FixSshMode() error {
|
||||
return repository.SessionRepository.UpdateMode(context.TODO())
|
||||
}
|
||||
|
Reference in New Issue
Block a user