refactor: cast包替换

This commit is contained in:
meilin.huang
2025-06-27 12:17:45 +08:00
parent 54d3a5b368
commit f7480f3bac
60 changed files with 91 additions and 94 deletions

View File

@@ -29,7 +29,7 @@
"jsencrypt": "^3.3.2",
"mitt": "^3.0.1",
"monaco-editor": "^0.52.2",
"monaco-sql-languages": "^0.15.0",
"monaco-sql-languages": "^0.15.1",
"monaco-themes": "^0.4.5",
"nprogress": "^0.2.0",
"pinia": "^3.0.3",
@@ -40,33 +40,33 @@
"trzsz": "^1.1.5",
"uuid": "^9.0.1",
"vue": "^3.5.17",
"vue-i18n": "^11.1.6",
"vue-i18n": "^11.1.7",
"vue-router": "^4.5.1",
"vuedraggable": "^4.1.0"
},
"devDependencies": {
"@tailwindcss/vite": "^4.1.10",
"@tailwindcss/vite": "^4.1.11",
"@types/crypto-js": "^4.2.2",
"@types/node": "^18.14.0",
"@types/node": "^22.13.14",
"@types/nprogress": "^0.2.0",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@vitejs/plugin-vue": "^5.2.4",
"@typescript-eslint/eslint-plugin": "^8.35.0",
"@typescript-eslint/parser": "^8.35.0",
"@vitejs/plugin-vue": "^6.0.0",
"@vue/compiler-sfc": "^3.5.17",
"autoprefixer": "^10.4.21",
"code-inspector-plugin": "^0.20.9",
"dotenv": "^16.3.1",
"eslint": "^9.27.0",
"code-inspector-plugin": "^0.20.12",
"dotenv": "^16.5.0",
"eslint": "^9.29.0",
"eslint-plugin-vue": "^10.2.0",
"postcss": "^8.5.6",
"prettier": "^3.5.3",
"prettier": "^3.6.1",
"sass": "^1.89.2",
"tailwindcss": "^4.1.10",
"typescript": "^5.8.2",
"tailwindcss": "^4.1.11",
"typescript": "^5.8.3",
"vite": "npm:rolldown-vite@latest",
"vite-plugin-progress": "0.0.7",
"vue-eslint-parser": "^10.1.3"
"vue-eslint-parser": "^10.1.4"
},
"browserslist": [
"> 1%",

View File

@@ -77,9 +77,6 @@ const viteConfig: UserConfig = {
},
},
},
esbuild: {
drop: isProd ? ['console', 'debugger'] : [],
},
define: {
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
__VUE_I18N_FULL_INSTALL__: JSON.stringify(false),
@@ -100,11 +97,6 @@ const viteConfig: UserConfig = {
},
],
},
preprocessorOptions: {
scss: {
api: 'modern-compiler', // or 'modern'
},
},
},
};

View File

