mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
refactor: pacakge version upgrade
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
package form
|
||||
|
||||
import tagentity "mayfly-go/internal/tag/domain/entity"
|
||||
import (
|
||||
tagentity "mayfly-go/internal/tag/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type InstanceForm struct {
|
||||
model.ExtraData
|
||||
|
||||
Id uint64 `json:"id"`
|
||||
Name string `binding:"required" json:"name"`
|
||||
Type string `binding:"required" json:"type"` // 类型,mysql oracle等
|
||||
Host string `binding:"required" json:"host"`
|
||||
Port int `json:"port"`
|
||||
Extra string `json:"extra"`
|
||||
Params string `json:"params"`
|
||||
Remark string `json:"remark"`
|
||||
SshTunnelMachineId int `json:"sshTunnelMachineId"`
|
||||
@@ -18,11 +22,12 @@ type InstanceForm struct {
|
||||
}
|
||||
|
||||
type InstanceDbNamesForm struct {
|
||||
model.ExtraData
|
||||
|
||||
Type string `binding:"required" json:"type"` // 类型,mysql oracle等
|
||||
Host string `binding:"required" json:"host"`
|
||||
Port int `json:"port"`
|
||||
Params string `json:"params"`
|
||||
Extra string `json:"extra"`
|
||||
SshTunnelMachineId int `json:"sshTunnelMachineId"`
|
||||
AuthCert *tagentity.ResourceAuthCert `json:"authCert" binding:"required"` // 资产授权凭证信息
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@ package vo
|
||||
|
||||
import (
|
||||
tagentity "mayfly-go/internal/tag/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type InstanceListVO struct {
|
||||
model.ExtraData
|
||||
tagentity.AuthCerts // 授权凭证信息
|
||||
tagentity.ResourceTags
|
||||
|
||||
@@ -16,7 +18,6 @@ type InstanceListVO struct {
|
||||
Port *int `json:"port"`
|
||||
Type *string `json:"type"`
|
||||
Params string `json:"params"`
|
||||
Extra string `json:"extra"`
|
||||
Remark *string `json:"remark"`
|
||||
CreateTime *time.Time `json:"createTime"`
|
||||
Creator *string `json:"creator"`
|
||||
|
||||
@@ -244,6 +244,7 @@ func (app *instanceAppImpl) toDbInfoByAc(instance *entity.DbInstance, ac *tagent
|
||||
di.InstanceId = instance.Id
|
||||
di.Database = database
|
||||
structx.Copy(di, instance)
|
||||
di.Extra = instance.Extra
|
||||
|
||||
di.Username = ac.Username
|
||||
di.Password = ac.Ciphertext
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"mayfly-go/internal/machine/mcm"
|
||||
"mayfly-go/pkg/errorx"
|
||||
"mayfly-go/pkg/logx"
|
||||
"mayfly-go/pkg/model"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -20,6 +21,8 @@ func (dbType DbType) Equal(typ string) bool {
|
||||
}
|
||||
|
||||
type DbInfo struct {
|
||||
model.ExtraData // 连接需要的其他额外参数(json字符串),如oracle数据库需要指定sid等
|
||||
|
||||
InstanceId uint64 // 实例id
|
||||
Id uint64 // dbId
|
||||
Name string
|
||||
@@ -27,7 +30,6 @@ type DbInfo struct {
|
||||
Type DbType // 类型,mysql postgres等
|
||||
Host string
|
||||
Port int
|
||||
Extra string // 连接需要的其他额外参数(json字符串),如oracle数据库需要指定sid等
|
||||
Network string
|
||||
Username string
|
||||
Password string
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"mayfly-go/internal/db/dbm/dbi"
|
||||
"mayfly-go/pkg/utils/collx"
|
||||
"mayfly-go/pkg/utils/jsonx"
|
||||
"strings"
|
||||
|
||||
"github.com/may-fly/cast"
|
||||
@@ -59,13 +58,9 @@ func (om *Meta) GetSqlDb(d *dbi.DbInfo) (*sql.DB, error) {
|
||||
}
|
||||
|
||||
// 从extra获取sid或serviceName
|
||||
serviceName := ""
|
||||
if d.Extra != "" {
|
||||
extraMap := jsonx.ToMap(d.Extra)
|
||||
serviceName = cast.ToString(extraMap["serviceName"])
|
||||
if sid := cast.ToString(extraMap["sid"]); sid != "" {
|
||||
urlOptions["SID"] = sid
|
||||
}
|
||||
serviceName := d.GetExtraString("serviceName")
|
||||
if sid := d.GetExtraString("sid"); sid != "" {
|
||||
urlOptions["SID"] = sid
|
||||
}
|
||||
|
||||
urlOptions["TIMEOUT"] = "1000"
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
// DbInstance 数据库实例信息
|
||||
type DbInstance struct {
|
||||
model.Model
|
||||
model.ExtraData // 连接需要的其他额外参数(json字符串),如oracle数据库需要指定sid等
|
||||
|
||||
Code string `json:"code" gorm:"size:32;not null;"`
|
||||
Name string `json:"name" gorm:"size:32;not null;"`
|
||||
@@ -15,8 +16,7 @@ type DbInstance struct {
|
||||
Host string `json:"host" gorm:"size:255;not null;"`
|
||||
Port int `json:"port"`
|
||||
Network string `json:"network" gorm:"size:20;"`
|
||||
Extra *string `json:"extra" gorm:"size:1000;comment:连接需要的额外参数,如oracle数据库需要sid等"` // 连接需要的其他额外参数(json格式), 如oracle需要sid等
|
||||
Params *string `json:"params" gorm:"size:255;comment:其他连接参数"` // 使用指针类型,可更新为零值(空字符串)
|
||||
Params *string `json:"params" gorm:"size:255;comment:其他连接参数"` // 使用指针类型,可更新为零值(空字符串)
|
||||
Remark *string `json:"remark" gorm:"size:255;"`
|
||||
SshTunnelMachineId int `json:"sshTunnelMachineId"` // ssh隧道机器id
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
tagapp "mayfly-go/internal/tag/application"
|
||||
tagentity "mayfly-go/internal/tag/domain/entity"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/errorx"
|
||||
"mayfly-go/pkg/global"
|
||||
"mayfly-go/pkg/logx"
|
||||
"mayfly-go/pkg/model"
|
||||
@@ -69,8 +68,8 @@ func (m *Machine) ReqConfs() *req.Confs {
|
||||
req.NewGet(":machineId/term-recs", m.MachineTermOpRecords).RequiredPermission(saveMachineP),
|
||||
|
||||
// 终端操作
|
||||
req.NewGet("terminal/:ac", m.WsSSH),
|
||||
req.NewGet("rdp/:ac", m.WsGuacamole),
|
||||
req.NewGet("terminal/:ac", m.WsSSH).NoRes(),
|
||||
req.NewGet("rdp/:ac", m.WsGuacamole).NoRes(),
|
||||
}
|
||||
|
||||
return req.NewConfs("machines", reqs[:]...)
|
||||
@@ -248,9 +247,8 @@ func (m *Machine) WsSSH(rc *req.Ctx) {
|
||||
|
||||
// 权限校验
|
||||
rc = rc.WithRequiredPermission(req.NewPermission("machine:terminal"))
|
||||
if err = req.PermissionHandler(rc); err != nil {
|
||||
panic(errorx.NewBiz(mcm.GetErrorContentRn("You do not have permission to operate the machine terminal, please log in again and try again ~")))
|
||||
}
|
||||
err = req.PermissionHandler(rc)
|
||||
biz.ErrIsNil(err, mcm.GetErrorContentRn("You do not have permission to operate the machine terminal, please log in again and try again ~"))
|
||||
|
||||
cli, err := m.machineApp.NewCli(GetMachineAc(rc))
|
||||
biz.ErrIsNilAppendErr(err, mcm.GetErrorContentRn("connection error: %s"))
|
||||
@@ -265,7 +263,6 @@ func (m *Machine) WsSSH(rc *req.Ctx) {
|
||||
// 记录系统操作日志
|
||||
rc.WithLog(req.NewLogSaveI(imsg.LogMachineTerminalOp))
|
||||
rc.ReqParam = cli.Info
|
||||
req.LogHandler(rc)
|
||||
|
||||
err = m.machineTermOpApp.TermConn(rc.MetaCtx, cli, wsConn, rows, cols)
|
||||
biz.ErrIsNilAppendErr(err, mcm.GetErrorContentRn("connect fail: %s"))
|
||||
@@ -305,9 +302,8 @@ func (m *Machine) WsGuacamole(rc *req.Ctx) {
|
||||
biz.ErrIsNil(err)
|
||||
|
||||
rc = rc.WithRequiredPermission(req.NewPermission("machine:terminal"))
|
||||
if err = req.PermissionHandler(rc); err != nil {
|
||||
panic(errorx.NewBiz(mcm.GetErrorContentRn("You do not have permission to operate the machine terminal, please log in again and try again ~")))
|
||||
}
|
||||
err = req.PermissionHandler(rc)
|
||||
biz.ErrIsNil(err, mcm.GetErrorContentRn("You do not have permission to operate the machine terminal, please log in again and try again ~"))
|
||||
|
||||
ac := GetMachineAc(rc)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ type System struct {
|
||||
|
||||
func (s *System) ReqConfs() *req.Confs {
|
||||
reqs := [...]*req.Conf{
|
||||
req.NewGet("", s.ConnectWs),
|
||||
req.NewGet("", s.ConnectWs).NoRes(),
|
||||
}
|
||||
return req.NewConfs("sysmsg", reqs[:]...)
|
||||
}
|
||||
@@ -39,7 +39,6 @@ func (s *System) ConnectWs(rc *req.Ctx) {
|
||||
biz.NotEmpty(clientId, "clientId cannot be empty")
|
||||
|
||||
// 权限校验
|
||||
// rc := req.NewCtxWithGin(g)
|
||||
err = req.PermissionHandler(rc)
|
||||
biz.ErrIsNil(err, "sys-websocket connect without permission")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user