mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 00:10:25 +08:00 
			
		
		
		
	refactor: 去除无用的getter方法
This commit is contained in:
		@@ -10,13 +10,13 @@ require (
 | 
				
			|||||||
	github.com/gin-gonic/gin v1.9.1
 | 
						github.com/gin-gonic/gin v1.9.1
 | 
				
			||||||
	github.com/glebarez/sqlite v1.10.0
 | 
						github.com/glebarez/sqlite v1.10.0
 | 
				
			||||||
	github.com/go-gormigrate/gormigrate/v2 v2.1.0
 | 
						github.com/go-gormigrate/gormigrate/v2 v2.1.0
 | 
				
			||||||
	github.com/go-ldap/ldap/v3 v3.4.5
 | 
						github.com/go-ldap/ldap/v3 v3.4.6
 | 
				
			||||||
	github.com/go-playground/locales v0.14.1
 | 
						github.com/go-playground/locales v0.14.1
 | 
				
			||||||
	github.com/go-playground/universal-translator v0.18.1
 | 
						github.com/go-playground/universal-translator v0.18.1
 | 
				
			||||||
	github.com/go-playground/validator/v10 v10.14.0
 | 
						github.com/go-playground/validator/v10 v10.14.0
 | 
				
			||||||
	github.com/go-sql-driver/mysql v1.7.1
 | 
						github.com/go-sql-driver/mysql v1.7.1
 | 
				
			||||||
	github.com/golang-jwt/jwt/v5 v5.2.0
 | 
						github.com/golang-jwt/jwt/v5 v5.2.0
 | 
				
			||||||
	github.com/google/uuid v1.3.0
 | 
						github.com/google/uuid v1.3.1
 | 
				
			||||||
	github.com/gorilla/websocket v1.5.1
 | 
						github.com/gorilla/websocket v1.5.1
 | 
				
			||||||
	github.com/kanzihuang/vitess/go/vt/sqlparser v0.0.0-20231018071450-ac8d9f0167e9
 | 
						github.com/kanzihuang/vitess/go/vt/sqlparser v0.0.0-20231018071450-ac8d9f0167e9
 | 
				
			||||||
	github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230712084735-068dc2aee82d
 | 
						github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230712084735-068dc2aee82d
 | 
				
			||||||
@@ -26,7 +26,7 @@ require (
 | 
				
			|||||||
	github.com/pquerna/otp v1.4.0
 | 
						github.com/pquerna/otp v1.4.0
 | 
				
			||||||
	github.com/redis/go-redis/v9 v9.4.0
 | 
						github.com/redis/go-redis/v9 v9.4.0
 | 
				
			||||||
	github.com/robfig/cron/v3 v3.0.1 // 定时任务
 | 
						github.com/robfig/cron/v3 v3.0.1 // 定时任务
 | 
				
			||||||
	github.com/sijms/go-ora/v2 v2.8.6
 | 
						github.com/sijms/go-ora/v2 v2.8.7
 | 
				
			||||||
	github.com/stretchr/testify v1.8.4
 | 
						github.com/stretchr/testify v1.8.4
 | 
				
			||||||
	go.mongodb.org/mongo-driver v1.13.1 // mongo
 | 
						go.mongodb.org/mongo-driver v1.13.1 // mongo
 | 
				
			||||||
	golang.org/x/crypto v0.18.0 // ssh
 | 
						golang.org/x/crypto v0.18.0 // ssh
 | 
				
			||||||
@@ -36,7 +36,7 @@ require (
 | 
				
			|||||||
	gopkg.in/yaml.v3 v3.0.1
 | 
						gopkg.in/yaml.v3 v3.0.1
 | 
				
			||||||
	// gorm
 | 
						// gorm
 | 
				
			||||||
	gorm.io/driver/mysql v1.5.2
 | 
						gorm.io/driver/mysql v1.5.2
 | 
				
			||||||
	gorm.io/gorm v1.25.5
 | 
						gorm.io/gorm v1.25.6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,7 +52,7 @@ require (
 | 
				
			|||||||
	github.com/gabriel-vasile/mimetype v1.4.2 // indirect
 | 
						github.com/gabriel-vasile/mimetype v1.4.2 // indirect
 | 
				
			||||||
	github.com/gin-contrib/sse v0.1.0 // indirect
 | 
						github.com/gin-contrib/sse v0.1.0 // indirect
 | 
				
			||||||
	github.com/glebarez/go-sqlite v1.21.2 // indirect
 | 
						github.com/glebarez/go-sqlite v1.21.2 // indirect
 | 
				
			||||||
	github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
 | 
						github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
 | 
				
			||||||
	github.com/goccy/go-json v0.10.2 // indirect
 | 
						github.com/goccy/go-json v0.10.2 // indirect
 | 
				
			||||||
	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
 | 
						github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
 | 
				
			||||||
	github.com/golang/glog v1.0.0 // indirect
 | 
						github.com/golang/glog v1.0.0 // indirect
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,3 @@ func InitIoc() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	ioc.Register(new(oauth2AppImpl), ioc.WithComponentName("Oauth2App"))
 | 
						ioc.Register(new(oauth2AppImpl), ioc.WithComponentName("Oauth2App"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetAuthApp() Oauth2 {
 | 
					 | 
				
			||||||
	return ioc.Get[Oauth2]("Oauth2App")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,9 @@
 | 
				
			|||||||
package persistence
 | 
					package persistence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"mayfly-go/internal/auth/domain/repository"
 | 
					 | 
				
			||||||
	"mayfly-go/pkg/ioc"
 | 
						"mayfly-go/pkg/ioc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Init() {
 | 
					func Init() {
 | 
				
			||||||
	ioc.Register(newAuthAccountRepo(), ioc.WithComponentName("Oauth2AccountRepo"))
 | 
						ioc.Register(newAuthAccountRepo(), ioc.WithComponentName("Oauth2AccountRepo"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetOauthAccountRepo() repository.Oauth2Account {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Oauth2Account]("Oauth2AccountRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,22 +34,6 @@ func Init() {
 | 
				
			|||||||
	})()
 | 
						})()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func GetInstanceApp() Instance {
 | 
					 | 
				
			||||||
	return ioc.Get[Instance]("DbInstance")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbApp() Db {
 | 
					 | 
				
			||||||
	return ioc.Get[Db]("DbApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbSqlApp() DbSql {
 | 
					 | 
				
			||||||
	return ioc.Get[DbSql]("DbSqlApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbSqlExecApp() DbSqlExec {
 | 
					 | 
				
			||||||
	return ioc.Get[DbSqlExec]("DbSqlExecApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbBackupApp() *DbBackupApp {
 | 
					func GetDbBackupApp() *DbBackupApp {
 | 
				
			||||||
	return ioc.Get[*DbBackupApp]("DbBackupApp")
 | 
						return ioc.Get[*DbBackupApp]("DbBackupApp")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,6 +45,8 @@ type dataSyncAppImpl struct {
 | 
				
			|||||||
	base.AppImpl[*entity.DataSyncTask, repository.DataSyncTask]
 | 
						base.AppImpl[*entity.DataSyncTask, repository.DataSyncTask]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dbDataSyncLogRepo repository.DataSyncLog `inject:"DbDataSyncLogRepo"`
 | 
						dbDataSyncLogRepo repository.DataSyncLog `inject:"DbDataSyncLogRepo"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dbApp Db `inject:"DbApp"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
@@ -130,7 +132,7 @@ func (app *dataSyncAppImpl) RunCronJob(id uint64) error {
 | 
				
			|||||||
		updSql := ""
 | 
							updSql := ""
 | 
				
			||||||
		orderSql := ""
 | 
							orderSql := ""
 | 
				
			||||||
		if task.UpdFieldVal != "0" && task.UpdFieldVal != "" && task.UpdField != "" {
 | 
							if task.UpdFieldVal != "0" && task.UpdFieldVal != "" && task.UpdField != "" {
 | 
				
			||||||
			srcConn, _ := GetDbApp().GetDbConn(uint64(task.SrcDbId), task.SrcDbName)
 | 
								srcConn, _ := app.dbApp.GetDbConn(uint64(task.SrcDbId), task.SrcDbName)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			task.UpdFieldVal = strings.Trim(task.UpdFieldVal, " ")
 | 
								task.UpdFieldVal = strings.Trim(task.UpdFieldVal, " ")
 | 
				
			||||||
			// 把UpdFieldVal尝试转为int,如果可以转为int,则不添加引号,否则添加引号
 | 
								// 把UpdFieldVal尝试转为int,如果可以转为int,则不添加引号,否则添加引号
 | 
				
			||||||
@@ -173,13 +175,13 @@ func (app *dataSyncAppImpl) doDataSync(sql string, task *entity.DataSyncTask) (*
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 获取源数据库连接
 | 
						// 获取源数据库连接
 | 
				
			||||||
	srcConn, err := GetDbApp().GetDbConn(uint64(task.SrcDbId), task.SrcDbName)
 | 
						srcConn, err := app.dbApp.GetDbConn(uint64(task.SrcDbId), task.SrcDbName)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return syncLog, errorx.NewBiz("连接源数据库失败: %s", err.Error())
 | 
							return syncLog, errorx.NewBiz("连接源数据库失败: %s", err.Error())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 获取目标数据库连接
 | 
						// 获取目标数据库连接
 | 
				
			||||||
	targetConn, err := GetDbApp().GetDbConn(uint64(task.TargetDbId), task.TargetDbName)
 | 
						targetConn, err := app.dbApp.GetDbConn(uint64(task.TargetDbId), task.TargetDbName)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return syncLog, errorx.NewBiz("连接目标数据库失败: %s", err.Error())
 | 
							return syncLog, errorx.NewBiz("连接目标数据库失败: %s", err.Error())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
package persistence
 | 
					package persistence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"mayfly-go/internal/db/domain/repository"
 | 
					 | 
				
			||||||
	"mayfly-go/pkg/ioc"
 | 
						"mayfly-go/pkg/ioc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -20,35 +19,3 @@ func Init() {
 | 
				
			|||||||
	ioc.Register(NewDbBinlogRepo(), ioc.WithComponentName("DbBinlogRepo"))
 | 
						ioc.Register(NewDbBinlogRepo(), ioc.WithComponentName("DbBinlogRepo"))
 | 
				
			||||||
	ioc.Register(NewDbBinlogHistoryRepo(), ioc.WithComponentName("DbBinlogHistoryRepo"))
 | 
						ioc.Register(NewDbBinlogHistoryRepo(), ioc.WithComponentName("DbBinlogHistoryRepo"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetInstanceRepo() repository.Instance {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Instance]("DbInstanceRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbRepo() repository.Db {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Db]("DbRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbSqlRepo() repository.DbSql {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.DbSql]("DbSqlRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbSqlExecRepo() repository.DbSqlExec {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.DbSqlExec]("DbSqlExecRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbBackupHistoryRepo() repository.DbBackupHistory {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.DbBackupHistory]("DbBackupHistoryRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDbRestoreHistoryRepo() repository.DbRestoreHistory {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.DbRestoreHistory]("DbRestoreHistoryRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDataSyncLogRepo() repository.DataSyncLog {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.DataSyncLog]("DataSyncLogRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetDataSyncTaskRepo() repository.DataSyncTask {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.DataSyncTask]("DataSyncTaskRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,10 +28,6 @@ func GetMachineScriptApp() MachineScript {
 | 
				
			|||||||
	return ioc.Get[MachineScript]("MachineScriptApp")
 | 
						return ioc.Get[MachineScript]("MachineScriptApp")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func GetAuthCertApp() AuthCert {
 | 
					 | 
				
			||||||
	return ioc.Get[AuthCert]("AuthCertApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMachineCronJobApp() MachineCronJob {
 | 
					func GetMachineCronJobApp() MachineCronJob {
 | 
				
			||||||
	return ioc.Get[MachineCronJob]("MachineCronJobApp")
 | 
						return ioc.Get[MachineCronJob]("MachineCronJobApp")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
package persistence
 | 
					package persistence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"mayfly-go/internal/machine/domain/repository"
 | 
					 | 
				
			||||||
	"mayfly-go/pkg/ioc"
 | 
						"mayfly-go/pkg/ioc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,35 +14,3 @@ func Init() {
 | 
				
			|||||||
	ioc.Register(newMachineCronJobRelateRepo(), ioc.WithComponentName("MachineCronJobRelateRepo"))
 | 
						ioc.Register(newMachineCronJobRelateRepo(), ioc.WithComponentName("MachineCronJobRelateRepo"))
 | 
				
			||||||
	ioc.Register(newMachineTermOpRepoImpl(), ioc.WithComponentName("MachineTermOpRepo"))
 | 
						ioc.Register(newMachineTermOpRepoImpl(), ioc.WithComponentName("MachineTermOpRepo"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMachineRepo() repository.Machine {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Machine]("MachineRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMachineFileRepo() repository.MachineFile {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.MachineFile]("MachineFileRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMachineScriptRepo() repository.MachineScript {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.MachineScript]("MachineScriptRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetAuthCertRepo() repository.AuthCert {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.AuthCert]("AuthCertRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMachineCronJobRepo() repository.MachineCronJob {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.MachineCronJob]("MachineCronJobRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMachineCronJobExecRepo() repository.MachineCronJobExec {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.MachineCronJobExec]("MachineCronJobExecRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMachineCronJobRelateRepo() repository.MachineCronJobRelate {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.MachineCronJobRelate]("MachineCropJobRelateRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMachineTermOpRepo() repository.MachineTermOp {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.MachineTermOp]("MachineTermOpRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,3 @@ func InitIoc() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	ioc.Register(new(mongoAppImpl), ioc.WithComponentName("MongoApp"))
 | 
						ioc.Register(new(mongoAppImpl), ioc.WithComponentName("MongoApp"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMongoApp() Mongo {
 | 
					 | 
				
			||||||
	return ioc.Get[Mongo]("MongoApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,9 @@
 | 
				
			|||||||
package persistence
 | 
					package persistence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"mayfly-go/internal/mongo/domain/repository"
 | 
					 | 
				
			||||||
	"mayfly-go/pkg/ioc"
 | 
						"mayfly-go/pkg/ioc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Init() {
 | 
					func Init() {
 | 
				
			||||||
	ioc.Register(newMongoRepo(), ioc.WithComponentName("MongoRepo"))
 | 
						ioc.Register(newMongoRepo(), ioc.WithComponentName("MongoRepo"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMongoRepo() repository.Mongo {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Mongo]("MongoRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,9 @@
 | 
				
			|||||||
package persistence
 | 
					package persistence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"mayfly-go/internal/msg/domain/repository"
 | 
					 | 
				
			||||||
	"mayfly-go/pkg/ioc"
 | 
						"mayfly-go/pkg/ioc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Init() {
 | 
					func Init() {
 | 
				
			||||||
	ioc.Register(newMsgRepo(), ioc.WithComponentName("MsgRepo"))
 | 
						ioc.Register(newMsgRepo(), ioc.WithComponentName("MsgRepo"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMsgRepo() repository.Msg {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Msg]("msgRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,3 @@ func InitIoc() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	ioc.Register(new(redisAppImpl), ioc.WithComponentName("RedisApp"))
 | 
						ioc.Register(new(redisAppImpl), ioc.WithComponentName("RedisApp"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetRedisApp() Redis {
 | 
					 | 
				
			||||||
	return ioc.Get[Redis]("RedisApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,9 @@
 | 
				
			|||||||
package persistence
 | 
					package persistence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"mayfly-go/internal/redis/domain/repository"
 | 
					 | 
				
			||||||
	"mayfly-go/pkg/ioc"
 | 
						"mayfly-go/pkg/ioc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Init() {
 | 
					func Init() {
 | 
				
			||||||
	ioc.Register(newRedisRepo(), ioc.WithComponentName("RedisRepo"))
 | 
						ioc.Register(newRedisRepo(), ioc.WithComponentName("RedisRepo"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetRedisRepo() repository.Redis {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Redis]("RedisRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,14 +23,6 @@ func GetConfigApp() Config {
 | 
				
			|||||||
	return ioc.Get[Config]("ConfigApp")
 | 
						return ioc.Get[Config]("ConfigApp")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func GetResourceApp() Resource {
 | 
					 | 
				
			||||||
	return ioc.Get[Resource]("ResourceApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetRoleApp() Role {
 | 
					 | 
				
			||||||
	return ioc.Get[Role]("RoleApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetSyslogApp() Syslog {
 | 
					func GetSyslogApp() Syslog {
 | 
				
			||||||
	return ioc.Get[Syslog]("SyslogApp")
 | 
						return ioc.Get[Syslog]("SyslogApp")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
package persistence
 | 
					package persistence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"mayfly-go/internal/sys/domain/repository"
 | 
					 | 
				
			||||||
	"mayfly-go/pkg/ioc"
 | 
						"mayfly-go/pkg/ioc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -13,27 +12,3 @@ func Init() {
 | 
				
			|||||||
	ioc.Register(newConfigRepo(), ioc.WithComponentName("ConfigRepo"))
 | 
						ioc.Register(newConfigRepo(), ioc.WithComponentName("ConfigRepo"))
 | 
				
			||||||
	ioc.Register(newSyslogRepo(), ioc.WithComponentName("SyslogRepo"))
 | 
						ioc.Register(newSyslogRepo(), ioc.WithComponentName("SyslogRepo"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetAccountRepo() repository.Account {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Account]("AccountRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetConfigRepo() repository.Config {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Config]("ConfigRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetResourceRepo() repository.Resource {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Resource]("ResourceRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetRoleRepo() repository.Role {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Role]("RoleRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetAccountRoleRepo() repository.AccountRole {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.AccountRole]("AccountRoleRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetSyslogRepo() repository.Syslog {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Syslog]("SyslogRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,15 +12,3 @@ func InitIoc() {
 | 
				
			|||||||
	ioc.Register(new(teamAppImpl), ioc.WithComponentName("TeamApp"))
 | 
						ioc.Register(new(teamAppImpl), ioc.WithComponentName("TeamApp"))
 | 
				
			||||||
	ioc.Register(new(tagResourceAppImpl), ioc.WithComponentName("TagResourceApp"))
 | 
						ioc.Register(new(tagResourceAppImpl), ioc.WithComponentName("TagResourceApp"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetTagTreeApp() TagTree {
 | 
					 | 
				
			||||||
	return ioc.Get[TagTree]("TagTreeApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetTeamApp() Team {
 | 
					 | 
				
			||||||
	return ioc.Get[Team]("TeamApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetTagResourceApp() TagResource {
 | 
					 | 
				
			||||||
	return ioc.Get[TagResource]("TagResourceApp")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
package persistence
 | 
					package persistence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"mayfly-go/internal/tag/domain/repository"
 | 
					 | 
				
			||||||
	"mayfly-go/pkg/ioc"
 | 
						"mayfly-go/pkg/ioc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -12,23 +11,3 @@ func Init() {
 | 
				
			|||||||
	ioc.Register(newTeamRepo(), ioc.WithComponentName("TeamRepo"))
 | 
						ioc.Register(newTeamRepo(), ioc.WithComponentName("TeamRepo"))
 | 
				
			||||||
	ioc.Register(newTeamMemberRepo(), ioc.WithComponentName("TeamMemberRepo"))
 | 
						ioc.Register(newTeamMemberRepo(), ioc.WithComponentName("TeamMemberRepo"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetTagTreeRepo() repository.TagTree {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.TagTree]("TagTreeRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetTagTreeTeamRepo() repository.TagTreeTeam {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.TagTreeTeam]("TagTreeTeamRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetTagResourceRepo() repository.TagResource {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.TagResource]("TagResourceRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetTeamRepo() repository.Team {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.Team]("TeamRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetTeamMemberRepo() repository.TeamMember {
 | 
					 | 
				
			||||||
	return ioc.Get[repository.TeamMember]("TeamMemberRepo")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,7 +67,7 @@ func (c *Container) Inject(obj any) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// 对所有组件实例执行Inject。即为实例字段注入依赖的组件实例
 | 
					// 对所有组件实例执行Inject。即为实例字段注入依赖的组件实例
 | 
				
			||||||
func (c *Container) InjectComponents() error {
 | 
					func (c *Container) InjectComponents() error {
 | 
				
			||||||
	componentsGroups := collx.ArraySplit[*Component](collx.MapValues(c.components), 10)
 | 
						componentsGroups := collx.ArraySplit[*Component](collx.MapValues(c.components), 3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
						ctx, cancel := context.WithCancel(context.Background())
 | 
				
			||||||
	defer cancel()
 | 
						defer cancel()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user