@@ -19,15 +19,15 @@ require (
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20250508043914-ed57fa5c5274
github.com/may-fly/cast v1.7.1
github.com/microsoft/go-mssqldb v1.8.2
github.com/microsoft/go-mssqldb v1.9.1
github.com/mojocn/base64Captcha v1.3.8 //
github.com/pkg/errors v0.9.1
github.com/pkg/sftp v1.13.9
github.com/pquerna/otp v1.5.0
github.com/redis/go-redis/v9 v9.10.0
github.com/redis/go-redis/v9 v9.11.0
github.com/robfig/cron/v3 v3.0.1 //
github.com/sijms/go-ora/v2 v2.9.0
github.com/spf13/cast v1.9.2
github.com/stretchr/testify v1.10.0
github.com/tidwall/gjson v1.18.0
github.com/veops/go-ansiterm v0.0.5
@@ -91,7 +91,7 @@ require (
golang.org/x/arch v0.14.0 // indirect
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
golang.org/x/image v0.23.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.26.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect

View File

@@ -1,10 +1,11 @@
package config
import (
"cmp"
sysapp "mayfly-go/internal/sys/application"
"mayfly-go/pkg/utils/stringx"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (
@@ -28,8 +29,8 @@ func GetAccountLoginSecurity() *AccountLoginSecurity {
als := new(AccountLoginSecurity)
als.UseCaptcha = c.ConvBool(jm["useCaptcha"], true)
als.UseOtp = c.ConvBool(jm["useOtp"], false)
als.LoginFailCount = cast.ToIntD(jm["loginFailCount"], 5)
als.LoginFailMin = cast.ToIntD(jm["loginFailMin"], 10)
als.LoginFailCount = cmp.Or(cast.ToInt(jm["loginFailCount"]), 5)
als.LoginFailMin = cmp.Or(cast.ToInt(jm["loginFailMin"]), 10)
otpIssuer := jm["otpIssuer"]
if otpIssuer == "" {
otpIssuer = "mayfly-go"

View File

@@ -29,7 +29,7 @@ import (
"strings"
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type Db struct {

View File

@@ -13,7 +13,7 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type DataSyncTask struct {

View File

@@ -17,7 +17,7 @@ import (
"mayfly-go/pkg/utils/collx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type Instance struct {

View File

@@ -7,7 +7,7 @@ import (
"mayfly-go/pkg/req"
"mayfly-go/pkg/utils/collx"
"github.com/may-fly/cast"
"github.com/spf13/cast"
"strings"
)

View File

@@ -15,7 +15,7 @@ import (
"mayfly-go/pkg/req"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type DbTransferTask struct {

View File

@@ -23,7 +23,7 @@ import (
"time"
"github.com/google/uuid"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type DataSyncTask interface {

View File

@@ -6,7 +6,7 @@ import (
"path/filepath"
"runtime"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (
@@ -29,7 +29,7 @@ func GetDbms() *Dbms {
dbmsConf := new(Dbms)
dbmsConf.QuerySqlSave = c.ConvBool(jm["querySqlSave"], false)
dbmsConf.MaxResultSet = cast.ToInt(jm["maxResultSet"])
dbmsConf.SqlExecTl = cast.ToIntD(jm["sqlExecTl"], 60)
dbmsConf.SqlExecTl = cmp.Or(cast.ToInt(jm["sqlExecTl"]), 60)
return dbmsConf
}

View File

@@ -10,7 +10,7 @@ import (
"strings"
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
var (

View File

@@ -10,7 +10,7 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (

View File

@@ -9,7 +9,7 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (

View File

@@ -9,7 +9,7 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (

View File

@@ -6,7 +6,7 @@ import (
"mayfly-go/pkg/utils/collx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type SQLGenerator struct {

View File

@@ -8,8 +8,8 @@ import (
"mayfly-go/pkg/utils/collx"
"strings"
"github.com/may-fly/cast"
go_ora "github.com/sijms/go-ora/v2"
"github.com/spf13/cast"
)
func init() {

View File

@@ -8,7 +8,7 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
// ---------------------------------- DM元数据 -----------------------------------

View File

@@ -6,7 +6,7 @@ import (
"mayfly-go/pkg/utils/collx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (

View File

@@ -5,7 +5,7 @@ import (
"mayfly-go/internal/db/dbm/dbi"
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type PgsqlDialect struct {

View File

@@ -8,7 +8,7 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (

View File

@@ -10,7 +10,7 @@ import (
"regexp"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (

View File

@@ -6,7 +6,7 @@ import (
mysqlparser "mayfly-go/internal/db/dbm/sqlparser/mysql/antlr4"
"mayfly-go/internal/db/dbm/sqlparser/sqlstmt"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type MysqlVisitor struct {

View File

@@ -6,7 +6,7 @@ import (
pgparser "mayfly-go/internal/db/dbm/sqlparser/pgsql/antlr4"
"mayfly-go/internal/db/dbm/sqlparser/sqlstmt"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type PgsqlVisitor struct {

View File

@@ -19,7 +19,7 @@ import (
"net/url"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type Instance struct {

View File

@@ -16,7 +16,7 @@ import (
"path/filepath"
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type File interface {

View File

@@ -1,9 +1,10 @@
package config
import (
"cmp"
sysapp "mayfly-go/internal/sys/application"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (
@@ -19,6 +20,6 @@ func GetFileConfig() *FileConfig {
jm := c.GetJsonMap()
fc := new(FileConfig)
fc.BasePath = cast.ToStringD(jm["basePath"], "./file")
fc.BasePath = cmp.Or(cast.ToString(jm["basePath"]), "./file")
return fc
}

View File

@@ -18,7 +18,7 @@ import (
"mayfly-go/pkg/utils/structx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type Procdef struct {

View File

@@ -11,7 +11,7 @@ import (
"mayfly-go/pkg/global"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
/******************* 用户任务节点 *******************/

View File

@@ -11,7 +11,7 @@ import (
"mayfly-go/pkg/model"
"mayfly-go/pkg/utils/stringx"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type ProcinstTask interface {

View File

@@ -9,7 +9,7 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
// 流程定义信息

View File

@@ -28,7 +28,7 @@ import (
"time"
"github.com/gorilla/websocket"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type Machine struct {

View File

@@ -17,7 +17,7 @@ import (
"mayfly-go/pkg/scheduler"
"mayfly-go/pkg/utils/collx"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type MachineCronJob struct {

View File

@@ -30,8 +30,8 @@ import (
"strings"
"sync"
"github.com/may-fly/cast"
"github.com/pkg/sftp"
"github.com/spf13/cast"
)
type MachineFile struct {

View File

@@ -14,7 +14,7 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type MachineScript struct {

View File

@@ -1,11 +1,12 @@
package config
import (
"cmp"
sysapp "mayfly-go/internal/sys/application"
"mayfly-go/pkg/logx"
"mayfly-go/pkg/utils/bytex"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (
@@ -38,11 +39,11 @@ func GetMachine() *Machine {
}
}
mc.UploadMaxFileSize = uploadMaxFileSize
mc.TermOpSaveDays = cast.ToIntD(jm["termOpSaveDays"], 30)
mc.TermOpSaveDays = cmp.Or(cast.ToInt(jm["termOpSaveDays"]), 30)
// guacd
mc.GuacdHost = cast.ToString(jm["guacdHost"])
mc.GuacdPort = cast.ToIntD(jm["guacdPort"], 4822)
mc.GuacdFilePath = cast.ToStringD(jm["guacdFilePath"], "")
mc.GuacdPort = cmp.Or(cast.ToInt(jm["guacdPort"]), 4822)
mc.GuacdFilePath = cast.ToString(jm["guacdFilePath"])
return mc
}

View File

@@ -5,8 +5,8 @@ import (
"mayfly-go/pkg/logx"
"strings"
"github.com/may-fly/cast"
"github.com/pkg/sftp"
"github.com/spf13/cast"
"golang.org/x/crypto/ssh"
)

View File

@@ -1,13 +1,14 @@
package mcm
import (
"cmp"
"context"
"fmt"
"io"
"mayfly-go/pkg/errorx"
"mayfly-go/pkg/logx"
"github.com/may-fly/cast"
"github.com/spf13/cast"
"strings"
"time"
@@ -258,15 +259,15 @@ func parseMsg(msg []byte) (*WsMsg, error) {
}
// 获取消息类型, 提取第一个 "|" 之前的内容
msgType := cast.ToIntD(msgStr[:index], Ping)
msgType := cmp.Or(cast.ToInt(msgStr[:index]), Ping)
// 其余内容则为消息内容
msgContent := msgStr[index+1:]
wsMsg := &WsMsg{Type: msgType, Msg: msgContent}
if msgType == Resize {
rowsAndCols := strings.Split(msgContent, MsgSplit)
wsMsg.Rows = cast.ToIntD(rowsAndCols[0], 80)
wsMsg.Cols = cast.ToIntD(rowsAndCols[1], 80)
wsMsg.Rows = cmp.Or(cast.ToInt(rowsAndCols[0]), 80)
wsMsg.Cols = cmp.Or(cast.ToInt(rowsAndCols[1]), 80)
}
return wsMsg, nil
}

View File

@@ -19,7 +19,7 @@ import (
"regexp"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo/options"

View File

@@ -9,7 +9,7 @@ import (
"mayfly-go/pkg/req"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type MsgChannel struct {

View File

@@ -12,7 +12,7 @@ import (
"mayfly-go/pkg/utils/jsonx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type MsgTmpl struct {

View File

@@ -11,7 +11,7 @@ import (
"net/smtp"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type EmailSender struct{}

View File

@@ -14,7 +14,7 @@ import (
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type feishuBotMsgReq struct {

View File

@@ -20,8 +20,8 @@ import (
"mayfly-go/pkg/utils/stringx"
"strings"
"github.com/may-fly/cast"
"github.com/redis/go-redis/v9"
"github.com/spf13/cast"
)
type Redis struct {

View File

@@ -24,8 +24,8 @@ import (
"strconv"
"strings"
"github.com/may-fly/cast"
"github.com/redis/go-redis/v9"
"github.com/spf13/cast"
)
type Redis interface {

View File

@@ -1,6 +1,6 @@
package rdm
import "github.com/may-fly/cast"
import "github.com/spf13/cast"
// write cmd
var writeCmd = map[string]string{

View File

@@ -18,7 +18,7 @@ import (
"strings"
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (

View File

@@ -11,7 +11,7 @@ import (
"mayfly-go/pkg/utils/collx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type Role struct {

View File

@@ -1,10 +1,11 @@
package entity
import (
"cmp"
"encoding/json"
"mayfly-go/pkg/model"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
const (
@@ -50,7 +51,7 @@ func (c *Config) IntValue(defaultValue int) int {
if c.Id == 0 {
return defaultValue
}
return cast.ToIntD(c.Value, defaultValue)
return cmp.Or(cast.ToInt(c.Value), defaultValue)
}
// 转换配置中的值为bool类型默认"1"或"true"为true其他为false

View File

@@ -11,7 +11,7 @@ import (
"mayfly-go/pkg/req"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type ResourceAuthCert struct {

View File

@@ -16,7 +16,7 @@ import (
"mayfly-go/pkg/utils/collx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type Team struct {

View File

@@ -18,7 +18,7 @@ import (
"slices"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type TagTree interface {

View File

@@ -7,7 +7,7 @@ import (
"strings"
"testing"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
func TestTagPath(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"mayfly-go/pkg/utils/collx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type TypePath string

View File

@@ -7,7 +7,7 @@ import (
"mayfly-go/pkg/utils/collx"
"strings"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
// 标签树

View File

@@ -5,7 +5,7 @@ import (
"mayfly-go/pkg/utils/anyx"
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type Cache interface {

View File

@@ -4,7 +4,7 @@ import (
"strings"
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
type LocalCache struct {

View File

@@ -14,7 +14,7 @@ import (
"os"
"time"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
// 默认超时

View File

@@ -5,7 +5,7 @@ import (
"encoding/json"
"mayfly-go/pkg/utils/anyx"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
// M is a shortcut for map[string]any

View File

@@ -6,7 +6,7 @@ import (
"strings"
"testing"
"github.com/may-fly/cast"
"github.com/spf13/cast"
)
func TestTemplateParse(t *testing.T) {