mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 07:50:25 +08:00
refactor: pacakge version upgrade
This commit is contained in:
@@ -18,21 +18,21 @@ require (
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230712084735-068dc2aee82d
|
||||
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20241220152942-06eb5c6e8230
|
||||
github.com/may-fly/cast v1.7.1
|
||||
github.com/microsoft/go-mssqldb v1.8.0
|
||||
github.com/mojocn/base64Captcha v1.3.8 // 验证码
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/sftp v1.13.7
|
||||
github.com/pquerna/otp v1.4.0
|
||||
github.com/redis/go-redis/v9 v9.7.0
|
||||
github.com/redis/go-redis/v9 v9.7.1
|
||||
github.com/robfig/cron/v3 v3.0.1 // 定时任务
|
||||
github.com/sijms/go-ora/v2 v2.8.23
|
||||
github.com/sijms/go-ora/v2 v2.8.24
|
||||
github.com/stretchr/testify v1.10.0
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/veops/go-ansiterm v0.0.5
|
||||
go.mongodb.org/mongo-driver v1.16.0 // mongo
|
||||
golang.org/x/crypto v0.33.0 // ssh
|
||||
golang.org/x/crypto v0.35.0 // ssh
|
||||
golang.org/x/oauth2 v0.26.0
|
||||
golang.org/x/sync v0.11.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func Init() []*gormigrate.Migration {
|
||||
|
||||
new(machineentity.Machine),
|
||||
new(machineentity.MachineFile),
|
||||
new(machineentity.MachineMonitor),
|
||||
new(machineentity.MachineTermOp),
|
||||
new(machineentity.MachineScript),
|
||||
new(machineentity.MachineCronJob),
|
||||
new(machineentity.MachineCronJobExec),
|
||||
|
||||
@@ -204,26 +204,38 @@ func GetIdByGenType(genType IdGenType) uint64 {
|
||||
type Map[K comparable, V any] map[K]V
|
||||
|
||||
func (m *Map[K, V]) Scan(value any) error {
|
||||
return json.Unmarshal(value.([]byte), m)
|
||||
if v, ok := value.([]byte); ok && len(v) > 0 {
|
||||
return json.Unmarshal(v, m)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m Map[K, V]) Value() (driver.Value, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return json.Marshal(m)
|
||||
}
|
||||
|
||||
type Slice[T int | string | Map[string, any]] []T
|
||||
|
||||
func (s *Slice[T]) Scan(value any) error {
|
||||
return json.Unmarshal(value.([]byte), s)
|
||||
if v, ok := value.([]byte); ok && len(v) > 0 {
|
||||
return json.Unmarshal(v, s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s Slice[T]) Value() (driver.Value, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return json.Marshal(s)
|
||||
}
|
||||
|
||||
// 带有额外其他信息字段的结构体
|
||||
type ExtraData struct {
|
||||
Extra Map[string, any] `json:"extra" gorm:"type:varchar(1000)"`
|
||||
Extra Map[string, any] `json:"extra" gorm:"type:varchar(2000)"`
|
||||
}
|
||||
|
||||
// SetExtraValue 设置额外信息字段值
|
||||
|
||||
Reference in New Issue
Block a user