From 9e8efe81439bf68a4e239ebba78af43f7a56d105 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 15 Mar 2025 03:43:10 +0800 Subject: [PATCH 01/19] feat: draft gorm --- .../internal/data/migration/migration.go | 23 ++++ .../internal/data/migration/migration_test.go | 19 +++ app/sephirah/internal/data/migration/v1.go | 120 ++++++++++++++++++ app/sephirah/internal/data/migration/v2.go | 21 +++ go.mod | 10 +- go.sum | 16 ++- 6 files changed, 202 insertions(+), 7 deletions(-) create mode 100644 app/sephirah/internal/data/migration/migration.go create mode 100644 app/sephirah/internal/data/migration/migration_test.go create mode 100644 app/sephirah/internal/data/migration/v1.go create mode 100644 app/sephirah/internal/data/migration/v2.go diff --git a/app/sephirah/internal/data/migration/migration.go b/app/sephirah/internal/data/migration/migration.go new file mode 100644 index 00000000..c17e2b67 --- /dev/null +++ b/app/sephirah/internal/data/migration/migration.go @@ -0,0 +1,23 @@ +package migration + +import "gorm.io/gorm" + +type latestVersion struct { + v2 +} + +type Migration struct { + migrator latestVersion +} + +func NewMigration(db *gorm.DB) *Migration { + m := latestVersion{} + m.init(db) + return &Migration{ + migrator: m, + } +} + +func (m *Migration) Migrate() error { + return m.migrator.migrate() +} diff --git a/app/sephirah/internal/data/migration/migration_test.go b/app/sephirah/internal/data/migration/migration_test.go new file mode 100644 index 00000000..13be4d68 --- /dev/null +++ b/app/sephirah/internal/data/migration/migration_test.go @@ -0,0 +1,19 @@ +package migration_test + +import ( + "github.com/tuihub/librarian/app/sephirah/internal/data/migration" + "gorm.io/driver/sqlite" + "gorm.io/gorm" + "testing" +) + +func TestNewMigration(t *testing.T) { + db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{}) + if err != nil { + t.Fatalf("Failed to open database: %v", err) + } + err = migration.NewMigration(db).Migrate() + if err != nil { + t.Fatalf("Failed to migrate: %v", err) + } +} diff --git a/app/sephirah/internal/data/migration/v1.go b/app/sephirah/internal/data/migration/v1.go new file mode 100644 index 00000000..c66d41f9 --- /dev/null +++ b/app/sephirah/internal/data/migration/v1.go @@ -0,0 +1,120 @@ +package migration + +import ( + "errors" + "time" + + "github.com/tuihub/librarian/internal/model" + + "gorm.io/gorm" +) + +type v1 struct { + useTxForMigration *gorm.DB + tx *gorm.DB + targetVersion *uint + curVersion *uint +} + +func (v *v1) init(db *gorm.DB) { + v.useTxForMigration = db +} + +func (v *v1) migrate() error { + version := new(Version) + version.Version = 1 + if !v.tx.Migrator().HasTable(version) { + err := v.tx.Migrator().CreateTable(version) + if err != nil { + return err + } + } + err := v.tx.Create(version).Error + if err != nil { + return err + } + v.curVersion = &version.Version + return nil +} + +func (v *v1) migrateWrapper(migrateVersion uint, doPreMigration func() error, doMigration func() error) error { + var err error + if v.targetVersion == nil { + v.targetVersion = &migrateVersion + v.tx = v.useTxForMigration.Begin() + defer func() { + if e := recover(); e != nil { + v.tx.Rollback() + panic(e) + } + v.targetVersion = nil + v.curVersion = nil + v.tx = nil + if err != nil { + v.tx.Rollback() + } else { + err = v.tx.Commit().Error + } + }() + } + + if v.curVersion == nil { + version := new(Version) + // check if the version table exists + if !v.tx.Migrator().HasTable(version) { + var cv uint = 0 + v.curVersion = &cv + } else { + err = v.tx.Order("version desc").First(version).Error + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return err + } + v.curVersion = &version.Version + } + } + + if *v.curVersion > migrateVersion { + return errors.New("database version is newer than the migration version") + } + + if *v.curVersion == migrateVersion { + return err + } + + if *v.curVersion < migrateVersion-1 { + err = doPreMigration() + if err != nil { + return err + } + } + + if *v.curVersion != migrateVersion-1 { + return errors.New("invalid migration sequence") + } + + err = doMigration() + if err != nil { + return err + } + err = v.tx.Create(&Version{Version: migrateVersion}).Error + if err != nil { + return err + } + v.curVersion = &migrateVersion + + return err +} + +type Version struct { + Version uint `gorm:"primaryKey"` + CreatedAt time.Time + UpdatedAt time.Time + DeletedAt gorm.DeletedAt `gorm:"index"` +} + +type Model struct { + ID model.InternalID `gorm:"primarykey"` + CreatedAt time.Time + UpdatedAt time.Time + DeletedAt gorm.DeletedAt `gorm:"index"` +} diff --git a/app/sephirah/internal/data/migration/v2.go b/app/sephirah/internal/data/migration/v2.go new file mode 100644 index 00000000..48f2b52d --- /dev/null +++ b/app/sephirah/internal/data/migration/v2.go @@ -0,0 +1,21 @@ +package migration + +type v2 struct { + v1 +} + +func (v *v2) migrate() error { + return v.migrateWrapper(2, v.v1.migrate, func() error { + type User struct { + Model + Username string + Password string + Status string + Type string + } + if err := v.tx.Migrator().CreateTable(new(User)); err != nil { + return err + } + return nil + }) +} diff --git a/go.mod b/go.mod index d2e598c6..1f906a58 100644 --- a/go.mod +++ b/go.mod @@ -49,10 +49,11 @@ require ( go.uber.org/ratelimit v0.3.1 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.35.0 - golang.org/x/exp v0.0.0-20250228200357-dead58393ab7 google.golang.org/grpc v1.70.0 google.golang.org/protobuf v1.36.5 gopkg.in/natefinch/lumberjack.v2 v2.2.1 + gorm.io/driver/sqlite v1.5.7 + gorm.io/gorm v1.25.12 ) require ( @@ -126,6 +127,8 @@ require ( github.com/hashicorp/hcl/v2 v2.16.1 // indirect github.com/hashicorp/serf v0.10.1 // indirect github.com/jhump/protoreflect v1.15.1 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect github.com/jonboulle/clockwork v0.5.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -171,11 +174,12 @@ require ( go.shabbyrobe.org/gocovmerge v0.0.0-20230507111327-fa4f82cfbf4d // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.11.0 // indirect + golang.org/x/exp v0.0.0-20250228200357-dead58393ab7 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/net v0.35.0 // indirect - golang.org/x/sync v0.11.0 // indirect + golang.org/x/sync v0.12.0 // indirect golang.org/x/sys v0.30.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/text v0.23.0 // indirect golang.org/x/tools v0.30.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect diff --git a/go.sum b/go.sum index 6806795f..92df5551 100644 --- a/go.sum +++ b/go.sum @@ -423,6 +423,10 @@ github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7 github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -861,8 +865,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -948,8 +952,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1057,6 +1061,10 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I= +gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4= +gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= +gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From fc94093d63262ea7dc4e6dce4dcac3629c4d6412 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 15 Mar 2025 21:13:42 +0800 Subject: [PATCH 02/19] feat: refactor --- app/sephirah/cmd/sephirah/wire.go | 10 ++-- app/sephirah/cmd/sephirah/wire_gen.go | 54 +++++++++---------- app/sephirah/internal/biz/biz.go | 24 --------- app/sephirah/internal/data/angela.go | 10 ++-- app/sephirah/internal/data/binah.go | 2 +- app/sephirah/internal/data/chesed.go | 4 +- app/sephirah/internal/data/gebura.go | 4 +- .../data/internal/converter/biz_to_ent.go | 12 ++--- .../data/internal/converter/converter.go | 4 +- .../data/internal/converter/ent_to_biz.go | 12 ++--- .../data/internal/converter/generated.go | 12 ++--- .../data/internal/ent/feedactionset.go | 2 +- .../data/internal/ent/feedactionset_create.go | 2 +- .../data/internal/ent/feedactionset_update.go | 2 +- .../internal/data/internal/ent/feedconfig.go | 2 +- .../data/internal/ent/feedconfig_create.go | 2 +- .../data/internal/ent/feedconfig_update.go | 2 +- .../internal/data/internal/ent/mutation.go | 2 +- .../data/internal/ent/notifytarget.go | 2 +- .../data/internal/ent/notifytarget_create.go | 2 +- .../data/internal/ent/notifytarget_update.go | 2 +- .../data/internal/ent/porterinstance.go | 2 +- .../internal/ent/porterinstance_create.go | 2 +- .../internal/ent/porterinstance_update.go | 2 +- .../internal/ent/schema/feed_action_set.go | 2 +- .../data/internal/ent/schema/feed_config.go | 2 +- .../data/internal/ent/schema/notify_target.go | 2 +- .../internal/ent/schema/porter_instance.go | 2 +- app/sephirah/internal/data/netzach.go | 4 +- app/sephirah/internal/data/tiphereth.go | 6 +-- app/sephirah/internal/data/yesod.go | 6 +-- app/sephirah/pkg/service/wire.go | 10 ++-- app/sephirah/pkg/service/wire_gen.go | 54 +++++++++---------- internal/biz/biz.go | 24 +++++++++ .../biz/bizangela/account.go | 8 +-- .../biz/bizangela/angela.go | 14 ++--- .../biz/bizangela/app.go | 8 +-- .../biz/bizangela/feed.go | 10 ++-- .../biz/bizangela/index.go | 2 +- .../biz/bizangela/notify.go | 8 +-- .../biz/bizangela/porter.go | 4 +- .../biz/bizbinah/binah.go | 2 +- .../biz/bizbinah/presigned.go | 0 .../biz/bizbinah/simple.go | 2 +- .../biz/bizchesed/chesed.go | 8 +-- .../biz/bizgebura/app.go | 4 +- .../biz/bizgebura/app_info.go | 8 +-- .../biz/bizgebura/app_inst.go | 4 +- .../biz/bizgebura/gebura.go | 6 +-- .../biz/bizgebura/run_time.go | 2 +- .../biz/biznetzach/netzach.go | 8 +-- .../biz/biznetzach/system.go | 2 +- .../biz/biztiphereth/account.go | 4 +- .../biz/biztiphereth/porter.go | 6 +-- .../biz/biztiphereth/tiphereth.go | 6 +-- .../biz/biztiphereth/token.go | 4 +- .../biz/biztiphereth/user.go | 4 +- .../biz/bizutils/utils.go | 0 .../biz/bizyesod/builtin_action.go | 4 +- .../biz/bizyesod/collection.go | 4 +- .../biz/bizyesod/feed.go | 4 +- .../biz/bizyesod/feed_action.go | 4 +- .../biz/bizyesod/feed_config.go | 4 +- .../biz/bizyesod/yesod.go | 10 ++-- .../client}/client/client.go | 0 .../client}/client/porter.go | 0 .../client}/client/porter_static_discovery.go | 0 .../data/db}/migration/migration.go | 0 .../data/db}/migration/migration_test.go | 6 ++- .../data => internal/data/db}/migration/v1.go | 0 .../data => internal/data/db}/migration/v2.go | 0 .../model/converter/biz_to_pb.go | 10 ++-- .../model/converter/converter.go | 0 .../model/converter/generated.go | 12 ++--- .../model/converter/pb_to_biz.go | 12 ++--- .../model/modelangela/modelangela.go | 4 +- .../model/modelbinah/callback.go | 0 .../model/modelbinah/control.go | 0 .../model/modelbinah/modelbinah.go | 0 .../model/modelchesed/modelchesed.go | 4 +- .../model/modelgebura/modelgebura.go | 0 .../model/modelnetzach/modelnetzach.go | 2 +- .../model/modelsupervisor/modelsupervisor.go | 2 +- .../model/modeltiphereth/modeltiphereth.go | 0 .../model/modelyesod/builtin_action.go | 0 .../model/modelyesod/builtin_action_test.go | 2 +- .../model/modelyesod/modelyesod.go | 4 +- .../service/sephirah}/binah.go | 2 +- .../service/sephirah}/chesed.go | 6 +-- .../service/sephirah}/gebura.go | 4 +- .../sephirah}/librariansephirahservice.go | 20 +++---- .../service/sephirah}/netzach.go | 4 +- .../service/sephirah}/porter.go | 4 +- .../service/sephirah}/service.go | 2 +- .../service/sephirah}/tiphereth.go | 8 +-- .../service/sephirah}/yesod.go | 4 +- .../service}/supervisor/feature.go | 4 +- .../service}/supervisor/summary.go | 2 +- .../service}/supervisor/supervisor.go | 10 ++-- .../service}/supervisor/task.go | 6 +-- 100 files changed, 287 insertions(+), 287 deletions(-) delete mode 100644 app/sephirah/internal/biz/biz.go create mode 100644 internal/biz/biz.go rename {app/sephirah/internal => internal}/biz/bizangela/account.go (92%) rename {app/sephirah/internal => internal}/biz/bizangela/angela.go (87%) rename {app/sephirah/internal => internal}/biz/bizangela/app.go (90%) rename {app/sephirah/internal => internal}/biz/bizangela/feed.go (94%) rename {app/sephirah/internal => internal}/biz/bizangela/index.go (92%) rename {app/sephirah/internal => internal}/biz/bizangela/notify.go (95%) rename {app/sephirah/internal => internal}/biz/bizangela/porter.go (82%) rename {app/sephirah/internal => internal}/biz/bizbinah/binah.go (93%) rename {app/sephirah/internal => internal}/biz/bizbinah/presigned.go (100%) rename {app/sephirah/internal => internal}/biz/bizbinah/simple.go (94%) rename {app/sephirah/internal => internal}/biz/bizchesed/chesed.go (96%) rename {app/sephirah/internal => internal}/biz/bizgebura/app.go (96%) rename {app/sephirah/internal => internal}/biz/bizgebura/app_info.go (96%) rename {app/sephirah/internal => internal}/biz/bizgebura/app_inst.go (92%) rename {app/sephirah/internal => internal}/biz/bizgebura/gebura.go (94%) rename {app/sephirah/internal => internal}/biz/bizgebura/run_time.go (95%) rename {app/sephirah/internal => internal}/biz/biznetzach/netzach.go (96%) rename {app/sephirah/internal => internal}/biz/biznetzach/system.go (89%) rename {app/sephirah/internal => internal}/biz/biztiphereth/account.go (93%) rename {app/sephirah/internal => internal}/biz/biztiphereth/porter.go (95%) rename {app/sephirah/internal => internal}/biz/biztiphereth/tiphereth.go (97%) rename {app/sephirah/internal => internal}/biz/biztiphereth/token.go (98%) rename {app/sephirah/internal => internal}/biz/biztiphereth/user.go (98%) rename {app/sephirah/internal => internal}/biz/bizutils/utils.go (100%) rename {app/sephirah/internal => internal}/biz/bizyesod/builtin_action.go (97%) rename {app/sephirah/internal => internal}/biz/bizyesod/collection.go (95%) rename {app/sephirah/internal => internal}/biz/bizyesod/feed.go (97%) rename {app/sephirah/internal => internal}/biz/bizyesod/feed_action.go (92%) rename {app/sephirah/internal => internal}/biz/bizyesod/feed_config.go (94%) rename {app/sephirah/internal => internal}/biz/bizyesod/yesod.go (94%) rename {app/sephirah/internal => internal/client}/client/client.go (100%) rename {app/sephirah/internal => internal/client}/client/porter.go (100%) rename {app/sephirah/internal => internal/client}/client/porter_static_discovery.go (100%) rename {app/sephirah/internal/data => internal/data/db}/migration/migration.go (100%) rename {app/sephirah/internal/data => internal/data/db}/migration/migration_test.go (84%) rename {app/sephirah/internal/data => internal/data/db}/migration/v1.go (100%) rename {app/sephirah/internal/data => internal/data/db}/migration/v2.go (100%) rename {app/sephirah/internal => internal}/model/converter/biz_to_pb.go (97%) rename {app/sephirah/internal => internal}/model/converter/converter.go (100%) rename {app/sephirah/internal => internal}/model/converter/generated.go (99%) mode change 100755 => 100644 rename {app/sephirah/internal => internal}/model/converter/pb_to_biz.go (96%) rename {app/sephirah/internal => internal}/model/modelangela/modelangela.go (85%) rename {app/sephirah/internal => internal}/model/modelbinah/callback.go (100%) rename {app/sephirah/internal => internal}/model/modelbinah/control.go (100%) rename {app/sephirah/internal => internal}/model/modelbinah/modelbinah.go (100%) rename {app/sephirah/internal => internal}/model/modelchesed/modelchesed.go (90%) rename {app/sephirah/internal => internal}/model/modelgebura/modelgebura.go (100%) rename {app/sephirah/internal => internal}/model/modelnetzach/modelnetzach.go (97%) rename {app/sephirah/internal => internal}/model/modelsupervisor/modelsupervisor.go (98%) rename {app/sephirah/internal => internal}/model/modeltiphereth/modeltiphereth.go (100%) rename {app/sephirah/internal => internal}/model/modelyesod/builtin_action.go (100%) rename {app/sephirah/internal => internal}/model/modelyesod/builtin_action_test.go (91%) rename {app/sephirah/internal => internal}/model/modelyesod/modelyesod.go (93%) rename {app/sephirah/internal/service => internal/service/sephirah}/binah.go (99%) rename {app/sephirah/internal/service => internal/service/sephirah}/chesed.go (93%) rename {app/sephirah/internal/service => internal/service/sephirah}/gebura.go (99%) rename {app/sephirah/internal/service => internal/service/sephirah}/librariansephirahservice.go (80%) rename {app/sephirah/internal/service => internal/service/sephirah}/netzach.go (97%) rename {app/sephirah/internal/service => internal/service/sephirah}/porter.go (88%) rename {app/sephirah/internal/service => internal/service/sephirah}/service.go (88%) rename {app/sephirah/internal/service => internal/service/sephirah}/tiphereth.go (97%) rename {app/sephirah/internal/service => internal/service/sephirah}/yesod.go (99%) rename {app/sephirah/internal => internal/service}/supervisor/feature.go (95%) rename {app/sephirah/internal => internal/service}/supervisor/summary.go (96%) rename {app/sephirah/internal => internal/service}/supervisor/supervisor.go (97%) rename {app/sephirah/internal => internal/service}/supervisor/task.go (94%) diff --git a/app/sephirah/cmd/sephirah/wire.go b/app/sephirah/cmd/sephirah/wire.go index 44cf4548..156aa363 100644 --- a/app/sephirah/cmd/sephirah/wire.go +++ b/app/sephirah/cmd/sephirah/wire.go @@ -5,12 +5,10 @@ package main import ( - "github.com/tuihub/librarian/app/sephirah/internal/biz" - "github.com/tuihub/librarian/app/sephirah/internal/client" "github.com/tuihub/librarian/app/sephirah/internal/data" - "github.com/tuihub/librarian/app/sephirah/internal/service" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" + "github.com/tuihub/librarian/internal/biz" globalclient "github.com/tuihub/librarian/internal/client" + "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" @@ -21,6 +19,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libobserve" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/server" + "github.com/tuihub/librarian/internal/service/sephirah" + "github.com/tuihub/librarian/internal/service/supervisor" "github.com/go-kratos/kratos/v2" "github.com/google/wire" @@ -46,7 +46,7 @@ func wireApp( biz.ProviderSet, client.ProviderSet, supervisor.ProviderSet, - service.ProviderSet, + sephirah.ProviderSet, libauth.ProviderSet, libmq.ProviderSet, libcron.ProviderSet, diff --git a/app/sephirah/cmd/sephirah/wire_gen.go b/app/sephirah/cmd/sephirah/wire_gen.go index c17d6816..c072dd73 100644 --- a/app/sephirah/cmd/sephirah/wire_gen.go +++ b/app/sephirah/cmd/sephirah/wire_gen.go @@ -8,18 +8,16 @@ package main import ( "github.com/go-kratos/kratos/v2" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizangela" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizbinah" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizchesed" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizgebura" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biznetzach" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biztiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizyesod" - "github.com/tuihub/librarian/app/sephirah/internal/client" "github.com/tuihub/librarian/app/sephirah/internal/data" - "github.com/tuihub/librarian/app/sephirah/internal/service" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" + bizangela2 "github.com/tuihub/librarian/internal/biz/bizangela" + "github.com/tuihub/librarian/internal/biz/bizbinah" + "github.com/tuihub/librarian/internal/biz/bizchesed" + "github.com/tuihub/librarian/internal/biz/bizgebura" + biznetzach2 "github.com/tuihub/librarian/internal/biz/biznetzach" + "github.com/tuihub/librarian/internal/biz/biztiphereth" + "github.com/tuihub/librarian/internal/biz/bizyesod" client2 "github.com/tuihub/librarian/internal/client" + "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" @@ -30,6 +28,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libobserve" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/server" + "github.com/tuihub/librarian/internal/service/sephirah" + "github.com/tuihub/librarian/internal/service/supervisor" ) // Injectors from wire.go: @@ -70,7 +70,7 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c } netzachRepo := data.NewNetzachRepo(dataData) idGenerator := libidgenerator.NewIDGenerator() - topic := biznetzach.NewSystemNotificationTopic(netzachRepo, idGenerator) + topic := biznetzach2.NewSystemNotificationTopic(netzachRepo, idGenerator) tipherethRepo := data.NewTipherethRepo(dataData) store, err := libcache.NewStore(cache) if err != nil { @@ -93,25 +93,25 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c cleanup() return nil, nil, err } - angelaBase, err := bizangela.NewAngelaBase(angelaRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, libsearchSearch, idGenerator) + angelaBase, err := bizangela2.NewAngelaBase(angelaRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, libsearchSearch, idGenerator) if err != nil { cleanup2() cleanup() return nil, nil, err } - map3 := bizangela.NewAppInfoCache(geburaRepo, store) - libmqTopic := bizangela.NewUpdateAppInfoIndexTopic(angelaBase) - topic2 := bizangela.NewPullAppInfoTopic(angelaBase, map3, libmqTopic) - topic3 := bizangela.NewPullAccountAppInfoRelationTopic(angelaBase, topic2) - topic4 := bizangela.NewPullAccountTopic(angelaBase, topic3) - map4 := bizangela.NewNotifyFlowCache(netzachRepo, store) - map5 := bizangela.NewFeedToNotifyFlowCache(netzachRepo, store) - map6 := bizangela.NewNotifyTargetCache(netzachRepo, store) - topic5 := bizangela.NewNotifyPushTopic(angelaBase, map6) - topic6 := bizangela.NewNotifyRouterTopic(angelaBase, map4, map5, topic5) - topic7 := bizangela.NewFeedItemPostprocessTopic(angelaBase, topic6, topic) - topic8 := bizangela.NewPullFeedTopic(angelaBase, topic7, topic) - angela, err := bizangela.NewAngela(angelaBase, libmqMQ, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) + map3 := bizangela2.NewAppInfoCache(geburaRepo, store) + libmqTopic := bizangela2.NewUpdateAppInfoIndexTopic(angelaBase) + topic2 := bizangela2.NewPullAppInfoTopic(angelaBase, map3, libmqTopic) + topic3 := bizangela2.NewPullAccountAppInfoRelationTopic(angelaBase, topic2) + topic4 := bizangela2.NewPullAccountTopic(angelaBase, topic3) + map4 := bizangela2.NewNotifyFlowCache(netzachRepo, store) + map5 := bizangela2.NewFeedToNotifyFlowCache(netzachRepo, store) + map6 := bizangela2.NewNotifyTargetCache(netzachRepo, store) + topic5 := bizangela2.NewNotifyPushTopic(angelaBase, map6) + topic6 := bizangela2.NewNotifyRouterTopic(angelaBase, map4, map5, topic5) + topic7 := bizangela2.NewFeedItemPostprocessTopic(angelaBase, topic6, topic) + topic8 := bizangela2.NewPullFeedTopic(angelaBase, topic7, topic) + angela, err := bizangela2.NewAngela(angelaBase, libmqMQ, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) if err != nil { cleanup2() cleanup() @@ -147,7 +147,7 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c cleanup() return nil, nil, err } - netzach, err := biznetzach.NewNetzach(netzachRepo, supervisorSupervisor, idGenerator, libsearchSearch, libmqMQ, map5, map4, map6, topic) + netzach, err := biznetzach2.NewNetzach(netzachRepo, supervisorSupervisor, idGenerator, libsearchSearch, libmqMQ, map5, map4, map6, topic) if err != nil { cleanup2() cleanup() @@ -167,7 +167,7 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c cleanup() return nil, nil, err } - librarianSephirahServiceServer := service.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, libauthAuth, sephirahServer) + librarianSephirahServiceServer := sephirah.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, libauthAuth, sephirahServer) grpcServer, err := server.NewGRPCServer(sephirahServer, libauthAuth, librarianSephirahServiceServer, settings, builtInObserver) if err != nil { cleanup2() diff --git a/app/sephirah/internal/biz/biz.go b/app/sephirah/internal/biz/biz.go deleted file mode 100644 index 2fa06761..00000000 --- a/app/sephirah/internal/biz/biz.go +++ /dev/null @@ -1,24 +0,0 @@ -package biz - -import ( - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizangela" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizbinah" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizchesed" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizgebura" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biznetzach" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biztiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizyesod" - - "github.com/google/wire" -) - -// ProviderSet is biz providers. -var ProviderSet = wire.NewSet( - bizangela.ProviderSet, - biztiphereth.ProviderSet, - bizgebura.NewGebura, - bizbinah.ProviderSet, - bizyesod.ProviderSet, - biznetzach.ProviderSet, - bizchesed.ProviderSet, -) diff --git a/app/sephirah/internal/data/angela.go b/app/sephirah/internal/data/angela.go index 3b1063b7..52279a31 100644 --- a/app/sephirah/internal/data/angela.go +++ b/app/sephirah/internal/data/angela.go @@ -4,7 +4,6 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizangela" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" @@ -15,12 +14,13 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/biz/bizangela" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" "entgo.io/ent/dialect/sql" ) diff --git a/app/sephirah/internal/data/binah.go b/app/sephirah/internal/data/binah.go index 71f3203f..9b7c742a 100644 --- a/app/sephirah/internal/data/binah.go +++ b/app/sephirah/internal/data/binah.go @@ -6,7 +6,7 @@ import ( "net/url" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizbinah" + "github.com/tuihub/librarian/internal/biz/bizbinah" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/logger" diff --git a/app/sephirah/internal/data/chesed.go b/app/sephirah/internal/data/chesed.go index ad1615f6..8c48cdb1 100644 --- a/app/sephirah/internal/data/chesed.go +++ b/app/sephirah/internal/data/chesed.go @@ -3,12 +3,12 @@ package data import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizchesed" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" + "github.com/tuihub/librarian/internal/biz/bizchesed" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelchesed" ) type chesedRepo struct { diff --git a/app/sephirah/internal/data/gebura.go b/app/sephirah/internal/data/gebura.go index 8e698553..b5bf713f 100644 --- a/app/sephirah/internal/data/gebura.go +++ b/app/sephirah/internal/data/gebura.go @@ -5,7 +5,6 @@ import ( "errors" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizgebura" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" @@ -13,8 +12,9 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/biz/bizgebura" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelgebura" ) type geburaRepo struct { diff --git a/app/sephirah/internal/data/internal/converter/biz_to_ent.go b/app/sephirah/internal/data/internal/converter/biz_to_ent.go index 403b73f0..6c1a550c 100644 --- a/app/sephirah/internal/data/internal/converter/biz_to_ent.go +++ b/app/sephirah/internal/data/internal/converter/biz_to_ent.go @@ -12,13 +12,13 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libauth" + "github.com/tuihub/librarian/internal/model/modelchesed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" ) // goverter:converter diff --git a/app/sephirah/internal/data/internal/converter/converter.go b/app/sephirah/internal/data/internal/converter/converter.go index e63d8c21..a6f95518 100644 --- a/app/sephirah/internal/data/internal/converter/converter.go +++ b/app/sephirah/internal/data/internal/converter/converter.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelyesod" ) //go:generate go run github.com/jmattheis/goverter/cmd/goverter gen . diff --git a/app/sephirah/internal/data/internal/converter/ent_to_biz.go b/app/sephirah/internal/data/internal/converter/ent_to_biz.go index de3ae0bb..6d912392 100644 --- a/app/sephirah/internal/data/internal/converter/ent_to_biz.go +++ b/app/sephirah/internal/data/internal/converter/ent_to_biz.go @@ -14,14 +14,14 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libauth" + "github.com/tuihub/librarian/internal/model/modelchesed" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" ) // goverter:converter diff --git a/app/sephirah/internal/data/internal/converter/generated.go b/app/sephirah/internal/data/internal/converter/generated.go index 9c1d4b1e..4a241abb 100644 --- a/app/sephirah/internal/data/internal/converter/generated.go +++ b/app/sephirah/internal/data/internal/converter/generated.go @@ -15,15 +15,15 @@ import ( porterinstance "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" systemnotification "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" user "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - modelchesed "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" - modelgebura "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - modelnetzach "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - modelsupervisor "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - modeltiphereth "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - modelyesod "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" libauth "github.com/tuihub/librarian/internal/lib/libauth" model "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelchesed" modelfeed "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" "time" ) diff --git a/app/sephirah/internal/data/internal/ent/feedactionset.go b/app/sephirah/internal/data/internal/ent/feedactionset.go index e495e33e..127d599e 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset.go +++ b/app/sephirah/internal/data/internal/ent/feedactionset.go @@ -5,6 +5,7 @@ package ent import ( "encoding/json" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "strings" "time" @@ -12,7 +13,6 @@ import ( "entgo.io/ent/dialect/sql" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedactionset_create.go b/app/sephirah/internal/data/internal/ent/feedactionset_create.go index 204fe235..4e8e7585 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset_create.go +++ b/app/sephirah/internal/data/internal/ent/feedactionset_create.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" @@ -14,7 +15,6 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedactionset_update.go b/app/sephirah/internal/data/internal/ent/feedactionset_update.go index 4134842d..8d8891da 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset_update.go +++ b/app/sephirah/internal/data/internal/ent/feedactionset_update.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" @@ -16,7 +17,6 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfig.go b/app/sephirah/internal/data/internal/ent/feedconfig.go index 23b04ab7..6d04e281 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig.go +++ b/app/sephirah/internal/data/internal/ent/feedconfig.go @@ -5,6 +5,7 @@ package ent import ( "encoding/json" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "strings" "time" @@ -13,7 +14,6 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfig_create.go b/app/sephirah/internal/data/internal/ent/feedconfig_create.go index 96cb1bc1..d0db3986 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig_create.go +++ b/app/sephirah/internal/data/internal/ent/feedconfig_create.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" @@ -17,7 +18,6 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfig_update.go b/app/sephirah/internal/data/internal/ent/feedconfig_update.go index 7548f410..ee3bbcf5 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig_update.go +++ b/app/sephirah/internal/data/internal/ent/feedconfig_update.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" @@ -18,7 +19,6 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/mutation.go b/app/sephirah/internal/data/internal/ent/mutation.go index 86178320..2fdf6ec8 100644 --- a/app/sephirah/internal/data/internal/ent/mutation.go +++ b/app/sephirah/internal/data/internal/ent/mutation.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "sync" "time" @@ -39,7 +40,6 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) diff --git a/app/sephirah/internal/data/internal/ent/notifytarget.go b/app/sephirah/internal/data/internal/ent/notifytarget.go index 53a3035e..aa7b76e0 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget.go +++ b/app/sephirah/internal/data/internal/ent/notifytarget.go @@ -5,6 +5,7 @@ package ent import ( "encoding/json" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "strings" "time" @@ -12,7 +13,6 @@ import ( "entgo.io/ent/dialect/sql" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifytarget_create.go b/app/sephirah/internal/data/internal/ent/notifytarget_create.go index 0e3cf31b..c7e3f054 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget_create.go +++ b/app/sephirah/internal/data/internal/ent/notifytarget_create.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" @@ -15,7 +16,6 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifytarget_update.go b/app/sephirah/internal/data/internal/ent/notifytarget_update.go index d176c04e..2918fcd8 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget_update.go +++ b/app/sephirah/internal/data/internal/ent/notifytarget_update.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" @@ -16,7 +17,6 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/porterinstance.go b/app/sephirah/internal/data/internal/ent/porterinstance.go index 9d5d3b5d..a67b4468 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance.go +++ b/app/sephirah/internal/data/internal/ent/porterinstance.go @@ -5,13 +5,13 @@ package ent import ( "encoding/json" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/porterinstance_create.go b/app/sephirah/internal/data/internal/ent/porterinstance_create.go index 0cd74429..03f2d475 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance_create.go +++ b/app/sephirah/internal/data/internal/ent/porterinstance_create.go @@ -6,13 +6,13 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/porterinstance_update.go b/app/sephirah/internal/data/internal/ent/porterinstance_update.go index e94cd401..a9279fa2 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance_update.go +++ b/app/sephirah/internal/data/internal/ent/porterinstance_update.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" @@ -13,7 +14,6 @@ import ( "entgo.io/ent/schema/field" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" ) // PorterInstanceUpdate is the builder for updating PorterInstance entities. diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go b/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go index 8648e0d4..a62c8874 100644 --- a/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go +++ b/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go @@ -3,7 +3,7 @@ package schema import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "entgo.io/ent" "entgo.io/ent/schema/edge" diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_config.go b/app/sephirah/internal/data/internal/ent/schema/feed_config.go index 5eefe32e..74ab460d 100644 --- a/app/sephirah/internal/data/internal/ent/schema/feed_config.go +++ b/app/sephirah/internal/data/internal/ent/schema/feed_config.go @@ -3,8 +3,8 @@ package schema import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "entgo.io/ent" "entgo.io/ent/schema/edge" diff --git a/app/sephirah/internal/data/internal/ent/schema/notify_target.go b/app/sephirah/internal/data/internal/ent/schema/notify_target.go index 0b4c713f..98bdf73d 100644 --- a/app/sephirah/internal/data/internal/ent/schema/notify_target.go +++ b/app/sephirah/internal/data/internal/ent/schema/notify_target.go @@ -3,7 +3,7 @@ package schema import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "entgo.io/ent" "entgo.io/ent/schema/edge" diff --git a/app/sephirah/internal/data/internal/ent/schema/porter_instance.go b/app/sephirah/internal/data/internal/ent/schema/porter_instance.go index 66b8051f..752867fc 100644 --- a/app/sephirah/internal/data/internal/ent/schema/porter_instance.go +++ b/app/sephirah/internal/data/internal/ent/schema/porter_instance.go @@ -3,7 +3,7 @@ package schema import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modelsupervisor" "entgo.io/ent" "entgo.io/ent/schema/field" diff --git a/app/sephirah/internal/data/netzach.go b/app/sephirah/internal/data/netzach.go index 48cab91f..d91fcc73 100644 --- a/app/sephirah/internal/data/netzach.go +++ b/app/sephirah/internal/data/netzach.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biznetzach" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" @@ -13,8 +12,9 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/biz/biznetzach" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelnetzach" "entgo.io/ent/dialect/sql" ) diff --git a/app/sephirah/internal/data/tiphereth.go b/app/sephirah/internal/data/tiphereth.go index 56a21fda..1aa666f8 100644 --- a/app/sephirah/internal/data/tiphereth.go +++ b/app/sephirah/internal/data/tiphereth.go @@ -4,7 +4,6 @@ import ( "context" "errors" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biztiphereth" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" @@ -14,10 +13,11 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/biz/biztiphereth" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" "entgo.io/ent/dialect/sql" ) diff --git a/app/sephirah/internal/data/yesod.go b/app/sephirah/internal/data/yesod.go index efcfbe48..1a7bf759 100644 --- a/app/sephirah/internal/data/yesod.go +++ b/app/sephirah/internal/data/yesod.go @@ -4,7 +4,6 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizyesod" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" @@ -13,11 +12,12 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/biz/bizyesod" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" ) type yesodRepo struct { diff --git a/app/sephirah/pkg/service/wire.go b/app/sephirah/pkg/service/wire.go index 9926df38..ffc28663 100644 --- a/app/sephirah/pkg/service/wire.go +++ b/app/sephirah/pkg/service/wire.go @@ -5,11 +5,9 @@ package service import ( - "github.com/tuihub/librarian/app/sephirah/internal/biz" - "github.com/tuihub/librarian/app/sephirah/internal/client" "github.com/tuihub/librarian/app/sephirah/internal/data" - "github.com/tuihub/librarian/app/sephirah/internal/service" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" + "github.com/tuihub/librarian/internal/biz" + "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" @@ -18,6 +16,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libidgenerator" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libsearch" + "github.com/tuihub/librarian/internal/service/sephirah" + "github.com/tuihub/librarian/internal/service/supervisor" miner "github.com/tuihub/protos/pkg/librarian/miner/v1" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" @@ -45,6 +45,6 @@ func NewSephirahService( biz.ProviderSet, client.ProviderSet, supervisor.ProviderSet, - service.ProviderSet, + sephirah.ProviderSet, )) } diff --git a/app/sephirah/pkg/service/wire_gen.go b/app/sephirah/pkg/service/wire_gen.go index 265774af..53126ff1 100644 --- a/app/sephirah/pkg/service/wire_gen.go +++ b/app/sephirah/pkg/service/wire_gen.go @@ -7,17 +7,15 @@ package service import ( - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizangela" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizbinah" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizchesed" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizgebura" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biznetzach" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biztiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizyesod" - "github.com/tuihub/librarian/app/sephirah/internal/client" "github.com/tuihub/librarian/app/sephirah/internal/data" - "github.com/tuihub/librarian/app/sephirah/internal/service" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" + bizangela2 "github.com/tuihub/librarian/internal/biz/bizangela" + "github.com/tuihub/librarian/internal/biz/bizbinah" + "github.com/tuihub/librarian/internal/biz/bizchesed" + "github.com/tuihub/librarian/internal/biz/bizgebura" + biznetzach2 "github.com/tuihub/librarian/internal/biz/biznetzach" + "github.com/tuihub/librarian/internal/biz/biztiphereth" + "github.com/tuihub/librarian/internal/biz/bizyesod" + "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" @@ -26,6 +24,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libidgenerator" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libsearch" + "github.com/tuihub/librarian/internal/service/sephirah" + "github.com/tuihub/librarian/internal/service/supervisor" "github.com/tuihub/protos/pkg/librarian/miner/v1" v1_2 "github.com/tuihub/protos/pkg/librarian/sephirah/v1" ) @@ -50,7 +50,7 @@ func NewSephirahService(sephirahServer *conf.SephirahServer, database *conf.Data return nil, nil, err } netzachRepo := data.NewNetzachRepo(dataData) - topic := biznetzach.NewSystemNotificationTopic(netzachRepo, idGenerator) + topic := biznetzach2.NewSystemNotificationTopic(netzachRepo, idGenerator) tipherethRepo := data.NewTipherethRepo(dataData) libcacheMap := biztiphereth.NewPorterInstanceCache(tipherethRepo, store) map2 := biztiphereth.NewPorterContextCache(tipherethRepo, store) @@ -60,24 +60,24 @@ func NewSephirahService(sephirahServer *conf.SephirahServer, database *conf.Data return nil, nil, err } geburaRepo := data.NewGeburaRepo(dataData) - angelaBase, err := bizangela.NewAngelaBase(angelaRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, search, idGenerator) + angelaBase, err := bizangela2.NewAngelaBase(angelaRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, search, idGenerator) if err != nil { cleanup() return nil, nil, err } - map3 := bizangela.NewAppInfoCache(geburaRepo, store) - libmqTopic := bizangela.NewUpdateAppInfoIndexTopic(angelaBase) - topic2 := bizangela.NewPullAppInfoTopic(angelaBase, map3, libmqTopic) - topic3 := bizangela.NewPullAccountAppInfoRelationTopic(angelaBase, topic2) - topic4 := bizangela.NewPullAccountTopic(angelaBase, topic3) - map4 := bizangela.NewNotifyFlowCache(netzachRepo, store) - map5 := bizangela.NewFeedToNotifyFlowCache(netzachRepo, store) - map6 := bizangela.NewNotifyTargetCache(netzachRepo, store) - topic5 := bizangela.NewNotifyPushTopic(angelaBase, map6) - topic6 := bizangela.NewNotifyRouterTopic(angelaBase, map4, map5, topic5) - topic7 := bizangela.NewFeedItemPostprocessTopic(angelaBase, topic6, topic) - topic8 := bizangela.NewPullFeedTopic(angelaBase, topic7, topic) - angela, err := bizangela.NewAngela(angelaBase, mq, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) + map3 := bizangela2.NewAppInfoCache(geburaRepo, store) + libmqTopic := bizangela2.NewUpdateAppInfoIndexTopic(angelaBase) + topic2 := bizangela2.NewPullAppInfoTopic(angelaBase, map3, libmqTopic) + topic3 := bizangela2.NewPullAccountAppInfoRelationTopic(angelaBase, topic2) + topic4 := bizangela2.NewPullAccountTopic(angelaBase, topic3) + map4 := bizangela2.NewNotifyFlowCache(netzachRepo, store) + map5 := bizangela2.NewFeedToNotifyFlowCache(netzachRepo, store) + map6 := bizangela2.NewNotifyTargetCache(netzachRepo, store) + topic5 := bizangela2.NewNotifyPushTopic(angelaBase, map6) + topic6 := bizangela2.NewNotifyRouterTopic(angelaBase, map4, map5, topic5) + topic7 := bizangela2.NewFeedItemPostprocessTopic(angelaBase, topic6, topic) + topic8 := bizangela2.NewPullFeedTopic(angelaBase, topic7, topic) + angela, err := bizangela2.NewAngela(angelaBase, mq, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) if err != nil { cleanup() return nil, nil, err @@ -103,7 +103,7 @@ func NewSephirahService(sephirahServer *conf.SephirahServer, database *conf.Data cleanup() return nil, nil, err } - netzach, err := biznetzach.NewNetzach(netzachRepo, supervisorSupervisor, idGenerator, search, mq, map5, map4, map6, topic) + netzach, err := biznetzach2.NewNetzach(netzachRepo, supervisorSupervisor, idGenerator, search, mq, map5, map4, map6, topic) if err != nil { cleanup() return nil, nil, err @@ -115,7 +115,7 @@ func NewSephirahService(sephirahServer *conf.SephirahServer, database *conf.Data cleanup() return nil, nil, err } - librarianSephirahServiceServer := service.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, auth, sephirahServer) + librarianSephirahServiceServer := sephirah.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, auth, sephirahServer) return librarianSephirahServiceServer, func() { cleanup() }, nil diff --git a/internal/biz/biz.go b/internal/biz/biz.go new file mode 100644 index 00000000..c461ebfa --- /dev/null +++ b/internal/biz/biz.go @@ -0,0 +1,24 @@ +package biz + +import ( + "github.com/tuihub/librarian/internal/biz/bizangela" + "github.com/tuihub/librarian/internal/biz/bizbinah" + "github.com/tuihub/librarian/internal/biz/bizchesed" + "github.com/tuihub/librarian/internal/biz/bizgebura" + "github.com/tuihub/librarian/internal/biz/biznetzach" + "github.com/tuihub/librarian/internal/biz/biztiphereth" + "github.com/tuihub/librarian/internal/biz/bizyesod" + + "github.com/google/wire" +) + +// ProviderSet is biz providers. +var ProviderSet = wire.NewSet( + bizangela.ProviderSet, + biztiphereth.ProviderSet, + bizgebura.NewGebura, + bizbinah.ProviderSet, + bizyesod.ProviderSet, + biznetzach.ProviderSet, + bizchesed.ProviderSet, +) diff --git a/app/sephirah/internal/biz/bizangela/account.go b/internal/biz/bizangela/account.go similarity index 92% rename from app/sephirah/internal/biz/bizangela/account.go rename to internal/biz/bizangela/account.go index cf8610cd..f2776009 100644 --- a/app/sephirah/internal/biz/bizangela/account.go +++ b/internal/biz/bizangela/account.go @@ -4,12 +4,12 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelangela" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modeltiphereth" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/app/sephirah/internal/biz/bizangela/angela.go b/internal/biz/bizangela/angela.go similarity index 87% rename from app/sephirah/internal/biz/bizangela/angela.go rename to internal/biz/bizangela/angela.go index 35f8efe0..de68beb8 100644 --- a/app/sephirah/internal/biz/bizangela/angela.go +++ b/internal/biz/bizangela/angela.go @@ -3,18 +3,18 @@ package bizangela import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" + "github.com/tuihub/librarian/internal/biz/bizgebura" "github.com/tuihub/librarian/internal/lib/libidgenerator" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/service/supervisor" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" "github.com/google/wire" diff --git a/app/sephirah/internal/biz/bizangela/app.go b/internal/biz/bizangela/app.go similarity index 90% rename from app/sephirah/internal/biz/bizangela/app.go rename to internal/biz/bizangela/app.go index 4d5b55a4..5446b3cd 100644 --- a/app/sephirah/internal/biz/bizangela/app.go +++ b/internal/biz/bizangela/app.go @@ -5,14 +5,14 @@ import ( "strconv" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/biz/bizgebura" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelangela" + "github.com/tuihub/librarian/internal/model/modelgebura" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/app/sephirah/internal/biz/bizangela/feed.go b/internal/biz/bizangela/feed.go similarity index 94% rename from app/sephirah/internal/biz/bizangela/feed.go rename to internal/biz/bizangela/feed.go index aeeec83f..f48daf6d 100644 --- a/app/sephirah/internal/biz/bizangela/feed.go +++ b/internal/biz/bizangela/feed.go @@ -7,13 +7,13 @@ import ( "sort" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizyesod" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/biz/bizyesod" "github.com/tuihub/librarian/internal/lib/libmq" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelyesod" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" ) diff --git a/app/sephirah/internal/biz/bizangela/index.go b/internal/biz/bizangela/index.go similarity index 92% rename from app/sephirah/internal/biz/bizangela/index.go rename to internal/biz/bizangela/index.go index 341eafdf..e7014339 100644 --- a/app/sephirah/internal/biz/bizangela/index.go +++ b/internal/biz/bizangela/index.go @@ -3,9 +3,9 @@ package bizangela import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libsearch" + "github.com/tuihub/librarian/internal/model/modelangela" ) func NewUpdateAppInfoIndexTopic( diff --git a/app/sephirah/internal/biz/bizangela/notify.go b/internal/biz/bizangela/notify.go similarity index 95% rename from app/sephirah/internal/biz/bizangela/notify.go rename to internal/biz/bizangela/notify.go index 85270256..a1b3ef5f 100644 --- a/app/sephirah/internal/biz/bizangela/notify.go +++ b/internal/biz/bizangela/notify.go @@ -6,15 +6,15 @@ import ( "strconv" "strings" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biznetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/biz/biznetzach" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelnetzach" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" ) diff --git a/app/sephirah/internal/biz/bizangela/porter.go b/internal/biz/bizangela/porter.go similarity index 82% rename from app/sephirah/internal/biz/bizangela/porter.go rename to internal/biz/bizangela/porter.go index 6187e44c..aeab9b54 100644 --- a/app/sephirah/internal/biz/bizangela/porter.go +++ b/internal/biz/bizangela/porter.go @@ -3,11 +3,11 @@ package bizangela import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) func (a *Angela) PorterGetNotifyTargetItems(ctx context.Context, id model.InternalID, paging model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) { diff --git a/app/sephirah/internal/biz/bizbinah/binah.go b/internal/biz/bizbinah/binah.go similarity index 93% rename from app/sephirah/internal/biz/bizbinah/binah.go rename to internal/biz/bizbinah/binah.go index 9c095f82..b091ee80 100644 --- a/app/sephirah/internal/biz/bizbinah/binah.go +++ b/internal/biz/bizbinah/binah.go @@ -5,8 +5,8 @@ import ( "io" "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelbinah" "github.com/tuihub/librarian/internal/lib/libauth" + "github.com/tuihub/librarian/internal/model/modelbinah" "github.com/google/wire" ) diff --git a/app/sephirah/internal/biz/bizbinah/presigned.go b/internal/biz/bizbinah/presigned.go similarity index 100% rename from app/sephirah/internal/biz/bizbinah/presigned.go rename to internal/biz/bizbinah/presigned.go diff --git a/app/sephirah/internal/biz/bizbinah/simple.go b/internal/biz/bizbinah/simple.go similarity index 94% rename from app/sephirah/internal/biz/bizbinah/simple.go rename to internal/biz/bizbinah/simple.go index 4d5333ca..21b07604 100644 --- a/app/sephirah/internal/biz/bizbinah/simple.go +++ b/internal/biz/bizbinah/simple.go @@ -6,8 +6,8 @@ import ( "os" "strconv" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelbinah" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelbinah" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/bizchesed/chesed.go b/internal/biz/bizchesed/chesed.go similarity index 96% rename from app/sephirah/internal/biz/bizchesed/chesed.go rename to internal/biz/bizchesed/chesed.go index a410b541..8816249f 100644 --- a/app/sephirah/internal/biz/bizchesed/chesed.go +++ b/internal/biz/bizchesed/chesed.go @@ -5,10 +5,8 @@ import ( "strconv" "sync" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizbinah" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelbinah" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" + "github.com/tuihub/librarian/internal/biz/bizbinah" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libcron" @@ -16,6 +14,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelbinah" + "github.com/tuihub/librarian/internal/model/modelchesed" miner "github.com/tuihub/protos/pkg/librarian/miner/v1" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" diff --git a/app/sephirah/internal/biz/bizgebura/app.go b/internal/biz/bizgebura/app.go similarity index 96% rename from app/sephirah/internal/biz/bizgebura/app.go rename to internal/biz/bizgebura/app.go index f8e671eb..3f26dea9 100644 --- a/app/sephirah/internal/biz/bizgebura/app.go +++ b/internal/biz/bizgebura/app.go @@ -3,10 +3,10 @@ package bizgebura import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelgebura" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/bizgebura/app_info.go b/internal/biz/bizgebura/app_info.go similarity index 96% rename from app/sephirah/internal/biz/bizgebura/app_info.go rename to internal/biz/bizgebura/app_info.go index 22287e38..9e906cf8 100644 --- a/app/sephirah/internal/biz/bizgebura/app_info.go +++ b/internal/biz/bizgebura/app_info.go @@ -5,13 +5,13 @@ import ( "fmt" "strconv" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelangela" + "github.com/tuihub/librarian/internal/model/modelgebura" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" diff --git a/app/sephirah/internal/biz/bizgebura/app_inst.go b/internal/biz/bizgebura/app_inst.go similarity index 92% rename from app/sephirah/internal/biz/bizgebura/app_inst.go rename to internal/biz/bizgebura/app_inst.go index d3cb8193..1bbd14a4 100644 --- a/app/sephirah/internal/biz/bizgebura/app_inst.go +++ b/internal/biz/bizgebura/app_inst.go @@ -3,10 +3,10 @@ package bizgebura import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelgebura" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/bizgebura/gebura.go b/internal/biz/bizgebura/gebura.go similarity index 94% rename from app/sephirah/internal/biz/bizgebura/gebura.go rename to internal/biz/bizgebura/gebura.go index c75d8d64..230337f5 100644 --- a/app/sephirah/internal/biz/bizgebura/gebura.go +++ b/internal/biz/bizgebura/gebura.go @@ -4,15 +4,15 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libidgenerator" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelangela" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/service/supervisor" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/bizgebura/run_time.go b/internal/biz/bizgebura/run_time.go similarity index 95% rename from app/sephirah/internal/biz/bizgebura/run_time.go rename to internal/biz/bizgebura/run_time.go index ec730803..59dea112 100644 --- a/app/sephirah/internal/biz/bizgebura/run_time.go +++ b/internal/biz/bizgebura/run_time.go @@ -4,7 +4,7 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" diff --git a/app/sephirah/internal/biz/biznetzach/netzach.go b/internal/biz/biznetzach/netzach.go similarity index 96% rename from app/sephirah/internal/biz/biznetzach/netzach.go rename to internal/biz/biznetzach/netzach.go index 56481e96..f7b5f305 100644 --- a/app/sephirah/internal/biz/biznetzach/netzach.go +++ b/internal/biz/biznetzach/netzach.go @@ -3,10 +3,7 @@ package biznetzach import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelangela" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libidgenerator" @@ -14,6 +11,9 @@ import ( "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelangela" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/service/supervisor" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/biznetzach/system.go b/internal/biz/biznetzach/system.go similarity index 89% rename from app/sephirah/internal/biz/biznetzach/system.go rename to internal/biz/biznetzach/system.go index d0c77b78..26bf841b 100644 --- a/app/sephirah/internal/biz/biznetzach/system.go +++ b/internal/biz/biznetzach/system.go @@ -3,9 +3,9 @@ package biznetzach import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/lib/libidgenerator" "github.com/tuihub/librarian/internal/lib/libmq" + "github.com/tuihub/librarian/internal/model/modelnetzach" ) func NewSystemNotificationTopic( diff --git a/app/sephirah/internal/biz/biztiphereth/account.go b/internal/biz/biztiphereth/account.go similarity index 93% rename from app/sephirah/internal/biz/biztiphereth/account.go rename to internal/biz/biztiphereth/account.go index cf5f2b12..81ab63d7 100644 --- a/app/sephirah/internal/biz/biztiphereth/account.go +++ b/internal/biz/biztiphereth/account.go @@ -3,11 +3,11 @@ package biztiphereth import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/biztiphereth/porter.go b/internal/biz/biztiphereth/porter.go similarity index 95% rename from app/sephirah/internal/biz/biztiphereth/porter.go rename to internal/biz/biztiphereth/porter.go index 027a162d..d9475b54 100644 --- a/app/sephirah/internal/biz/biztiphereth/porter.go +++ b/internal/biz/biztiphereth/porter.go @@ -3,12 +3,12 @@ package biztiphereth import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/biztiphereth/tiphereth.go b/internal/biz/biztiphereth/tiphereth.go similarity index 97% rename from app/sephirah/internal/biz/biztiphereth/tiphereth.go rename to internal/biz/biztiphereth/tiphereth.go index 86f74bc6..ea0f18e9 100644 --- a/app/sephirah/internal/biz/biztiphereth/tiphereth.go +++ b/internal/biz/biztiphereth/tiphereth.go @@ -4,9 +4,6 @@ import ( "context" "strconv" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" @@ -17,6 +14,9 @@ import ( "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/service/supervisor" "github.com/google/wire" ) diff --git a/app/sephirah/internal/biz/biztiphereth/token.go b/internal/biz/biztiphereth/token.go similarity index 98% rename from app/sephirah/internal/biz/biztiphereth/token.go rename to internal/biz/biztiphereth/token.go index 0e92d250..9bbd5d9a 100644 --- a/app/sephirah/internal/biz/biztiphereth/token.go +++ b/internal/biz/biztiphereth/token.go @@ -4,12 +4,12 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/biztiphereth/user.go b/internal/biz/biztiphereth/user.go similarity index 98% rename from app/sephirah/internal/biz/biztiphereth/user.go rename to internal/biz/biztiphereth/user.go index b864e660..14207fb9 100644 --- a/app/sephirah/internal/biz/biztiphereth/user.go +++ b/internal/biz/biztiphereth/user.go @@ -5,12 +5,12 @@ import ( "context" "strconv" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/dchest/captcha" diff --git a/app/sephirah/internal/biz/bizutils/utils.go b/internal/biz/bizutils/utils.go similarity index 100% rename from app/sephirah/internal/biz/bizutils/utils.go rename to internal/biz/bizutils/utils.go diff --git a/app/sephirah/internal/biz/bizyesod/builtin_action.go b/internal/biz/bizyesod/builtin_action.go similarity index 97% rename from app/sephirah/internal/biz/bizyesod/builtin_action.go rename to internal/biz/bizyesod/builtin_action.go index 26a4414a..5cccdfbc 100644 --- a/app/sephirah/internal/biz/bizyesod/builtin_action.go +++ b/internal/biz/bizyesod/builtin_action.go @@ -5,10 +5,10 @@ import ( "net/url" "strings" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libcodec" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modelyesod" "github.com/PuerkitoBio/goquery" ) diff --git a/app/sephirah/internal/biz/bizyesod/collection.go b/internal/biz/bizyesod/collection.go similarity index 95% rename from app/sephirah/internal/biz/bizyesod/collection.go rename to internal/biz/bizyesod/collection.go index e89de57f..01410f43 100644 --- a/app/sephirah/internal/biz/bizyesod/collection.go +++ b/internal/biz/bizyesod/collection.go @@ -3,10 +3,10 @@ package bizyesod import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelyesod" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/bizyesod/feed.go b/internal/biz/bizyesod/feed.go similarity index 97% rename from app/sephirah/internal/biz/bizyesod/feed.go rename to internal/biz/bizyesod/feed.go index fdb591a4..bfdc127e 100644 --- a/app/sephirah/internal/biz/bizyesod/feed.go +++ b/internal/biz/bizyesod/feed.go @@ -4,11 +4,11 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelyesod" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/bizyesod/feed_action.go b/internal/biz/bizyesod/feed_action.go similarity index 92% rename from app/sephirah/internal/biz/bizyesod/feed_action.go rename to internal/biz/bizyesod/feed_action.go index a52cc322..a9349e9b 100644 --- a/app/sephirah/internal/biz/bizyesod/feed_action.go +++ b/internal/biz/bizyesod/feed_action.go @@ -3,10 +3,10 @@ package bizyesod import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelyesod" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/bizyesod/feed_config.go b/internal/biz/bizyesod/feed_config.go similarity index 94% rename from app/sephirah/internal/biz/bizyesod/feed_config.go rename to internal/biz/bizyesod/feed_config.go index f48558a4..d0c542f8 100644 --- a/app/sephirah/internal/biz/bizyesod/feed_config.go +++ b/internal/biz/bizyesod/feed_config.go @@ -3,10 +3,10 @@ package bizyesod import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelyesod" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" diff --git a/app/sephirah/internal/biz/bizyesod/yesod.go b/internal/biz/bizyesod/yesod.go similarity index 94% rename from app/sephirah/internal/biz/bizyesod/yesod.go rename to internal/biz/bizyesod/yesod.go index b039d803..8260900d 100644 --- a/app/sephirah/internal/biz/bizyesod/yesod.go +++ b/internal/biz/bizyesod/yesod.go @@ -6,11 +6,6 @@ import ( "strconv" "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libcron" "github.com/tuihub/librarian/internal/lib/libidgenerator" @@ -20,6 +15,11 @@ import ( "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/service/supervisor" "github.com/google/wire" ) diff --git a/app/sephirah/internal/client/client.go b/internal/client/client/client.go similarity index 100% rename from app/sephirah/internal/client/client.go rename to internal/client/client/client.go diff --git a/app/sephirah/internal/client/porter.go b/internal/client/client/porter.go similarity index 100% rename from app/sephirah/internal/client/porter.go rename to internal/client/client/porter.go diff --git a/app/sephirah/internal/client/porter_static_discovery.go b/internal/client/client/porter_static_discovery.go similarity index 100% rename from app/sephirah/internal/client/porter_static_discovery.go rename to internal/client/client/porter_static_discovery.go diff --git a/app/sephirah/internal/data/migration/migration.go b/internal/data/db/migration/migration.go similarity index 100% rename from app/sephirah/internal/data/migration/migration.go rename to internal/data/db/migration/migration.go diff --git a/app/sephirah/internal/data/migration/migration_test.go b/internal/data/db/migration/migration_test.go similarity index 84% rename from app/sephirah/internal/data/migration/migration_test.go rename to internal/data/db/migration/migration_test.go index 13be4d68..fd5f941d 100644 --- a/app/sephirah/internal/data/migration/migration_test.go +++ b/internal/data/db/migration/migration_test.go @@ -1,10 +1,12 @@ package migration_test import ( - "github.com/tuihub/librarian/app/sephirah/internal/data/migration" + "testing" + + "github.com/tuihub/librarian/internal/data/db/migration" + "gorm.io/driver/sqlite" "gorm.io/gorm" - "testing" ) func TestNewMigration(t *testing.T) { diff --git a/app/sephirah/internal/data/migration/v1.go b/internal/data/db/migration/v1.go similarity index 100% rename from app/sephirah/internal/data/migration/v1.go rename to internal/data/db/migration/v1.go diff --git a/app/sephirah/internal/data/migration/v2.go b/internal/data/db/migration/v2.go similarity index 100% rename from app/sephirah/internal/data/migration/v2.go rename to internal/data/db/migration/v2.go diff --git a/app/sephirah/internal/model/converter/biz_to_pb.go b/internal/model/converter/biz_to_pb.go similarity index 97% rename from app/sephirah/internal/model/converter/biz_to_pb.go rename to internal/model/converter/biz_to_pb.go index 16afe5e6..d7e1fdd0 100644 --- a/app/sephirah/internal/model/converter/biz_to_pb.go +++ b/internal/model/converter/biz_to_pb.go @@ -3,14 +3,14 @@ package converter import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" diff --git a/app/sephirah/internal/model/converter/converter.go b/internal/model/converter/converter.go similarity index 100% rename from app/sephirah/internal/model/converter/converter.go rename to internal/model/converter/converter.go diff --git a/app/sephirah/internal/model/converter/generated.go b/internal/model/converter/generated.go old mode 100755 new mode 100644 similarity index 99% rename from app/sephirah/internal/model/converter/generated.go rename to internal/model/converter/generated.go index b4294f01..59c4e4a8 --- a/app/sephirah/internal/model/converter/generated.go +++ b/internal/model/converter/generated.go @@ -4,15 +4,15 @@ package converter import ( - modelbinah "github.com/tuihub/librarian/app/sephirah/internal/model/modelbinah" - modelgebura "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - modelnetzach "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - modelsupervisor "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - modeltiphereth "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - modelyesod "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" libauth "github.com/tuihub/librarian/internal/lib/libauth" model "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelbinah" modelfeed "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" v11 "github.com/tuihub/protos/pkg/librarian/sephirah/v1" v1 "github.com/tuihub/protos/pkg/librarian/v1" timestamppb "google.golang.org/protobuf/types/known/timestamppb" diff --git a/app/sephirah/internal/model/converter/pb_to_biz.go b/internal/model/converter/pb_to_biz.go similarity index 96% rename from app/sephirah/internal/model/converter/pb_to_biz.go rename to internal/model/converter/pb_to_biz.go index 0d5b545c..7479b96a 100644 --- a/app/sephirah/internal/model/converter/pb_to_biz.go +++ b/internal/model/converter/pb_to_biz.go @@ -3,15 +3,15 @@ package converter import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelbinah" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelbinah" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/model/modelyesod" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" diff --git a/app/sephirah/internal/model/modelangela/modelangela.go b/internal/model/modelangela/modelangela.go similarity index 85% rename from app/sephirah/internal/model/modelangela/modelangela.go rename to internal/model/modelangela/modelangela.go index 00da75ea..ad2773f4 100644 --- a/app/sephirah/internal/model/modelangela/modelangela.go +++ b/internal/model/modelangela/modelangela.go @@ -1,10 +1,10 @@ package modelangela import ( - "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelnetzach" ) type PullAccountAppInfoRelation struct { diff --git a/app/sephirah/internal/model/modelbinah/callback.go b/internal/model/modelbinah/callback.go similarity index 100% rename from app/sephirah/internal/model/modelbinah/callback.go rename to internal/model/modelbinah/callback.go diff --git a/app/sephirah/internal/model/modelbinah/control.go b/internal/model/modelbinah/control.go similarity index 100% rename from app/sephirah/internal/model/modelbinah/control.go rename to internal/model/modelbinah/control.go diff --git a/app/sephirah/internal/model/modelbinah/modelbinah.go b/internal/model/modelbinah/modelbinah.go similarity index 100% rename from app/sephirah/internal/model/modelbinah/modelbinah.go rename to internal/model/modelbinah/modelbinah.go diff --git a/app/sephirah/internal/model/modelchesed/modelchesed.go b/internal/model/modelchesed/modelchesed.go similarity index 90% rename from app/sephirah/internal/model/modelchesed/modelchesed.go rename to internal/model/modelchesed/modelchesed.go index 0ac6b387..dae2a65f 100644 --- a/app/sephirah/internal/model/modelchesed/modelchesed.go +++ b/internal/model/modelchesed/modelchesed.go @@ -1,8 +1,6 @@ package modelchesed -import ( - "github.com/tuihub/librarian/internal/model" -) +import "github.com/tuihub/librarian/internal/model" type Image struct { ID model.InternalID diff --git a/app/sephirah/internal/model/modelgebura/modelgebura.go b/internal/model/modelgebura/modelgebura.go similarity index 100% rename from app/sephirah/internal/model/modelgebura/modelgebura.go rename to internal/model/modelgebura/modelgebura.go diff --git a/app/sephirah/internal/model/modelnetzach/modelnetzach.go b/internal/model/modelnetzach/modelnetzach.go similarity index 97% rename from app/sephirah/internal/model/modelnetzach/modelnetzach.go rename to internal/model/modelnetzach/modelnetzach.go index 89ef10ba..cdd42607 100644 --- a/app/sephirah/internal/model/modelnetzach/modelnetzach.go +++ b/internal/model/modelnetzach/modelnetzach.go @@ -3,8 +3,8 @@ package modelnetzach import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) type NotifyFlow struct { diff --git a/app/sephirah/internal/model/modelsupervisor/modelsupervisor.go b/internal/model/modelsupervisor/modelsupervisor.go similarity index 98% rename from app/sephirah/internal/model/modelsupervisor/modelsupervisor.go rename to internal/model/modelsupervisor/modelsupervisor.go index 0182255e..fca672f6 100644 --- a/app/sephirah/internal/model/modelsupervisor/modelsupervisor.go +++ b/internal/model/modelsupervisor/modelsupervisor.go @@ -3,9 +3,9 @@ package modelsupervisor import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/lib/libtype" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modeltiphereth" ) type PorterInstanceController struct { diff --git a/app/sephirah/internal/model/modeltiphereth/modeltiphereth.go b/internal/model/modeltiphereth/modeltiphereth.go similarity index 100% rename from app/sephirah/internal/model/modeltiphereth/modeltiphereth.go rename to internal/model/modeltiphereth/modeltiphereth.go diff --git a/app/sephirah/internal/model/modelyesod/builtin_action.go b/internal/model/modelyesod/builtin_action.go similarity index 100% rename from app/sephirah/internal/model/modelyesod/builtin_action.go rename to internal/model/modelyesod/builtin_action.go diff --git a/app/sephirah/internal/model/modelyesod/builtin_action_test.go b/internal/model/modelyesod/builtin_action_test.go similarity index 91% rename from app/sephirah/internal/model/modelyesod/builtin_action_test.go rename to internal/model/modelyesod/builtin_action_test.go index 67872cdb..bb43469f 100644 --- a/app/sephirah/internal/model/modelyesod/builtin_action_test.go +++ b/internal/model/modelyesod/builtin_action_test.go @@ -3,7 +3,7 @@ package modelyesod_test import ( "testing" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/model/modelyesod" ) func TestGetSimpleKeywordFilterActionConfigSchema(t *testing.T) { diff --git a/app/sephirah/internal/model/modelyesod/modelyesod.go b/internal/model/modelyesod/modelyesod.go similarity index 93% rename from app/sephirah/internal/model/modelyesod/modelyesod.go rename to internal/model/modelyesod/modelyesod.go index cfa5ea64..ad7c13fe 100644 --- a/app/sephirah/internal/model/modelyesod/modelyesod.go +++ b/internal/model/modelyesod/modelyesod.go @@ -3,10 +3,10 @@ package modelyesod import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) type FeedItemDigest struct { diff --git a/app/sephirah/internal/service/binah.go b/internal/service/sephirah/binah.go similarity index 99% rename from app/sephirah/internal/service/binah.go rename to internal/service/sephirah/binah.go index dd0399c3..29c13405 100644 --- a/app/sephirah/internal/service/binah.go +++ b/internal/service/sephirah/binah.go @@ -1,4 +1,4 @@ -package service +package sephirah import ( "context" diff --git a/app/sephirah/internal/service/chesed.go b/internal/service/sephirah/chesed.go similarity index 93% rename from app/sephirah/internal/service/chesed.go rename to internal/service/sephirah/chesed.go index b0a12096..771e8cd0 100644 --- a/app/sephirah/internal/service/chesed.go +++ b/internal/service/sephirah/chesed.go @@ -1,11 +1,11 @@ -package service +package sephirah import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelchesed" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" diff --git a/app/sephirah/internal/service/gebura.go b/internal/service/sephirah/gebura.go similarity index 99% rename from app/sephirah/internal/service/gebura.go rename to internal/service/sephirah/gebura.go index 0d61f28a..9499bfaf 100644 --- a/app/sephirah/internal/service/gebura.go +++ b/internal/service/sephirah/gebura.go @@ -1,10 +1,10 @@ -package service +package sephirah import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" diff --git a/app/sephirah/internal/service/librariansephirahservice.go b/internal/service/sephirah/librariansephirahservice.go similarity index 80% rename from app/sephirah/internal/service/librariansephirahservice.go rename to internal/service/sephirah/librariansephirahservice.go index 00cc2dc8..0ee287f1 100644 --- a/app/sephirah/internal/service/librariansephirahservice.go +++ b/internal/service/sephirah/librariansephirahservice.go @@ -1,21 +1,21 @@ -package service +package sephirah import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizangela" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizbinah" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizchesed" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizgebura" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biznetzach" - "github.com/tuihub/librarian/app/sephirah/internal/biz/biztiphereth" - "github.com/tuihub/librarian/app/sephirah/internal/biz/bizyesod" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/supervisor" + "github.com/tuihub/librarian/internal/biz/bizangela" + "github.com/tuihub/librarian/internal/biz/bizbinah" + "github.com/tuihub/librarian/internal/biz/bizchesed" + "github.com/tuihub/librarian/internal/biz/bizgebura" + "github.com/tuihub/librarian/internal/biz/biznetzach" + "github.com/tuihub/librarian/internal/biz/biztiphereth" + "github.com/tuihub/librarian/internal/biz/bizyesod" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/service/supervisor" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "google.golang.org/protobuf/types/known/timestamppb" diff --git a/app/sephirah/internal/service/netzach.go b/internal/service/sephirah/netzach.go similarity index 97% rename from app/sephirah/internal/service/netzach.go rename to internal/service/sephirah/netzach.go index ffd7d525..9712a7dd 100644 --- a/app/sephirah/internal/service/netzach.go +++ b/internal/service/sephirah/netzach.go @@ -1,10 +1,10 @@ -package service +package sephirah import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/app/sephirah/internal/service/porter.go b/internal/service/sephirah/porter.go similarity index 88% rename from app/sephirah/internal/service/porter.go rename to internal/service/sephirah/porter.go index a3045905..c75b1b71 100644 --- a/app/sephirah/internal/service/porter.go +++ b/internal/service/sephirah/porter.go @@ -1,10 +1,10 @@ -package service +package sephirah import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" ) diff --git a/app/sephirah/internal/service/service.go b/internal/service/sephirah/service.go similarity index 88% rename from app/sephirah/internal/service/service.go rename to internal/service/sephirah/service.go index 9c08df1c..36aed3d2 100644 --- a/app/sephirah/internal/service/service.go +++ b/internal/service/sephirah/service.go @@ -1,4 +1,4 @@ -package service +package sephirah import "github.com/google/wire" diff --git a/app/sephirah/internal/service/tiphereth.go b/internal/service/sephirah/tiphereth.go similarity index 97% rename from app/sephirah/internal/service/tiphereth.go rename to internal/service/sephirah/tiphereth.go index 5e6f06eb..b143f40b 100644 --- a/app/sephirah/internal/service/tiphereth.go +++ b/internal/service/sephirah/tiphereth.go @@ -1,14 +1,14 @@ -package service +package sephirah import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/app/sephirah/internal/service/yesod.go b/internal/service/sephirah/yesod.go similarity index 99% rename from app/sephirah/internal/service/yesod.go rename to internal/service/sephirah/yesod.go index 91d19190..21a3fe21 100644 --- a/app/sephirah/internal/service/yesod.go +++ b/internal/service/sephirah/yesod.go @@ -1,10 +1,10 @@ -package service +package sephirah import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/app/sephirah/internal/supervisor/feature.go b/internal/service/supervisor/feature.go similarity index 95% rename from app/sephirah/internal/supervisor/feature.go rename to internal/service/supervisor/feature.go index 77d366ed..ad9e0bc5 100644 --- a/app/sephirah/internal/supervisor/feature.go +++ b/internal/service/supervisor/feature.go @@ -3,8 +3,8 @@ package supervisor import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/client" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/client/client" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) func (s *Supervisor) HasAccountPlatform(platform string) bool { diff --git a/app/sephirah/internal/supervisor/summary.go b/internal/service/supervisor/summary.go similarity index 96% rename from app/sephirah/internal/supervisor/summary.go rename to internal/service/supervisor/summary.go index 7f3cfffd..aa3f20a8 100644 --- a/app/sephirah/internal/supervisor/summary.go +++ b/internal/service/supervisor/summary.go @@ -3,8 +3,8 @@ package supervisor import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/lib/libtype" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) func (s *Supervisor) GetFeatureSummary() *modelsupervisor.ServerFeatureSummary { diff --git a/app/sephirah/internal/supervisor/supervisor.go b/internal/service/supervisor/supervisor.go similarity index 97% rename from app/sephirah/internal/supervisor/supervisor.go rename to internal/service/supervisor/supervisor.go index ef36813e..19d87594 100644 --- a/app/sephirah/internal/supervisor/supervisor.go +++ b/internal/service/supervisor/supervisor.go @@ -7,11 +7,7 @@ import ( "sync" "time" - "github.com/tuihub/librarian/app/sephirah/internal/client" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" @@ -20,6 +16,10 @@ import ( "github.com/tuihub/librarian/internal/lib/libtype" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/model/modeltiphereth" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" "github.com/google/uuid" diff --git a/app/sephirah/internal/supervisor/task.go b/internal/service/supervisor/task.go similarity index 94% rename from app/sephirah/internal/supervisor/task.go rename to internal/service/supervisor/task.go index 8dd9856a..93d7b023 100644 --- a/app/sephirah/internal/supervisor/task.go +++ b/internal/service/supervisor/task.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/tuihub/librarian/app/sephirah/internal/client" - "github.com/tuihub/librarian/app/sephirah/internal/model/converter" - "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtype" + "github.com/tuihub/librarian/internal/model/converter" + "github.com/tuihub/librarian/internal/model/modelsupervisor" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" ) From a6b221c322c06cf3a5f7b2b5e7bb865fa205cb54 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 15 Mar 2025 21:40:51 +0800 Subject: [PATCH 03/19] feat: draft angela web --- go.mod | 9 ++ go.sum | 18 +++ internal/service/angelaweb/angela_web.go | 39 ++++++ .../angelaweb/internal/dashboard_handler.go | 1 + .../service/angelaweb/internal/handler.go | 11 ++ .../angelaweb/internal/login_handler.go | 1 + .../angelaweb/internal/user_handler.go | 1 + internal/service/angelaweb/routes.go | 8 ++ .../service/angelaweb/static/css/style.css | 3 + .../service/angelaweb/view/dashboard.html | 21 ++++ .../angelaweb/view/layout/default.html | 30 +++++ internal/service/angelaweb/view/login.html | 70 +++++++++++ internal/service/angelaweb/view/user.html | 117 ++++++++++++++++++ .../service/angelaweb/view/user_form.html | 112 +++++++++++++++++ 14 files changed, 441 insertions(+) create mode 100644 internal/service/angelaweb/angela_web.go create mode 100644 internal/service/angelaweb/internal/dashboard_handler.go create mode 100644 internal/service/angelaweb/internal/handler.go create mode 100644 internal/service/angelaweb/internal/login_handler.go create mode 100644 internal/service/angelaweb/internal/user_handler.go create mode 100644 internal/service/angelaweb/routes.go create mode 100644 internal/service/angelaweb/static/css/style.css create mode 100644 internal/service/angelaweb/view/dashboard.html create mode 100644 internal/service/angelaweb/view/layout/default.html create mode 100644 internal/service/angelaweb/view/login.html create mode 100644 internal/service/angelaweb/view/user.html create mode 100644 internal/service/angelaweb/view/user_form.html diff --git a/go.mod b/go.mod index 1f906a58..3395a017 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,8 @@ require ( github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/v2 v2.8.3 + github.com/gofiber/fiber/v2 v2.52.6 + github.com/gofiber/template/html/v2 v2.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 @@ -110,6 +112,8 @@ require ( github.com/go-openapi/inflect v0.19.0 // indirect github.com/go-playground/form/v4 v4.2.0 // indirect github.com/goccy/go-json v0.10.5 // indirect + github.com/gofiber/template v1.8.3 // indirect + github.com/gofiber/utils v1.1.0 // indirect github.com/golang-jwt/jwt/v4 v4.5.1 // indirect github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -139,6 +143,7 @@ require ( github.com/mailru/easyjson v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/minio/crc64nvme v1.0.1 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -150,6 +155,7 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect + github.com/rivo/uniseg v0.2.0 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect github.com/rs/cors v1.8.3 // indirect github.com/rs/xid v1.6.0 // indirect @@ -161,6 +167,9 @@ require ( github.com/stretchr/objx v0.5.2 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.1 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.51.0 // indirect + github.com/valyala/tcplisten v1.0.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect diff --git a/go.sum b/go.sum index 92df5551..1afe929f 100644 --- a/go.sum +++ b/go.sum @@ -260,6 +260,14 @@ github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= +github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI= +github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= +github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc= +github.com/gofiber/template v1.8.3/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8= +github.com/gofiber/template/html/v2 v2.1.3 h1:n1LYBtmr9C0V/k/3qBblXyMxV5B0o/gpb6dFLp8ea+o= +github.com/gofiber/template/html/v2 v2.1.3/go.mod h1:U5Fxgc5KpyujU9OqKzy6Kn6Qup6Tm7zdsISR+VpnHRE= +github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= +github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -501,6 +509,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM= github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -619,6 +629,8 @@ github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/redis/go-redis/v9 v9.7.1 h1:4LhKRCIduqXqtvCUlaq9c8bdHOkICjDMrr1+Zb3osAc= github.com/redis/go-redis/v9 v9.7.1/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -701,6 +713,12 @@ github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= +github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= +github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= diff --git a/internal/service/angelaweb/angela_web.go b/internal/service/angelaweb/angela_web.go new file mode 100644 index 00000000..b0222c9f --- /dev/null +++ b/internal/service/angelaweb/angela_web.go @@ -0,0 +1,39 @@ +package angelaweb + +import ( + "context" + "github.com/gofiber/fiber/v2" + "github.com/gofiber/template/html/v2" + "github.com/tuihub/librarian/internal/service/angelaweb/internal" +) + +type AngelaWeb struct { + handler *internal.Handler + app *fiber.App +} + +func NewAngelaWeb(handler *internal.Handler) *AngelaWeb { + viewsEngine := html.New("./view", ".html") + + app := fiber.New(fiber.Config{ + Views: viewsEngine, + ViewsLayout: "layout/default", + }) + + app.Static("/static", "./static") + + initRoutes(app) + + return &AngelaWeb{ + handler: handler, + app: app, + } +} + +func (a *AngelaWeb) Start(ctx context.Context) error { + return a.app.Listen(":3000") +} + +func (a *AngelaWeb) Stop(ctx context.Context) error { + return a.app.ShutdownWithContext(ctx) +} diff --git a/internal/service/angelaweb/internal/dashboard_handler.go b/internal/service/angelaweb/internal/dashboard_handler.go new file mode 100644 index 00000000..5bf0569c --- /dev/null +++ b/internal/service/angelaweb/internal/dashboard_handler.go @@ -0,0 +1 @@ +package internal diff --git a/internal/service/angelaweb/internal/handler.go b/internal/service/angelaweb/internal/handler.go new file mode 100644 index 00000000..9b6dffdd --- /dev/null +++ b/internal/service/angelaweb/internal/handler.go @@ -0,0 +1,11 @@ +package internal + +import "gorm.io/gorm" + +type Handler struct { + db *gorm.DB +} + +func NewHandler(db *gorm.DB) *Handler { + return &Handler{db: db} +} diff --git a/internal/service/angelaweb/internal/login_handler.go b/internal/service/angelaweb/internal/login_handler.go new file mode 100644 index 00000000..5bf0569c --- /dev/null +++ b/internal/service/angelaweb/internal/login_handler.go @@ -0,0 +1 @@ +package internal diff --git a/internal/service/angelaweb/internal/user_handler.go b/internal/service/angelaweb/internal/user_handler.go new file mode 100644 index 00000000..5bf0569c --- /dev/null +++ b/internal/service/angelaweb/internal/user_handler.go @@ -0,0 +1 @@ +package internal diff --git a/internal/service/angelaweb/routes.go b/internal/service/angelaweb/routes.go new file mode 100644 index 00000000..30e5dace --- /dev/null +++ b/internal/service/angelaweb/routes.go @@ -0,0 +1,8 @@ +package angelaweb + +import ( + "github.com/gofiber/fiber/v2" +) + +func initRoutes(app *fiber.App) { +} diff --git a/internal/service/angelaweb/static/css/style.css b/internal/service/angelaweb/static/css/style.css new file mode 100644 index 00000000..3497c985 --- /dev/null +++ b/internal/service/angelaweb/static/css/style.css @@ -0,0 +1,3 @@ +.custom-shadow { + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); +} \ No newline at end of file diff --git a/internal/service/angelaweb/view/dashboard.html b/internal/service/angelaweb/view/dashboard.html new file mode 100644 index 00000000..6d79aed2 --- /dev/null +++ b/internal/service/angelaweb/view/dashboard.html @@ -0,0 +1,21 @@ +
+

系统概览

+
+
+

用户总数

+

{{.UserCount}}

+
+
+
+ +
+

快速操作

+ +
\ No newline at end of file diff --git a/internal/service/angelaweb/view/layout/default.html b/internal/service/angelaweb/view/layout/default.html new file mode 100644 index 00000000..087bb8be --- /dev/null +++ b/internal/service/angelaweb/view/layout/default.html @@ -0,0 +1,30 @@ + + + + + + {{.Title}} + + + +
+ +
+
+

用户管理系统

+ +
+
+ + +
+
+ {{embed}} +
+
+
+ + \ No newline at end of file diff --git a/internal/service/angelaweb/view/login.html b/internal/service/angelaweb/view/login.html new file mode 100644 index 00000000..329f01b1 --- /dev/null +++ b/internal/service/angelaweb/view/login.html @@ -0,0 +1,70 @@ +
+
+

登录系统

+
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/internal/service/angelaweb/view/user.html b/internal/service/angelaweb/view/user.html new file mode 100644 index 00000000..5d1f5dc8 --- /dev/null +++ b/internal/service/angelaweb/view/user.html @@ -0,0 +1,117 @@ +
+

用户列表

+ + 添加用户 + +
+ +
+ + + + + + + + + + + + + {{range .Users}} + + + + + + + + + {{else}} + + + + {{end}} + +
ID用户名邮箱角色创建时间操作
{{.ID}}{{.Username}}{{.Email}} + {{if eq .Role "admin"}} + 管理员 + {{else}} + 普通用户 + {{end}} + {{.CreatedAt.Format "2006-01-02 15:04:05"}} +
+ + 编辑 + + +
+
暂无用户数据
+
+ + + + + \ No newline at end of file diff --git a/internal/service/angelaweb/view/user_form.html b/internal/service/angelaweb/view/user_form.html new file mode 100644 index 00000000..2c1bfd34 --- /dev/null +++ b/internal/service/angelaweb/view/user_form.html @@ -0,0 +1,112 @@ +
+

+ {{if .User.ID}}编辑用户{{else}}创建新用户{{end}} +

+
+ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + 返回列表 + + +
+
+ + \ No newline at end of file From 07520ebd4ef615c3c34ca259b78de26aa1ba9e73 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 15 Mar 2025 22:14:37 +0800 Subject: [PATCH 04/19] feat: draft angela web --- go.mod | 19 ++++---- go.sum | 27 ++++++------ internal/service/angelaweb/angela_web.go | 9 ++-- internal/service/angelaweb/angela_web_test.go | 24 +++++++++++ .../service/angelaweb/internal/api/handler.go | 19 ++++++++ .../service/angelaweb/internal/api/login.go | 43 +++++++++++++++++++ .../service/angelaweb/internal/api/user.go | 1 + .../angelaweb/internal/dashboard_handler.go | 1 - .../service/angelaweb/internal/handler.go | 11 ----- .../angelaweb/internal/login_handler.go | 1 - .../service/angelaweb/internal/page/login.go | 1 + .../service/angelaweb/internal/page/page.go | 11 +++++ .../angelaweb/internal/user_handler.go | 1 - internal/service/angelaweb/routes.go | 9 ++++ 14 files changed, 139 insertions(+), 38 deletions(-) create mode 100644 internal/service/angelaweb/angela_web_test.go create mode 100644 internal/service/angelaweb/internal/api/handler.go create mode 100644 internal/service/angelaweb/internal/api/login.go create mode 100644 internal/service/angelaweb/internal/api/user.go delete mode 100644 internal/service/angelaweb/internal/dashboard_handler.go delete mode 100644 internal/service/angelaweb/internal/handler.go delete mode 100644 internal/service/angelaweb/internal/login_handler.go create mode 100644 internal/service/angelaweb/internal/page/login.go create mode 100644 internal/service/angelaweb/internal/page/page.go delete mode 100644 internal/service/angelaweb/internal/user_handler.go diff --git a/go.mod b/go.mod index 3395a017..b76e0379 100644 --- a/go.mod +++ b/go.mod @@ -19,8 +19,10 @@ require ( github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/v2 v2.8.3 + github.com/gofiber/contrib/jwt v1.0.10 github.com/gofiber/fiber/v2 v2.52.6 github.com/gofiber/template/html/v2 v2.1.3 + github.com/golang-jwt/jwt/v4 v4.5.1 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 @@ -35,6 +37,7 @@ require ( github.com/minio/minio-go/v7 v7.0.87 github.com/redis/go-redis/v9 v9.7.1 github.com/sony/sonyflake v1.2.0 + github.com/stretchr/testify v1.10.0 github.com/tuihub/protos v0.4.25 go.opentelemetry.io/otel v1.34.0 go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.10.0 @@ -63,6 +66,7 @@ require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.5-20250130201111-63bb56e20495.1 // indirect cel.dev/expr v0.19.1 // indirect dario.cat/mergo v1.0.0 // indirect + github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect github.com/Rican7/retry v0.3.1 // indirect github.com/RoaringBitmap/roaring v1.9.3 // indirect github.com/agext/levenshtein v1.2.3 // indirect @@ -99,6 +103,7 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -114,7 +119,6 @@ require ( github.com/goccy/go-json v0.10.5 // indirect github.com/gofiber/template v1.8.3 // indirect github.com/gofiber/utils v1.1.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.1 // indirect github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -136,12 +140,12 @@ require ( github.com/jonboulle/clockwork v0.5.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.11 // indirect + github.com/klauspost/compress v1.18.0 // indirect github.com/klauspost/cpuid/v2 v2.2.9 // indirect github.com/lithammer/shortuuid/v3 v3.0.7 // indirect github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect github.com/mailru/easyjson v0.9.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/minio/crc64nvme v1.0.1 // indirect @@ -154,8 +158,9 @@ require ( github.com/mschoch/smat v0.2.0 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect - github.com/rivo/uniseg v0.2.0 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect github.com/rs/cors v1.8.3 // indirect github.com/rs/xid v1.6.0 // indirect @@ -164,12 +169,10 @@ require ( github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sony/gobreaker v1.0.0 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect - github.com/stretchr/objx v0.5.2 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.51.0 // indirect - github.com/valyala/tcplisten v1.0.0 // indirect + github.com/valyala/fasthttp v1.59.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect @@ -187,7 +190,7 @@ require ( golang.org/x/mod v0.23.0 // indirect golang.org/x/net v0.35.0 // indirect golang.org/x/sync v0.12.0 // indirect - golang.org/x/sys v0.30.0 // indirect + golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect golang.org/x/tools v0.30.0 // indirect google.golang.org/appengine v1.6.8 // indirect diff --git a/go.sum b/go.sum index 1afe929f..96181448 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20O github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/MicahParks/keyfunc/v2 v2.1.0 h1:6ZXKb9Rp6qp1bDbJefnG7cTH8yMN1IC/4nf+GVjO99k= +github.com/MicahParks/keyfunc/v2 v2.1.0/go.mod h1:rW42fi+xgLJ2FRRXAfNx9ZA8WpD4OeE/yHVMteCkw9k= github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8= github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU= github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc= @@ -260,6 +262,8 @@ github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= +github.com/gofiber/contrib/jwt v1.0.10 h1:/ilGepl6i0Bntl0Zcd+lAzagY8BiS1+fEiAj32HMApk= +github.com/gofiber/contrib/jwt v1.0.10/go.mod h1:1qBENE6sZ6PPT4xIpBzx1VxeyROQO7sj48OlM1I9qdU= github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI= github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc= @@ -461,8 +465,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= -github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= @@ -497,15 +501,14 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -629,8 +632,9 @@ github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/redis/go-redis/v9 v9.7.1 h1:4LhKRCIduqXqtvCUlaq9c8bdHOkICjDMrr1+Zb3osAc= github.com/redis/go-redis/v9 v9.7.1/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -715,10 +719,8 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= -github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/valyala/fasthttp v1.59.0 h1:Qu0qYHfXvPk1mSLNqcFtEk6DpxgA26hy6bmydotDpRI= +github.com/valyala/fasthttp v1.59.0/go.mod h1:GTxNb9Bc6r2a9D0TWNSPwDz78UxnTGBViY3xZNEqyYU= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= @@ -929,7 +931,6 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -943,8 +944,8 @@ golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/internal/service/angelaweb/angela_web.go b/internal/service/angelaweb/angela_web.go index b0222c9f..a979da95 100644 --- a/internal/service/angelaweb/angela_web.go +++ b/internal/service/angelaweb/angela_web.go @@ -4,15 +4,17 @@ import ( "context" "github.com/gofiber/fiber/v2" "github.com/gofiber/template/html/v2" - "github.com/tuihub/librarian/internal/service/angelaweb/internal" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" ) type AngelaWeb struct { - handler *internal.Handler + handler *api.Handler + builder *page.Builder app *fiber.App } -func NewAngelaWeb(handler *internal.Handler) *AngelaWeb { +func NewAngelaWeb(handler *api.Handler, builder *page.Builder) *AngelaWeb { viewsEngine := html.New("./view", ".html") app := fiber.New(fiber.Config{ @@ -26,6 +28,7 @@ func NewAngelaWeb(handler *internal.Handler) *AngelaWeb { return &AngelaWeb{ handler: handler, + builder: builder, app: app, } } diff --git a/internal/service/angelaweb/angela_web_test.go b/internal/service/angelaweb/angela_web_test.go new file mode 100644 index 00000000..87f58499 --- /dev/null +++ b/internal/service/angelaweb/angela_web_test.go @@ -0,0 +1,24 @@ +package angelaweb + +import ( + "context" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" + "testing" + + "github.com/stretchr/testify/assert" + "gorm.io/driver/sqlite" + "gorm.io/gorm" +) + +func Test_AngelaWeb(t *testing.T) { + db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{}) + if err != nil { + t.Fatal(err) + } + handler := api.NewHandler(db) + angelaWeb := NewAngelaWeb(handler) + + err = angelaWeb.Start(context.Background()) + + assert.NoError(t, err) +} diff --git a/internal/service/angelaweb/internal/api/handler.go b/internal/service/angelaweb/internal/api/handler.go new file mode 100644 index 00000000..bf553d54 --- /dev/null +++ b/internal/service/angelaweb/internal/api/handler.go @@ -0,0 +1,19 @@ +package api + +import ( + "gorm.io/gorm" +) + +type Handler struct { + db *gorm.DB +} + +func NewHandler(db *gorm.DB) *Handler { + return &Handler{db: db} +} + +type User struct { + ID uint `gorm:"primaryKey"` + Username string `gorm:"unique"` + Password string +} diff --git a/internal/service/angelaweb/internal/api/login.go b/internal/service/angelaweb/internal/api/login.go new file mode 100644 index 00000000..baf030c0 --- /dev/null +++ b/internal/service/angelaweb/internal/api/login.go @@ -0,0 +1,43 @@ +package api + +import ( + "github.com/gofiber/fiber/v2" + "github.com/golang-jwt/jwt/v5" + "time" +) + +func (h *Handler) Login(c *fiber.Ctx) error { + type LoginRequest struct { + Username string `json:"username"` + Password string `json:"password"` + } + + var req LoginRequest + if err := c.BodyParser(&req); err != nil { + return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request"}) + } + + // Validate user credentials (this is just an example, you should use a proper method to validate credentials) + var user User + if err := h.db.Where("username = ? AND password = ?", req.Username, req.Password).First(&user).Error; err != nil { + return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "Invalid credentials"}) + } + + // Generate JWT + token, err := generateJWT(user.ID) + if err != nil { + return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to generate token"}) + } + + return c.JSON(fiber.Map{"token": token}) +} + +// Helper function to generate JWT +func generateJWT(userID uint) (string, error) { + claims := jwt.MapClaims{ + "user_id": userID, + "exp": time.Now().Add(time.Hour * 72).Unix(), + } + token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + return token.SignedString([]byte("secret")) +} diff --git a/internal/service/angelaweb/internal/api/user.go b/internal/service/angelaweb/internal/api/user.go new file mode 100644 index 00000000..778f64ec --- /dev/null +++ b/internal/service/angelaweb/internal/api/user.go @@ -0,0 +1 @@ +package api diff --git a/internal/service/angelaweb/internal/dashboard_handler.go b/internal/service/angelaweb/internal/dashboard_handler.go deleted file mode 100644 index 5bf0569c..00000000 --- a/internal/service/angelaweb/internal/dashboard_handler.go +++ /dev/null @@ -1 +0,0 @@ -package internal diff --git a/internal/service/angelaweb/internal/handler.go b/internal/service/angelaweb/internal/handler.go deleted file mode 100644 index 9b6dffdd..00000000 --- a/internal/service/angelaweb/internal/handler.go +++ /dev/null @@ -1,11 +0,0 @@ -package internal - -import "gorm.io/gorm" - -type Handler struct { - db *gorm.DB -} - -func NewHandler(db *gorm.DB) *Handler { - return &Handler{db: db} -} diff --git a/internal/service/angelaweb/internal/login_handler.go b/internal/service/angelaweb/internal/login_handler.go deleted file mode 100644 index 5bf0569c..00000000 --- a/internal/service/angelaweb/internal/login_handler.go +++ /dev/null @@ -1 +0,0 @@ -package internal diff --git a/internal/service/angelaweb/internal/page/login.go b/internal/service/angelaweb/internal/page/login.go new file mode 100644 index 00000000..52aa8377 --- /dev/null +++ b/internal/service/angelaweb/internal/page/login.go @@ -0,0 +1 @@ +package page diff --git a/internal/service/angelaweb/internal/page/page.go b/internal/service/angelaweb/internal/page/page.go new file mode 100644 index 00000000..64ffe83c --- /dev/null +++ b/internal/service/angelaweb/internal/page/page.go @@ -0,0 +1,11 @@ +package page + +import "gorm.io/gorm" + +type Builder struct { + db *gorm.DB +} + +func NewBuilder(db *gorm.DB) *Builder { + return &Builder{db: db} +} diff --git a/internal/service/angelaweb/internal/user_handler.go b/internal/service/angelaweb/internal/user_handler.go deleted file mode 100644 index 5bf0569c..00000000 --- a/internal/service/angelaweb/internal/user_handler.go +++ /dev/null @@ -1 +0,0 @@ -package internal diff --git a/internal/service/angelaweb/routes.go b/internal/service/angelaweb/routes.go index 30e5dace..95ce4b44 100644 --- a/internal/service/angelaweb/routes.go +++ b/internal/service/angelaweb/routes.go @@ -1,8 +1,17 @@ package angelaweb import ( + jwtware "github.com/gofiber/contrib/jwt" "github.com/gofiber/fiber/v2" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" ) func initRoutes(app *fiber.App) { + handler := &api.Handler{} + + app.Post("/api/login", handler.Login) + + app.Use(jwtware.New(jwtware.Config{ + SigningKey: jwtware.SigningKey{Key: []byte("secret")}, + })) } From 3fc5aa741b8c3b03e36d122d29cbc3becf751706 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 15 Mar 2025 22:15:03 +0800 Subject: [PATCH 05/19] feat: draft angela web --- internal/service/angelaweb/angela_web_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/service/angelaweb/angela_web_test.go b/internal/service/angelaweb/angela_web_test.go index 87f58499..e2bbad21 100644 --- a/internal/service/angelaweb/angela_web_test.go +++ b/internal/service/angelaweb/angela_web_test.go @@ -3,6 +3,7 @@ package angelaweb import ( "context" "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" "testing" "github.com/stretchr/testify/assert" @@ -16,7 +17,8 @@ func Test_AngelaWeb(t *testing.T) { t.Fatal(err) } handler := api.NewHandler(db) - angelaWeb := NewAngelaWeb(handler) + builder := page.NewBuilder(db) + angelaWeb := NewAngelaWeb(handler, builder) err = angelaWeb.Start(context.Background()) From 102579c81e79902d4570b25ecce7e246f27d3a49 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 15 Mar 2025 22:31:00 +0800 Subject: [PATCH 06/19] feat: draft angela web --- go.mod | 5 +- go.sum | 41 +++++- internal/service/angelaweb/angela_web.go | 20 ++- .../service/angelaweb/internal/api/handler.go | 119 +++++++++++++++++- .../service/angelaweb/internal/api/login.go | 42 ------- .../service/angelaweb/internal/model/model.go | 23 ++++ .../service/angelaweb/internal/page/page.go | 64 +++++++++- internal/service/angelaweb/routes.go | 44 +++++-- 8 files changed, 285 insertions(+), 73 deletions(-) create mode 100644 internal/service/angelaweb/internal/model/model.go diff --git a/go.mod b/go.mod index b76e0379..5495964e 100644 --- a/go.mod +++ b/go.mod @@ -19,10 +19,9 @@ require ( github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/v2 v2.8.3 - github.com/gofiber/contrib/jwt v1.0.10 github.com/gofiber/fiber/v2 v2.52.6 + github.com/gofiber/jwt/v3 v3.3.10 github.com/gofiber/template/html/v2 v2.1.3 - github.com/golang-jwt/jwt/v4 v4.5.1 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 @@ -66,7 +65,6 @@ require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.5-20250130201111-63bb56e20495.1 // indirect cel.dev/expr v0.19.1 // indirect dario.cat/mergo v1.0.0 // indirect - github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect github.com/Rican7/retry v0.3.1 // indirect github.com/RoaringBitmap/roaring v1.9.3 // indirect github.com/agext/levenshtein v1.2.3 // indirect @@ -119,6 +117,7 @@ require ( github.com/goccy/go-json v0.10.5 // indirect github.com/gofiber/template v1.8.3 // indirect github.com/gofiber/utils v1.1.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.1 // indirect github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect diff --git a/go.sum b/go.sum index 96181448..36b658aa 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,6 @@ github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20O github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/MicahParks/keyfunc/v2 v2.1.0 h1:6ZXKb9Rp6qp1bDbJefnG7cTH8yMN1IC/4nf+GVjO99k= -github.com/MicahParks/keyfunc/v2 v2.1.0/go.mod h1:rW42fi+xgLJ2FRRXAfNx9ZA8WpD4OeE/yHVMteCkw9k= github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8= github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU= github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc= @@ -44,6 +42,7 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM= @@ -262,10 +261,11 @@ github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/gofiber/contrib/jwt v1.0.10 h1:/ilGepl6i0Bntl0Zcd+lAzagY8BiS1+fEiAj32HMApk= -github.com/gofiber/contrib/jwt v1.0.10/go.mod h1:1qBENE6sZ6PPT4xIpBzx1VxeyROQO7sj48OlM1I9qdU= +github.com/gofiber/fiber/v2 v2.45.0/go.mod h1:DNl0/c37WLe0g92U6lx1VMQuxGUQY5V7EIaVoEsUffc= github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI= github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= +github.com/gofiber/jwt/v3 v3.3.10 h1:0bpWtFKaGepjwYTU4efHfy0o+matSqZwTxGMo5a+uuc= +github.com/gofiber/jwt/v3 v3.3.10/go.mod h1:GJorFVaDyfMPSK9RB8RG4NQ3s1oXKTmYaoL/ny08O1A= github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc= github.com/gofiber/template v1.8.3/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8= github.com/gofiber/template/html/v2 v2.1.3 h1:n1LYBtmr9C0V/k/3qBblXyMxV5B0o/gpb6dFLp8ea+o= @@ -276,6 +276,7 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= @@ -329,6 +330,7 @@ github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI= @@ -465,6 +467,7 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -501,6 +504,7 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -509,9 +513,12 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM= @@ -586,6 +593,8 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= @@ -651,6 +660,9 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 h1:GHRpF1pTW19a8tTFrMLUcfWwyC0pnifVo2ClaLq+hP8= github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94/go.mod h1:90zrgN3D/WJsDd1iXHT96alCoN2KJo6/4x1DZC3wZs8= +github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d/go.mod h1:Gy+0tqhJvgGlqnTF8CVGP0AaGRjwBtXs/a5PA0Y3+A4= +github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee/go.mod h1:qwtSXrKuJh/zsFQ12yEE89xfCrGKK63Rr7ctU/uCo4g= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= @@ -702,6 +714,8 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw= +github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw= github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= @@ -719,8 +733,10 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.47.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= github.com/valyala/fasthttp v1.59.0 h1:Qu0qYHfXvPk1mSLNqcFtEk6DpxgA26hy6bmydotDpRI= github.com/valyala/fasthttp v1.59.0/go.mod h1:GTxNb9Bc6r2a9D0TWNSPwDz78UxnTGBViY3xZNEqyYU= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= @@ -728,6 +744,7 @@ github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+x github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= @@ -804,6 +821,7 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= @@ -827,7 +845,9 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -855,12 +875,15 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= @@ -878,6 +901,7 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -918,6 +942,7 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -931,9 +956,11 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -950,7 +977,9 @@ golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXct golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= @@ -965,7 +994,9 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= @@ -992,7 +1023,9 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= diff --git a/internal/service/angelaweb/angela_web.go b/internal/service/angelaweb/angela_web.go index a979da95..ab1c6a65 100644 --- a/internal/service/angelaweb/angela_web.go +++ b/internal/service/angelaweb/angela_web.go @@ -9,9 +9,9 @@ import ( ) type AngelaWeb struct { - handler *api.Handler - builder *page.Builder - app *fiber.App + apiHandler *api.Handler + pageBuilder *page.Builder + app *fiber.App } func NewAngelaWeb(handler *api.Handler, builder *page.Builder) *AngelaWeb { @@ -22,15 +22,13 @@ func NewAngelaWeb(handler *api.Handler, builder *page.Builder) *AngelaWeb { ViewsLayout: "layout/default", }) - app.Static("/static", "./static") - - initRoutes(app) - - return &AngelaWeb{ - handler: handler, - builder: builder, - app: app, + res := &AngelaWeb{ + apiHandler: handler, + pageBuilder: builder, + app: app, } + res.setupRoutes() + return res } func (a *AngelaWeb) Start(ctx context.Context) error { diff --git a/internal/service/angelaweb/internal/api/handler.go b/internal/service/angelaweb/internal/api/handler.go index bf553d54..a3047d32 100644 --- a/internal/service/angelaweb/internal/api/handler.go +++ b/internal/service/angelaweb/internal/api/handler.go @@ -1,7 +1,12 @@ package api import ( + "github.com/gofiber/fiber/v2" + "github.com/golang-jwt/jwt/v5" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + "golang.org/x/crypto/bcrypt" "gorm.io/gorm" + "time" ) type Handler struct { @@ -12,8 +17,114 @@ func NewHandler(db *gorm.DB) *Handler { return &Handler{db: db} } -type User struct { - ID uint `gorm:"primaryKey"` - Username string `gorm:"unique"` - Password string +func (h *Handler) Login(c *fiber.Ctx) error { + var req model.LoginRequest + if err := c.BodyParser(&req); err != nil { + return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + } + + var user model.User + if err := h.db.Where("username = ?", req.Username).First(&user).Error; err != nil { + return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) + } + + if err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(req.Password)); err != nil { + return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) + } + + // 生成JWT + token := jwt.New(jwt.SigningMethodHS256) + claims := token.Claims.(jwt.MapClaims) + claims["user_id"] = user.ID + claims["username"] = user.Username + claims["role"] = user.Role + claims["exp"] = time.Now().Add(time.Hour * 24).Unix() + + t, err := token.SignedString([]byte("your-secret-key")) // 在实际应用中使用环境变量 + if err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Could not login"}) + } + + return c.JSON(model.LoginResponse{Token: t}) +} + +func (h *Handler) ListUsers(c *fiber.Ctx) error { + var users []model.User + if err := h.db.Find(&users).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error fetching users"}) + } + return c.JSON(users) +} + +func (h *Handler) GetUser(c *fiber.Ctx) error { + id := c.Params("id") + var user model.User + if err := h.db.First(&user, id).Error; err != nil { + return c.Status(404).JSON(fiber.Map{"message": "User not found"}) + } + return c.JSON(user) +} + +func (h *Handler) CreateUser(c *fiber.Ctx) error { + var user model.User + if err := c.BodyParser(&user); err != nil { + return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + } + + // 加密密码 + hashedPassword, err := bcrypt.GenerateFromPassword([]byte(user.Password), bcrypt.DefaultCost) + if err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) + } + user.Password = string(hashedPassword) + + if err := h.db.Create(&user).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error creating user"}) + } + return c.JSON(user) +} + +func (h *Handler) UpdateUser(c *fiber.Ctx) error { + id := c.Params("id") + var updates model.User + if err := c.BodyParser(&updates); err != nil { + return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + } + + var user model.User + if err := h.db.First(&user, id).Error; err != nil { + return c.Status(404).JSON(fiber.Map{"message": "User not found"}) + } + + // 如果提供了新密码,则加密 + if updates.Password != "" { + hashedPassword, err := bcrypt.GenerateFromPassword([]byte(updates.Password), bcrypt.DefaultCost) + if err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) + } + updates.Password = string(hashedPassword) + } else { + updates.Password = user.Password + } + + if err := h.db.Model(&user).Updates(updates).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error updating user"}) + } + return c.JSON(user) +} + +func (h *Handler) DeleteUser(c *fiber.Ctx) error { + id := c.Params("id") + if err := h.db.Delete(&model.User{}, id).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error deleting user"}) + } + return c.JSON(fiber.Map{"message": "User deleted"}) +} + +func (h *Handler) GetDashboardStats(c *fiber.Ctx) error { + var userCount int64 + if err := h.db.Model(&model.User{}).Count(&userCount).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error fetching stats"}) + } + return c.JSON(fiber.Map{"user_count": userCount}) } diff --git a/internal/service/angelaweb/internal/api/login.go b/internal/service/angelaweb/internal/api/login.go index baf030c0..778f64ec 100644 --- a/internal/service/angelaweb/internal/api/login.go +++ b/internal/service/angelaweb/internal/api/login.go @@ -1,43 +1 @@ package api - -import ( - "github.com/gofiber/fiber/v2" - "github.com/golang-jwt/jwt/v5" - "time" -) - -func (h *Handler) Login(c *fiber.Ctx) error { - type LoginRequest struct { - Username string `json:"username"` - Password string `json:"password"` - } - - var req LoginRequest - if err := c.BodyParser(&req); err != nil { - return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request"}) - } - - // Validate user credentials (this is just an example, you should use a proper method to validate credentials) - var user User - if err := h.db.Where("username = ? AND password = ?", req.Username, req.Password).First(&user).Error; err != nil { - return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "Invalid credentials"}) - } - - // Generate JWT - token, err := generateJWT(user.ID) - if err != nil { - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to generate token"}) - } - - return c.JSON(fiber.Map{"token": token}) -} - -// Helper function to generate JWT -func generateJWT(userID uint) (string, error) { - claims := jwt.MapClaims{ - "user_id": userID, - "exp": time.Now().Add(time.Hour * 72).Unix(), - } - token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) - return token.SignedString([]byte("secret")) -} diff --git a/internal/service/angelaweb/internal/model/model.go b/internal/service/angelaweb/internal/model/model.go new file mode 100644 index 00000000..c7597d62 --- /dev/null +++ b/internal/service/angelaweb/internal/model/model.go @@ -0,0 +1,23 @@ +package model + +import ( + "time" +) + +type User struct { + ID uint `json:"id" gorm:"primarykey"` + Username string `json:"username" gorm:"unique"` + Password string `json:"-"` // 不在JSON中显示密码 + Email string `json:"email"` + Role string `json:"role"` + CreatedAt time.Time `json:"created_at"` +} + +type LoginRequest struct { + Username string `json:"username"` + Password string `json:"password"` +} + +type LoginResponse struct { + Token string `json:"token"` +} diff --git a/internal/service/angelaweb/internal/page/page.go b/internal/service/angelaweb/internal/page/page.go index 64ffe83c..8a4a4cac 100644 --- a/internal/service/angelaweb/internal/page/page.go +++ b/internal/service/angelaweb/internal/page/page.go @@ -1,6 +1,10 @@ package page -import "gorm.io/gorm" +import ( + "github.com/gofiber/fiber/v2" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + "gorm.io/gorm" +) type Builder struct { db *gorm.DB @@ -9,3 +13,61 @@ type Builder struct { func NewBuilder(db *gorm.DB) *Builder { return &Builder{db: db} } + +func (b *Builder) Dashboard(c *fiber.Ctx) error { + var userCount int64 + if err := b.db.Model(&model.User{}).Count(&userCount).Error; err != nil { + return c.Status(500).SendString("Error fetching dashboard data") + } + + return c.Render("dashboard", fiber.Map{ + "Title": "Dashboard", + "UserCount": userCount, + }) +} + +func (b *Builder) UserList(c *fiber.Ctx) error { + var users []model.User + if err := b.db.Find(&users).Error; err != nil { + return c.Status(500).SendString("Error fetching users") + } + + return c.Render("user", fiber.Map{ + "Title": "用户管理", + "Users": users, + }) +} + +func (b *Builder) UserForm(c *fiber.Ctx) error { + id := c.Params("id") + var user model.User + var title string + var action string + var method string + + if id != "" { + if err := b.db.First(&user, id).Error; err != nil { + return c.Status(404).SendString("User not found") + } + title = "编辑用户" + action = "/api/users/" + id + method = "PUT" + } else { + title = "创建用户" + action = "/api/users" + method = "POST" + } + + return c.Render("user_form", fiber.Map{ + "Title": title, + "User": user, + "Action": action, + "Method": method, + }) +} + +func (b *Builder) Login(c *fiber.Ctx) error { + return c.Render("login", fiber.Map{ + "Title": "登录", + }) +} diff --git a/internal/service/angelaweb/routes.go b/internal/service/angelaweb/routes.go index 95ce4b44..51697a2e 100644 --- a/internal/service/angelaweb/routes.go +++ b/internal/service/angelaweb/routes.go @@ -1,17 +1,45 @@ package angelaweb import ( - jwtware "github.com/gofiber/contrib/jwt" - "github.com/gofiber/fiber/v2" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" + "github.com/gofiber/fiber/v2/middleware/cors" + jwtware "github.com/gofiber/jwt/v3" ) -func initRoutes(app *fiber.App) { - handler := &api.Handler{} +func (a *AngelaWeb) setupRoutes() { + // 静态文件 + a.app.Static("/static", "./static") - app.Post("/api/login", handler.Login) + // CORS + a.app.Use(cors.New()) - app.Use(jwtware.New(jwtware.Config{ - SigningKey: jwtware.SigningKey{Key: []byte("secret")}, + // API路由 + api := a.app.Group("/api") + api.Post("/login", a.apiHandler.Login) + + // JWT中间件 + api.Use(jwtware.New(jwtware.Config{ + SigningKey: []byte("your-secret-key"), + })) + + // 受保护的API路由 + api.Get("/users", a.apiHandler.ListUsers) + api.Post("/users", a.apiHandler.CreateUser) + api.Get("/users/:id", a.apiHandler.GetUser) + api.Put("/users/:id", a.apiHandler.UpdateUser) + api.Delete("/users/:id", a.apiHandler.DeleteUser) + api.Get("/dashboard/stats", a.apiHandler.GetDashboardStats) + + // 页面路由 + a.app.Get("/login", a.pageBuilder.Login) + + // 受保护的页面路由 + auth := a.app.Group("/") + auth.Use(jwtware.New(jwtware.Config{ + SigningKey: []byte("your-secret-key"), })) + + auth.Get("/", a.pageBuilder.Dashboard) + auth.Get("/users", a.pageBuilder.UserList) + auth.Get("/users/new", a.pageBuilder.UserForm) + auth.Get("/users/edit/:id", a.pageBuilder.UserForm) } From c4f9eaabeed40d78773f9085b7a43addc25be74a Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 15 Mar 2025 22:36:55 +0800 Subject: [PATCH 07/19] feat: draft angela web --- go.mod | 3 +- go.sum | 41 ++----------------- internal/service/angelaweb/angela_web_test.go | 13 ++++++ internal/service/angelaweb/routes.go | 6 +-- 4 files changed, 22 insertions(+), 41 deletions(-) diff --git a/go.mod b/go.mod index 5495964e..fbbe5124 100644 --- a/go.mod +++ b/go.mod @@ -19,8 +19,8 @@ require ( github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/v2 v2.8.3 + github.com/gofiber/contrib/jwt v1.0.10 github.com/gofiber/fiber/v2 v2.52.6 - github.com/gofiber/jwt/v3 v3.3.10 github.com/gofiber/template/html/v2 v2.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-cmp v0.7.0 @@ -65,6 +65,7 @@ require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.5-20250130201111-63bb56e20495.1 // indirect cel.dev/expr v0.19.1 // indirect dario.cat/mergo v1.0.0 // indirect + github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect github.com/Rican7/retry v0.3.1 // indirect github.com/RoaringBitmap/roaring v1.9.3 // indirect github.com/agext/levenshtein v1.2.3 // indirect diff --git a/go.sum b/go.sum index 36b658aa..96181448 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20O github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/MicahParks/keyfunc/v2 v2.1.0 h1:6ZXKb9Rp6qp1bDbJefnG7cTH8yMN1IC/4nf+GVjO99k= +github.com/MicahParks/keyfunc/v2 v2.1.0/go.mod h1:rW42fi+xgLJ2FRRXAfNx9ZA8WpD4OeE/yHVMteCkw9k= github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8= github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU= github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc= @@ -42,7 +44,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM= @@ -261,11 +262,10 @@ github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/gofiber/fiber/v2 v2.45.0/go.mod h1:DNl0/c37WLe0g92U6lx1VMQuxGUQY5V7EIaVoEsUffc= +github.com/gofiber/contrib/jwt v1.0.10 h1:/ilGepl6i0Bntl0Zcd+lAzagY8BiS1+fEiAj32HMApk= +github.com/gofiber/contrib/jwt v1.0.10/go.mod h1:1qBENE6sZ6PPT4xIpBzx1VxeyROQO7sj48OlM1I9qdU= github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI= github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= -github.com/gofiber/jwt/v3 v3.3.10 h1:0bpWtFKaGepjwYTU4efHfy0o+matSqZwTxGMo5a+uuc= -github.com/gofiber/jwt/v3 v3.3.10/go.mod h1:GJorFVaDyfMPSK9RB8RG4NQ3s1oXKTmYaoL/ny08O1A= github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc= github.com/gofiber/template v1.8.3/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8= github.com/gofiber/template/html/v2 v2.1.3 h1:n1LYBtmr9C0V/k/3qBblXyMxV5B0o/gpb6dFLp8ea+o= @@ -276,7 +276,6 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= @@ -330,7 +329,6 @@ github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI= @@ -467,7 +465,6 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -504,7 +501,6 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -513,12 +509,9 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM= @@ -593,8 +586,6 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= @@ -660,9 +651,6 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 h1:GHRpF1pTW19a8tTFrMLUcfWwyC0pnifVo2ClaLq+hP8= github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94/go.mod h1:90zrgN3D/WJsDd1iXHT96alCoN2KJo6/4x1DZC3wZs8= -github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d/go.mod h1:Gy+0tqhJvgGlqnTF8CVGP0AaGRjwBtXs/a5PA0Y3+A4= -github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee/go.mod h1:qwtSXrKuJh/zsFQ12yEE89xfCrGKK63Rr7ctU/uCo4g= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= @@ -714,8 +702,6 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw= -github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw= github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= @@ -733,10 +719,8 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.47.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= github.com/valyala/fasthttp v1.59.0 h1:Qu0qYHfXvPk1mSLNqcFtEk6DpxgA26hy6bmydotDpRI= github.com/valyala/fasthttp v1.59.0/go.mod h1:GTxNb9Bc6r2a9D0TWNSPwDz78UxnTGBViY3xZNEqyYU= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= @@ -744,7 +728,6 @@ github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+x github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= @@ -821,7 +804,6 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= @@ -845,9 +827,7 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -875,15 +855,12 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= @@ -901,7 +878,6 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -942,7 +918,6 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -956,11 +931,9 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -977,9 +950,7 @@ golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXct golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= @@ -994,9 +965,7 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= @@ -1023,9 +992,7 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= diff --git a/internal/service/angelaweb/angela_web_test.go b/internal/service/angelaweb/angela_web_test.go index e2bbad21..8deec67a 100644 --- a/internal/service/angelaweb/angela_web_test.go +++ b/internal/service/angelaweb/angela_web_test.go @@ -3,6 +3,7 @@ package angelaweb import ( "context" "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" "testing" @@ -16,6 +17,18 @@ func Test_AngelaWeb(t *testing.T) { if err != nil { t.Fatal(err) } + + admin := model.User{ + Username: "admin", + Password: "admin123", + Email: "admin@example.com", + Role: "admin", + } + err = db.Create(&admin).Error + if err != nil { + t.Fatal(err) + } + handler := api.NewHandler(db) builder := page.NewBuilder(db) angelaWeb := NewAngelaWeb(handler, builder) diff --git a/internal/service/angelaweb/routes.go b/internal/service/angelaweb/routes.go index 51697a2e..b0b23559 100644 --- a/internal/service/angelaweb/routes.go +++ b/internal/service/angelaweb/routes.go @@ -1,8 +1,8 @@ package angelaweb import ( + jwtware "github.com/gofiber/contrib/jwt" "github.com/gofiber/fiber/v2/middleware/cors" - jwtware "github.com/gofiber/jwt/v3" ) func (a *AngelaWeb) setupRoutes() { @@ -18,7 +18,7 @@ func (a *AngelaWeb) setupRoutes() { // JWT中间件 api.Use(jwtware.New(jwtware.Config{ - SigningKey: []byte("your-secret-key"), + SigningKey: jwtware.SigningKey{Key: []byte("secret")}, })) // 受保护的API路由 @@ -35,7 +35,7 @@ func (a *AngelaWeb) setupRoutes() { // 受保护的页面路由 auth := a.app.Group("/") auth.Use(jwtware.New(jwtware.Config{ - SigningKey: []byte("your-secret-key"), + SigningKey: jwtware.SigningKey{Key: []byte("secret")}, })) auth.Get("/", a.pageBuilder.Dashboard) From c2a31726c0784a0114c09c9b03e8023a25c47266 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 15 Mar 2025 22:39:19 +0800 Subject: [PATCH 08/19] feat: draft angela web --- internal/service/angelaweb/angela_web_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/service/angelaweb/angela_web_test.go b/internal/service/angelaweb/angela_web_test.go index 8deec67a..4e6a4027 100644 --- a/internal/service/angelaweb/angela_web_test.go +++ b/internal/service/angelaweb/angela_web_test.go @@ -5,6 +5,7 @@ import ( "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" + "golang.org/x/crypto/bcrypt" "testing" "github.com/stretchr/testify/assert" @@ -24,6 +25,15 @@ func Test_AngelaWeb(t *testing.T) { Email: "admin@example.com", Role: "admin", } + hashedPassword, err := bcrypt.GenerateFromPassword([]byte(admin.Password), bcrypt.DefaultCost) + if err != nil { + t.Fatal(err) + } + admin.Password = string(hashedPassword) + err = db.AutoMigrate(&admin) + if err != nil { + t.Fatal(err) + } err = db.Create(&admin).Error if err != nil { t.Fatal(err) From ddde2b84c2ab246e4da56556801e43fe50395b03 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sun, 16 Mar 2025 00:46:52 +0800 Subject: [PATCH 09/19] feat: draft angela web --- internal/lib/libauth/jwt.go | 8 ++ internal/service/angelaweb/angela_web.go | 5 +- internal/service/angelaweb/angela_web_test.go | 11 +- .../service/angelaweb/internal/api/handler.go | 116 ++---------------- .../service/angelaweb/internal/api/login.go | 46 +++++++ .../service/angelaweb/internal/api/user.go | 78 ++++++++++++ .../service/angelaweb/internal/page/login.go | 1 - .../service/angelaweb/internal/page/page.go | 12 +- internal/service/angelaweb/routes.go | 21 +++- internal/service/angelaweb/view/login.html | 5 +- 10 files changed, 174 insertions(+), 129 deletions(-) delete mode 100644 internal/service/angelaweb/internal/page/login.go diff --git a/internal/lib/libauth/jwt.go b/internal/lib/libauth/jwt.go index 19c1a7e9..5c848559 100644 --- a/internal/lib/libauth/jwt.go +++ b/internal/lib/libauth/jwt.go @@ -72,6 +72,14 @@ func RawFromContext(ctx context.Context) string { return "" } +func ValidateString(tokenString string, keyFunc jwtv5.Keyfunc) (bool, error) { + token, err := jwtv5.ParseWithClaims(tokenString, &Claims{}, keyFunc) + if err != nil { + return false, err + } + return token.Valid, nil +} + func FromContextAssertUserType(ctx context.Context, userTypes ...UserType) *Claims { if userTypes == nil { userTypes = []UserType{UserTypeAdmin, UserTypeNormal} diff --git a/internal/service/angelaweb/angela_web.go b/internal/service/angelaweb/angela_web.go index ab1c6a65..cb40409f 100644 --- a/internal/service/angelaweb/angela_web.go +++ b/internal/service/angelaweb/angela_web.go @@ -4,6 +4,7 @@ import ( "context" "github.com/gofiber/fiber/v2" "github.com/gofiber/template/html/v2" + "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" ) @@ -11,10 +12,11 @@ import ( type AngelaWeb struct { apiHandler *api.Handler pageBuilder *page.Builder + auth *libauth.Auth app *fiber.App } -func NewAngelaWeb(handler *api.Handler, builder *page.Builder) *AngelaWeb { +func NewAngelaWeb(handler *api.Handler, builder *page.Builder, auth *libauth.Auth) *AngelaWeb { viewsEngine := html.New("./view", ".html") app := fiber.New(fiber.Config{ @@ -25,6 +27,7 @@ func NewAngelaWeb(handler *api.Handler, builder *page.Builder) *AngelaWeb { res := &AngelaWeb{ apiHandler: handler, pageBuilder: builder, + auth: auth, app: app, } res.setupRoutes() diff --git a/internal/service/angelaweb/angela_web_test.go b/internal/service/angelaweb/angela_web_test.go index 4e6a4027..ea648d84 100644 --- a/internal/service/angelaweb/angela_web_test.go +++ b/internal/service/angelaweb/angela_web_test.go @@ -2,6 +2,8 @@ package angelaweb import ( "context" + "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" @@ -14,6 +16,11 @@ import ( ) func Test_AngelaWeb(t *testing.T) { + auth, err := libauth.NewAuth(&conf.Auth{ + PasswordSalt: "", + JwtIssuer: "", + JwtSecret: "", + }) db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{}) if err != nil { t.Fatal(err) @@ -39,9 +46,9 @@ func Test_AngelaWeb(t *testing.T) { t.Fatal(err) } - handler := api.NewHandler(db) + handler := api.NewHandler(db, auth) builder := page.NewBuilder(db) - angelaWeb := NewAngelaWeb(handler, builder) + angelaWeb := NewAngelaWeb(handler, builder, auth) err = angelaWeb.Start(context.Background()) diff --git a/internal/service/angelaweb/internal/api/handler.go b/internal/service/angelaweb/internal/api/handler.go index a3047d32..e30dbe6c 100644 --- a/internal/service/angelaweb/internal/api/handler.go +++ b/internal/service/angelaweb/internal/api/handler.go @@ -2,123 +2,21 @@ package api import ( "github.com/gofiber/fiber/v2" - "github.com/golang-jwt/jwt/v5" + "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" - "golang.org/x/crypto/bcrypt" "gorm.io/gorm" - "time" ) type Handler struct { - db *gorm.DB + db *gorm.DB + auth *libauth.Auth } -func NewHandler(db *gorm.DB) *Handler { - return &Handler{db: db} -} - -func (h *Handler) Login(c *fiber.Ctx) error { - var req model.LoginRequest - if err := c.BodyParser(&req); err != nil { - return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) - } - - var user model.User - if err := h.db.Where("username = ?", req.Username).First(&user).Error; err != nil { - return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) - } - - if err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(req.Password)); err != nil { - return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) - } - - // 生成JWT - token := jwt.New(jwt.SigningMethodHS256) - claims := token.Claims.(jwt.MapClaims) - claims["user_id"] = user.ID - claims["username"] = user.Username - claims["role"] = user.Role - claims["exp"] = time.Now().Add(time.Hour * 24).Unix() - - t, err := token.SignedString([]byte("your-secret-key")) // 在实际应用中使用环境变量 - if err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Could not login"}) - } - - return c.JSON(model.LoginResponse{Token: t}) -} - -func (h *Handler) ListUsers(c *fiber.Ctx) error { - var users []model.User - if err := h.db.Find(&users).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error fetching users"}) - } - return c.JSON(users) -} - -func (h *Handler) GetUser(c *fiber.Ctx) error { - id := c.Params("id") - var user model.User - if err := h.db.First(&user, id).Error; err != nil { - return c.Status(404).JSON(fiber.Map{"message": "User not found"}) - } - return c.JSON(user) -} - -func (h *Handler) CreateUser(c *fiber.Ctx) error { - var user model.User - if err := c.BodyParser(&user); err != nil { - return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) - } - - // 加密密码 - hashedPassword, err := bcrypt.GenerateFromPassword([]byte(user.Password), bcrypt.DefaultCost) - if err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) - } - user.Password = string(hashedPassword) - - if err := h.db.Create(&user).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error creating user"}) - } - return c.JSON(user) -} - -func (h *Handler) UpdateUser(c *fiber.Ctx) error { - id := c.Params("id") - var updates model.User - if err := c.BodyParser(&updates); err != nil { - return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) - } - - var user model.User - if err := h.db.First(&user, id).Error; err != nil { - return c.Status(404).JSON(fiber.Map{"message": "User not found"}) - } - - // 如果提供了新密码,则加密 - if updates.Password != "" { - hashedPassword, err := bcrypt.GenerateFromPassword([]byte(updates.Password), bcrypt.DefaultCost) - if err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) - } - updates.Password = string(hashedPassword) - } else { - updates.Password = user.Password - } - - if err := h.db.Model(&user).Updates(updates).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error updating user"}) - } - return c.JSON(user) -} - -func (h *Handler) DeleteUser(c *fiber.Ctx) error { - id := c.Params("id") - if err := h.db.Delete(&model.User{}, id).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error deleting user"}) +func NewHandler(db *gorm.DB, auth *libauth.Auth) *Handler { + return &Handler{ + db: db, + auth: auth, } - return c.JSON(fiber.Map{"message": "User deleted"}) } func (h *Handler) GetDashboardStats(c *fiber.Ctx) error { diff --git a/internal/service/angelaweb/internal/api/login.go b/internal/service/angelaweb/internal/api/login.go index 778f64ec..531af528 100644 --- a/internal/service/angelaweb/internal/api/login.go +++ b/internal/service/angelaweb/internal/api/login.go @@ -1 +1,47 @@ package api + +import ( + "github.com/gofiber/fiber/v2" + "github.com/tuihub/librarian/internal/lib/libauth" + model2 "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + "time" +) + +func (h *Handler) Login(c *fiber.Ctx) error { + var req model.LoginRequest + if err := c.BodyParser(&req); err != nil { + return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + } + + var user model.User + if err := h.db.Where("username = ?", req.Username).First(&user).Error; err != nil { + return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) + } + + hashedPassword, err := h.auth.GeneratePassword(req.Password) + if err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) + } + + if hashedPassword != user.Password { + return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) + } + + token, err := h.auth.GenerateToken(model2.InternalID(user.ID), 0, libauth.ClaimsTypeAccessToken, libauth.UserTypeAdmin, nil, 24*time.Hour) + if err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error generating token"}) + } + + c.Cookie(&fiber.Cookie{ + Name: "access_token", + Value: token, + Expires: time.Now().Add(24 * time.Hour), + HTTPOnly: true, + Secure: true, + SameSite: "strict", + Path: "/", + }) + + return c.JSON(model.LoginResponse{}) +} diff --git a/internal/service/angelaweb/internal/api/user.go b/internal/service/angelaweb/internal/api/user.go index 778f64ec..3aac6bc0 100644 --- a/internal/service/angelaweb/internal/api/user.go +++ b/internal/service/angelaweb/internal/api/user.go @@ -1 +1,79 @@ package api + +import ( + "github.com/gofiber/fiber/v2" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" +) + +func (h *Handler) ListUsers(c *fiber.Ctx) error { + var users []model.User + if err := h.db.Find(&users).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error fetching users"}) + } + return c.JSON(users) +} + +func (h *Handler) GetUser(c *fiber.Ctx) error { + id := c.Params("id") + var user model.User + if err := h.db.First(&user, id).Error; err != nil { + return c.Status(404).JSON(fiber.Map{"message": "User not found"}) + } + return c.JSON(user) +} + +func (h *Handler) CreateUser(c *fiber.Ctx) error { + var user model.User + if err := c.BodyParser(&user); err != nil { + return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + } + + // 加密密码 + hashedPassword, err := h.auth.GeneratePassword(user.Password) + if err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) + } + user.Password = hashedPassword + + if err := h.db.Create(&user).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error creating user"}) + } + return c.JSON(user) +} + +func (h *Handler) UpdateUser(c *fiber.Ctx) error { + id := c.Params("id") + var updates model.User + if err := c.BodyParser(&updates); err != nil { + return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + } + + var user model.User + if err := h.db.First(&user, id).Error; err != nil { + return c.Status(404).JSON(fiber.Map{"message": "User not found"}) + } + + // 如果提供了新密码,则加密 + if updates.Password != "" { + hashedPassword, err := h.auth.GeneratePassword(user.Password) + if err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) + } + updates.Password = hashedPassword + } else { + updates.Password = user.Password + } + + if err := h.db.Model(&user).Updates(updates).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error updating user"}) + } + return c.JSON(user) +} + +func (h *Handler) DeleteUser(c *fiber.Ctx) error { + id := c.Params("id") + if err := h.db.Delete(&model.User{}, id).Error; err != nil { + return c.Status(500).JSON(fiber.Map{"message": "Error deleting user"}) + } + return c.JSON(fiber.Map{"message": "User deleted"}) +} diff --git a/internal/service/angelaweb/internal/page/login.go b/internal/service/angelaweb/internal/page/login.go deleted file mode 100644 index 52aa8377..00000000 --- a/internal/service/angelaweb/internal/page/login.go +++ /dev/null @@ -1 +0,0 @@ -package page diff --git a/internal/service/angelaweb/internal/page/page.go b/internal/service/angelaweb/internal/page/page.go index 8a4a4cac..23e4ef02 100644 --- a/internal/service/angelaweb/internal/page/page.go +++ b/internal/service/angelaweb/internal/page/page.go @@ -14,6 +14,12 @@ func NewBuilder(db *gorm.DB) *Builder { return &Builder{db: db} } +func (b *Builder) Login(c *fiber.Ctx) error { + return c.Render("login", fiber.Map{ + "Title": "登录", + }) +} + func (b *Builder) Dashboard(c *fiber.Ctx) error { var userCount int64 if err := b.db.Model(&model.User{}).Count(&userCount).Error; err != nil { @@ -65,9 +71,3 @@ func (b *Builder) UserForm(c *fiber.Ctx) error { "Method": method, }) } - -func (b *Builder) Login(c *fiber.Ctx) error { - return c.Render("login", fiber.Map{ - "Title": "登录", - }) -} diff --git a/internal/service/angelaweb/routes.go b/internal/service/angelaweb/routes.go index b0b23559..580a7344 100644 --- a/internal/service/angelaweb/routes.go +++ b/internal/service/angelaweb/routes.go @@ -1,10 +1,18 @@ package angelaweb import ( - jwtware "github.com/gofiber/contrib/jwt" + "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" + "github.com/gofiber/fiber/v2/middleware/keyauth" + "github.com/tuihub/librarian/internal/lib/libauth" ) +func (a *AngelaWeb) newValidator() func(ctx *fiber.Ctx, s string) (bool, error) { + return func(ctx *fiber.Ctx, s string) (bool, error) { + return libauth.ValidateString(s, a.auth.KeyFunc(libauth.ClaimsTypeAccessToken)) + } +} + func (a *AngelaWeb) setupRoutes() { // 静态文件 a.app.Static("/static", "./static") @@ -16,9 +24,9 @@ func (a *AngelaWeb) setupRoutes() { api := a.app.Group("/api") api.Post("/login", a.apiHandler.Login) - // JWT中间件 - api.Use(jwtware.New(jwtware.Config{ - SigningKey: jwtware.SigningKey{Key: []byte("secret")}, + api.Use(keyauth.New(keyauth.Config{ + KeyLookup: "cookie:access_token", + Validator: a.newValidator(), })) // 受保护的API路由 @@ -34,8 +42,9 @@ func (a *AngelaWeb) setupRoutes() { // 受保护的页面路由 auth := a.app.Group("/") - auth.Use(jwtware.New(jwtware.Config{ - SigningKey: jwtware.SigningKey{Key: []byte("secret")}, + auth.Use(keyauth.New(keyauth.Config{ + KeyLookup: "cookie:access_token", + Validator: a.newValidator(), })) auth.Get("/", a.pageBuilder.Dashboard) diff --git a/internal/service/angelaweb/view/login.html b/internal/service/angelaweb/view/login.html index 329f01b1..18563d5b 100644 --- a/internal/service/angelaweb/view/login.html +++ b/internal/service/angelaweb/view/login.html @@ -55,10 +55,7 @@

0 { q.Where(user.IDIn(ids...)) @@ -280,7 +277,7 @@ func (t tipherethRepo) ListUsers( return converter.ToBizUserList(u), int64(count), nil } -func (t tipherethRepo) GetUser(ctx context.Context, id model.InternalID) (*modeltiphereth.User, error) { +func (t tipherethRepo) GetUser(ctx context.Context, id model.InternalID) (*model.User, error) { u, err := t.data.db.User.Get(ctx, id) if err != nil { return nil, err @@ -294,7 +291,7 @@ func (t tipherethRepo) GetUserCount(ctx context.Context) (int, error) { func (t tipherethRepo) LinkAccount( ctx context.Context, - a modeltiphereth.Account, + a model.Account, userID model.InternalID, ) (model.InternalID, error) { accountID := a.ID @@ -348,7 +345,7 @@ func (t tipherethRepo) LinkAccount( return accountID, nil } -func (t tipherethRepo) UnLinkAccount(ctx context.Context, a modeltiphereth.Account, u model.InternalID) error { +func (t tipherethRepo) UnLinkAccount(ctx context.Context, a model.Account, u model.InternalID) error { return t.data.db.Account.Update().Where( account.PlatformEQ(a.Platform), account.PlatformAccountIDEQ(a.PlatformAccountID), @@ -361,7 +358,7 @@ func (t tipherethRepo) UnLinkAccount(ctx context.Context, a modeltiphereth.Accou func (t tipherethRepo) ListLinkAccounts( ctx context.Context, userID model.InternalID, -) ([]*modeltiphereth.Account, error) { +) ([]*model.Account, error) { a, err := t.data.db.Account.Query(). Where( account.HasBindUserWith(user.IDEQ(userID)), @@ -429,7 +426,7 @@ func (t tipherethRepo) ListPorters( func (t tipherethRepo) UpdatePorterStatus( ctx context.Context, id model.InternalID, - status modeltiphereth.UserStatus, + status model.UserStatus, ) (*modelsupervisor.PorterInstance, error) { pi, err := t.data.db.PorterInstance.Get(ctx, id) if err != nil { @@ -509,7 +506,7 @@ func (t tipherethRepo) UpdatePorterContext( func (t tipherethRepo) ListPorterGroups( ctx context.Context, - status []modeltiphereth.UserStatus, + status []model.UserStatus, ) ([]*modelsupervisor.PorterGroup, error) { var res []struct { ent.PorterInstance diff --git a/app/sephirah/internal/data/yesod.go b/app/sephirah/internal/data/yesod.go index 1a7bf759..f6384c84 100644 --- a/app/sephirah/internal/data/yesod.go +++ b/app/sephirah/internal/data/yesod.go @@ -16,7 +16,6 @@ import ( "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" - "github.com/tuihub/librarian/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/model/modelyesod" ) @@ -537,7 +536,7 @@ func (y *yesodRepo) ListFeedItemsInCollection( return res, total, nil } -func (y *yesodRepo) GetFeedOwner(ctx context.Context, id model.InternalID) (*modeltiphereth.User, error) { +func (y *yesodRepo) GetFeedOwner(ctx context.Context, id model.InternalID) (*model.User, error) { only, err := y.data.db.FeedConfig.Query().Where(feedconfig.IDEQ(id)).QueryOwner().Only(ctx) if err != nil { return nil, err diff --git a/go.mod b/go.mod index fbbe5124..7eec3f57 100644 --- a/go.mod +++ b/go.mod @@ -102,6 +102,7 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/dave/jennifer v1.6.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect @@ -137,6 +138,7 @@ require ( github.com/jhump/protoreflect v1.15.1 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/jmattheis/goverter v1.5.0 // indirect github.com/jonboulle/clockwork v0.5.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect diff --git a/go.sum b/go.sum index 96181448..533ff9df 100644 --- a/go.sum +++ b/go.sum @@ -157,6 +157,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/dave/jennifer v1.6.0 h1:MQ/6emI2xM7wt0tJzJzyUik2Q3Tcn2eE0vtYgh4GPVI= +github.com/dave/jennifer v1.6.0/go.mod h1:AxTG893FiZKqxy3FP1kL80VMshSMuz2G+EgvszgGRnk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -439,6 +441,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jmattheis/goverter v1.5.0 h1:3ANt/y+OzmB63Kw55ejYPv0J44RqNY781zNETVgi8WQ= +github.com/jmattheis/goverter v1.5.0/go.mod h1:iVIl/4qItWjWj2g3vjouGoYensJbRqDHpzlEVMHHFeY= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/internal/biz/bizangela/account.go b/internal/biz/bizangela/account.go index f2776009..1ebfd46e 100644 --- a/internal/biz/bizangela/account.go +++ b/internal/biz/bizangela/account.go @@ -6,10 +6,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" - "github.com/tuihub/librarian/internal/model/modeltiphereth" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) @@ -17,10 +15,10 @@ import ( func NewPullAccountTopic( a *AngelaBase, sr *libmq.Topic[modelangela.PullAccountAppInfoRelation], -) *libmq.Topic[modeltiphereth.PullAccountInfo] { - return libmq.NewTopic[modeltiphereth.PullAccountInfo]( +) *libmq.Topic[model.PullAccountInfo] { + return libmq.NewTopic[model.PullAccountInfo]( "PullAccountInfo", - func(ctx context.Context, info *modeltiphereth.PullAccountInfo) error { + func(ctx context.Context, info *model.PullAccountInfo) error { if !a.supv.HasAccountPlatform(info.Platform) { return nil } @@ -34,7 +32,7 @@ func NewPullAccountTopic( if err != nil { return err } - err = a.repo.UpsertAccount(ctx, modeltiphereth.Account{ + err = a.repo.UpsertAccount(ctx, model.Account{ ID: info.ID, Platform: info.Platform, PlatformAccountID: info.PlatformAccountID, diff --git a/internal/biz/bizangela/angela.go b/internal/biz/bizangela/angela.go index de68beb8..e6cc2956 100644 --- a/internal/biz/bizangela/angela.go +++ b/internal/biz/bizangela/angela.go @@ -12,7 +12,6 @@ import ( "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelgebura" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/model/modelyesod" "github.com/tuihub/librarian/internal/service/supervisor" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" @@ -51,7 +50,7 @@ type AngelaBase struct { } type AngelaRepo interface { - UpsertAccount(context.Context, modeltiphereth.Account) error + UpsertAccount(context.Context, model.Account) error UpsertAppInfo(context.Context, *modelgebura.AppInfo, *modelgebura.AppInfo) error UpsertAppInfos(context.Context, []*modelgebura.AppInfo) error AccountPurchaseAppInfos(context.Context, model.InternalID, []model.InternalID) error @@ -86,7 +85,7 @@ func NewAngelaBase( func NewAngela( base *AngelaBase, mq *libmq.MQ, - pullAccountInfo *libmq.Topic[modeltiphereth.PullAccountInfo], + pullAccountInfo *libmq.Topic[model.PullAccountInfo], pullAccountAppInfoRelation *libmq.Topic[modelangela.PullAccountAppInfoRelation], pullAppInfo *libmq.Topic[modelangela.PullAppInfo], pullFeed *libmq.Topic[modelyesod.PullFeed], diff --git a/internal/biz/bizangela/app.go b/internal/biz/bizangela/app.go index 5446b3cd..8764f0a6 100644 --- a/internal/biz/bizangela/app.go +++ b/internal/biz/bizangela/app.go @@ -10,7 +10,6 @@ import ( "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" diff --git a/internal/biz/bizangela/feed.go b/internal/biz/bizangela/feed.go index f48daf6d..a4af41e4 100644 --- a/internal/biz/bizangela/feed.go +++ b/internal/biz/bizangela/feed.go @@ -9,7 +9,6 @@ import ( "github.com/tuihub/librarian/internal/biz/bizyesod" "github.com/tuihub/librarian/internal/lib/libmq" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelnetzach" diff --git a/internal/biz/bizangela/notify.go b/internal/biz/bizangela/notify.go index a1b3ef5f..8e68c8c0 100644 --- a/internal/biz/bizangela/notify.go +++ b/internal/biz/bizangela/notify.go @@ -11,7 +11,6 @@ import ( "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelnetzach" diff --git a/internal/biz/bizangela/porter.go b/internal/biz/bizangela/porter.go index aeab9b54..4cfab7d2 100644 --- a/internal/biz/bizangela/porter.go +++ b/internal/biz/bizangela/porter.go @@ -2,7 +2,6 @@ package bizangela import ( "context" - "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" @@ -11,7 +10,7 @@ import ( ) func (a *Angela) PorterGetNotifyTargetItems(ctx context.Context, id model.InternalID, paging model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) { - claims := libauth.FromContextAssertUserType(ctx, libauth.UserTypePorter) + claims := libauth.FromContextAssertUserType(ctx, model.UserTypePorter) if claims == nil { return nil, nil, bizutils.NoPermissionError() } diff --git a/internal/biz/bizgebura/app_info.go b/internal/biz/bizgebura/app_info.go index 9e906cf8..87403ce7 100644 --- a/internal/biz/bizgebura/app_info.go +++ b/internal/biz/bizgebura/app_info.go @@ -9,7 +9,6 @@ import ( "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" @@ -22,7 +21,7 @@ func (g *Gebura) CreateAppInfo( ctx context.Context, appInfo *modelgebura.AppInfo, ) (*modelgebura.AppInfo, *errors.Error) { - if libauth.FromContextAssertUserType(ctx, libauth.UserTypeAdmin) == nil { + if libauth.FromContextAssertUserType(ctx, model.UserTypeAdmin) == nil { return nil, bizutils.NoPermissionError() } id, err := g.id.New() @@ -42,7 +41,7 @@ func (g *Gebura) CreateAppInfo( } func (g *Gebura) UpdateAppInfo(ctx context.Context, appInfo *modelgebura.AppInfo) *errors.Error { - if libauth.FromContextAssertUserType(ctx, libauth.UserTypeAdmin) == nil { + if libauth.FromContextAssertUserType(ctx, model.UserTypeAdmin) == nil { return bizutils.NoPermissionError() } appInfo.Internal = true @@ -62,7 +61,7 @@ func (g *Gebura) ListAppInfos( ids []model.InternalID, containDetails bool, ) ([]*modelgebura.AppInfo, int64, *errors.Error) { - if libauth.FromContextAssertUserType(ctx, libauth.UserTypeAdmin) == nil { + if libauth.FromContextAssertUserType(ctx, model.UserTypeAdmin) == nil { return nil, 0, bizutils.NoPermissionError() } infos, total, err := g.repo.ListAppInfos(ctx, paging, sources, types, ids, containDetails) @@ -73,7 +72,7 @@ func (g *Gebura) ListAppInfos( } func (g *Gebura) MergeAppInfos(ctx context.Context, base modelgebura.AppInfo, merged model.InternalID) *errors.Error { - if libauth.FromContextAssertUserType(ctx, libauth.UserTypeAdmin) == nil { + if libauth.FromContextAssertUserType(ctx, model.UserTypeAdmin) == nil { return bizutils.NoPermissionError() } if !base.Internal { diff --git a/internal/biz/biznetzach/netzach.go b/internal/biz/biznetzach/netzach.go index f7b5f305..21b30c80 100644 --- a/internal/biz/biznetzach/netzach.go +++ b/internal/biz/biznetzach/netzach.go @@ -2,7 +2,6 @@ package biznetzach import ( "context" - "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" @@ -246,7 +245,7 @@ func (n *Netzach) ListSystemNotifications( return nil, 0, bizutils.NoPermissionError() } var userID *model.InternalID - if claims.UserType != libauth.UserTypeAdmin { + if claims.UserType != model.UserTypeAdmin { types = []modelnetzach.SystemNotificationType{modelnetzach.SystemNotificationTypeUser} userID = &claims.UserID } diff --git a/internal/biz/biztiphereth/account.go b/internal/biz/biztiphereth/account.go index 81ab63d7..66f24daf 100644 --- a/internal/biz/biztiphereth/account.go +++ b/internal/biz/biztiphereth/account.go @@ -7,7 +7,6 @@ import ( "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" @@ -15,8 +14,8 @@ import ( func (t *Tiphereth) LinkAccount( ctx context.Context, - a modeltiphereth.Account, -) (*modeltiphereth.Account, *errors.Error) { + a model.Account, +) (*model.Account, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() @@ -29,7 +28,7 @@ func (t *Tiphereth) LinkAccount( return nil, pb.ErrorErrorReasonUnspecified("%s", err) } a.ID = id - if err = t.pullAccount.LocalCall(ctx, modeltiphereth.PullAccountInfo{ + if err = t.pullAccount.LocalCall(ctx, model.PullAccountInfo{ ID: a.ID, Platform: a.Platform, PlatformAccountID: a.PlatformAccountID, @@ -44,7 +43,7 @@ func (t *Tiphereth) LinkAccount( return &a, nil } -func (t *Tiphereth) UnLinkAccount(ctx context.Context, a modeltiphereth.Account) *errors.Error { +func (t *Tiphereth) UnLinkAccount(ctx context.Context, a model.Account) *errors.Error { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return bizutils.NoPermissionError() @@ -60,7 +59,7 @@ func (t *Tiphereth) UnLinkAccount(ctx context.Context, a modeltiphereth.Account) func (t *Tiphereth) ListLinkAccounts( ctx context.Context, id model.InternalID, -) ([]*modeltiphereth.Account, *errors.Error) { +) ([]*model.Account, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() diff --git a/internal/biz/biztiphereth/porter.go b/internal/biz/biztiphereth/porter.go index d9475b54..5dee5afb 100644 --- a/internal/biz/biztiphereth/porter.go +++ b/internal/biz/biztiphereth/porter.go @@ -8,7 +8,6 @@ import ( "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" @@ -40,7 +39,7 @@ func (t *Tiphereth) updatePorters(ctx context.Context) error { } for i, porter := range newPorters { porter.ID = ids[i] - porter.Status = modeltiphereth.UserStatusBlocked + porter.Status = model.UserStatusBlocked } err = t.repo.UpsertPorters(ctx, newPorters) if err != nil { @@ -54,7 +53,7 @@ func (t *Tiphereth) ListPorters( ctx context.Context, paging model.Paging, ) ([]*modelsupervisor.PorterInstance, int64, *errors.Error) { - if libauth.FromContextAssertUserType(ctx, libauth.UserTypeAdmin) == nil { + if libauth.FromContextAssertUserType(ctx, model.UserTypeAdmin) == nil { return nil, 0, bizutils.NoPermissionError() } porters, total, err := t.repo.ListPorters(ctx, paging) @@ -67,9 +66,9 @@ func (t *Tiphereth) ListPorters( func (t *Tiphereth) UpdatePorterStatus( ctx context.Context, id model.InternalID, - status modeltiphereth.UserStatus, + status model.UserStatus, ) *errors.Error { - if libauth.FromContextAssertUserType(ctx, libauth.UserTypeAdmin) == nil { + if libauth.FromContextAssertUserType(ctx, model.UserTypeAdmin) == nil { return bizutils.NoPermissionError() } pi, err := t.repo.UpdatePorterStatus(ctx, id, status) @@ -127,14 +126,14 @@ func (t *Tiphereth) UpdatePorterContext( func (t *Tiphereth) ListPorterGroups( ctx context.Context, paging model.Paging, - status []modeltiphereth.UserStatus, + status []model.UserStatus, ) ([]*modelsupervisor.PorterGroup, int64, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, 0, bizutils.NoPermissionError() } - if claims.UserType != libauth.UserTypeAdmin { - status = []modeltiphereth.UserStatus{modeltiphereth.UserStatusActive} + if claims.UserType != model.UserTypeAdmin { + status = []model.UserStatus{model.UserStatusActive} } groups, err := t.repo.ListPorterGroups(ctx, status) if err != nil { diff --git a/internal/biz/biztiphereth/tiphereth.go b/internal/biz/biztiphereth/tiphereth.go index ea0f18e9..8e41ab64 100644 --- a/internal/biz/biztiphereth/tiphereth.go +++ b/internal/biz/biztiphereth/tiphereth.go @@ -15,7 +15,6 @@ import ( "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/service/supervisor" "github.com/google/wire" @@ -29,36 +28,36 @@ var ProviderSet = wire.NewSet( ) type TipherethRepo interface { - FetchUserByPassword(context.Context, string, string) (*modeltiphereth.User, error) - CreateUser(context.Context, *modeltiphereth.User, model.InternalID) error - UpdateUser(context.Context, *modeltiphereth.User, string) error + FetchUserByPassword(context.Context, string, string) (*model.User, error) + CreateUser(context.Context, *model.User, model.InternalID) error + UpdateUser(context.Context, *model.User, string) error ListUsers(context.Context, model.Paging, []model.InternalID, - []libauth.UserType, []modeltiphereth.UserStatus, []model.InternalID, - model.InternalID) ([]*modeltiphereth.User, int64, error) + []model.UserType, []model.UserStatus, []model.InternalID, + model.InternalID) ([]*model.User, int64, error) GetUserCount(context.Context) (int, error) - LinkAccount(context.Context, modeltiphereth.Account, model.InternalID) (model.InternalID, error) - UnLinkAccount(context.Context, modeltiphereth.Account, model.InternalID) error - ListLinkAccounts(context.Context, model.InternalID) ([]*modeltiphereth.Account, error) - GetUser(context.Context, model.InternalID) (*modeltiphereth.User, error) + LinkAccount(context.Context, model.Account, model.InternalID) (model.InternalID, error) + UnLinkAccount(context.Context, model.Account, model.InternalID) error + ListLinkAccounts(context.Context, model.InternalID) ([]*model.Account, error) + GetUser(context.Context, model.InternalID) (*model.User, error) UpsertPorters(context.Context, []*modelsupervisor.PorterInstance) error ListPorters(context.Context, model.Paging) ([]*modelsupervisor.PorterInstance, int64, error) FetchPorterByAddress(context.Context, string) (*modelsupervisor.PorterInstance, error) UpdatePorterStatus(context.Context, model.InternalID, - modeltiphereth.UserStatus) (*modelsupervisor.PorterInstance, error) + model.UserStatus) (*modelsupervisor.PorterInstance, error) CreatePorterContext(context.Context, model.InternalID, *modelsupervisor.PorterContext) error GetEnabledPorterContexts(context.Context) ([]*modelsupervisor.PorterContext, error) ListPorterContexts(context.Context, model.InternalID, model.Paging) ([]*modelsupervisor.PorterContext, int64, error) UpdatePorterContext(context.Context, model.InternalID, *modelsupervisor.PorterContext) error FetchPorterContext(context.Context, model.InternalID) (*modelsupervisor.PorterContext, error) - CreateDevice(context.Context, model.InternalID, *modeltiphereth.DeviceInfo, *string) (model.InternalID, error) - ListUserSessions(context.Context, model.InternalID) ([]*modeltiphereth.UserSession, error) + CreateDevice(context.Context, model.InternalID, *model.DeviceInfo, *string) (model.InternalID, error) + ListUserSessions(context.Context, model.InternalID) ([]*model.UserSession, error) DeleteUserSession(context.Context, model.InternalID, model.InternalID) error - FetchDeviceInfo(context.Context, model.InternalID) (*modeltiphereth.DeviceInfo, error) - CreateUserSession(context.Context, *modeltiphereth.UserSession) error - FetchUserSession(context.Context, model.InternalID, string) (*modeltiphereth.UserSession, error) - UpdateUserSession(context.Context, *modeltiphereth.UserSession) error - ListDevices(context.Context, model.InternalID) ([]*modeltiphereth.DeviceInfo, error) - ListPorterGroups(context.Context, []modeltiphereth.UserStatus) ([]*modelsupervisor.PorterGroup, error) + FetchDeviceInfo(context.Context, model.InternalID) (*model.DeviceInfo, error) + CreateUserSession(context.Context, *model.UserSession) error + FetchUserSession(context.Context, model.InternalID, string) (*model.UserSession, error) + UpdateUserSession(context.Context, *model.UserSession) error + ListDevices(context.Context, model.InternalID) ([]*model.DeviceInfo, error) + ListPorterGroups(context.Context, []model.UserStatus) ([]*modelsupervisor.PorterGroup, error) } type Tiphereth struct { @@ -68,8 +67,8 @@ type Tiphereth struct { supv *supervisor.Supervisor id *libidgenerator.IDGenerator search libsearch.Search - pullAccount *libmq.Topic[modeltiphereth.PullAccountInfo] - userCountCache *libcache.Key[modeltiphereth.UserCount] + pullAccount *libmq.Topic[model.PullAccountInfo] + userCountCache *libcache.Key[model.UserCount] porterInstanceCache *libcache.Map[string, modelsupervisor.PorterInstance] } @@ -80,9 +79,9 @@ func NewTiphereth( supv *supervisor.Supervisor, id *libidgenerator.IDGenerator, search libsearch.Search, - pullAccount *libmq.Topic[modeltiphereth.PullAccountInfo], + pullAccount *libmq.Topic[model.PullAccountInfo], cron *libcron.Cron, - userCountCache *libcache.Key[modeltiphereth.UserCount], + userCountCache *libcache.Key[model.UserCount], porterInstanceCache *libcache.Map[string, modelsupervisor.PorterInstance], ) (*Tiphereth, error) { t := &Tiphereth{ @@ -117,25 +116,25 @@ func (t *Tiphereth) CreateConfiguredAdmin() { if !(t.app.EnvExist(libapp.EnvDemoMode) || t.app.EnvExist(libapp.EnvCreateAdminUserName)) { return } - user := &modeltiphereth.User{ + user := &model.User{ ID: 0, - UserName: demoAdminUserName, - PassWord: demoAdminPassword, - Type: libauth.UserTypeAdmin, - Status: modeltiphereth.UserStatusActive, + Username: demoAdminUserName, + Password: demoAdminPassword, + Type: model.UserTypeAdmin, + Status: model.UserStatusActive, } if username, err := t.app.Env(libapp.EnvCreateAdminUserName); err == nil && username != "" { - user.UserName = username + user.Username = username } if password, err := t.app.Env(libapp.EnvCreateAdminPassword); err == nil && password != "" { - user.PassWord = password + user.Password = password } - password, err := t.auth.GeneratePassword(user.PassWord) + password, err := t.auth.GeneratePassword(user.Password) if err != nil { logger.Infof("generate password failed: %s", err.Error()) return } - user.PassWord = password + user.Password = password id, err := t.id.New() if err != nil { return @@ -159,16 +158,16 @@ func (t *Tiphereth) CreateConfiguredAdmin() { func NewUserCountCache( t TipherethRepo, store libcache.Store, -) *libcache.Key[modeltiphereth.UserCount] { - return libcache.NewKey[modeltiphereth.UserCount]( +) *libcache.Key[model.UserCount] { + return libcache.NewKey[model.UserCount]( store, "UserCount", - func(ctx context.Context) (*modeltiphereth.UserCount, error) { + func(ctx context.Context) (*model.UserCount, error) { res, err := t.GetUserCount(ctx) if err != nil { return nil, err } - return &modeltiphereth.UserCount{Count: res}, nil + return &model.UserCount{Count: res}, nil }, libcache.WithExpiration(libtime.SevenDays), ) diff --git a/internal/biz/biztiphereth/token.go b/internal/biz/biztiphereth/token.go index 9bbd5d9a..4a5b8031 100644 --- a/internal/biz/biztiphereth/token.go +++ b/internal/biz/biztiphereth/token.go @@ -9,7 +9,6 @@ import ( "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/go-kratos/kratos/v2/errors" @@ -23,7 +22,7 @@ func (t *Tiphereth) GetToken( ctx context.Context, username, password string, deviceID *model.InternalID, -) (modeltiphereth.AccessToken, modeltiphereth.RefreshToken, *errors.Error) { +) (model.AccessToken, model.RefreshToken, *errors.Error) { password, err := t.auth.GeneratePassword(password) if err != nil { logger.Infof("generate password failed: %s", err.Error()) @@ -35,7 +34,7 @@ func (t *Tiphereth) GetToken( logger.Infof("FetchUserByPassword failed: %s", err.Error()) return "", "", pb.ErrorErrorReasonUnauthorized("invalid user or password") } - if user.Status != modeltiphereth.UserStatusActive { + if user.Status != model.UserStatusActive { return "", "", pb.ErrorErrorReasonUnauthorized("user not active") } @@ -43,7 +42,7 @@ func (t *Tiphereth) GetToken( if err != nil { return "", "", pb.ErrorErrorReasonUnspecified("%s", err.Error()) } - userSession := &modeltiphereth.UserSession{ + userSession := &model.UserSession{ ID: sessionID, UserID: user.ID, RefreshToken: "", @@ -90,15 +89,15 @@ func (t *Tiphereth) GetToken( logger.Infof("create user session failed: %s", err.Error()) return "", "", pb.ErrorErrorReasonUnspecified("%s", err.Error()) } - return modeltiphereth.AccessToken(accessToken), modeltiphereth.RefreshToken(refreshToken), nil + return model.AccessToken(accessToken), model.RefreshToken(refreshToken), nil } func (t *Tiphereth) RefreshToken( //nolint:gocognit // TODO ctx context.Context, deviceID *model.InternalID, -) (modeltiphereth.AccessToken, modeltiphereth.RefreshToken, *errors.Error) { +) (model.AccessToken, model.RefreshToken, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx, - libauth.UserTypeAdmin, libauth.UserTypeNormal, libauth.UserTypeSentinel, libauth.UserTypePorter) + model.UserTypeAdmin, model.UserTypeNormal, model.UserTypeSentinel, model.UserTypePorter) if claims == nil { return "", "", bizutils.NoPermissionError() } @@ -107,9 +106,9 @@ func (t *Tiphereth) RefreshToken( //nolint:gocognit // TODO return "", "", bizutils.NoPermissionError() } needUpdate := false - session := new(modeltiphereth.UserSession) + session := new(model.UserSession) var err error - if claims.UserType != libauth.UserTypePorter { //nolint:nestif // TODO + if claims.UserType != model.UserTypePorter { //nolint:nestif // TODO session, err = t.repo.FetchUserSession(ctx, claims.UserID, oldRefreshToken) if err != nil { return "", "", bizutils.NoPermissionError() @@ -159,21 +158,21 @@ func (t *Tiphereth) RefreshToken( //nolint:gocognit // TODO session.ExpireAt = time.Now().Add(refreshTokenExpire) needUpdate = true } - if claims.UserType != libauth.UserTypePorter && needUpdate { + if claims.UserType != model.UserTypePorter && needUpdate { err = t.repo.UpdateUserSession(ctx, session) if err != nil { logger.Infof("update user session failed: %s", err.Error()) return "", "", pb.ErrorErrorReasonUnspecified("%s", err.Error()) } } - return modeltiphereth.AccessToken(accessToken), modeltiphereth.RefreshToken(refreshToken), nil + return model.AccessToken(accessToken), model.RefreshToken(refreshToken), nil } func (t *Tiphereth) AcquireUserToken( ctx context.Context, userID model.InternalID, -) (modeltiphereth.AccessToken, *errors.Error) { - claims := libauth.FromContextAssertUserType(ctx, libauth.UserTypePorter) +) (model.AccessToken, *errors.Error) { + claims := libauth.FromContextAssertUserType(ctx, model.UserTypePorter) if claims == nil || claims.PorterID != 0 { return "", bizutils.NoPermissionError() } @@ -182,7 +181,7 @@ func (t *Tiphereth) AcquireUserToken( userID, claims.UserID, libauth.ClaimsTypeAccessToken, - libauth.UserTypeNormal, + model.UserTypeNormal, nil, libtime.Day, ) @@ -190,12 +189,12 @@ func (t *Tiphereth) AcquireUserToken( logger.Infof("generate access token failed: %s", err.Error()) return "", pb.ErrorErrorReasonUnspecified("%s", err.Error()) } - return modeltiphereth.AccessToken(accessToken), nil + return model.AccessToken(accessToken), nil } func (t *Tiphereth) RegisterDevice( ctx context.Context, - device *modeltiphereth.DeviceInfo, + device *model.DeviceInfo, clientLocalID *string, ) (model.InternalID, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) @@ -214,7 +213,7 @@ func (t *Tiphereth) RegisterDevice( return id, nil } -func (t *Tiphereth) ListRegisteredDevices(ctx context.Context) ([]*modeltiphereth.DeviceInfo, *errors.Error) { +func (t *Tiphereth) ListRegisteredDevices(ctx context.Context) ([]*model.DeviceInfo, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() @@ -226,7 +225,7 @@ func (t *Tiphereth) ListRegisteredDevices(ctx context.Context) ([]*modeltipheret return devices, nil } -func (t *Tiphereth) ListUserSessions(ctx context.Context) ([]*modeltiphereth.UserSession, *errors.Error) { +func (t *Tiphereth) ListUserSessions(ctx context.Context) ([]*model.UserSession, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() diff --git a/internal/biz/biztiphereth/user.go b/internal/biz/biztiphereth/user.go index 14207fb9..cb38c38c 100644 --- a/internal/biz/biztiphereth/user.go +++ b/internal/biz/biztiphereth/user.go @@ -10,32 +10,31 @@ import ( "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/dchest/captcha" "github.com/go-kratos/kratos/v2/errors" ) -func (t *Tiphereth) CreateUser(ctx context.Context, user *modeltiphereth.User) (*model.InternalID, *errors.Error) { +func (t *Tiphereth) CreateUser(ctx context.Context, user *model.User) (*model.InternalID, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() } - if claims.UserType != libauth.UserTypeAdmin && user.Type != libauth.UserTypeSentinel { + if claims.UserType != model.UserTypeAdmin && user.Type != model.UserTypeSentinel { return nil, bizutils.NoPermissionError() } if t.app.EnvExist(libapp.EnvDemoMode) { - if user.Type == libauth.UserTypeAdmin { + if user.Type == model.UserTypeAdmin { return nil, pb.ErrorErrorReasonForbidden("server running in demo mode, create admin user is not allowed") } } - password, err := t.auth.GeneratePassword(user.PassWord) + password, err := t.auth.GeneratePassword(user.Password) if err != nil { logger.Infof("generate password failed: %s", err.Error()) return nil, pb.ErrorErrorReasonBadRequest("invalid password") } - user.PassWord = password + user.Password = password id, err := t.id.New() if err != nil { return nil, pb.ErrorErrorReasonUnspecified("%s", err) @@ -60,7 +59,7 @@ func (t *Tiphereth) CreateUser(ctx context.Context, user *modeltiphereth.User) ( } func (t *Tiphereth) UpdateUser( - ctx context.Context, user *modeltiphereth.User, originPassword string, + ctx context.Context, user *model.User, originPassword string, ) *errors.Error { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { @@ -69,15 +68,15 @@ func (t *Tiphereth) UpdateUser( if user.ID == 0 { return pb.ErrorErrorReasonBadRequest("internal id required") } - if user.PassWord != "" && originPassword == "" { + if user.Password != "" && originPassword == "" { return pb.ErrorErrorReasonBadRequest("password required") } if t.app.EnvExist(libapp.EnvDemoMode) { - if user.Type == libauth.UserTypeAdmin { + if user.Type == model.UserTypeAdmin { return pb.ErrorErrorReasonForbidden("server running in demo mode, modify admin user is not allowed") } } - if claims.UserType != libauth.UserTypeAdmin && + if claims.UserType != model.UserTypeAdmin && claims.UserID != user.ID { res, _, err := t.repo.ListUsers(ctx, model.Paging{ @@ -85,7 +84,7 @@ func (t *Tiphereth) UpdateUser( PageNum: 1, }, []model.InternalID{user.ID}, - []libauth.UserType{libauth.UserTypeSentinel}, + []model.UserType{model.UserTypeSentinel}, nil, nil, claims.UserID, @@ -94,13 +93,13 @@ func (t *Tiphereth) UpdateUser( return bizutils.NoPermissionError() } } - if user.PassWord != "" { - password, err := t.auth.GeneratePassword(user.PassWord) + if user.Password != "" { + password, err := t.auth.GeneratePassword(user.Password) if err != nil { logger.Infof("generate password failed: %s", err.Error()) return pb.ErrorErrorReasonBadRequest("invalid password") } - user.PassWord = password + user.Password = password originPassword, err = t.auth.GeneratePassword(originPassword) if err != nil { logger.Infof("generate password failed: %s", err.Error()) @@ -115,8 +114,8 @@ func (t *Tiphereth) UpdateUser( } func (t *Tiphereth) ListUsers( - ctx context.Context, paging model.Paging, types []libauth.UserType, statuses []modeltiphereth.UserStatus, -) ([]*modeltiphereth.User, int64, *errors.Error) { + ctx context.Context, paging model.Paging, types []model.UserType, statuses []model.UserStatus, +) ([]*model.User, int64, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, 0, bizutils.NoPermissionError() @@ -129,7 +128,7 @@ func (t *Tiphereth) ListUsers( return users, total, nil } -func (t *Tiphereth) GetUser(ctx context.Context, id *model.InternalID) (*modeltiphereth.User, *errors.Error) { +func (t *Tiphereth) GetUser(ctx context.Context, id *model.InternalID) (*model.User, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() @@ -151,8 +150,8 @@ func (t *Tiphereth) RegisterUser( ctx context.Context, username string, password string, - captchaReq *modeltiphereth.CaptchaAns, -) (*modeltiphereth.CaptchaQue, string, *errors.Error) { + captchaReq *model.CaptchaAns, +) (*model.CaptchaQue, string, *errors.Error) { if t.app.EnvExist(libapp.EnvDemoMode) { return nil, "", pb.ErrorErrorReasonForbidden("server running in demo mode, register user is not allowed") } @@ -170,7 +169,7 @@ func (t *Tiphereth) RegisterUser( if err != nil { return nil, "", pb.ErrorErrorReasonUnspecified("%s", err.Error()) } - return &modeltiphereth.CaptchaQue{ + return &model.CaptchaQue{ ID: captchaID, Image: captchaImg.Bytes(), }, "", nil @@ -187,12 +186,12 @@ func (t *Tiphereth) RegisterUser( if err != nil { return nil, "", pb.ErrorErrorReasonUnspecified("%s", err) } - user := &modeltiphereth.User{ + user := &model.User{ ID: id, - UserName: username, - PassWord: passwordParsed, - Type: libauth.UserTypeNormal, - Status: modeltiphereth.UserStatusActive, + Username: username, + Password: passwordParsed, + Type: model.UserTypeNormal, + Status: model.UserStatusActive, } if err = t.repo.CreateUser(ctx, user, user.ID); err != nil { logger.Infof("repo CreateUser failed: %s", err.Error()) diff --git a/internal/biz/bizyesod/yesod.go b/internal/biz/bizyesod/yesod.go index 8260900d..88f26eeb 100644 --- a/internal/biz/bizyesod/yesod.go +++ b/internal/biz/bizyesod/yesod.go @@ -17,7 +17,6 @@ import ( "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/model/modelyesod" "github.com/tuihub/librarian/internal/service/supervisor" @@ -54,7 +53,7 @@ type YesodRepo interface { RemoveFeedItemFromCollection(context.Context, model.InternalID, model.InternalID, model.InternalID) error ListFeedItemsInCollection(context.Context, model.InternalID, model.Paging, []model.InternalID, []string, []string, []string, *model.TimeRange) ([]*modelyesod.FeedItemDigest, int, error) - GetFeedOwner(context.Context, model.InternalID) (*modeltiphereth.User, error) + GetFeedOwner(context.Context, model.InternalID) (*model.User, error) CreateFeedActionSet(context.Context, model.InternalID, *modelyesod.FeedActionSet) error UpdateFeedActionSet(context.Context, model.InternalID, *modelyesod.FeedActionSet) error ListFeedActionSets(context.Context, model.InternalID, model.Paging) ([]*modelyesod.FeedActionSet, int, error) @@ -67,7 +66,7 @@ type Yesod struct { search libsearch.Search pullFeed *libmq.Topic[modelyesod.PullFeed] systemNotify *libmq.Topic[modelnetzach.SystemNotify] - feedOwner *libcache.Map[modelyesod.FeedConfig, modeltiphereth.User] + feedOwner *libcache.Map[modelyesod.FeedConfig, model.User] builtinFeedActions []*modelsupervisor.FeatureFlag } @@ -79,7 +78,7 @@ func NewYesod( search libsearch.Search, pullFeed *libmq.Topic[modelyesod.PullFeed], systemNotify *libmq.Topic[modelnetzach.SystemNotify], - feedOwner *libcache.Map[modelyesod.FeedConfig, modeltiphereth.User], + feedOwner *libcache.Map[modelyesod.FeedConfig, model.User], ) (*Yesod, error) { builtinFeedActions, err := getBuiltinActionFeatureFlags() if err != nil { @@ -117,7 +116,7 @@ func (y *Yesod) PullFeeds(ctx context.Context) error { var errRes error for _, c := range configs { doNotify := func() *modelnetzach.SystemNotify { - var owner *modeltiphereth.User + var owner *model.User owner, err = y.feedOwner.Get(ctx, *c) if err != nil { return nil @@ -160,14 +159,14 @@ func (y *Yesod) PullFeeds(ctx context.Context) error { func NewFeedOwnerCache( repo YesodRepo, store libcache.Store, -) *libcache.Map[modelyesod.FeedConfig, modeltiphereth.User] { - return libcache.NewMap[modelyesod.FeedConfig, modeltiphereth.User]( +) *libcache.Map[modelyesod.FeedConfig, model.User] { + return libcache.NewMap[modelyesod.FeedConfig, model.User]( store, "FeedOwner", func(k modelyesod.FeedConfig) string { return strconv.FormatInt(int64(k.ID), 10) }, - func(ctx context.Context, fc modelyesod.FeedConfig) (*modeltiphereth.User, error) { + func(ctx context.Context, fc modelyesod.FeedConfig) (*model.User, error) { res, err := repo.GetFeedOwner(ctx, fc.ID) if err != nil { return nil, err diff --git a/internal/data/db/db.go b/internal/data/db/db.go new file mode 100644 index 00000000..c13bcee5 --- /dev/null +++ b/internal/data/db/db.go @@ -0,0 +1,7 @@ +package db + +import "gorm.io/gorm" + +type DB struct { + gorm.DB +} diff --git a/internal/data/db/dbmodel/dbmodel.go b/internal/data/db/dbmodel/dbmodel.go new file mode 100644 index 00000000..f1cee941 --- /dev/null +++ b/internal/data/db/dbmodel/dbmodel.go @@ -0,0 +1,17 @@ +package dbmodel + +import ( + "gorm.io/gorm" + "time" +) + +type InternalID int64 + +type Model struct { + ID InternalID `gorm:"primarykey"` + CreatedAt time.Time + UpdatedAt time.Time + deletedAt gorm.DeletedAt `gorm:"index"` +} + +type ID InternalID diff --git a/internal/data/db/dbmodel/device.go b/internal/data/db/dbmodel/device.go new file mode 100644 index 00000000..356ce151 --- /dev/null +++ b/internal/data/db/dbmodel/device.go @@ -0,0 +1,25 @@ +package dbmodel + +type SystemType string + +const ( + SystemTypeUnspecified SystemType = "unspecified" + SystemTypeWindows SystemType = "windows" + SystemTypeMacOS SystemType = "macos" + SystemTypeLinux SystemType = "linux" + SystemTypeWeb SystemType = "web" + SystemTypeAndroid SystemType = "android" + SystemTypeIOS SystemType = "ios" +) + +type Device struct { + Model + UserID ID + ClientLocalID *ID + Name string + SystemType SystemType + SystemVersion string + ClientName string + ClientSourceCodeAddress string + ClientVersion string +} diff --git a/internal/data/db/dbmodel/session.go b/internal/data/db/dbmodel/session.go new file mode 100644 index 00000000..72e94e3b --- /dev/null +++ b/internal/data/db/dbmodel/session.go @@ -0,0 +1,11 @@ +package dbmodel + +import "time" + +type Session struct { + Model + UserID ID + DeviceID ID + Token string + ExpireAt time.Time +} diff --git a/internal/data/db/dbmodel/user.go b/internal/data/db/dbmodel/user.go new file mode 100644 index 00000000..d5bd0c0e --- /dev/null +++ b/internal/data/db/dbmodel/user.go @@ -0,0 +1,27 @@ +package dbmodel + +type UserStatus string + +const ( + UserStatusUnspecified UserStatus = "unspecified" + UserStatusActive UserStatus = "active" + UserStatusBlocked UserStatus = "blocked" +) + +type UserType string + +const ( + UserTypeUnspecified UserType = "unspecified" + UserTypeAdmin UserType = "admin" + UserTypeNormal UserType = "normal" + UserTypeSentinel UserType = "sentinel" + UserTypePorter UserType = "porter" +) + +type User struct { + Model + Username string + Password string + Status UserStatus + Type UserType +} diff --git a/internal/data/db/migration/v1.go b/internal/data/db/migration/v1.go index c66d41f9..540a6b4b 100644 --- a/internal/data/db/migration/v1.go +++ b/internal/data/db/migration/v1.go @@ -21,7 +21,7 @@ func (v *v1) init(db *gorm.DB) { } func (v *v1) migrate() error { - version := new(Version) + version := new(_Version) version.Version = 1 if !v.tx.Migrator().HasTable(version) { err := v.tx.Migrator().CreateTable(version) @@ -59,7 +59,7 @@ func (v *v1) migrateWrapper(migrateVersion uint, doPreMigration func() error, do } if v.curVersion == nil { - version := new(Version) + version := new(_Version) // check if the version table exists if !v.tx.Migrator().HasTable(version) { var cv uint = 0 @@ -96,7 +96,7 @@ func (v *v1) migrateWrapper(migrateVersion uint, doPreMigration func() error, do if err != nil { return err } - err = v.tx.Create(&Version{Version: migrateVersion}).Error + err = v.tx.Create(&_Version{Version: migrateVersion}).Error if err != nil { return err } @@ -105,16 +105,18 @@ func (v *v1) migrateWrapper(migrateVersion uint, doPreMigration func() error, do return err } -type Version struct { +type _Version struct { Version uint `gorm:"primaryKey"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` } -type Model struct { +type _Model struct { ID model.InternalID `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` } + +type _ID model.InternalID diff --git a/internal/data/db/migration/v2.go b/internal/data/db/migration/v2.go index 48f2b52d..3990a3ab 100644 --- a/internal/data/db/migration/v2.go +++ b/internal/data/db/migration/v2.go @@ -1,5 +1,7 @@ package migration +import "time" + type v2 struct { v1 } @@ -7,7 +9,7 @@ type v2 struct { func (v *v2) migrate() error { return v.migrateWrapper(2, v.v1.migrate, func() error { type User struct { - Model + _Model Username string Password string Status string @@ -16,6 +18,30 @@ func (v *v2) migrate() error { if err := v.tx.Migrator().CreateTable(new(User)); err != nil { return err } + type Session struct { + _Model + UserID _ID + DeviceID _ID + Token string + ExpireAt time.Time + } + if err := v.tx.Migrator().CreateTable(new(Session)); err != nil { + return err + } + type Device struct { + _Model + UserID _ID + ClientLocalID string + Name string + SystemType string + SystemVersion string + ClientName string + ClientSourceCodeAddress string + ClientVersion string + } + if err := v.tx.Migrator().CreateTable(new(Device)); err != nil { + return err + } return nil }) } diff --git a/internal/lib/libauth/jwt.go b/internal/lib/libauth/jwt.go index 5c848559..4c7d05bb 100644 --- a/internal/lib/libauth/jwt.go +++ b/internal/lib/libauth/jwt.go @@ -17,7 +17,7 @@ type Claims struct { UserID model.InternalID `json:"uid,string"` PorterID model.InternalID `json:"pid,string,omitempty"` Type ClaimsType `json:"ct"` - UserType UserType `json:"ut"` + UserType model.UserType `json:"ut"` TransferMetadata any `json:"tm,omitempty"` jwtv5.RegisteredClaims } @@ -32,16 +32,6 @@ const ( ClaimsTypeDownloadToken ) -type UserType int - -const ( - UserTypeUnspecified UserType = iota - UserTypeAdmin - UserTypeNormal - UserTypeSentinel - UserTypePorter -) - func (a *Auth) KeyFunc(t ClaimsType) jwtv5.Keyfunc { return func(token *jwtv5.Token) (interface{}, error) { return a.generateSecret(t), nil @@ -80,9 +70,9 @@ func ValidateString(tokenString string, keyFunc jwtv5.Keyfunc) (bool, error) { return token.Valid, nil } -func FromContextAssertUserType(ctx context.Context, userTypes ...UserType) *Claims { +func FromContextAssertUserType(ctx context.Context, userTypes ...model.UserType) *Claims { if userTypes == nil { - userTypes = []UserType{UserTypeAdmin, UserTypeNormal} + userTypes = []model.UserType{model.UserTypeAdmin, model.UserTypeNormal} } c := FromContext(ctx) for _, ut := range userTypes { @@ -101,7 +91,7 @@ func (a *Auth) GenerateToken( uid model.InternalID, pid model.InternalID, claimsType ClaimsType, - userType UserType, + userType model.UserType, transferMetadata any, expire time.Duration, ) (string, error) { diff --git a/internal/model/modelsupervisor/modelsupervisor.go b/internal/model/modelsupervisor/modelsupervisor.go index fca672f6..f074eb96 100644 --- a/internal/model/modelsupervisor/modelsupervisor.go +++ b/internal/model/modelsupervisor/modelsupervisor.go @@ -5,7 +5,6 @@ import ( "github.com/tuihub/librarian/internal/lib/libtype" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modeltiphereth" ) type PorterInstanceController struct { @@ -30,7 +29,7 @@ type PorterInstance struct { Address string Region string FeatureSummary *PorterFeatureSummary - Status modeltiphereth.UserStatus + Status model.UserStatus ContextJSONSchema string } diff --git a/internal/model/modeltiphereth/modeltiphereth.go b/internal/model/tiphereth.go similarity index 72% rename from internal/model/modeltiphereth/modeltiphereth.go rename to internal/model/tiphereth.go index e6fcece5..b9d3c43f 100644 --- a/internal/model/modeltiphereth/modeltiphereth.go +++ b/internal/model/tiphereth.go @@ -1,18 +1,17 @@ -package modeltiphereth +package model import ( "time" - - "github.com/tuihub/librarian/internal/lib/libauth" - "github.com/tuihub/librarian/internal/model" ) type User struct { - ID model.InternalID - UserName string - PassWord string - Type libauth.UserType - Status UserStatus + ID InternalID + Username string + Password string + Type UserType + Status UserStatus + CreatedAt time.Time + UpdatedAt time.Time } type UserStatus int @@ -23,11 +22,21 @@ const ( UserStatusBlocked ) +type UserType int + +const ( + UserTypeUnspecified UserType = iota + UserTypeAdmin + UserTypeNormal + UserTypeSentinel + UserTypePorter +) + type AccessToken string type RefreshToken string type Account struct { - ID model.InternalID + ID InternalID Platform string PlatformAccountID string Name string @@ -37,14 +46,14 @@ type Account struct { } type PullAccountInfo struct { - ID model.InternalID + ID InternalID Platform string PlatformAccountID string } type UserSession struct { - ID model.InternalID - UserID model.InternalID + ID InternalID + UserID InternalID RefreshToken string DeviceInfo *DeviceInfo CreateAt time.Time @@ -52,7 +61,7 @@ type UserSession struct { } type DeviceInfo struct { - ID model.InternalID + ID InternalID DeviceName string SystemType SystemType SystemVersion string diff --git a/internal/service/angelaweb/angela_web.go b/internal/service/angelaweb/angela_web.go index cb40409f..a8423589 100644 --- a/internal/service/angelaweb/angela_web.go +++ b/internal/service/angelaweb/angela_web.go @@ -7,6 +7,7 @@ import ( "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" + "gorm.io/gorm" ) type AngelaWeb struct { @@ -16,7 +17,7 @@ type AngelaWeb struct { app *fiber.App } -func NewAngelaWeb(handler *api.Handler, builder *page.Builder, auth *libauth.Auth) *AngelaWeb { +func NewAngelaWeb(db *gorm.DB, auth *libauth.Auth) *AngelaWeb { viewsEngine := html.New("./view", ".html") app := fiber.New(fiber.Config{ @@ -25,8 +26,8 @@ func NewAngelaWeb(handler *api.Handler, builder *page.Builder, auth *libauth.Aut }) res := &AngelaWeb{ - apiHandler: handler, - pageBuilder: builder, + apiHandler: api.NewHandler(db, auth), + pageBuilder: page.NewBuilder(db), auth: auth, app: app, } diff --git a/internal/service/angelaweb/internal/api/login.go b/internal/service/angelaweb/internal/api/login.go index 531af528..ad4ecbd2 100644 --- a/internal/service/angelaweb/internal/api/login.go +++ b/internal/service/angelaweb/internal/api/login.go @@ -28,7 +28,7 @@ func (h *Handler) Login(c *fiber.Ctx) error { return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) } - token, err := h.auth.GenerateToken(model2.InternalID(user.ID), 0, libauth.ClaimsTypeAccessToken, libauth.UserTypeAdmin, nil, 24*time.Hour) + token, err := h.auth.GenerateToken(model2.InternalID(user.ID), 0, libauth.ClaimsTypeAccessToken, model2.UserTypeAdmin, nil, 24*time.Hour) if err != nil { return c.Status(500).JSON(fiber.Map{"message": "Error generating token"}) } diff --git a/internal/service/sephirah/chesed.go b/internal/service/sephirah/chesed.go index 771e8cd0..da96477a 100644 --- a/internal/service/sephirah/chesed.go +++ b/internal/service/sephirah/chesed.go @@ -2,9 +2,9 @@ package sephirah import ( "context" + "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelchesed" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" diff --git a/internal/service/sephirah/gebura.go b/internal/service/sephirah/gebura.go index 9499bfaf..218f1c9f 100644 --- a/internal/service/sephirah/gebura.go +++ b/internal/service/sephirah/gebura.go @@ -2,9 +2,9 @@ package sephirah import ( "context" + "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" diff --git a/internal/model/converter/biz_to_pb.go b/internal/service/sephirah/internal/converter/biz_to_pb.go similarity index 93% rename from internal/model/converter/biz_to_pb.go rename to internal/service/sephirah/internal/converter/biz_to_pb.go index d7e1fdd0..427a4705 100644 --- a/internal/model/converter/biz_to_pb.go +++ b/internal/service/sephirah/internal/converter/biz_to_pb.go @@ -3,13 +3,11 @@ package converter import ( "time" - "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelgebura" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/model/modelyesod" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" @@ -21,7 +19,7 @@ import ( // goverter:converter // goverter:output:format function // goverter:output:file ./generated.go -// goverter:output:package github.com/tuihub/librarian/app/sephirah/internal/model/converter +// goverter:output:package github.com/tuihub/librarian/internal/service/sephirah/internal/converter // goverter:matchIgnoreCase // goverter:ignoreUnexported // goverter:extend ToPBInternalID @@ -37,8 +35,8 @@ type toPBConverter interface { //nolint:unused // used by generator ToPBFeatureRequest(*modelsupervisor.FeatureRequest) *librarian.FeatureRequest // goverter:map ID DeviceId - ToPBDeviceInfo(*modeltiphereth.DeviceInfo) *pb.DeviceInfo - ToPBDeviceInfoList([]*modeltiphereth.DeviceInfo) []*pb.DeviceInfo + ToPBDeviceInfo(*model.DeviceInfo) *pb.DeviceInfo + ToPBDeviceInfoList([]*model.DeviceInfo) []*pb.DeviceInfo // goverter:enum:unknown SystemType_SYSTEM_TYPE_UNSPECIFIED // goverter:enum:map SystemTypeUnspecified SystemType_SYSTEM_TYPE_UNSPECIFIED // goverter:enum:map SystemTypeIOS SystemType_SYSTEM_TYPE_IOS @@ -47,31 +45,31 @@ type toPBConverter interface { //nolint:unused // used by generator // goverter:enum:map SystemTypeWindows SystemType_SYSTEM_TYPE_WINDOWS // goverter:enum:map SystemTypeMacOS SystemType_SYSTEM_TYPE_MACOS // goverter:enum:map SystemTypeLinux SystemType_SYSTEM_TYPE_LINUX - ToPBSystemType(modeltiphereth.SystemType) pb.SystemType + ToPBSystemType(model.SystemType) pb.SystemType // goverter:map CreateAt CreateTime // goverter:map ExpireAt ExpireTime - ToPBUserSession(*modeltiphereth.UserSession) *pb.UserSession - ToPBUserSessionList([]*modeltiphereth.UserSession) []*pb.UserSession + ToPBUserSession(*model.UserSession) *pb.UserSession + ToPBUserSessionList([]*model.UserSession) []*pb.UserSession // goverter:ignore Password - ToPBUser(*modeltiphereth.User) *pb.User - ToPBUserList([]*modeltiphereth.User) []*pb.User + ToPBUser(*model.User) *pb.User + ToPBUserList([]*model.User) []*pb.User // goverter:enum:unknown UserType_USER_TYPE_UNSPECIFIED // goverter:enum:map UserTypeUnspecified UserType_USER_TYPE_UNSPECIFIED // goverter:enum:map UserTypeAdmin UserType_USER_TYPE_ADMIN // goverter:enum:map UserTypeNormal UserType_USER_TYPE_NORMAL // goverter:enum:map UserTypeSentinel UserType_USER_TYPE_SENTINEL // goverter:enum:map UserTypePorter UserType_USER_TYPE_PORTER - ToPBUserType(libauth.UserType) pb.UserType + ToPBUserType(model.UserType) pb.UserType // goverter:enum:unknown UserStatus_USER_STATUS_UNSPECIFIED // goverter:enum:map UserStatusUnspecified UserStatus_USER_STATUS_UNSPECIFIED // goverter:enum:map UserStatusActive UserStatus_USER_STATUS_ACTIVE // goverter:enum:map UserStatusBlocked UserStatus_USER_STATUS_BLOCKED - ToPBUserStatus(modeltiphereth.UserStatus) pb.UserStatus + ToPBUserStatus(model.UserStatus) pb.UserStatus - ToPBAccount(*modeltiphereth.Account) *librarian.Account - ToPBAccountList([]*modeltiphereth.Account) []*librarian.Account + ToPBAccount(*model.Account) *librarian.Account + ToPBAccountList([]*model.Account) []*librarian.Account // goverter:autoMap PorterInstance ToPBPorter(*modelsupervisor.PorterInstanceController) *pb.Porter diff --git a/internal/model/converter/converter.go b/internal/service/sephirah/internal/converter/converter.go similarity index 100% rename from internal/model/converter/converter.go rename to internal/service/sephirah/internal/converter/converter.go diff --git a/internal/model/converter/generated.go b/internal/service/sephirah/internal/converter/generated.go similarity index 95% rename from internal/model/converter/generated.go rename to internal/service/sephirah/internal/converter/generated.go index 59c4e4a8..9e01ee91 100644 --- a/internal/model/converter/generated.go +++ b/internal/service/sephirah/internal/converter/generated.go @@ -4,14 +4,12 @@ package converter import ( - libauth "github.com/tuihub/librarian/internal/lib/libauth" model "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelbinah" modelfeed "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelgebura" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/model/modelyesod" v11 "github.com/tuihub/protos/pkg/librarian/sephirah/v1" v1 "github.com/tuihub/protos/pkg/librarian/v1" @@ -164,10 +162,10 @@ func ToBizAppTypeList(source []v1.AppType) []modelgebura.AppType { } return modelgeburaAppTypeList } -func ToBizDeviceInfo(source *v11.DeviceInfo) *modeltiphereth.DeviceInfo { - var pModeltipherethDeviceInfo *modeltiphereth.DeviceInfo +func ToBizDeviceInfo(source *v11.DeviceInfo) *model.DeviceInfo { + var pModeltipherethDeviceInfo *model.DeviceInfo if source != nil { - var modeltipherethDeviceInfo modeltiphereth.DeviceInfo + var modeltipherethDeviceInfo model.DeviceInfo modeltipherethDeviceInfo.ID = ToBizInternalID((*source).DeviceId) modeltipherethDeviceInfo.DeviceName = (*source).DeviceName modeltipherethDeviceInfo.SystemType = ToBizSystemType((*source).SystemType) @@ -679,25 +677,25 @@ func ToBizSystemNotificationTypeList(source []v11.SystemNotificationType) []mode } return modelnetzachSystemNotificationTypeList } -func ToBizSystemType(source v11.SystemType) modeltiphereth.SystemType { - var modeltipherethSystemType modeltiphereth.SystemType +func ToBizSystemType(source v11.SystemType) model.SystemType { + var modeltipherethSystemType model.SystemType switch source { case v11.SystemType_SYSTEM_TYPE_ANDROID: - modeltipherethSystemType = modeltiphereth.SystemTypeAndroid + modeltipherethSystemType = model.SystemTypeAndroid case v11.SystemType_SYSTEM_TYPE_IOS: - modeltipherethSystemType = modeltiphereth.SystemTypeIOS + modeltipherethSystemType = model.SystemTypeIOS case v11.SystemType_SYSTEM_TYPE_LINUX: - modeltipherethSystemType = modeltiphereth.SystemTypeLinux + modeltipherethSystemType = model.SystemTypeLinux case v11.SystemType_SYSTEM_TYPE_MACOS: - modeltipherethSystemType = modeltiphereth.SystemTypeMacOS + modeltipherethSystemType = model.SystemTypeMacOS case v11.SystemType_SYSTEM_TYPE_UNSPECIFIED: - modeltipherethSystemType = modeltiphereth.SystemTypeUnspecified + modeltipherethSystemType = model.SystemTypeUnspecified case v11.SystemType_SYSTEM_TYPE_WEB: - modeltipherethSystemType = modeltiphereth.SystemTypeWeb + modeltipherethSystemType = model.SystemTypeWeb case v11.SystemType_SYSTEM_TYPE_WINDOWS: - modeltipherethSystemType = modeltiphereth.SystemTypeWindows + modeltipherethSystemType = model.SystemTypeWindows default: - modeltipherethSystemType = modeltiphereth.SystemTypeUnspecified + modeltipherethSystemType = model.SystemTypeUnspecified } return modeltipherethSystemType } @@ -711,65 +709,65 @@ func ToBizTimeRange(source *v1.TimeRange) *model.TimeRange { } return pModelTimeRange } -func ToBizUser(source *v11.User) *modeltiphereth.User { - var pModeltipherethUser *modeltiphereth.User +func ToBizUser(source *v11.User) *model.User { + var pModeltipherethUser *model.User if source != nil { - var modeltipherethUser modeltiphereth.User + var modeltipherethUser model.User modeltipherethUser.ID = ToBizInternalID((*source).Id) - modeltipherethUser.UserName = (*source).Username - modeltipherethUser.PassWord = (*source).Password + modeltipherethUser.Username = (*source).Username + modeltipherethUser.Password = (*source).Password modeltipherethUser.Type = ToLibAuthUserType((*source).Type) modeltipherethUser.Status = ToBizUserStatus((*source).Status) pModeltipherethUser = &modeltipherethUser } return pModeltipherethUser } -func ToBizUserStatus(source v11.UserStatus) modeltiphereth.UserStatus { - var modeltipherethUserStatus modeltiphereth.UserStatus +func ToBizUserStatus(source v11.UserStatus) model.UserStatus { + var modeltipherethUserStatus model.UserStatus switch source { case v11.UserStatus_USER_STATUS_ACTIVE: - modeltipherethUserStatus = modeltiphereth.UserStatusActive + modeltipherethUserStatus = model.UserStatusActive case v11.UserStatus_USER_STATUS_BLOCKED: - modeltipherethUserStatus = modeltiphereth.UserStatusBlocked + modeltipherethUserStatus = model.UserStatusBlocked case v11.UserStatus_USER_STATUS_UNSPECIFIED: - modeltipherethUserStatus = modeltiphereth.UserStatusUnspecified + modeltipherethUserStatus = model.UserStatusUnspecified default: - modeltipherethUserStatus = modeltiphereth.UserStatusUnspecified + modeltipherethUserStatus = model.UserStatusUnspecified } return modeltipherethUserStatus } -func ToBizUserStatusList(source []v11.UserStatus) []modeltiphereth.UserStatus { - var modeltipherethUserStatusList []modeltiphereth.UserStatus +func ToBizUserStatusList(source []v11.UserStatus) []model.UserStatus { + var modeltipherethUserStatusList []model.UserStatus if source != nil { - modeltipherethUserStatusList = make([]modeltiphereth.UserStatus, len(source)) + modeltipherethUserStatusList = make([]model.UserStatus, len(source)) for i := 0; i < len(source); i++ { modeltipherethUserStatusList[i] = ToBizUserStatus(source[i]) } } return modeltipherethUserStatusList } -func ToLibAuthUserType(source v11.UserType) libauth.UserType { - var libauthUserType libauth.UserType +func ToLibAuthUserType(source v11.UserType) model.UserType { + var libauthUserType model.UserType switch source { case v11.UserType_USER_TYPE_ADMIN: - libauthUserType = libauth.UserTypeAdmin + libauthUserType = model.UserTypeAdmin case v11.UserType_USER_TYPE_NORMAL: - libauthUserType = libauth.UserTypeNormal + libauthUserType = model.UserTypeNormal case v11.UserType_USER_TYPE_PORTER: - libauthUserType = libauth.UserTypePorter + libauthUserType = model.UserTypePorter case v11.UserType_USER_TYPE_SENTINEL: - libauthUserType = libauth.UserTypeSentinel + libauthUserType = model.UserTypeSentinel case v11.UserType_USER_TYPE_UNSPECIFIED: - libauthUserType = libauth.UserTypeUnspecified + libauthUserType = model.UserTypeUnspecified default: - libauthUserType = libauth.UserTypeUnspecified + libauthUserType = model.UserTypeUnspecified } return libauthUserType } -func ToLibAuthUserTypeList(source []v11.UserType) []libauth.UserType { - var libauthUserTypeList []libauth.UserType +func ToLibAuthUserTypeList(source []v11.UserType) []model.UserType { + var libauthUserTypeList []model.UserType if source != nil { - libauthUserTypeList = make([]libauth.UserType, len(source)) + libauthUserTypeList = make([]model.UserType, len(source)) for i := 0; i < len(source); i++ { libauthUserTypeList[i] = ToLibAuthUserType(source[i]) } @@ -816,7 +814,7 @@ func pV1FeedPersonToPModelfeedPerson(source *v1.FeedPerson) *modelfeed.Person { } return pModelfeedPerson } -func ToPBAccount(source *modeltiphereth.Account) *v1.Account { +func ToPBAccount(source *model.Account) *v1.Account { var pV1Account *v1.Account if source != nil { var v1Account v1.Account @@ -831,7 +829,7 @@ func ToPBAccount(source *modeltiphereth.Account) *v1.Account { } return pV1Account } -func ToPBAccountList(source []*modeltiphereth.Account) []*v1.Account { +func ToPBAccountList(source []*model.Account) []*v1.Account { var pV1AccountList []*v1.Account if source != nil { pV1AccountList = make([]*v1.Account, len(source)) @@ -976,7 +974,7 @@ func ToPBAppType(source modelgebura.AppType) v1.AppType { } return v1AppType } -func ToPBDeviceInfo(source *modeltiphereth.DeviceInfo) *v11.DeviceInfo { +func ToPBDeviceInfo(source *model.DeviceInfo) *v11.DeviceInfo { var pV1DeviceInfo *v11.DeviceInfo if source != nil { var v1DeviceInfo v11.DeviceInfo @@ -991,7 +989,7 @@ func ToPBDeviceInfo(source *modeltiphereth.DeviceInfo) *v11.DeviceInfo { } return pV1DeviceInfo } -func ToPBDeviceInfoList(source []*modeltiphereth.DeviceInfo) []*v11.DeviceInfo { +func ToPBDeviceInfoList(source []*model.DeviceInfo) []*v11.DeviceInfo { var pV1DeviceInfoList []*v11.DeviceInfo if source != nil { pV1DeviceInfoList = make([]*v11.DeviceInfo, len(source)) @@ -1606,22 +1604,22 @@ func ToPBSystemNotificationType(source modelnetzach.SystemNotificationType) v11. } return v1SystemNotificationType } -func ToPBSystemType(source modeltiphereth.SystemType) v11.SystemType { +func ToPBSystemType(source model.SystemType) v11.SystemType { var v1SystemType v11.SystemType switch source { - case modeltiphereth.SystemTypeAndroid: + case model.SystemTypeAndroid: v1SystemType = v11.SystemType_SYSTEM_TYPE_ANDROID - case modeltiphereth.SystemTypeIOS: + case model.SystemTypeIOS: v1SystemType = v11.SystemType_SYSTEM_TYPE_IOS - case modeltiphereth.SystemTypeLinux: + case model.SystemTypeLinux: v1SystemType = v11.SystemType_SYSTEM_TYPE_LINUX - case modeltiphereth.SystemTypeMacOS: + case model.SystemTypeMacOS: v1SystemType = v11.SystemType_SYSTEM_TYPE_MACOS - case modeltiphereth.SystemTypeUnspecified: + case model.SystemTypeUnspecified: v1SystemType = v11.SystemType_SYSTEM_TYPE_UNSPECIFIED - case modeltiphereth.SystemTypeWeb: + case model.SystemTypeWeb: v1SystemType = v11.SystemType_SYSTEM_TYPE_WEB - case modeltiphereth.SystemTypeWindows: + case model.SystemTypeWindows: v1SystemType = v11.SystemType_SYSTEM_TYPE_WINDOWS default: v1SystemType = v11.SystemType_SYSTEM_TYPE_UNSPECIFIED @@ -1638,19 +1636,19 @@ func ToPBTimeRange(source *model.TimeRange) *v1.TimeRange { } return pV1TimeRange } -func ToPBUser(source *modeltiphereth.User) *v11.User { +func ToPBUser(source *model.User) *v11.User { var pV1User *v11.User if source != nil { var v1User v11.User v1User.Id = ToPBInternalID((*source).ID) - v1User.Username = (*source).UserName + v1User.Username = (*source).Username v1User.Type = ToPBUserType((*source).Type) v1User.Status = ToPBUserStatus((*source).Status) pV1User = &v1User } return pV1User } -func ToPBUserList(source []*modeltiphereth.User) []*v11.User { +func ToPBUserList(source []*model.User) []*v11.User { var pV1UserList []*v11.User if source != nil { pV1UserList = make([]*v11.User, len(source)) @@ -1660,7 +1658,7 @@ func ToPBUserList(source []*modeltiphereth.User) []*v11.User { } return pV1UserList } -func ToPBUserSession(source *modeltiphereth.UserSession) *v11.UserSession { +func ToPBUserSession(source *model.UserSession) *v11.UserSession { var pV1UserSession *v11.UserSession if source != nil { var v1UserSession v11.UserSession @@ -1673,7 +1671,7 @@ func ToPBUserSession(source *modeltiphereth.UserSession) *v11.UserSession { } return pV1UserSession } -func ToPBUserSessionList(source []*modeltiphereth.UserSession) []*v11.UserSession { +func ToPBUserSessionList(source []*model.UserSession) []*v11.UserSession { var pV1UserSessionList []*v11.UserSession if source != nil { pV1UserSessionList = make([]*v11.UserSession, len(source)) @@ -1683,32 +1681,32 @@ func ToPBUserSessionList(source []*modeltiphereth.UserSession) []*v11.UserSessio } return pV1UserSessionList } -func ToPBUserStatus(source modeltiphereth.UserStatus) v11.UserStatus { +func ToPBUserStatus(source model.UserStatus) v11.UserStatus { var v1UserStatus v11.UserStatus switch source { - case modeltiphereth.UserStatusActive: + case model.UserStatusActive: v1UserStatus = v11.UserStatus_USER_STATUS_ACTIVE - case modeltiphereth.UserStatusBlocked: + case model.UserStatusBlocked: v1UserStatus = v11.UserStatus_USER_STATUS_BLOCKED - case modeltiphereth.UserStatusUnspecified: + case model.UserStatusUnspecified: v1UserStatus = v11.UserStatus_USER_STATUS_UNSPECIFIED default: v1UserStatus = v11.UserStatus_USER_STATUS_UNSPECIFIED } return v1UserStatus } -func ToPBUserType(source libauth.UserType) v11.UserType { +func ToPBUserType(source model.UserType) v11.UserType { var v1UserType v11.UserType switch source { - case libauth.UserTypeAdmin: + case model.UserTypeAdmin: v1UserType = v11.UserType_USER_TYPE_ADMIN - case libauth.UserTypeNormal: + case model.UserTypeNormal: v1UserType = v11.UserType_USER_TYPE_NORMAL - case libauth.UserTypePorter: + case model.UserTypePorter: v1UserType = v11.UserType_USER_TYPE_PORTER - case libauth.UserTypeSentinel: + case model.UserTypeSentinel: v1UserType = v11.UserType_USER_TYPE_SENTINEL - case libauth.UserTypeUnspecified: + case model.UserTypeUnspecified: v1UserType = v11.UserType_USER_TYPE_UNSPECIFIED default: v1UserType = v11.UserType_USER_TYPE_UNSPECIFIED diff --git a/internal/model/converter/pb_to_biz.go b/internal/service/sephirah/internal/converter/pb_to_biz.go similarity index 95% rename from internal/model/converter/pb_to_biz.go rename to internal/service/sephirah/internal/converter/pb_to_biz.go index 7479b96a..3f7cb1ba 100644 --- a/internal/model/converter/pb_to_biz.go +++ b/internal/service/sephirah/internal/converter/pb_to_biz.go @@ -3,14 +3,12 @@ package converter import ( "time" - "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelbinah" "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelgebura" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/model/modelyesod" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" @@ -22,7 +20,7 @@ import ( // goverter:converter // goverter:output:format function // goverter:output:file ./generated.go -// goverter:output:package github.com/tuihub/librarian/app/sephirah/internal/model/converter +// goverter:output:package github.com/tuihub/librarian/internal/service/sephirah/internal/converter // goverter:matchIgnoreCase // goverter:ignoreUnexported // goverter:extend ToBizInternalID @@ -43,7 +41,7 @@ type toBizConverter interface { //nolint:unused // used by generator ToBizInternalIDList([]*librarian.InternalID) []model.InternalID // goverter:map DeviceId ID - ToBizDeviceInfo(*pb.DeviceInfo) *modeltiphereth.DeviceInfo + ToBizDeviceInfo(*pb.DeviceInfo) *model.DeviceInfo // goverter:enum:unknown SystemTypeUnspecified // goverter:enum:map SystemType_SYSTEM_TYPE_UNSPECIFIED SystemTypeUnspecified // goverter:enum:map SystemType_SYSTEM_TYPE_IOS SystemTypeIOS @@ -52,22 +50,22 @@ type toBizConverter interface { //nolint:unused // used by generator // goverter:enum:map SystemType_SYSTEM_TYPE_WINDOWS SystemTypeWindows // goverter:enum:map SystemType_SYSTEM_TYPE_MACOS SystemTypeMacOS // goverter:enum:map SystemType_SYSTEM_TYPE_LINUX SystemTypeLinux - ToBizSystemType(pb.SystemType) modeltiphereth.SystemType - ToBizUser(*pb.User) *modeltiphereth.User + ToBizSystemType(pb.SystemType) model.SystemType + ToBizUser(*pb.User) *model.User // goverter:enum:unknown UserTypeUnspecified // goverter:enum:map UserType_USER_TYPE_UNSPECIFIED UserTypeUnspecified // goverter:enum:map UserType_USER_TYPE_ADMIN UserTypeAdmin // goverter:enum:map UserType_USER_TYPE_NORMAL UserTypeNormal // goverter:enum:map UserType_USER_TYPE_SENTINEL UserTypeSentinel // goverter:enum:map UserType_USER_TYPE_PORTER UserTypePorter - ToLibAuthUserType(pb.UserType) libauth.UserType - ToLibAuthUserTypeList([]pb.UserType) []libauth.UserType - ToBizUserStatusList([]pb.UserStatus) []modeltiphereth.UserStatus + ToLibAuthUserType(pb.UserType) model.UserType + ToLibAuthUserTypeList([]pb.UserType) []model.UserType + ToBizUserStatusList([]pb.UserStatus) []model.UserStatus // goverter:enum:unknown UserStatusUnspecified // goverter:enum:map UserStatus_USER_STATUS_UNSPECIFIED UserStatusUnspecified // goverter:enum:map UserStatus_USER_STATUS_ACTIVE UserStatusActive // goverter:enum:map UserStatus_USER_STATUS_BLOCKED UserStatusBlocked - ToBizUserStatus(pb.UserStatus) modeltiphereth.UserStatus + ToBizUserStatus(pb.UserStatus) model.UserStatus ToBizPorterContext(*pb.PorterContext) *modelsupervisor.PorterContext // goverter:enum:unknown PorterContextStatusUnspecified diff --git a/internal/service/sephirah/librariansephirahservice.go b/internal/service/sephirah/librariansephirahservice.go index 0ee287f1..b7f7f353 100644 --- a/internal/service/sephirah/librariansephirahservice.go +++ b/internal/service/sephirah/librariansephirahservice.go @@ -2,6 +2,7 @@ package sephirah import ( "context" + "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "time" "github.com/tuihub/librarian/internal/biz/bizangela" @@ -14,7 +15,6 @@ import ( "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/service/supervisor" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" diff --git a/internal/service/sephirah/netzach.go b/internal/service/sephirah/netzach.go index 9712a7dd..0ab98fef 100644 --- a/internal/service/sephirah/netzach.go +++ b/internal/service/sephirah/netzach.go @@ -2,9 +2,9 @@ package sephirah import ( "context" + "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/internal/service/sephirah/porter.go b/internal/service/sephirah/porter.go index c75b1b71..9a9273c7 100644 --- a/internal/service/sephirah/porter.go +++ b/internal/service/sephirah/porter.go @@ -2,9 +2,9 @@ package sephirah import ( "context" + "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" ) diff --git a/internal/service/sephirah/tiphereth.go b/internal/service/sephirah/tiphereth.go index b143f40b..52310975 100644 --- a/internal/service/sephirah/tiphereth.go +++ b/internal/service/sephirah/tiphereth.go @@ -2,13 +2,12 @@ package sephirah import ( "context" + "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "time" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) @@ -65,9 +64,9 @@ func (s *LibrarianSephirahServiceService) AcquireUserToken(ctx context.Context, func (s *LibrarianSephirahServiceService) RegisterUser(ctx context.Context, req *pb.RegisterUserRequest) ( *pb.RegisterUserResponse, error, ) { - var captchaAns *modeltiphereth.CaptchaAns + var captchaAns *model.CaptchaAns if req.GetCaptcha() != nil { - captchaAns = &modeltiphereth.CaptchaAns{ + captchaAns = &model.CaptchaAns{ ID: req.GetCaptcha().GetId(), Value: req.GetCaptcha().GetValue(), } @@ -205,7 +204,7 @@ func (s *LibrarianSephirahServiceService) LinkAccount(ctx context.Context, req * if req.GetAccountId() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - a, err := s.t.LinkAccount(ctx, modeltiphereth.Account{ + a, err := s.t.LinkAccount(ctx, model.Account{ ID: 0, Platform: req.GetAccountId().GetPlatform(), PlatformAccountID: req.GetAccountId().GetPlatformAccountId(), @@ -225,7 +224,7 @@ func (s *LibrarianSephirahServiceService) UnLinkAccount(ctx context.Context, req if req.GetAccountId() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - if err := s.t.UnLinkAccount(ctx, modeltiphereth.Account{ + if err := s.t.UnLinkAccount(ctx, model.Account{ ID: 0, Platform: req.GetAccountId().GetPlatform(), PlatformAccountID: req.GetAccountId().GetPlatformAccountId(), diff --git a/internal/service/sephirah/yesod.go b/internal/service/sephirah/yesod.go index 21a3fe21..0815377c 100644 --- a/internal/service/sephirah/yesod.go +++ b/internal/service/sephirah/yesod.go @@ -2,9 +2,9 @@ package sephirah import ( "context" + "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/internal/service/supervisor/supervisor.go b/internal/service/supervisor/supervisor.go index 19d87594..ecbbef36 100644 --- a/internal/service/supervisor/supervisor.go +++ b/internal/service/supervisor/supervisor.go @@ -16,10 +16,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libtype" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modeltiphereth" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" "github.com/google/uuid" @@ -185,7 +183,7 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit,funlen // TODO var ins *modelsupervisor.PorterInstance if ins, err = s.instanceCache.Get(ctx, address); err != nil || ins == nil || - ins.Status != modeltiphereth.UserStatusActive { + ins.Status != model.UserStatusActive { return true } @@ -288,7 +286,7 @@ func (s *Supervisor) evaluatePorterInstance( Address: address, Region: info.GetRegion(), FeatureSummary: feature, - Status: modeltiphereth.UserStatusUnspecified, + Status: model.UserStatusUnspecified, ContextJSONSchema: info.GetContextJsonSchema(), }, nil } @@ -314,7 +312,7 @@ func (s *Supervisor) enablePorterInstance( instance.ID, 0, libauth.ClaimsTypeRefreshToken, - libauth.UserTypePorter, + model.UserTypePorter, nil, libtime.Hour, ) diff --git a/internal/service/supervisor/task.go b/internal/service/supervisor/task.go index 93d7b023..792b5427 100644 --- a/internal/service/supervisor/task.go +++ b/internal/service/supervisor/task.go @@ -3,11 +3,11 @@ package supervisor import ( "context" "fmt" + "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtype" - "github.com/tuihub/librarian/internal/model/converter" "github.com/tuihub/librarian/internal/model/modelsupervisor" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" ) From d63a4cc602e17941353177fe18160da0a345d56b Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 22 Mar 2025 00:02:50 +0800 Subject: [PATCH 11/19] feat: draft angela web --- app/sephirah/cmd/sephirah/wire.go | 2 +- app/sephirah/cmd/sephirah/wire_gen.go | 5 +- .../data/internal/ent/runtime/runtime.go | 10 - app/sephirah/pkg/service/wire.go | 2 +- app/sephirah/pkg/service/wire_gen.go | 5 +- go.sum | 7 + internal/biz/bizangela/account.go | 1 + internal/biz/bizangela/app.go | 1 + internal/biz/bizangela/feed.go | 1 + internal/biz/bizangela/notify.go | 1 + internal/biz/bizangela/porter.go | 1 + internal/biz/bizgebura/app_info.go | 1 + internal/biz/biznetzach/netzach.go | 1 + .../internal => internal}/data/angela.go | 20 +- .../internal => internal}/data/binah.go | 0 .../internal => internal}/data/chesed.go | 6 +- .../internal => internal}/data/data.go | 4 +- internal/data/db/db.go | 7 - internal/data/db/dbmodel/dbmodel.go | 17 -- internal/data/db/dbmodel/device.go | 25 --- internal/data/db/dbmodel/session.go | 11 - internal/data/db/dbmodel/user.go | 27 --- internal/data/db/migration/migration.go | 23 -- internal/data/db/migration/migration_test.go | 21 -- internal/data/db/migration/v1.go | 122 ----------- internal/data/db/migration/v2.go | 47 ----- .../internal => internal}/data/gebura.go | 14 +- .../data/internal/converter/biz_to_ent.go | 24 +-- .../data/internal/converter/converter.go | 2 +- .../data/internal/converter/ent_to_biz.go | 26 +-- .../data/internal/converter/generated.go | 198 +++++++++--------- .../data/internal/ent/account.go | 4 +- .../data/internal/ent/account/account.go | 0 .../data/internal/ent/account/where.go | 2 +- .../data/internal/ent/account_create.go | 6 +- .../data/internal/ent/account_delete.go | 4 +- .../data/internal/ent/account_query.go | 8 +- .../data/internal/ent/account_update.go | 8 +- .../data/internal/ent/app.go | 6 +- .../data/internal/ent/app/app.go | 0 .../data/internal/ent/app/where.go | 2 +- .../data/internal/ent/app_create.go | 6 +- .../data/internal/ent/app_delete.go | 4 +- .../data/internal/ent/app_query.go | 8 +- .../data/internal/ent/app_update.go | 8 +- .../data/internal/ent/appbinary.go | 4 +- .../data/internal/ent/appbinary/appbinary.go | 0 .../data/internal/ent/appbinary/where.go | 2 +- .../data/internal/ent/appbinary_create.go | 4 +- .../data/internal/ent/appbinary_delete.go | 4 +- .../data/internal/ent/appbinary_query.go | 6 +- .../data/internal/ent/appbinary_update.go | 6 +- .../data/internal/ent/appinfo.go | 2 +- .../data/internal/ent/appinfo/appinfo.go | 0 .../data/internal/ent/appinfo/where.go | 2 +- .../data/internal/ent/appinfo_create.go | 10 +- .../data/internal/ent/appinfo_delete.go | 4 +- .../data/internal/ent/appinfo_query.go | 12 +- .../data/internal/ent/appinfo_update.go | 12 +- .../data/internal/ent/appinst.go | 4 +- .../data/internal/ent/appinst/appinst.go | 0 .../data/internal/ent/appinst/where.go | 2 +- .../data/internal/ent/appinst_create.go | 4 +- .../data/internal/ent/appinst_delete.go | 4 +- .../data/internal/ent/appinst_query.go | 6 +- .../data/internal/ent/appinst_update.go | 6 +- .../data/internal/ent/appinstruntime.go | 2 +- .../ent/appinstruntime/appinstruntime.go | 0 .../data/internal/ent/appinstruntime/where.go | 2 +- .../internal/ent/appinstruntime_create.go | 2 +- .../internal/ent/appinstruntime_delete.go | 4 +- .../data/internal/ent/appinstruntime_query.go | 4 +- .../internal/ent/appinstruntime_update.go | 4 +- .../data/internal/ent/client.go | 56 ++--- .../data/internal/ent/deviceinfo.go | 2 +- .../internal/ent/deviceinfo/deviceinfo.go | 0 .../data/internal/ent/deviceinfo/where.go | 2 +- .../data/internal/ent/deviceinfo_create.go | 8 +- .../data/internal/ent/deviceinfo_delete.go | 4 +- .../data/internal/ent/deviceinfo_query.go | 10 +- .../data/internal/ent/deviceinfo_update.go | 10 +- .../data/internal/ent/ent.go | 54 ++--- .../data/internal/ent/enttest/enttest.go | 6 +- .../data/internal/ent/feed.go | 4 +- .../data/internal/ent/feed/feed.go | 0 .../data/internal/ent/feed/where.go | 2 +- .../data/internal/ent/feed_create.go | 6 +- .../data/internal/ent/feed_delete.go | 4 +- .../data/internal/ent/feed_query.go | 8 +- .../data/internal/ent/feed_update.go | 8 +- .../data/internal/ent/feedactionset.go | 6 +- .../ent/feedactionset/feedactionset.go | 0 .../data/internal/ent/feedactionset/where.go | 2 +- .../data/internal/ent/feedactionset_create.go | 8 +- .../data/internal/ent/feedactionset_delete.go | 4 +- .../data/internal/ent/feedactionset_query.go | 8 +- .../data/internal/ent/feedactionset_update.go | 10 +- .../data/internal/ent/feedconfig.go | 8 +- .../internal/ent/feedconfig/feedconfig.go | 0 .../data/internal/ent/feedconfig/where.go | 2 +- .../data/internal/ent/feedconfig_create.go | 14 +- .../data/internal/ent/feedconfig_delete.go | 4 +- .../data/internal/ent/feedconfig_query.go | 14 +- .../data/internal/ent/feedconfig_update.go | 16 +- .../data/internal/ent/feedconfigaction.go | 6 +- .../ent/feedconfigaction/feedconfigaction.go | 0 .../internal/ent/feedconfigaction/where.go | 2 +- .../internal/ent/feedconfigaction_create.go | 6 +- .../internal/ent/feedconfigaction_delete.go | 4 +- .../internal/ent/feedconfigaction_query.go | 8 +- .../internal/ent/feedconfigaction_update.go | 8 +- .../data/internal/ent/feeditem.go | 4 +- .../data/internal/ent/feeditem/feeditem.go | 0 .../data/internal/ent/feeditem/where.go | 2 +- .../data/internal/ent/feeditem_create.go | 6 +- .../data/internal/ent/feeditem_delete.go | 4 +- .../data/internal/ent/feeditem_query.go | 8 +- .../data/internal/ent/feeditem_update.go | 6 +- .../data/internal/ent/feeditemcollection.go | 4 +- .../feeditemcollection/feeditemcollection.go | 0 .../internal/ent/feeditemcollection/where.go | 2 +- .../internal/ent/feeditemcollection_create.go | 8 +- .../internal/ent/feeditemcollection_delete.go | 4 +- .../internal/ent/feeditemcollection_query.go | 10 +- .../internal/ent/feeditemcollection_update.go | 10 +- .../data/internal/ent/file.go | 6 +- .../data/internal/ent/file/file.go | 0 .../data/internal/ent/file/where.go | 2 +- .../data/internal/ent/file_create.go | 6 +- .../data/internal/ent/file_delete.go | 4 +- .../data/internal/ent/file_query.go | 8 +- .../data/internal/ent/file_update.go | 8 +- .../data/internal/ent/generate.go | 0 .../data/internal/ent/hook/hook.go | 2 +- .../data/internal/ent/image.go | 6 +- .../data/internal/ent/image/image.go | 0 .../data/internal/ent/image/where.go | 2 +- .../data/internal/ent/image_create.go | 6 +- .../data/internal/ent/image_delete.go | 4 +- .../data/internal/ent/image_query.go | 8 +- .../data/internal/ent/image_update.go | 8 +- .../data/internal/ent/migrate/migrate.go | 0 .../data/internal/ent/migrate/schema.go | 0 .../data/internal/ent/mutation.go | 58 ++--- .../data/internal/ent/notifyflow.go | 4 +- .../internal/ent/notifyflow/notifyflow.go | 0 .../data/internal/ent/notifyflow/where.go | 2 +- .../data/internal/ent/notifyflow_create.go | 12 +- .../data/internal/ent/notifyflow_delete.go | 4 +- .../data/internal/ent/notifyflow_query.go | 14 +- .../data/internal/ent/notifyflow_update.go | 14 +- .../data/internal/ent/notifyflowsource.go | 6 +- .../ent/notifyflowsource/notifyflowsource.go | 0 .../internal/ent/notifyflowsource/where.go | 2 +- .../internal/ent/notifyflowsource_create.go | 6 +- .../internal/ent/notifyflowsource_delete.go | 4 +- .../internal/ent/notifyflowsource_query.go | 8 +- .../internal/ent/notifyflowsource_update.go | 8 +- .../data/internal/ent/notifyflowtarget.go | 6 +- .../ent/notifyflowtarget/notifyflowtarget.go | 0 .../internal/ent/notifyflowtarget/where.go | 2 +- .../internal/ent/notifyflowtarget_create.go | 6 +- .../internal/ent/notifyflowtarget_delete.go | 4 +- .../internal/ent/notifyflowtarget_query.go | 8 +- .../internal/ent/notifyflowtarget_update.go | 8 +- .../data/internal/ent/notifysource.go | 8 +- .../internal/ent/notifysource/notifysource.go | 0 .../data/internal/ent/notifysource/where.go | 2 +- .../data/internal/ent/notifysource_create.go | 12 +- .../data/internal/ent/notifysource_delete.go | 4 +- .../data/internal/ent/notifysource_query.go | 14 +- .../data/internal/ent/notifysource_update.go | 14 +- .../data/internal/ent/notifytarget.go | 6 +- .../internal/ent/notifytarget/notifytarget.go | 0 .../data/internal/ent/notifytarget/where.go | 2 +- .../data/internal/ent/notifytarget_create.go | 10 +- .../data/internal/ent/notifytarget_delete.go | 4 +- .../data/internal/ent/notifytarget_query.go | 10 +- .../data/internal/ent/notifytarget_update.go | 12 +- .../data/internal/ent/portercontext.go | 4 +- .../ent/portercontext/portercontext.go | 0 .../data/internal/ent/portercontext/where.go | 2 +- .../data/internal/ent/portercontext_create.go | 4 +- .../data/internal/ent/portercontext_delete.go | 4 +- .../data/internal/ent/portercontext_query.go | 6 +- .../data/internal/ent/portercontext_update.go | 6 +- .../data/internal/ent/porterinstance.go | 4 +- .../ent/porterinstance/porterinstance.go | 0 .../data/internal/ent/porterinstance/where.go | 2 +- .../internal/ent/porterinstance_create.go | 4 +- .../internal/ent/porterinstance_delete.go | 4 +- .../data/internal/ent/porterinstance_query.go | 4 +- .../internal/ent/porterinstance_update.go | 6 +- .../data/internal/ent/predicate/predicate.go | 0 .../data/internal/ent/runtime.go | 56 ++--- internal/data/internal/ent/runtime/runtime.go | 10 + .../data/internal/ent/schema/account.go | 0 .../data/internal/ent/schema/app.go | 0 .../data/internal/ent/schema/app_binary.go | 0 .../data/internal/ent/schema/app_info.go | 0 .../data/internal/ent/schema/app_inst.go | 0 .../internal/ent/schema/app_inst_run_time.go | 0 .../data/internal/ent/schema/device_info.go | 0 .../data/internal/ent/schema/feed.go | 0 .../internal/ent/schema/feed_action_set.go | 0 .../data/internal/ent/schema/feed_config.go | 0 .../internal/ent/schema/feed_config_action.go | 0 .../data/internal/ent/schema/feed_item.go | 0 .../ent/schema/feed_item_collection.go | 0 .../data/internal/ent/schema/file.go | 0 .../data/internal/ent/schema/image.go | 0 .../data/internal/ent/schema/notify_flow.go | 0 .../internal/ent/schema/notify_flow_source.go | 0 .../internal/ent/schema/notify_flow_taget.go | 0 .../data/internal/ent/schema/notify_source.go | 0 .../data/internal/ent/schema/notify_target.go | 0 .../internal/ent/schema/porter_context.go | 0 .../internal/ent/schema/porter_instance.go | 0 .../data/internal/ent/schema/schema.go | 0 .../ent/schema/system_notification.go | 0 .../data/internal/ent/schema/tag.go | 0 .../data/internal/ent/schema/user.go | 0 .../data/internal/ent/schema/user_device.go | 0 .../data/internal/ent/schema/user_session.go | 0 .../data/internal/ent/systemnotification.go | 2 +- .../systemnotification/systemnotification.go | 0 .../internal/ent/systemnotification/where.go | 2 +- .../internal/ent/systemnotification_create.go | 2 +- .../internal/ent/systemnotification_delete.go | 4 +- .../internal/ent/systemnotification_query.go | 4 +- .../internal/ent/systemnotification_update.go | 4 +- .../data/internal/ent/tag.go | 4 +- .../data/internal/ent/tag/tag.go | 0 .../data/internal/ent/tag/where.go | 2 +- .../data/internal/ent/tag_create.go | 4 +- .../data/internal/ent/tag_delete.go | 4 +- .../data/internal/ent/tag_query.go | 6 +- .../data/internal/ent/tag_update.go | 6 +- .../data/internal/ent/tx.go | 0 .../data/internal/ent/user.go | 2 +- .../data/internal/ent/user/user.go | 0 .../data/internal/ent/user/where.go | 2 +- .../data/internal/ent/user_create.go | 34 +-- .../data/internal/ent/user_delete.go | 4 +- .../data/internal/ent/user_query.go | 36 ++-- .../data/internal/ent/user_update.go | 36 ++-- .../data/internal/ent/userdevice.go | 6 +- .../internal/ent/userdevice/userdevice.go | 0 .../data/internal/ent/userdevice/where.go | 2 +- .../data/internal/ent/userdevice_create.go | 6 +- .../data/internal/ent/userdevice_delete.go | 4 +- .../data/internal/ent/userdevice_query.go | 8 +- .../data/internal/ent/userdevice_update.go | 8 +- .../data/internal/ent/usersession.go | 4 +- .../internal/ent/usersession/usersession.go | 0 .../data/internal/ent/usersession/where.go | 2 +- .../data/internal/ent/usersession_create.go | 4 +- .../data/internal/ent/usersession_delete.go | 4 +- .../data/internal/ent/usersession_query.go | 6 +- .../data/internal/ent/usersession_update.go | 6 +- .../internal => internal}/data/netzach.go | 16 +- .../internal => internal}/data/tiphereth.go | 21 +- .../internal => internal}/data/yesod.go | 16 +- internal/model/tiphereth.go | 12 +- .../service/angelaweb/internal/api/handler.go | 3 +- .../service/angelaweb/internal/api/login.go | 6 +- .../service/angelaweb/internal/api/user.go | 3 +- .../service/angelaweb/internal/model/model.go | 4 +- .../service/angelaweb/internal/page/page.go | 3 +- internal/service/sephirah/chesed.go | 10 +- .../{internal => }/converter/biz_to_pb.go | 0 .../{internal => }/converter/converter.go | 0 .../{internal => }/converter/generated.go | 0 .../{internal => }/converter/pb_to_biz.go | 0 internal/service/sephirah/gebura.go | 60 +++--- .../sephirah/librariansephirahservice.go | 2 +- internal/service/sephirah/netzach.go | 32 +-- internal/service/sephirah/porter.go | 8 +- internal/service/sephirah/tiphereth.go | 58 ++--- internal/service/sephirah/yesod.go | 70 +++---- internal/service/supervisor/supervisor.go | 1 + internal/service/supervisor/task.go | 2 +- 282 files changed, 959 insertions(+), 1238 deletions(-) delete mode 100644 app/sephirah/internal/data/internal/ent/runtime/runtime.go rename {app/sephirah/internal => internal}/data/angela.go (92%) rename {app/sephirah/internal => internal}/data/binah.go (100%) rename {app/sephirah/internal => internal}/data/chesed.go (89%) rename {app/sephirah/internal => internal}/data/data.go (95%) delete mode 100644 internal/data/db/db.go delete mode 100644 internal/data/db/dbmodel/dbmodel.go delete mode 100644 internal/data/db/dbmodel/device.go delete mode 100644 internal/data/db/dbmodel/session.go delete mode 100644 internal/data/db/dbmodel/user.go delete mode 100644 internal/data/db/migration/migration.go delete mode 100644 internal/data/db/migration/migration_test.go delete mode 100644 internal/data/db/migration/v1.go delete mode 100644 internal/data/db/migration/v2.go rename {app/sephirah/internal => internal}/data/gebura.go (96%) rename {app/sephirah/internal => internal}/data/internal/converter/biz_to_ent.go (85%) rename {app/sephirah/internal => internal}/data/internal/converter/converter.go (97%) rename {app/sephirah/internal => internal}/data/internal/converter/ent_to_biz.go (88%) rename {app/sephirah/internal => internal}/data/internal/converter/generated.go (88%) rename {app/sephirah/internal => internal}/data/internal/ent/account.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/account/account.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/account/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/account_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/account_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/account_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/account_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/app.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/app/app.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/app/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/app_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/app_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/app_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/app_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/appbinary.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/appbinary/appbinary.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/appbinary/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appbinary_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appbinary_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/appbinary_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/appbinary_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/appinfo.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appinfo/appinfo.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/appinfo/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appinfo_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appinfo_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/appinfo_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/appinfo_update.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appinst.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/appinst/appinst.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/appinst/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appinst_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appinst_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/appinst_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/appinst_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/appinstruntime.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/appinstruntime/appinstruntime.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/appinstruntime/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appinstruntime_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/appinstruntime_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/appinstruntime_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/appinstruntime_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/client.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/deviceinfo.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/deviceinfo/deviceinfo.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/deviceinfo/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/deviceinfo_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/deviceinfo_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/deviceinfo_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/deviceinfo_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/ent.go (88%) rename {app/sephirah/internal => internal}/data/internal/ent/enttest/enttest.go (88%) rename {app/sephirah/internal => internal}/data/internal/ent/feed.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feed/feed.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/feed/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feed_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feed_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/feed_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feed_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedactionset.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/feedactionset/feedactionset.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/feedactionset/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feedactionset_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feedactionset_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/feedactionset_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedactionset_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfig.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfig/feedconfig.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfig/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfig_create.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfig_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfig_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfig_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfigaction.go (96%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfigaction/feedconfigaction.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfigaction/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfigaction_create.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfigaction_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfigaction_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feedconfigaction_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditem.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditem/feeditem.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditem/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditem_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditem_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditem_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditem_update.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditemcollection.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditemcollection/feeditemcollection.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditemcollection/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditemcollection_create.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditemcollection_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditemcollection_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/feeditemcollection_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/file.go (96%) rename {app/sephirah/internal => internal}/data/internal/ent/file/file.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/file/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/file_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/file_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/file_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/file_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/generate.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/hook/hook.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/image.go (96%) rename {app/sephirah/internal => internal}/data/internal/ent/image/image.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/image/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/image_create.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/image_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/image_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/image_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/migrate/migrate.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/migrate/schema.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/mutation.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflow.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflow/notifyflow.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflow/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflow_create.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflow_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflow_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflow_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowsource.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowsource/notifyflowsource.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowsource/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowsource_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowsource_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowsource_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowsource_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowtarget.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowtarget/notifyflowtarget.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowtarget/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowtarget_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowtarget_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowtarget_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifyflowtarget_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifysource.go (96%) rename {app/sephirah/internal => internal}/data/internal/ent/notifysource/notifysource.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/notifysource/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/notifysource_create.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifysource_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/notifysource_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifysource_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifytarget.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifytarget/notifytarget.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/notifytarget/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/notifytarget_create.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifytarget_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/notifytarget_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/notifytarget_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/portercontext.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/portercontext/portercontext.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/portercontext/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/portercontext_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/portercontext_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/portercontext_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/portercontext_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/porterinstance.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/porterinstance/porterinstance.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/porterinstance/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/porterinstance_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/porterinstance_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/porterinstance_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/porterinstance_update.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/predicate/predicate.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/runtime.go (91%) create mode 100644 internal/data/internal/ent/runtime/runtime.go rename {app/sephirah/internal => internal}/data/internal/ent/schema/account.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/app.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/app_binary.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/app_info.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/app_inst.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/app_inst_run_time.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/device_info.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/feed.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/feed_action_set.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/feed_config.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/feed_config_action.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/feed_item.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/feed_item_collection.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/file.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/image.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/notify_flow.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/notify_flow_source.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/notify_flow_taget.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/notify_source.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/notify_target.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/porter_context.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/porter_instance.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/schema.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/system_notification.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/tag.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/user.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/user_device.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/schema/user_session.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/systemnotification.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/systemnotification/systemnotification.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/systemnotification/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/systemnotification_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/systemnotification_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/systemnotification_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/systemnotification_update.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/tag.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/tag/tag.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/tag/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/tag_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/tag_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/tag_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/tag_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/tx.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/user.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/user/user.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/user/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/user_create.go (96%) rename {app/sephirah/internal => internal}/data/internal/ent/user_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/user_query.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/user_update.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/userdevice.go (96%) rename {app/sephirah/internal => internal}/data/internal/ent/userdevice/userdevice.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/userdevice/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/userdevice_create.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/userdevice_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/userdevice_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/userdevice_update.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/usersession.go (97%) rename {app/sephirah/internal => internal}/data/internal/ent/usersession/usersession.go (100%) rename {app/sephirah/internal => internal}/data/internal/ent/usersession/where.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/usersession_create.go (99%) rename {app/sephirah/internal => internal}/data/internal/ent/usersession_delete.go (93%) rename {app/sephirah/internal => internal}/data/internal/ent/usersession_query.go (98%) rename {app/sephirah/internal => internal}/data/internal/ent/usersession_update.go (98%) rename {app/sephirah/internal => internal}/data/netzach.go (93%) rename {app/sephirah/internal => internal}/data/tiphereth.go (95%) rename {app/sephirah/internal => internal}/data/yesod.go (96%) rename internal/service/sephirah/{internal => }/converter/biz_to_pb.go (100%) rename internal/service/sephirah/{internal => }/converter/converter.go (100%) rename internal/service/sephirah/{internal => }/converter/generated.go (100%) rename internal/service/sephirah/{internal => }/converter/pb_to_biz.go (100%) diff --git a/app/sephirah/cmd/sephirah/wire.go b/app/sephirah/cmd/sephirah/wire.go index 156aa363..8a788b42 100644 --- a/app/sephirah/cmd/sephirah/wire.go +++ b/app/sephirah/cmd/sephirah/wire.go @@ -5,11 +5,11 @@ package main import ( - "github.com/tuihub/librarian/app/sephirah/internal/data" "github.com/tuihub/librarian/internal/biz" globalclient "github.com/tuihub/librarian/internal/client" "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" diff --git a/app/sephirah/cmd/sephirah/wire_gen.go b/app/sephirah/cmd/sephirah/wire_gen.go index c072dd73..f07a5fe4 100644 --- a/app/sephirah/cmd/sephirah/wire_gen.go +++ b/app/sephirah/cmd/sephirah/wire_gen.go @@ -8,7 +8,6 @@ package main import ( "github.com/go-kratos/kratos/v2" - "github.com/tuihub/librarian/app/sephirah/internal/data" bizangela2 "github.com/tuihub/librarian/internal/biz/bizangela" "github.com/tuihub/librarian/internal/biz/bizbinah" "github.com/tuihub/librarian/internal/biz/bizchesed" @@ -19,6 +18,8 @@ import ( client2 "github.com/tuihub/librarian/internal/client" "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/data" + data2 "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" @@ -71,7 +72,7 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c netzachRepo := data.NewNetzachRepo(dataData) idGenerator := libidgenerator.NewIDGenerator() topic := biznetzach2.NewSystemNotificationTopic(netzachRepo, idGenerator) - tipherethRepo := data.NewTipherethRepo(dataData) + tipherethRepo := data2.NewTipherethRepo(dataData) store, err := libcache.NewStore(cache) if err != nil { cleanup2() diff --git a/app/sephirah/internal/data/internal/ent/runtime/runtime.go b/app/sephirah/internal/data/internal/ent/runtime/runtime.go deleted file mode 100644 index e40243f4..00000000 --- a/app/sephirah/internal/data/internal/ent/runtime/runtime.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package runtime - -// The schema-stitching logic is generated in github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/runtime.go - -const ( - Version = "v0.14.1" // Version of ent codegen. - Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen. -) diff --git a/app/sephirah/pkg/service/wire.go b/app/sephirah/pkg/service/wire.go index ffc28663..cc6650b8 100644 --- a/app/sephirah/pkg/service/wire.go +++ b/app/sephirah/pkg/service/wire.go @@ -5,10 +5,10 @@ package service import ( - "github.com/tuihub/librarian/app/sephirah/internal/data" "github.com/tuihub/librarian/internal/biz" "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" diff --git a/app/sephirah/pkg/service/wire_gen.go b/app/sephirah/pkg/service/wire_gen.go index 53126ff1..33925f16 100644 --- a/app/sephirah/pkg/service/wire_gen.go +++ b/app/sephirah/pkg/service/wire_gen.go @@ -7,7 +7,6 @@ package service import ( - "github.com/tuihub/librarian/app/sephirah/internal/data" bizangela2 "github.com/tuihub/librarian/internal/biz/bizangela" "github.com/tuihub/librarian/internal/biz/bizbinah" "github.com/tuihub/librarian/internal/biz/bizchesed" @@ -17,6 +16,8 @@ import ( "github.com/tuihub/librarian/internal/biz/bizyesod" "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/data" + data2 "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" @@ -51,7 +52,7 @@ func NewSephirahService(sephirahServer *conf.SephirahServer, database *conf.Data } netzachRepo := data.NewNetzachRepo(dataData) topic := biznetzach2.NewSystemNotificationTopic(netzachRepo, idGenerator) - tipherethRepo := data.NewTipherethRepo(dataData) + tipherethRepo := data2.NewTipherethRepo(dataData) libcacheMap := biztiphereth.NewPorterInstanceCache(tipherethRepo, store) map2 := biztiphereth.NewPorterContextCache(tipherethRepo, store) supervisorSupervisor, err := supervisor.NewSupervisor(porter, mq, auth, clientPorter, topic, libcacheMap, map2) diff --git a/go.sum b/go.sum index 533ff9df..e2e4af91 100644 --- a/go.sum +++ b/go.sum @@ -412,6 +412,8 @@ github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmK github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E= github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= @@ -572,6 +574,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -680,7 +684,10 @@ github.com/sony/sonyflake v1.2.0 h1:Pfr3A+ejSg+0SPqpoAmQgEtNDAhc2G1SUYk205qVMLQ= github.com/sony/sonyflake v1.2.0/go.mod h1:LORtCywH/cq10ZbyfhKrHYgAUGH7mOBa76enV9txy/Y= github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= diff --git a/internal/biz/bizangela/account.go b/internal/biz/bizangela/account.go index 1ebfd46e..1edfd13e 100644 --- a/internal/biz/bizangela/account.go +++ b/internal/biz/bizangela/account.go @@ -8,6 +8,7 @@ import ( "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/internal/biz/bizangela/app.go b/internal/biz/bizangela/app.go index 8764f0a6..2b39ef60 100644 --- a/internal/biz/bizangela/app.go +++ b/internal/biz/bizangela/app.go @@ -12,6 +12,7 @@ import ( "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) diff --git a/internal/biz/bizangela/feed.go b/internal/biz/bizangela/feed.go index a4af41e4..c293029d 100644 --- a/internal/biz/bizangela/feed.go +++ b/internal/biz/bizangela/feed.go @@ -13,6 +13,7 @@ import ( "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" ) diff --git a/internal/biz/bizangela/notify.go b/internal/biz/bizangela/notify.go index 8e68c8c0..cbcd28b5 100644 --- a/internal/biz/bizangela/notify.go +++ b/internal/biz/bizangela/notify.go @@ -14,6 +14,7 @@ import ( "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelnetzach" + "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" ) diff --git a/internal/biz/bizangela/porter.go b/internal/biz/bizangela/porter.go index 4cfab7d2..195a8993 100644 --- a/internal/biz/bizangela/porter.go +++ b/internal/biz/bizangela/porter.go @@ -2,6 +2,7 @@ package bizangela import ( "context" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" diff --git a/internal/biz/bizgebura/app_info.go b/internal/biz/bizgebura/app_info.go index 87403ce7..fe8fa543 100644 --- a/internal/biz/bizgebura/app_info.go +++ b/internal/biz/bizgebura/app_info.go @@ -11,6 +11,7 @@ import ( "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" diff --git a/internal/biz/biznetzach/netzach.go b/internal/biz/biznetzach/netzach.go index 21b30c80..c8dbaf08 100644 --- a/internal/biz/biznetzach/netzach.go +++ b/internal/biz/biznetzach/netzach.go @@ -2,6 +2,7 @@ package biznetzach import ( "context" + "github.com/tuihub/librarian/internal/biz/bizutils" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" diff --git a/app/sephirah/internal/data/angela.go b/internal/data/angela.go similarity index 92% rename from app/sephirah/internal/data/angela.go rename to internal/data/angela.go index 5ed265f9..602ea303 100644 --- a/app/sephirah/internal/data/angela.go +++ b/internal/data/angela.go @@ -4,17 +4,17 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" "github.com/tuihub/librarian/internal/biz/bizangela" + "github.com/tuihub/librarian/internal/data/internal/converter" + "github.com/tuihub/librarian/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelgebura" diff --git a/app/sephirah/internal/data/binah.go b/internal/data/binah.go similarity index 100% rename from app/sephirah/internal/data/binah.go rename to internal/data/binah.go diff --git a/app/sephirah/internal/data/chesed.go b/internal/data/chesed.go similarity index 89% rename from app/sephirah/internal/data/chesed.go rename to internal/data/chesed.go index 8c48cdb1..92ca728a 100644 --- a/app/sephirah/internal/data/chesed.go +++ b/internal/data/chesed.go @@ -3,10 +3,10 @@ package data import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/biz/bizchesed" + "github.com/tuihub/librarian/internal/data/internal/converter" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelchesed" ) diff --git a/app/sephirah/internal/data/data.go b/internal/data/data.go similarity index 95% rename from app/sephirah/internal/data/data.go rename to internal/data/data.go index a61cbaeb..fd3a252a 100644 --- a/app/sephirah/internal/data/data.go +++ b/internal/data/data.go @@ -7,9 +7,9 @@ import ( "path" "slices" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/migrate" "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent/migrate" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/logger" diff --git a/internal/data/db/db.go b/internal/data/db/db.go deleted file mode 100644 index c13bcee5..00000000 --- a/internal/data/db/db.go +++ /dev/null @@ -1,7 +0,0 @@ -package db - -import "gorm.io/gorm" - -type DB struct { - gorm.DB -} diff --git a/internal/data/db/dbmodel/dbmodel.go b/internal/data/db/dbmodel/dbmodel.go deleted file mode 100644 index f1cee941..00000000 --- a/internal/data/db/dbmodel/dbmodel.go +++ /dev/null @@ -1,17 +0,0 @@ -package dbmodel - -import ( - "gorm.io/gorm" - "time" -) - -type InternalID int64 - -type Model struct { - ID InternalID `gorm:"primarykey"` - CreatedAt time.Time - UpdatedAt time.Time - deletedAt gorm.DeletedAt `gorm:"index"` -} - -type ID InternalID diff --git a/internal/data/db/dbmodel/device.go b/internal/data/db/dbmodel/device.go deleted file mode 100644 index 356ce151..00000000 --- a/internal/data/db/dbmodel/device.go +++ /dev/null @@ -1,25 +0,0 @@ -package dbmodel - -type SystemType string - -const ( - SystemTypeUnspecified SystemType = "unspecified" - SystemTypeWindows SystemType = "windows" - SystemTypeMacOS SystemType = "macos" - SystemTypeLinux SystemType = "linux" - SystemTypeWeb SystemType = "web" - SystemTypeAndroid SystemType = "android" - SystemTypeIOS SystemType = "ios" -) - -type Device struct { - Model - UserID ID - ClientLocalID *ID - Name string - SystemType SystemType - SystemVersion string - ClientName string - ClientSourceCodeAddress string - ClientVersion string -} diff --git a/internal/data/db/dbmodel/session.go b/internal/data/db/dbmodel/session.go deleted file mode 100644 index 72e94e3b..00000000 --- a/internal/data/db/dbmodel/session.go +++ /dev/null @@ -1,11 +0,0 @@ -package dbmodel - -import "time" - -type Session struct { - Model - UserID ID - DeviceID ID - Token string - ExpireAt time.Time -} diff --git a/internal/data/db/dbmodel/user.go b/internal/data/db/dbmodel/user.go deleted file mode 100644 index d5bd0c0e..00000000 --- a/internal/data/db/dbmodel/user.go +++ /dev/null @@ -1,27 +0,0 @@ -package dbmodel - -type UserStatus string - -const ( - UserStatusUnspecified UserStatus = "unspecified" - UserStatusActive UserStatus = "active" - UserStatusBlocked UserStatus = "blocked" -) - -type UserType string - -const ( - UserTypeUnspecified UserType = "unspecified" - UserTypeAdmin UserType = "admin" - UserTypeNormal UserType = "normal" - UserTypeSentinel UserType = "sentinel" - UserTypePorter UserType = "porter" -) - -type User struct { - Model - Username string - Password string - Status UserStatus - Type UserType -} diff --git a/internal/data/db/migration/migration.go b/internal/data/db/migration/migration.go deleted file mode 100644 index c17e2b67..00000000 --- a/internal/data/db/migration/migration.go +++ /dev/null @@ -1,23 +0,0 @@ -package migration - -import "gorm.io/gorm" - -type latestVersion struct { - v2 -} - -type Migration struct { - migrator latestVersion -} - -func NewMigration(db *gorm.DB) *Migration { - m := latestVersion{} - m.init(db) - return &Migration{ - migrator: m, - } -} - -func (m *Migration) Migrate() error { - return m.migrator.migrate() -} diff --git a/internal/data/db/migration/migration_test.go b/internal/data/db/migration/migration_test.go deleted file mode 100644 index fd5f941d..00000000 --- a/internal/data/db/migration/migration_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package migration_test - -import ( - "testing" - - "github.com/tuihub/librarian/internal/data/db/migration" - - "gorm.io/driver/sqlite" - "gorm.io/gorm" -) - -func TestNewMigration(t *testing.T) { - db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{}) - if err != nil { - t.Fatalf("Failed to open database: %v", err) - } - err = migration.NewMigration(db).Migrate() - if err != nil { - t.Fatalf("Failed to migrate: %v", err) - } -} diff --git a/internal/data/db/migration/v1.go b/internal/data/db/migration/v1.go deleted file mode 100644 index 540a6b4b..00000000 --- a/internal/data/db/migration/v1.go +++ /dev/null @@ -1,122 +0,0 @@ -package migration - -import ( - "errors" - "time" - - "github.com/tuihub/librarian/internal/model" - - "gorm.io/gorm" -) - -type v1 struct { - useTxForMigration *gorm.DB - tx *gorm.DB - targetVersion *uint - curVersion *uint -} - -func (v *v1) init(db *gorm.DB) { - v.useTxForMigration = db -} - -func (v *v1) migrate() error { - version := new(_Version) - version.Version = 1 - if !v.tx.Migrator().HasTable(version) { - err := v.tx.Migrator().CreateTable(version) - if err != nil { - return err - } - } - err := v.tx.Create(version).Error - if err != nil { - return err - } - v.curVersion = &version.Version - return nil -} - -func (v *v1) migrateWrapper(migrateVersion uint, doPreMigration func() error, doMigration func() error) error { - var err error - if v.targetVersion == nil { - v.targetVersion = &migrateVersion - v.tx = v.useTxForMigration.Begin() - defer func() { - if e := recover(); e != nil { - v.tx.Rollback() - panic(e) - } - v.targetVersion = nil - v.curVersion = nil - v.tx = nil - if err != nil { - v.tx.Rollback() - } else { - err = v.tx.Commit().Error - } - }() - } - - if v.curVersion == nil { - version := new(_Version) - // check if the version table exists - if !v.tx.Migrator().HasTable(version) { - var cv uint = 0 - v.curVersion = &cv - } else { - err = v.tx.Order("version desc").First(version).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return err - } - v.curVersion = &version.Version - } - } - - if *v.curVersion > migrateVersion { - return errors.New("database version is newer than the migration version") - } - - if *v.curVersion == migrateVersion { - return err - } - - if *v.curVersion < migrateVersion-1 { - err = doPreMigration() - if err != nil { - return err - } - } - - if *v.curVersion != migrateVersion-1 { - return errors.New("invalid migration sequence") - } - - err = doMigration() - if err != nil { - return err - } - err = v.tx.Create(&_Version{Version: migrateVersion}).Error - if err != nil { - return err - } - v.curVersion = &migrateVersion - - return err -} - -type _Version struct { - Version uint `gorm:"primaryKey"` - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt gorm.DeletedAt `gorm:"index"` -} - -type _Model struct { - ID model.InternalID `gorm:"primarykey"` - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt gorm.DeletedAt `gorm:"index"` -} - -type _ID model.InternalID diff --git a/internal/data/db/migration/v2.go b/internal/data/db/migration/v2.go deleted file mode 100644 index 3990a3ab..00000000 --- a/internal/data/db/migration/v2.go +++ /dev/null @@ -1,47 +0,0 @@ -package migration - -import "time" - -type v2 struct { - v1 -} - -func (v *v2) migrate() error { - return v.migrateWrapper(2, v.v1.migrate, func() error { - type User struct { - _Model - Username string - Password string - Status string - Type string - } - if err := v.tx.Migrator().CreateTable(new(User)); err != nil { - return err - } - type Session struct { - _Model - UserID _ID - DeviceID _ID - Token string - ExpireAt time.Time - } - if err := v.tx.Migrator().CreateTable(new(Session)); err != nil { - return err - } - type Device struct { - _Model - UserID _ID - ClientLocalID string - Name string - SystemType string - SystemVersion string - ClientName string - ClientSourceCodeAddress string - ClientVersion string - } - if err := v.tx.Migrator().CreateTable(new(Device)); err != nil { - return err - } - return nil - }) -} diff --git a/app/sephirah/internal/data/gebura.go b/internal/data/gebura.go similarity index 96% rename from app/sephirah/internal/data/gebura.go rename to internal/data/gebura.go index b5bf713f..6b759303 100644 --- a/app/sephirah/internal/data/gebura.go +++ b/internal/data/gebura.go @@ -5,14 +5,14 @@ import ( "errors" "time" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/biz/bizgebura" + "github.com/tuihub/librarian/internal/data/internal/converter" + "github.com/tuihub/librarian/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelgebura" ) diff --git a/app/sephirah/internal/data/internal/converter/biz_to_ent.go b/internal/data/internal/converter/biz_to_ent.go similarity index 85% rename from app/sephirah/internal/data/internal/converter/biz_to_ent.go rename to internal/data/internal/converter/biz_to_ent.go index 9b82d22e..d5920f6c 100644 --- a/app/sephirah/internal/data/internal/converter/biz_to_ent.go +++ b/internal/data/internal/converter/biz_to_ent.go @@ -1,17 +1,17 @@ package converter import ( - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelchesed" "github.com/tuihub/librarian/internal/model/modelgebura" @@ -23,7 +23,7 @@ import ( // goverter:converter // goverter:output:format function // goverter:output:file ./generated.go -// goverter:output:package github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter +// goverter:output:package github.com/tuihub/librarian/internal/data/internal/converter // goverter:matchIgnoreCase // goverter:ignoreUnexported type toEntConverter interface { //nolint:unused // used by generator diff --git a/app/sephirah/internal/data/internal/converter/converter.go b/internal/data/internal/converter/converter.go similarity index 97% rename from app/sephirah/internal/data/internal/converter/converter.go rename to internal/data/internal/converter/converter.go index a6f95518..20bd7f7b 100644 --- a/app/sephirah/internal/data/internal/converter/converter.go +++ b/internal/data/internal/converter/converter.go @@ -5,7 +5,7 @@ package converter import ( "strings" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelyesod" ) diff --git a/app/sephirah/internal/data/internal/converter/ent_to_biz.go b/internal/data/internal/converter/ent_to_biz.go similarity index 88% rename from app/sephirah/internal/data/internal/converter/ent_to_biz.go rename to internal/data/internal/converter/ent_to_biz.go index d4a91e2d..29b66921 100644 --- a/app/sephirah/internal/data/internal/converter/ent_to_biz.go +++ b/internal/data/internal/converter/ent_to_biz.go @@ -1,20 +1,20 @@ package converter import ( - "github.com/tuihub/librarian/internal/model" "time" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelchesed" "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelgebura" @@ -26,7 +26,7 @@ import ( // goverter:converter // goverter:output:format function // goverter:output:file ./generated.go -// goverter:output:package github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter +// goverter:output:package github.com/tuihub/librarian/internal/data/internal/converter // goverter:matchIgnoreCase // goverter:ignoreUnexported // goverter:enum:exclude time:Duration diff --git a/app/sephirah/internal/data/internal/converter/generated.go b/internal/data/internal/converter/generated.go similarity index 88% rename from app/sephirah/internal/data/internal/converter/generated.go rename to internal/data/internal/converter/generated.go index 1f9b04b4..078f7eec 100644 --- a/app/sephirah/internal/data/internal/converter/generated.go +++ b/internal/data/internal/converter/generated.go @@ -4,51 +4,51 @@ package converter import ( - ent "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - appinfo "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - deviceinfo "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - feedconfig "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - image "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - notifyflow "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - notifytarget "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - portercontext "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - porterinstance "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - systemnotification "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" - user "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + ent "github.com/tuihub/librarian/internal/data/internal/ent" + appinfo "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + deviceinfo "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + feedconfig "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + image "github.com/tuihub/librarian/internal/data/internal/ent/image" + notifyflow "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + notifytarget "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + portercontext "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + porterinstance "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + systemnotification "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" + user "github.com/tuihub/librarian/internal/data/internal/ent/user" model "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelchesed" + modelchesed "github.com/tuihub/librarian/internal/model/modelchesed" modelfeed "github.com/tuihub/librarian/internal/model/modelfeed" - "github.com/tuihub/librarian/internal/model/modelgebura" - "github.com/tuihub/librarian/internal/model/modelnetzach" - "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modelyesod" + modelgebura "github.com/tuihub/librarian/internal/model/modelgebura" + modelnetzach "github.com/tuihub/librarian/internal/model/modelnetzach" + modelsupervisor "github.com/tuihub/librarian/internal/model/modelsupervisor" + modelyesod "github.com/tuihub/librarian/internal/model/modelyesod" "time" ) func ToBizAccount(source *ent.Account) *model.Account { - var pModeltipherethAccount *model.Account + var pModelAccount *model.Account if source != nil { - var modeltipherethAccount model.Account - modeltipherethAccount.ID = model.InternalID((*source).ID) - modeltipherethAccount.Platform = (*source).Platform - modeltipherethAccount.PlatformAccountID = (*source).PlatformAccountID - modeltipherethAccount.Name = (*source).Name - modeltipherethAccount.ProfileURL = (*source).ProfileURL - modeltipherethAccount.AvatarURL = (*source).AvatarURL - modeltipherethAccount.LatestUpdateTime = TimeToTime((*source).UpdatedAt) - pModeltipherethAccount = &modeltipherethAccount - } - return pModeltipherethAccount + var modelAccount model.Account + modelAccount.ID = model.InternalID((*source).ID) + modelAccount.Platform = (*source).Platform + modelAccount.PlatformAccountID = (*source).PlatformAccountID + modelAccount.Name = (*source).Name + modelAccount.ProfileURL = (*source).ProfileURL + modelAccount.AvatarURL = (*source).AvatarURL + modelAccount.LatestUpdateTime = TimeToTime((*source).UpdatedAt) + pModelAccount = &modelAccount + } + return pModelAccount } func ToBizAccountList(source []*ent.Account) []*model.Account { - var pModeltipherethAccountList []*model.Account + var pModelAccountList []*model.Account if source != nil { - pModeltipherethAccountList = make([]*model.Account, len(source)) + pModelAccountList = make([]*model.Account, len(source)) for i := 0; i < len(source); i++ { - pModeltipherethAccountList[i] = ToBizAccount(source[i]) + pModelAccountList[i] = ToBizAccount(source[i]) } } - return pModeltipherethAccountList + return pModelAccountList } func ToBizApp(source *ent.App) *modelgebura.App { var pModelgeburaApp *modelgebura.App @@ -151,29 +151,29 @@ func ToBizAppType(source appinfo.Type) modelgebura.AppType { return modelgeburaAppType } func ToBizDeviceInfo(source *ent.DeviceInfo) *model.DeviceInfo { - var pModeltipherethDeviceInfo *model.DeviceInfo + var pModelDeviceInfo *model.DeviceInfo if source != nil { - var modeltipherethDeviceInfo model.DeviceInfo - modeltipherethDeviceInfo.ID = modelInternalIDToModelInternalID((*source).ID) - modeltipherethDeviceInfo.DeviceName = (*source).DeviceName - modeltipherethDeviceInfo.SystemType = ToBizSystemType((*source).SystemType) - modeltipherethDeviceInfo.SystemVersion = (*source).SystemVersion - modeltipherethDeviceInfo.ClientName = (*source).ClientName - modeltipherethDeviceInfo.ClientSourceCodeAddress = (*source).ClientSourceCodeAddress - modeltipherethDeviceInfo.ClientVersion = (*source).ClientVersion - pModeltipherethDeviceInfo = &modeltipherethDeviceInfo - } - return pModeltipherethDeviceInfo + var modelDeviceInfo model.DeviceInfo + modelDeviceInfo.ID = modelInternalIDToModelInternalID((*source).ID) + modelDeviceInfo.DeviceName = (*source).DeviceName + modelDeviceInfo.SystemType = ToBizSystemType((*source).SystemType) + modelDeviceInfo.SystemVersion = (*source).SystemVersion + modelDeviceInfo.ClientName = (*source).ClientName + modelDeviceInfo.ClientSourceCodeAddress = (*source).ClientSourceCodeAddress + modelDeviceInfo.ClientVersion = (*source).ClientVersion + pModelDeviceInfo = &modelDeviceInfo + } + return pModelDeviceInfo } func ToBizDeviceInfoList(source []*ent.DeviceInfo) []*model.DeviceInfo { - var pModeltipherethDeviceInfoList []*model.DeviceInfo + var pModelDeviceInfoList []*model.DeviceInfo if source != nil { - pModeltipherethDeviceInfoList = make([]*model.DeviceInfo, len(source)) + pModelDeviceInfoList = make([]*model.DeviceInfo, len(source)) for i := 0; i < len(source); i++ { - pModeltipherethDeviceInfoList[i] = ToBizDeviceInfo(source[i]) + pModelDeviceInfoList[i] = ToBizDeviceInfo(source[i]) } } - return pModeltipherethDeviceInfoList + return pModelDeviceInfoList } func ToBizFeed(source *ent.Feed) *modelfeed.Feed { var pModelfeedFeed *modelfeed.Feed @@ -506,16 +506,16 @@ func ToBizPorterList(source []*ent.PorterInstance) []*modelsupervisor.PorterInst return pModelsupervisorPorterInstanceList } func ToBizPorterStatus(source porterinstance.Status) model.UserStatus { - var modeltipherethUserStatus model.UserStatus + var modelUserStatus model.UserStatus switch source { case porterinstance.StatusActive: - modeltipherethUserStatus = model.UserStatusActive + modelUserStatus = model.UserStatusActive case porterinstance.StatusBlocked: - modeltipherethUserStatus = model.UserStatusBlocked + modelUserStatus = model.UserStatusBlocked default: - modeltipherethUserStatus = model.UserStatusUnspecified + modelUserStatus = model.UserStatusUnspecified } - return modeltipherethUserStatus + return modelUserStatus } func ToBizSystemNotification(source *ent.SystemNotification) *modelnetzach.SystemNotification { var pModelnetzachSystemNotification *modelnetzach.SystemNotification @@ -586,97 +586,97 @@ func ToBizSystemNotificationType(source systemnotification.Type) modelnetzach.Sy return modelnetzachSystemNotificationType } func ToBizSystemType(source deviceinfo.SystemType) model.SystemType { - var modeltipherethSystemType model.SystemType + var modelSystemType model.SystemType switch source { case deviceinfo.SystemTypeAndroid: - modeltipherethSystemType = model.SystemTypeAndroid + modelSystemType = model.SystemTypeAndroid case deviceinfo.SystemTypeIos: - modeltipherethSystemType = model.SystemTypeIOS + modelSystemType = model.SystemTypeIOS case deviceinfo.SystemTypeLinux: - modeltipherethSystemType = model.SystemTypeLinux + modelSystemType = model.SystemTypeLinux case deviceinfo.SystemTypeMacos: - modeltipherethSystemType = model.SystemTypeMacOS + modelSystemType = model.SystemTypeMacOS case deviceinfo.SystemTypeUnknown: - modeltipherethSystemType = model.SystemTypeUnspecified + modelSystemType = model.SystemTypeUnspecified case deviceinfo.SystemTypeWeb: - modeltipherethSystemType = model.SystemTypeWeb + modelSystemType = model.SystemTypeWeb case deviceinfo.SystemTypeWindows: - modeltipherethSystemType = model.SystemTypeWindows + modelSystemType = model.SystemTypeWindows default: - modeltipherethSystemType = model.SystemTypeUnspecified + modelSystemType = model.SystemTypeUnspecified } - return modeltipherethSystemType + return modelSystemType } func ToBizUser(source *ent.User) *model.User { - var pModeltipherethUser *model.User + var pModelUser *model.User if source != nil { - var modeltipherethUser model.User - modeltipherethUser.ID = modelInternalIDToModelInternalID((*source).ID) - modeltipherethUser.Username = (*source).Username - modeltipherethUser.Type = ToLibAuthUserType((*source).Type) - modeltipherethUser.Status = ToBizUserStatus((*source).Status) - pModeltipherethUser = &modeltipherethUser + var modelUser model.User + modelUser.ID = modelInternalIDToModelInternalID((*source).ID) + modelUser.Username = (*source).Username + modelUser.Type = ToLibAuthUserType((*source).Type) + modelUser.Status = ToBizUserStatus((*source).Status) + pModelUser = &modelUser } - return pModeltipherethUser + return pModelUser } func ToBizUserList(source []*ent.User) []*model.User { - var pModeltipherethUserList []*model.User + var pModelUserList []*model.User if source != nil { - pModeltipherethUserList = make([]*model.User, len(source)) + pModelUserList = make([]*model.User, len(source)) for i := 0; i < len(source); i++ { - pModeltipherethUserList[i] = ToBizUser(source[i]) + pModelUserList[i] = ToBizUser(source[i]) } } - return pModeltipherethUserList + return pModelUserList } func ToBizUserSession(source *ent.UserSession) *model.UserSession { - var pModeltipherethUserSession *model.UserSession + var pModelUserSession *model.UserSession if source != nil { - var modeltipherethUserSession model.UserSession - modeltipherethUserSession.ID = modelInternalIDToModelInternalID((*source).ID) - modeltipherethUserSession.UserID = modelInternalIDToModelInternalID((*source).UserID) - modeltipherethUserSession.RefreshToken = (*source).RefreshToken - modeltipherethUserSession.CreateAt = TimeToTime((*source).CreatedAt) - modeltipherethUserSession.ExpireAt = TimeToTime((*source).ExpireAt) - pModeltipherethUserSession = &modeltipherethUserSession + var modelUserSession model.UserSession + modelUserSession.ID = modelInternalIDToModelInternalID((*source).ID) + modelUserSession.UserID = modelInternalIDToModelInternalID((*source).UserID) + modelUserSession.RefreshToken = (*source).RefreshToken + modelUserSession.CreateAt = TimeToTime((*source).CreatedAt) + modelUserSession.ExpireAt = TimeToTime((*source).ExpireAt) + pModelUserSession = &modelUserSession } - return pModeltipherethUserSession + return pModelUserSession } func ToBizUserSessionList(source []*ent.UserSession) []*model.UserSession { - var pModeltipherethUserSessionList []*model.UserSession + var pModelUserSessionList []*model.UserSession if source != nil { - pModeltipherethUserSessionList = make([]*model.UserSession, len(source)) + pModelUserSessionList = make([]*model.UserSession, len(source)) for i := 0; i < len(source); i++ { - pModeltipherethUserSessionList[i] = ToBizUserSession(source[i]) + pModelUserSessionList[i] = ToBizUserSession(source[i]) } } - return pModeltipherethUserSessionList + return pModelUserSessionList } func ToBizUserStatus(source user.Status) model.UserStatus { - var modeltipherethUserStatus model.UserStatus + var modelUserStatus model.UserStatus switch source { case user.StatusActive: - modeltipherethUserStatus = model.UserStatusActive + modelUserStatus = model.UserStatusActive case user.StatusBlocked: - modeltipherethUserStatus = model.UserStatusBlocked + modelUserStatus = model.UserStatusBlocked default: - modeltipherethUserStatus = model.UserStatusUnspecified + modelUserStatus = model.UserStatusUnspecified } - return modeltipherethUserStatus + return modelUserStatus } func ToLibAuthUserType(source user.Type) model.UserType { - var libauthUserType model.UserType + var modelUserType model.UserType switch source { case user.TypeAdmin: - libauthUserType = model.UserTypeAdmin + modelUserType = model.UserTypeAdmin case user.TypeNormal: - libauthUserType = model.UserTypeNormal + modelUserType = model.UserTypeNormal case user.TypeSentinel: - libauthUserType = model.UserTypeSentinel + modelUserType = model.UserTypeSentinel default: - libauthUserType = model.UserTypeUnspecified + modelUserType = model.UserTypeUnspecified } - return libauthUserType + return modelUserType } func entAppInfoToPModelgeburaAppInfoDetails(source ent.AppInfo) *modelgebura.AppInfoDetails { var modelgeburaAppInfoDetails modelgebura.AppInfoDetails diff --git a/app/sephirah/internal/data/internal/ent/account.go b/internal/data/internal/ent/account.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/account.go rename to internal/data/internal/ent/account.go index 2838f145..c08a2b99 100644 --- a/app/sephirah/internal/data/internal/ent/account.go +++ b/internal/data/internal/ent/account.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/account/account.go b/internal/data/internal/ent/account/account.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/account/account.go rename to internal/data/internal/ent/account/account.go diff --git a/app/sephirah/internal/data/internal/ent/account/where.go b/internal/data/internal/ent/account/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/account/where.go rename to internal/data/internal/ent/account/where.go index 0a0cf7fa..e456bf09 100644 --- a/app/sephirah/internal/data/internal/ent/account/where.go +++ b/internal/data/internal/ent/account/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/account_create.go b/internal/data/internal/ent/account_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/account_create.go rename to internal/data/internal/ent/account_create.go index a9cbb1c5..74531bef 100644 --- a/app/sephirah/internal/data/internal/ent/account_create.go +++ b/internal/data/internal/ent/account_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/account_delete.go b/internal/data/internal/ent/account_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/account_delete.go rename to internal/data/internal/ent/account_delete.go index 733aef55..bbbe77c8 100644 --- a/app/sephirah/internal/data/internal/ent/account_delete.go +++ b/internal/data/internal/ent/account_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // AccountDelete is the builder for deleting a Account entity. diff --git a/app/sephirah/internal/data/internal/ent/account_query.go b/internal/data/internal/ent/account_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/account_query.go rename to internal/data/internal/ent/account_query.go index c21c573c..c64d963e 100644 --- a/app/sephirah/internal/data/internal/ent/account_query.go +++ b/internal/data/internal/ent/account_query.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/account_update.go b/internal/data/internal/ent/account_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/account_update.go rename to internal/data/internal/ent/account_update.go index 0d2fdd26..ef0d7d15 100644 --- a/app/sephirah/internal/data/internal/ent/account_update.go +++ b/internal/data/internal/ent/account_update.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/app.go b/internal/data/internal/ent/app.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/app.go rename to internal/data/internal/ent/app.go index 16670312..289a8c18 100644 --- a/app/sephirah/internal/data/internal/ent/app.go +++ b/internal/data/internal/ent/app.go @@ -9,9 +9,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/app/app.go b/internal/data/internal/ent/app/app.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/app/app.go rename to internal/data/internal/ent/app/app.go diff --git a/app/sephirah/internal/data/internal/ent/app/where.go b/internal/data/internal/ent/app/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/app/where.go rename to internal/data/internal/ent/app/where.go index 8cb5ab60..7be1c71d 100644 --- a/app/sephirah/internal/data/internal/ent/app/where.go +++ b/internal/data/internal/ent/app/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/app_create.go b/internal/data/internal/ent/app_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/app_create.go rename to internal/data/internal/ent/app_create.go index ecec294c..bbfd9f48 100644 --- a/app/sephirah/internal/data/internal/ent/app_create.go +++ b/internal/data/internal/ent/app_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/app_delete.go b/internal/data/internal/ent/app_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/app_delete.go rename to internal/data/internal/ent/app_delete.go index 7539d84a..bb623570 100644 --- a/app/sephirah/internal/data/internal/ent/app_delete.go +++ b/internal/data/internal/ent/app_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // AppDelete is the builder for deleting a App entity. diff --git a/app/sephirah/internal/data/internal/ent/app_query.go b/internal/data/internal/ent/app_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/app_query.go rename to internal/data/internal/ent/app_query.go index 6de48220..f1742392 100644 --- a/app/sephirah/internal/data/internal/ent/app_query.go +++ b/internal/data/internal/ent/app_query.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/app_update.go b/internal/data/internal/ent/app_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/app_update.go rename to internal/data/internal/ent/app_update.go index e13c5a7b..e6b14b2c 100644 --- a/app/sephirah/internal/data/internal/ent/app_update.go +++ b/internal/data/internal/ent/app_update.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appbinary.go b/internal/data/internal/ent/appbinary.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/appbinary.go rename to internal/data/internal/ent/appbinary.go index efe7e4c8..6206b886 100644 --- a/app/sephirah/internal/data/internal/ent/appbinary.go +++ b/internal/data/internal/ent/appbinary.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appbinary/appbinary.go b/internal/data/internal/ent/appbinary/appbinary.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/appbinary/appbinary.go rename to internal/data/internal/ent/appbinary/appbinary.go diff --git a/app/sephirah/internal/data/internal/ent/appbinary/where.go b/internal/data/internal/ent/appbinary/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appbinary/where.go rename to internal/data/internal/ent/appbinary/where.go index fe60fefb..f718d8cc 100644 --- a/app/sephirah/internal/data/internal/ent/appbinary/where.go +++ b/internal/data/internal/ent/appbinary/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appbinary_create.go b/internal/data/internal/ent/appbinary_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appbinary_create.go rename to internal/data/internal/ent/appbinary_create.go index 77f39ebd..625fc097 100644 --- a/app/sephirah/internal/data/internal/ent/appbinary_create.go +++ b/internal/data/internal/ent/appbinary_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appbinary_delete.go b/internal/data/internal/ent/appbinary_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/appbinary_delete.go rename to internal/data/internal/ent/appbinary_delete.go index 6c0e0eda..efb3230c 100644 --- a/app/sephirah/internal/data/internal/ent/appbinary_delete.go +++ b/internal/data/internal/ent/appbinary_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // AppBinaryDelete is the builder for deleting a AppBinary entity. diff --git a/app/sephirah/internal/data/internal/ent/appbinary_query.go b/internal/data/internal/ent/appbinary_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/appbinary_query.go rename to internal/data/internal/ent/appbinary_query.go index 7a3a4797..44362aaa 100644 --- a/app/sephirah/internal/data/internal/ent/appbinary_query.go +++ b/internal/data/internal/ent/appbinary_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appbinary_update.go b/internal/data/internal/ent/appbinary_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/appbinary_update.go rename to internal/data/internal/ent/appbinary_update.go index 10df580f..3b86216f 100644 --- a/app/sephirah/internal/data/internal/ent/appbinary_update.go +++ b/internal/data/internal/ent/appbinary_update.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinfo.go b/internal/data/internal/ent/appinfo.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appinfo.go rename to internal/data/internal/ent/appinfo.go index 2755c660..c26ca3a4 100644 --- a/app/sephirah/internal/data/internal/ent/appinfo.go +++ b/internal/data/internal/ent/appinfo.go @@ -9,7 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinfo/appinfo.go b/internal/data/internal/ent/appinfo/appinfo.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/appinfo/appinfo.go rename to internal/data/internal/ent/appinfo/appinfo.go diff --git a/app/sephirah/internal/data/internal/ent/appinfo/where.go b/internal/data/internal/ent/appinfo/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appinfo/where.go rename to internal/data/internal/ent/appinfo/where.go index 659eaa45..0e044420 100644 --- a/app/sephirah/internal/data/internal/ent/appinfo/where.go +++ b/internal/data/internal/ent/appinfo/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinfo_create.go b/internal/data/internal/ent/appinfo_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appinfo_create.go rename to internal/data/internal/ent/appinfo_create.go index f1cec963..97e8474a 100644 --- a/app/sephirah/internal/data/internal/ent/appinfo_create.go +++ b/internal/data/internal/ent/appinfo_create.go @@ -11,11 +11,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinfo_delete.go b/internal/data/internal/ent/appinfo_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/appinfo_delete.go rename to internal/data/internal/ent/appinfo_delete.go index b7d20976..f1b79baa 100644 --- a/app/sephirah/internal/data/internal/ent/appinfo_delete.go +++ b/internal/data/internal/ent/appinfo_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // AppInfoDelete is the builder for deleting a AppInfo entity. diff --git a/app/sephirah/internal/data/internal/ent/appinfo_query.go b/internal/data/internal/ent/appinfo_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/appinfo_query.go rename to internal/data/internal/ent/appinfo_query.go index 2aaac56b..b3a13394 100644 --- a/app/sephirah/internal/data/internal/ent/appinfo_query.go +++ b/internal/data/internal/ent/appinfo_query.go @@ -12,12 +12,12 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinfo_update.go b/internal/data/internal/ent/appinfo_update.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appinfo_update.go rename to internal/data/internal/ent/appinfo_update.go index 9ebeae3f..25f8b35a 100644 --- a/app/sephirah/internal/data/internal/ent/appinfo_update.go +++ b/internal/data/internal/ent/appinfo_update.go @@ -11,12 +11,12 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinst.go b/internal/data/internal/ent/appinst.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/appinst.go rename to internal/data/internal/ent/appinst.go index 05eacb9a..28370e09 100644 --- a/app/sephirah/internal/data/internal/ent/appinst.go +++ b/internal/data/internal/ent/appinst.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinst/appinst.go b/internal/data/internal/ent/appinst/appinst.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/appinst/appinst.go rename to internal/data/internal/ent/appinst/appinst.go diff --git a/app/sephirah/internal/data/internal/ent/appinst/where.go b/internal/data/internal/ent/appinst/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appinst/where.go rename to internal/data/internal/ent/appinst/where.go index ef18eabf..dc6904ff 100644 --- a/app/sephirah/internal/data/internal/ent/appinst/where.go +++ b/internal/data/internal/ent/appinst/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinst_create.go b/internal/data/internal/ent/appinst_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appinst_create.go rename to internal/data/internal/ent/appinst_create.go index 154d662a..64cca893 100644 --- a/app/sephirah/internal/data/internal/ent/appinst_create.go +++ b/internal/data/internal/ent/appinst_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinst_delete.go b/internal/data/internal/ent/appinst_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/appinst_delete.go rename to internal/data/internal/ent/appinst_delete.go index 3f5959ff..023b7c4b 100644 --- a/app/sephirah/internal/data/internal/ent/appinst_delete.go +++ b/internal/data/internal/ent/appinst_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // AppInstDelete is the builder for deleting a AppInst entity. diff --git a/app/sephirah/internal/data/internal/ent/appinst_query.go b/internal/data/internal/ent/appinst_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/appinst_query.go rename to internal/data/internal/ent/appinst_query.go index 65e0a524..75b37139 100644 --- a/app/sephirah/internal/data/internal/ent/appinst_query.go +++ b/internal/data/internal/ent/appinst_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinst_update.go b/internal/data/internal/ent/appinst_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/appinst_update.go rename to internal/data/internal/ent/appinst_update.go index 9522dab0..c59291cf 100644 --- a/app/sephirah/internal/data/internal/ent/appinst_update.go +++ b/internal/data/internal/ent/appinst_update.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinstruntime.go b/internal/data/internal/ent/appinstruntime.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/appinstruntime.go rename to internal/data/internal/ent/appinstruntime.go index fdc43ce2..e2d36b56 100644 --- a/app/sephirah/internal/data/internal/ent/appinstruntime.go +++ b/internal/data/internal/ent/appinstruntime.go @@ -9,7 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinstruntime/appinstruntime.go b/internal/data/internal/ent/appinstruntime/appinstruntime.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/appinstruntime/appinstruntime.go rename to internal/data/internal/ent/appinstruntime/appinstruntime.go diff --git a/app/sephirah/internal/data/internal/ent/appinstruntime/where.go b/internal/data/internal/ent/appinstruntime/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appinstruntime/where.go rename to internal/data/internal/ent/appinstruntime/where.go index 89547c68..eee7f462 100644 --- a/app/sephirah/internal/data/internal/ent/appinstruntime/where.go +++ b/internal/data/internal/ent/appinstruntime/where.go @@ -6,7 +6,7 @@ import ( "time" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinstruntime_create.go b/internal/data/internal/ent/appinstruntime_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/appinstruntime_create.go rename to internal/data/internal/ent/appinstruntime_create.go index 2e588584..37a9c14d 100644 --- a/app/sephirah/internal/data/internal/ent/appinstruntime_create.go +++ b/internal/data/internal/ent/appinstruntime_create.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/appinstruntime_delete.go b/internal/data/internal/ent/appinstruntime_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/appinstruntime_delete.go rename to internal/data/internal/ent/appinstruntime_delete.go index 5c8ea5fd..6da19763 100644 --- a/app/sephirah/internal/data/internal/ent/appinstruntime_delete.go +++ b/internal/data/internal/ent/appinstruntime_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // AppInstRunTimeDelete is the builder for deleting a AppInstRunTime entity. diff --git a/app/sephirah/internal/data/internal/ent/appinstruntime_query.go b/internal/data/internal/ent/appinstruntime_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/appinstruntime_query.go rename to internal/data/internal/ent/appinstruntime_query.go index c40c8380..29b79b7a 100644 --- a/app/sephirah/internal/data/internal/ent/appinstruntime_query.go +++ b/internal/data/internal/ent/appinstruntime_query.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // AppInstRunTimeQuery is the builder for querying AppInstRunTime entities. diff --git a/app/sephirah/internal/data/internal/ent/appinstruntime_update.go b/internal/data/internal/ent/appinstruntime_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/appinstruntime_update.go rename to internal/data/internal/ent/appinstruntime_update.go index e172704e..99dd9724 100644 --- a/app/sephirah/internal/data/internal/ent/appinstruntime_update.go +++ b/internal/data/internal/ent/appinstruntime_update.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/client.go b/internal/data/internal/ent/client.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/client.go rename to internal/data/internal/ent/client.go index cba2bdb9..a4bf5b2f 100644 --- a/app/sephirah/internal/data/internal/ent/client.go +++ b/internal/data/internal/ent/client.go @@ -9,40 +9,40 @@ import ( "log" "reflect" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/migrate" + "github.com/tuihub/librarian/internal/data/internal/ent/migrate" "github.com/tuihub/librarian/internal/model" "entgo.io/ent" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" ) // Client is the client that holds all ent builders. diff --git a/app/sephirah/internal/data/internal/ent/deviceinfo.go b/internal/data/internal/ent/deviceinfo.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/deviceinfo.go rename to internal/data/internal/ent/deviceinfo.go index e0079b13..7fae8518 100644 --- a/app/sephirah/internal/data/internal/ent/deviceinfo.go +++ b/internal/data/internal/ent/deviceinfo.go @@ -9,7 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/deviceinfo/deviceinfo.go b/internal/data/internal/ent/deviceinfo/deviceinfo.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/deviceinfo/deviceinfo.go rename to internal/data/internal/ent/deviceinfo/deviceinfo.go diff --git a/app/sephirah/internal/data/internal/ent/deviceinfo/where.go b/internal/data/internal/ent/deviceinfo/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/deviceinfo/where.go rename to internal/data/internal/ent/deviceinfo/where.go index c8aeaf0b..011c12f4 100644 --- a/app/sephirah/internal/data/internal/ent/deviceinfo/where.go +++ b/internal/data/internal/ent/deviceinfo/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/deviceinfo_create.go b/internal/data/internal/ent/deviceinfo_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/deviceinfo_create.go rename to internal/data/internal/ent/deviceinfo_create.go index 76048d10..18b566d6 100644 --- a/app/sephirah/internal/data/internal/ent/deviceinfo_create.go +++ b/internal/data/internal/ent/deviceinfo_create.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/deviceinfo_delete.go b/internal/data/internal/ent/deviceinfo_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/deviceinfo_delete.go rename to internal/data/internal/ent/deviceinfo_delete.go index 9bf65281..8227b11c 100644 --- a/app/sephirah/internal/data/internal/ent/deviceinfo_delete.go +++ b/internal/data/internal/ent/deviceinfo_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // DeviceInfoDelete is the builder for deleting a DeviceInfo entity. diff --git a/app/sephirah/internal/data/internal/ent/deviceinfo_query.go b/internal/data/internal/ent/deviceinfo_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/deviceinfo_query.go rename to internal/data/internal/ent/deviceinfo_query.go index 7916bc0b..cdeef38d 100644 --- a/app/sephirah/internal/data/internal/ent/deviceinfo_query.go +++ b/internal/data/internal/ent/deviceinfo_query.go @@ -12,11 +12,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/deviceinfo_update.go b/internal/data/internal/ent/deviceinfo_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/deviceinfo_update.go rename to internal/data/internal/ent/deviceinfo_update.go index 6a920ed0..3b9abc7a 100644 --- a/app/sephirah/internal/data/internal/ent/deviceinfo_update.go +++ b/internal/data/internal/ent/deviceinfo_update.go @@ -11,11 +11,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/ent.go b/internal/data/internal/ent/ent.go similarity index 88% rename from app/sephirah/internal/data/internal/ent/ent.go rename to internal/data/internal/ent/ent.go index ac00c218..d34532ec 100644 --- a/app/sephirah/internal/data/internal/ent/ent.go +++ b/internal/data/internal/ent/ent.go @@ -12,33 +12,33 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" ) // ent aliases to avoid import conflicts in user's code. diff --git a/app/sephirah/internal/data/internal/ent/enttest/enttest.go b/internal/data/internal/ent/enttest/enttest.go similarity index 88% rename from app/sephirah/internal/data/internal/ent/enttest/enttest.go rename to internal/data/internal/ent/enttest/enttest.go index 4743b0d7..d2c82e96 100644 --- a/app/sephirah/internal/data/internal/ent/enttest/enttest.go +++ b/internal/data/internal/ent/enttest/enttest.go @@ -5,12 +5,12 @@ package enttest import ( "context" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent" // required by schema hooks. - _ "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/runtime" + _ "github.com/tuihub/librarian/internal/data/internal/ent/runtime" "entgo.io/ent/dialect/sql/schema" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/migrate" + "github.com/tuihub/librarian/internal/data/internal/ent/migrate" ) type ( diff --git a/app/sephirah/internal/data/internal/ent/feed.go b/internal/data/internal/ent/feed.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feed.go rename to internal/data/internal/ent/feed.go index 33a3b42d..007b1b2b 100644 --- a/app/sephirah/internal/data/internal/ent/feed.go +++ b/internal/data/internal/ent/feed.go @@ -10,8 +10,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) diff --git a/app/sephirah/internal/data/internal/ent/feed/feed.go b/internal/data/internal/ent/feed/feed.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/feed/feed.go rename to internal/data/internal/ent/feed/feed.go diff --git a/app/sephirah/internal/data/internal/ent/feed/where.go b/internal/data/internal/ent/feed/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feed/where.go rename to internal/data/internal/ent/feed/where.go index b870e8be..6ef0e962 100644 --- a/app/sephirah/internal/data/internal/ent/feed/where.go +++ b/internal/data/internal/ent/feed/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feed_create.go b/internal/data/internal/ent/feed_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feed_create.go rename to internal/data/internal/ent/feed_create.go index 201bd9fb..3be2439d 100644 --- a/app/sephirah/internal/data/internal/ent/feed_create.go +++ b/internal/data/internal/ent/feed_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) diff --git a/app/sephirah/internal/data/internal/ent/feed_delete.go b/internal/data/internal/ent/feed_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/feed_delete.go rename to internal/data/internal/ent/feed_delete.go index 1121936b..4aafd65f 100644 --- a/app/sephirah/internal/data/internal/ent/feed_delete.go +++ b/internal/data/internal/ent/feed_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // FeedDelete is the builder for deleting a Feed entity. diff --git a/app/sephirah/internal/data/internal/ent/feed_query.go b/internal/data/internal/ent/feed_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feed_query.go rename to internal/data/internal/ent/feed_query.go index 35391e5d..7a48c176 100644 --- a/app/sephirah/internal/data/internal/ent/feed_query.go +++ b/internal/data/internal/ent/feed_query.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feed_update.go b/internal/data/internal/ent/feed_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feed_update.go rename to internal/data/internal/ent/feed_update.go index 89968d5c..976ac2c7 100644 --- a/app/sephirah/internal/data/internal/ent/feed_update.go +++ b/internal/data/internal/ent/feed_update.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqljson" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) diff --git a/app/sephirah/internal/data/internal/ent/feedactionset.go b/internal/data/internal/ent/feedactionset.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/feedactionset.go rename to internal/data/internal/ent/feedactionset.go index 127d599e..6d411b5f 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset.go +++ b/internal/data/internal/ent/feedactionset.go @@ -5,15 +5,15 @@ package ent import ( "encoding/json" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // FeedActionSet is the model entity for the FeedActionSet schema. diff --git a/app/sephirah/internal/data/internal/ent/feedactionset/feedactionset.go b/internal/data/internal/ent/feedactionset/feedactionset.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/feedactionset/feedactionset.go rename to internal/data/internal/ent/feedactionset/feedactionset.go diff --git a/app/sephirah/internal/data/internal/ent/feedactionset/where.go b/internal/data/internal/ent/feedactionset/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feedactionset/where.go rename to internal/data/internal/ent/feedactionset/where.go index 24e2aff4..1b9b6add 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset/where.go +++ b/internal/data/internal/ent/feedactionset/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedactionset_create.go b/internal/data/internal/ent/feedactionset_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feedactionset_create.go rename to internal/data/internal/ent/feedactionset_create.go index 4e8e7585..9541c214 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset_create.go +++ b/internal/data/internal/ent/feedactionset_create.go @@ -6,16 +6,16 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // FeedActionSetCreate is the builder for creating a FeedActionSet entity. diff --git a/app/sephirah/internal/data/internal/ent/feedactionset_delete.go b/internal/data/internal/ent/feedactionset_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/feedactionset_delete.go rename to internal/data/internal/ent/feedactionset_delete.go index 48e96eb2..5147c472 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset_delete.go +++ b/internal/data/internal/ent/feedactionset_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // FeedActionSetDelete is the builder for deleting a FeedActionSet entity. diff --git a/app/sephirah/internal/data/internal/ent/feedactionset_query.go b/internal/data/internal/ent/feedactionset_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedactionset_query.go rename to internal/data/internal/ent/feedactionset_query.go index 482ac24d..854ccbf8 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset_query.go +++ b/internal/data/internal/ent/feedactionset_query.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedactionset_update.go b/internal/data/internal/ent/feedactionset_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedactionset_update.go rename to internal/data/internal/ent/feedactionset_update.go index 8d8891da..4b041d6f 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset_update.go +++ b/internal/data/internal/ent/feedactionset_update.go @@ -6,18 +6,18 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqljson" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // FeedActionSetUpdate is the builder for updating FeedActionSet entities. diff --git a/app/sephirah/internal/data/internal/ent/feedconfig.go b/internal/data/internal/ent/feedconfig.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedconfig.go rename to internal/data/internal/ent/feedconfig.go index 6d04e281..6f1aad0e 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig.go +++ b/internal/data/internal/ent/feedconfig.go @@ -5,16 +5,16 @@ package ent import ( "encoding/json" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // FeedConfig is the model entity for the FeedConfig schema. diff --git a/app/sephirah/internal/data/internal/ent/feedconfig/feedconfig.go b/internal/data/internal/ent/feedconfig/feedconfig.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/feedconfig/feedconfig.go rename to internal/data/internal/ent/feedconfig/feedconfig.go diff --git a/app/sephirah/internal/data/internal/ent/feedconfig/where.go b/internal/data/internal/ent/feedconfig/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feedconfig/where.go rename to internal/data/internal/ent/feedconfig/where.go index 51b3144c..1fea19eb 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig/where.go +++ b/internal/data/internal/ent/feedconfig/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfig_create.go b/internal/data/internal/ent/feedconfig_create.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedconfig_create.go rename to internal/data/internal/ent/feedconfig_create.go index d0db3986..1a1558e9 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig_create.go +++ b/internal/data/internal/ent/feedconfig_create.go @@ -6,19 +6,19 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // FeedConfigCreate is the builder for creating a FeedConfig entity. diff --git a/app/sephirah/internal/data/internal/ent/feedconfig_delete.go b/internal/data/internal/ent/feedconfig_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/feedconfig_delete.go rename to internal/data/internal/ent/feedconfig_delete.go index 9ea88c67..1f8eec23 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig_delete.go +++ b/internal/data/internal/ent/feedconfig_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // FeedConfigDelete is the builder for deleting a FeedConfig entity. diff --git a/app/sephirah/internal/data/internal/ent/feedconfig_query.go b/internal/data/internal/ent/feedconfig_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedconfig_query.go rename to internal/data/internal/ent/feedconfig_query.go index 343fdb21..7362454f 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig_query.go +++ b/internal/data/internal/ent/feedconfig_query.go @@ -12,13 +12,13 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfig_update.go b/internal/data/internal/ent/feedconfig_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedconfig_update.go rename to internal/data/internal/ent/feedconfig_update.go index ee3bbcf5..f48fe981 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig_update.go +++ b/internal/data/internal/ent/feedconfig_update.go @@ -6,20 +6,20 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // FeedConfigUpdate is the builder for updating FeedConfig entities. diff --git a/app/sephirah/internal/data/internal/ent/feedconfigaction.go b/internal/data/internal/ent/feedconfigaction.go similarity index 96% rename from app/sephirah/internal/data/internal/ent/feedconfigaction.go rename to internal/data/internal/ent/feedconfigaction.go index ba458388..3abdaf84 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfigaction.go +++ b/internal/data/internal/ent/feedconfigaction.go @@ -9,9 +9,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfigaction/feedconfigaction.go b/internal/data/internal/ent/feedconfigaction/feedconfigaction.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/feedconfigaction/feedconfigaction.go rename to internal/data/internal/ent/feedconfigaction/feedconfigaction.go diff --git a/app/sephirah/internal/data/internal/ent/feedconfigaction/where.go b/internal/data/internal/ent/feedconfigaction/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feedconfigaction/where.go rename to internal/data/internal/ent/feedconfigaction/where.go index 039e0b7c..0bbc4e2f 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfigaction/where.go +++ b/internal/data/internal/ent/feedconfigaction/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfigaction_create.go b/internal/data/internal/ent/feedconfigaction_create.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedconfigaction_create.go rename to internal/data/internal/ent/feedconfigaction_create.go index f2af216c..900aab73 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfigaction_create.go +++ b/internal/data/internal/ent/feedconfigaction_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfigaction_delete.go b/internal/data/internal/ent/feedconfigaction_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/feedconfigaction_delete.go rename to internal/data/internal/ent/feedconfigaction_delete.go index 0ec4b7b7..2c8cd786 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfigaction_delete.go +++ b/internal/data/internal/ent/feedconfigaction_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // FeedConfigActionDelete is the builder for deleting a FeedConfigAction entity. diff --git a/app/sephirah/internal/data/internal/ent/feedconfigaction_query.go b/internal/data/internal/ent/feedconfigaction_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedconfigaction_query.go rename to internal/data/internal/ent/feedconfigaction_query.go index cbc2adf0..1e71cb4e 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfigaction_query.go +++ b/internal/data/internal/ent/feedconfigaction_query.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feedconfigaction_update.go b/internal/data/internal/ent/feedconfigaction_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feedconfigaction_update.go rename to internal/data/internal/ent/feedconfigaction_update.go index 4cffb6fa..eb4925fc 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfigaction_update.go +++ b/internal/data/internal/ent/feedconfigaction_update.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditem.go b/internal/data/internal/ent/feeditem.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feeditem.go rename to internal/data/internal/ent/feeditem.go index ab7834cf..c0eeda9b 100644 --- a/app/sephirah/internal/data/internal/ent/feeditem.go +++ b/internal/data/internal/ent/feeditem.go @@ -10,8 +10,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditem/feeditem.go b/internal/data/internal/ent/feeditem/feeditem.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/feeditem/feeditem.go rename to internal/data/internal/ent/feeditem/feeditem.go diff --git a/app/sephirah/internal/data/internal/ent/feeditem/where.go b/internal/data/internal/ent/feeditem/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feeditem/where.go rename to internal/data/internal/ent/feeditem/where.go index dc51e340..9ca90fd9 100644 --- a/app/sephirah/internal/data/internal/ent/feeditem/where.go +++ b/internal/data/internal/ent/feeditem/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditem_create.go b/internal/data/internal/ent/feeditem_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feeditem_create.go rename to internal/data/internal/ent/feeditem_create.go index e4f6c009..f5b618bd 100644 --- a/app/sephirah/internal/data/internal/ent/feeditem_create.go +++ b/internal/data/internal/ent/feeditem_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditem_delete.go b/internal/data/internal/ent/feeditem_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/feeditem_delete.go rename to internal/data/internal/ent/feeditem_delete.go index 47dedcaf..43d08c9c 100644 --- a/app/sephirah/internal/data/internal/ent/feeditem_delete.go +++ b/internal/data/internal/ent/feeditem_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // FeedItemDelete is the builder for deleting a FeedItem entity. diff --git a/app/sephirah/internal/data/internal/ent/feeditem_query.go b/internal/data/internal/ent/feeditem_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feeditem_query.go rename to internal/data/internal/ent/feeditem_query.go index 95e18a3a..5fd8bfea 100644 --- a/app/sephirah/internal/data/internal/ent/feeditem_query.go +++ b/internal/data/internal/ent/feeditem_query.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditem_update.go b/internal/data/internal/ent/feeditem_update.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feeditem_update.go rename to internal/data/internal/ent/feeditem_update.go index 79610236..29cd95be 100644 --- a/app/sephirah/internal/data/internal/ent/feeditem_update.go +++ b/internal/data/internal/ent/feeditem_update.go @@ -12,9 +12,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqljson" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditemcollection.go b/internal/data/internal/ent/feeditemcollection.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feeditemcollection.go rename to internal/data/internal/ent/feeditemcollection.go index fc132406..19906755 100644 --- a/app/sephirah/internal/data/internal/ent/feeditemcollection.go +++ b/internal/data/internal/ent/feeditemcollection.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditemcollection/feeditemcollection.go b/internal/data/internal/ent/feeditemcollection/feeditemcollection.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/feeditemcollection/feeditemcollection.go rename to internal/data/internal/ent/feeditemcollection/feeditemcollection.go diff --git a/app/sephirah/internal/data/internal/ent/feeditemcollection/where.go b/internal/data/internal/ent/feeditemcollection/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/feeditemcollection/where.go rename to internal/data/internal/ent/feeditemcollection/where.go index 6a8ebf96..1638d2ab 100644 --- a/app/sephirah/internal/data/internal/ent/feeditemcollection/where.go +++ b/internal/data/internal/ent/feeditemcollection/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditemcollection_create.go b/internal/data/internal/ent/feeditemcollection_create.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feeditemcollection_create.go rename to internal/data/internal/ent/feeditemcollection_create.go index 405838b8..0da59e1e 100644 --- a/app/sephirah/internal/data/internal/ent/feeditemcollection_create.go +++ b/internal/data/internal/ent/feeditemcollection_create.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditemcollection_delete.go b/internal/data/internal/ent/feeditemcollection_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/feeditemcollection_delete.go rename to internal/data/internal/ent/feeditemcollection_delete.go index 49c46636..9668bfc9 100644 --- a/app/sephirah/internal/data/internal/ent/feeditemcollection_delete.go +++ b/internal/data/internal/ent/feeditemcollection_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // FeedItemCollectionDelete is the builder for deleting a FeedItemCollection entity. diff --git a/app/sephirah/internal/data/internal/ent/feeditemcollection_query.go b/internal/data/internal/ent/feeditemcollection_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feeditemcollection_query.go rename to internal/data/internal/ent/feeditemcollection_query.go index ff56b474..117d2eda 100644 --- a/app/sephirah/internal/data/internal/ent/feeditemcollection_query.go +++ b/internal/data/internal/ent/feeditemcollection_query.go @@ -12,11 +12,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/feeditemcollection_update.go b/internal/data/internal/ent/feeditemcollection_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/feeditemcollection_update.go rename to internal/data/internal/ent/feeditemcollection_update.go index a87ac66e..45528880 100644 --- a/app/sephirah/internal/data/internal/ent/feeditemcollection_update.go +++ b/internal/data/internal/ent/feeditemcollection_update.go @@ -11,11 +11,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/file.go b/internal/data/internal/ent/file.go similarity index 96% rename from app/sephirah/internal/data/internal/ent/file.go rename to internal/data/internal/ent/file.go index 3c5da477..efd13453 100644 --- a/app/sephirah/internal/data/internal/ent/file.go +++ b/internal/data/internal/ent/file.go @@ -9,9 +9,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/file/file.go b/internal/data/internal/ent/file/file.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/file/file.go rename to internal/data/internal/ent/file/file.go diff --git a/app/sephirah/internal/data/internal/ent/file/where.go b/internal/data/internal/ent/file/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/file/where.go rename to internal/data/internal/ent/file/where.go index 75382d69..28d0801f 100644 --- a/app/sephirah/internal/data/internal/ent/file/where.go +++ b/internal/data/internal/ent/file/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/file_create.go b/internal/data/internal/ent/file_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/file_create.go rename to internal/data/internal/ent/file_create.go index fe477f3d..5ba6e1ec 100644 --- a/app/sephirah/internal/data/internal/ent/file_create.go +++ b/internal/data/internal/ent/file_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/file_delete.go b/internal/data/internal/ent/file_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/file_delete.go rename to internal/data/internal/ent/file_delete.go index 1db87008..83b07d63 100644 --- a/app/sephirah/internal/data/internal/ent/file_delete.go +++ b/internal/data/internal/ent/file_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // FileDelete is the builder for deleting a File entity. diff --git a/app/sephirah/internal/data/internal/ent/file_query.go b/internal/data/internal/ent/file_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/file_query.go rename to internal/data/internal/ent/file_query.go index b4fc0bbf..e23890b6 100644 --- a/app/sephirah/internal/data/internal/ent/file_query.go +++ b/internal/data/internal/ent/file_query.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/file_update.go b/internal/data/internal/ent/file_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/file_update.go rename to internal/data/internal/ent/file_update.go index 86be04b9..864ff546 100644 --- a/app/sephirah/internal/data/internal/ent/file_update.go +++ b/internal/data/internal/ent/file_update.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/generate.go b/internal/data/internal/ent/generate.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/generate.go rename to internal/data/internal/ent/generate.go diff --git a/app/sephirah/internal/data/internal/ent/hook/hook.go b/internal/data/internal/ent/hook/hook.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/hook/hook.go rename to internal/data/internal/ent/hook/hook.go index c7dfed22..41399393 100644 --- a/app/sephirah/internal/data/internal/ent/hook/hook.go +++ b/internal/data/internal/ent/hook/hook.go @@ -6,7 +6,7 @@ import ( "context" "fmt" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent" ) // The AccountFunc type is an adapter to allow the use of ordinary diff --git a/app/sephirah/internal/data/internal/ent/image.go b/internal/data/internal/ent/image.go similarity index 96% rename from app/sephirah/internal/data/internal/ent/image.go rename to internal/data/internal/ent/image.go index 88e6b886..cb5f51a1 100644 --- a/app/sephirah/internal/data/internal/ent/image.go +++ b/internal/data/internal/ent/image.go @@ -9,9 +9,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/image/image.go b/internal/data/internal/ent/image/image.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/image/image.go rename to internal/data/internal/ent/image/image.go diff --git a/app/sephirah/internal/data/internal/ent/image/where.go b/internal/data/internal/ent/image/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/image/where.go rename to internal/data/internal/ent/image/where.go index 735b345d..7cfc99f5 100644 --- a/app/sephirah/internal/data/internal/ent/image/where.go +++ b/internal/data/internal/ent/image/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/image_create.go b/internal/data/internal/ent/image_create.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/image_create.go rename to internal/data/internal/ent/image_create.go index 6a21b86c..35469a33 100644 --- a/app/sephirah/internal/data/internal/ent/image_create.go +++ b/internal/data/internal/ent/image_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/image_delete.go b/internal/data/internal/ent/image_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/image_delete.go rename to internal/data/internal/ent/image_delete.go index d0ce75f8..7fb7a4e3 100644 --- a/app/sephirah/internal/data/internal/ent/image_delete.go +++ b/internal/data/internal/ent/image_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // ImageDelete is the builder for deleting a Image entity. diff --git a/app/sephirah/internal/data/internal/ent/image_query.go b/internal/data/internal/ent/image_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/image_query.go rename to internal/data/internal/ent/image_query.go index 60a7e624..01723528 100644 --- a/app/sephirah/internal/data/internal/ent/image_query.go +++ b/internal/data/internal/ent/image_query.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/image_update.go b/internal/data/internal/ent/image_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/image_update.go rename to internal/data/internal/ent/image_update.go index f4179de0..cd71b071 100644 --- a/app/sephirah/internal/data/internal/ent/image_update.go +++ b/internal/data/internal/ent/image_update.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/migrate/migrate.go b/internal/data/internal/ent/migrate/migrate.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/migrate/migrate.go rename to internal/data/internal/ent/migrate/migrate.go diff --git a/app/sephirah/internal/data/internal/ent/migrate/schema.go b/internal/data/internal/ent/migrate/schema.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/migrate/schema.go rename to internal/data/internal/ent/migrate/schema.go diff --git a/app/sephirah/internal/data/internal/ent/mutation.go b/internal/data/internal/ent/mutation.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/mutation.go rename to internal/data/internal/ent/mutation.go index 2fdf6ec8..d5ac75f0 100644 --- a/app/sephirah/internal/data/internal/ent/mutation.go +++ b/internal/data/internal/ent/mutation.go @@ -6,42 +6,42 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "sync" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) const ( diff --git a/app/sephirah/internal/data/internal/ent/notifyflow.go b/internal/data/internal/ent/notifyflow.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifyflow.go rename to internal/data/internal/ent/notifyflow.go index 904286a2..7640a5bf 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflow.go +++ b/internal/data/internal/ent/notifyflow.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflow/notifyflow.go b/internal/data/internal/ent/notifyflow/notifyflow.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/notifyflow/notifyflow.go rename to internal/data/internal/ent/notifyflow/notifyflow.go diff --git a/app/sephirah/internal/data/internal/ent/notifyflow/where.go b/internal/data/internal/ent/notifyflow/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/notifyflow/where.go rename to internal/data/internal/ent/notifyflow/where.go index fc280273..50253654 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflow/where.go +++ b/internal/data/internal/ent/notifyflow/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflow_create.go b/internal/data/internal/ent/notifyflow_create.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifyflow_create.go rename to internal/data/internal/ent/notifyflow_create.go index 4016798c..4a5e74b2 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflow_create.go +++ b/internal/data/internal/ent/notifyflow_create.go @@ -11,12 +11,12 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflow_delete.go b/internal/data/internal/ent/notifyflow_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/notifyflow_delete.go rename to internal/data/internal/ent/notifyflow_delete.go index 1af1c4db..18adb2e9 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflow_delete.go +++ b/internal/data/internal/ent/notifyflow_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // NotifyFlowDelete is the builder for deleting a NotifyFlow entity. diff --git a/app/sephirah/internal/data/internal/ent/notifyflow_query.go b/internal/data/internal/ent/notifyflow_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifyflow_query.go rename to internal/data/internal/ent/notifyflow_query.go index 5dd0fbc9..d6a11e71 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflow_query.go +++ b/internal/data/internal/ent/notifyflow_query.go @@ -12,13 +12,13 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflow_update.go b/internal/data/internal/ent/notifyflow_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifyflow_update.go rename to internal/data/internal/ent/notifyflow_update.go index f440b5d8..9edf65d1 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflow_update.go +++ b/internal/data/internal/ent/notifyflow_update.go @@ -11,13 +11,13 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowsource.go b/internal/data/internal/ent/notifyflowsource.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/notifyflowsource.go rename to internal/data/internal/ent/notifyflowsource.go index 983e262e..c4adac4b 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowsource.go +++ b/internal/data/internal/ent/notifyflowsource.go @@ -10,9 +10,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowsource/notifyflowsource.go b/internal/data/internal/ent/notifyflowsource/notifyflowsource.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/notifyflowsource/notifyflowsource.go rename to internal/data/internal/ent/notifyflowsource/notifyflowsource.go diff --git a/app/sephirah/internal/data/internal/ent/notifyflowsource/where.go b/internal/data/internal/ent/notifyflowsource/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/notifyflowsource/where.go rename to internal/data/internal/ent/notifyflowsource/where.go index 05e1e6db..e9072ca5 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowsource/where.go +++ b/internal/data/internal/ent/notifyflowsource/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowsource_create.go b/internal/data/internal/ent/notifyflowsource_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/notifyflowsource_create.go rename to internal/data/internal/ent/notifyflowsource_create.go index b0b85c11..ec8b59ee 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowsource_create.go +++ b/internal/data/internal/ent/notifyflowsource_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowsource_delete.go b/internal/data/internal/ent/notifyflowsource_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/notifyflowsource_delete.go rename to internal/data/internal/ent/notifyflowsource_delete.go index 410a1e43..f7575d1d 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowsource_delete.go +++ b/internal/data/internal/ent/notifyflowsource_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // NotifyFlowSourceDelete is the builder for deleting a NotifyFlowSource entity. diff --git a/app/sephirah/internal/data/internal/ent/notifyflowsource_query.go b/internal/data/internal/ent/notifyflowsource_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifyflowsource_query.go rename to internal/data/internal/ent/notifyflowsource_query.go index 31fa66a1..c38cfaad 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowsource_query.go +++ b/internal/data/internal/ent/notifyflowsource_query.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowsource_update.go b/internal/data/internal/ent/notifyflowsource_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifyflowsource_update.go rename to internal/data/internal/ent/notifyflowsource_update.go index 5e8b9419..c18c86d7 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowsource_update.go +++ b/internal/data/internal/ent/notifyflowsource_update.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqljson" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowtarget.go b/internal/data/internal/ent/notifyflowtarget.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/notifyflowtarget.go rename to internal/data/internal/ent/notifyflowtarget.go index c389e65d..b3e6e0b8 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowtarget.go +++ b/internal/data/internal/ent/notifyflowtarget.go @@ -10,9 +10,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowtarget/notifyflowtarget.go b/internal/data/internal/ent/notifyflowtarget/notifyflowtarget.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/notifyflowtarget/notifyflowtarget.go rename to internal/data/internal/ent/notifyflowtarget/notifyflowtarget.go diff --git a/app/sephirah/internal/data/internal/ent/notifyflowtarget/where.go b/internal/data/internal/ent/notifyflowtarget/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/notifyflowtarget/where.go rename to internal/data/internal/ent/notifyflowtarget/where.go index 5c6000c5..5480043f 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowtarget/where.go +++ b/internal/data/internal/ent/notifyflowtarget/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowtarget_create.go b/internal/data/internal/ent/notifyflowtarget_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/notifyflowtarget_create.go rename to internal/data/internal/ent/notifyflowtarget_create.go index ef7cf167..da3e4617 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowtarget_create.go +++ b/internal/data/internal/ent/notifyflowtarget_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowtarget_delete.go b/internal/data/internal/ent/notifyflowtarget_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/notifyflowtarget_delete.go rename to internal/data/internal/ent/notifyflowtarget_delete.go index d85df517..fa13adc1 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowtarget_delete.go +++ b/internal/data/internal/ent/notifyflowtarget_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // NotifyFlowTargetDelete is the builder for deleting a NotifyFlowTarget entity. diff --git a/app/sephirah/internal/data/internal/ent/notifyflowtarget_query.go b/internal/data/internal/ent/notifyflowtarget_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifyflowtarget_query.go rename to internal/data/internal/ent/notifyflowtarget_query.go index 8edd2f1e..7308d0f4 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowtarget_query.go +++ b/internal/data/internal/ent/notifyflowtarget_query.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifyflowtarget_update.go b/internal/data/internal/ent/notifyflowtarget_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifyflowtarget_update.go rename to internal/data/internal/ent/notifyflowtarget_update.go index ecb3c090..a0201902 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowtarget_update.go +++ b/internal/data/internal/ent/notifyflowtarget_update.go @@ -12,10 +12,10 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqljson" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifysource.go b/internal/data/internal/ent/notifysource.go similarity index 96% rename from app/sephirah/internal/data/internal/ent/notifysource.go rename to internal/data/internal/ent/notifysource.go index 2c982bb1..692e1e44 100644 --- a/app/sephirah/internal/data/internal/ent/notifysource.go +++ b/internal/data/internal/ent/notifysource.go @@ -9,10 +9,10 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifysource/notifysource.go b/internal/data/internal/ent/notifysource/notifysource.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/notifysource/notifysource.go rename to internal/data/internal/ent/notifysource/notifysource.go diff --git a/app/sephirah/internal/data/internal/ent/notifysource/where.go b/internal/data/internal/ent/notifysource/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/notifysource/where.go rename to internal/data/internal/ent/notifysource/where.go index 3a554184..a8956b3c 100644 --- a/app/sephirah/internal/data/internal/ent/notifysource/where.go +++ b/internal/data/internal/ent/notifysource/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifysource_create.go b/internal/data/internal/ent/notifysource_create.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifysource_create.go rename to internal/data/internal/ent/notifysource_create.go index 63817f43..5b488e8e 100644 --- a/app/sephirah/internal/data/internal/ent/notifysource_create.go +++ b/internal/data/internal/ent/notifysource_create.go @@ -11,12 +11,12 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifysource_delete.go b/internal/data/internal/ent/notifysource_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/notifysource_delete.go rename to internal/data/internal/ent/notifysource_delete.go index c0b293e4..f2b88d77 100644 --- a/app/sephirah/internal/data/internal/ent/notifysource_delete.go +++ b/internal/data/internal/ent/notifysource_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // NotifySourceDelete is the builder for deleting a NotifySource entity. diff --git a/app/sephirah/internal/data/internal/ent/notifysource_query.go b/internal/data/internal/ent/notifysource_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifysource_query.go rename to internal/data/internal/ent/notifysource_query.go index 5d6c1bfe..bdc304ea 100644 --- a/app/sephirah/internal/data/internal/ent/notifysource_query.go +++ b/internal/data/internal/ent/notifysource_query.go @@ -12,13 +12,13 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifysource_update.go b/internal/data/internal/ent/notifysource_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifysource_update.go rename to internal/data/internal/ent/notifysource_update.go index 70f40449..884ebef8 100644 --- a/app/sephirah/internal/data/internal/ent/notifysource_update.go +++ b/internal/data/internal/ent/notifysource_update.go @@ -11,13 +11,13 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifytarget.go b/internal/data/internal/ent/notifytarget.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifytarget.go rename to internal/data/internal/ent/notifytarget.go index aa7b76e0..a245a7c2 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget.go +++ b/internal/data/internal/ent/notifytarget.go @@ -5,15 +5,15 @@ package ent import ( "encoding/json" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // NotifyTarget is the model entity for the NotifyTarget schema. diff --git a/app/sephirah/internal/data/internal/ent/notifytarget/notifytarget.go b/internal/data/internal/ent/notifytarget/notifytarget.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/notifytarget/notifytarget.go rename to internal/data/internal/ent/notifytarget/notifytarget.go diff --git a/app/sephirah/internal/data/internal/ent/notifytarget/where.go b/internal/data/internal/ent/notifytarget/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/notifytarget/where.go rename to internal/data/internal/ent/notifytarget/where.go index d33b757d..35c6564d 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget/where.go +++ b/internal/data/internal/ent/notifytarget/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifytarget_create.go b/internal/data/internal/ent/notifytarget_create.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifytarget_create.go rename to internal/data/internal/ent/notifytarget_create.go index c7e3f054..4c163aa1 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget_create.go +++ b/internal/data/internal/ent/notifytarget_create.go @@ -6,17 +6,17 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // NotifyTargetCreate is the builder for creating a NotifyTarget entity. diff --git a/app/sephirah/internal/data/internal/ent/notifytarget_delete.go b/internal/data/internal/ent/notifytarget_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/notifytarget_delete.go rename to internal/data/internal/ent/notifytarget_delete.go index 116c3841..f2ee5107 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget_delete.go +++ b/internal/data/internal/ent/notifytarget_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // NotifyTargetDelete is the builder for deleting a NotifyTarget entity. diff --git a/app/sephirah/internal/data/internal/ent/notifytarget_query.go b/internal/data/internal/ent/notifytarget_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifytarget_query.go rename to internal/data/internal/ent/notifytarget_query.go index 12b56e00..22701918 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget_query.go +++ b/internal/data/internal/ent/notifytarget_query.go @@ -12,11 +12,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/notifytarget_update.go b/internal/data/internal/ent/notifytarget_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/notifytarget_update.go rename to internal/data/internal/ent/notifytarget_update.go index 2918fcd8..e8f81787 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget_update.go +++ b/internal/data/internal/ent/notifytarget_update.go @@ -6,18 +6,18 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // NotifyTargetUpdate is the builder for updating NotifyTarget entities. diff --git a/app/sephirah/internal/data/internal/ent/portercontext.go b/internal/data/internal/ent/portercontext.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/portercontext.go rename to internal/data/internal/ent/portercontext.go index f5616433..45da06bc 100644 --- a/app/sephirah/internal/data/internal/ent/portercontext.go +++ b/internal/data/internal/ent/portercontext.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/portercontext/portercontext.go b/internal/data/internal/ent/portercontext/portercontext.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/portercontext/portercontext.go rename to internal/data/internal/ent/portercontext/portercontext.go diff --git a/app/sephirah/internal/data/internal/ent/portercontext/where.go b/internal/data/internal/ent/portercontext/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/portercontext/where.go rename to internal/data/internal/ent/portercontext/where.go index e2b4e72c..a087da8b 100644 --- a/app/sephirah/internal/data/internal/ent/portercontext/where.go +++ b/internal/data/internal/ent/portercontext/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/portercontext_create.go b/internal/data/internal/ent/portercontext_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/portercontext_create.go rename to internal/data/internal/ent/portercontext_create.go index 3185dad7..ad51e77b 100644 --- a/app/sephirah/internal/data/internal/ent/portercontext_create.go +++ b/internal/data/internal/ent/portercontext_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/portercontext_delete.go b/internal/data/internal/ent/portercontext_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/portercontext_delete.go rename to internal/data/internal/ent/portercontext_delete.go index 8e461fbe..903da1cc 100644 --- a/app/sephirah/internal/data/internal/ent/portercontext_delete.go +++ b/internal/data/internal/ent/portercontext_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // PorterContextDelete is the builder for deleting a PorterContext entity. diff --git a/app/sephirah/internal/data/internal/ent/portercontext_query.go b/internal/data/internal/ent/portercontext_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/portercontext_query.go rename to internal/data/internal/ent/portercontext_query.go index 9a63ab23..d5a20aa0 100644 --- a/app/sephirah/internal/data/internal/ent/portercontext_query.go +++ b/internal/data/internal/ent/portercontext_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/portercontext_update.go b/internal/data/internal/ent/portercontext_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/portercontext_update.go rename to internal/data/internal/ent/portercontext_update.go index 1932857f..7d63c1d6 100644 --- a/app/sephirah/internal/data/internal/ent/portercontext_update.go +++ b/internal/data/internal/ent/portercontext_update.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/porterinstance.go b/internal/data/internal/ent/porterinstance.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/porterinstance.go rename to internal/data/internal/ent/porterinstance.go index a67b4468..c8a9ff98 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance.go +++ b/internal/data/internal/ent/porterinstance.go @@ -5,14 +5,14 @@ package ent import ( "encoding/json" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // PorterInstance is the model entity for the PorterInstance schema. diff --git a/app/sephirah/internal/data/internal/ent/porterinstance/porterinstance.go b/internal/data/internal/ent/porterinstance/porterinstance.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/porterinstance/porterinstance.go rename to internal/data/internal/ent/porterinstance/porterinstance.go diff --git a/app/sephirah/internal/data/internal/ent/porterinstance/where.go b/internal/data/internal/ent/porterinstance/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/porterinstance/where.go rename to internal/data/internal/ent/porterinstance/where.go index 03fa7bf7..083751d4 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance/where.go +++ b/internal/data/internal/ent/porterinstance/where.go @@ -6,7 +6,7 @@ import ( "time" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/porterinstance_create.go b/internal/data/internal/ent/porterinstance_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/porterinstance_create.go rename to internal/data/internal/ent/porterinstance_create.go index 03f2d475..012e787f 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance_create.go +++ b/internal/data/internal/ent/porterinstance_create.go @@ -6,14 +6,14 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // PorterInstanceCreate is the builder for creating a PorterInstance entity. diff --git a/app/sephirah/internal/data/internal/ent/porterinstance_delete.go b/internal/data/internal/ent/porterinstance_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/porterinstance_delete.go rename to internal/data/internal/ent/porterinstance_delete.go index eae5ee7c..95da78c8 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance_delete.go +++ b/internal/data/internal/ent/porterinstance_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" ) // PorterInstanceDelete is the builder for deleting a PorterInstance entity. diff --git a/app/sephirah/internal/data/internal/ent/porterinstance_query.go b/internal/data/internal/ent/porterinstance_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/porterinstance_query.go rename to internal/data/internal/ent/porterinstance_query.go index 2bdc1f30..1b069314 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance_query.go +++ b/internal/data/internal/ent/porterinstance_query.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/porterinstance_update.go b/internal/data/internal/ent/porterinstance_update.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/porterinstance_update.go rename to internal/data/internal/ent/porterinstance_update.go index a9279fa2..2160798b 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance_update.go +++ b/internal/data/internal/ent/porterinstance_update.go @@ -6,14 +6,14 @@ import ( "context" "errors" "fmt" - "github.com/tuihub/librarian/internal/model/modelsupervisor" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/model/modelsupervisor" ) // PorterInstanceUpdate is the builder for updating PorterInstance entities. diff --git a/app/sephirah/internal/data/internal/ent/predicate/predicate.go b/internal/data/internal/ent/predicate/predicate.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/predicate/predicate.go rename to internal/data/internal/ent/predicate/predicate.go diff --git a/app/sephirah/internal/data/internal/ent/runtime.go b/internal/data/internal/ent/runtime.go similarity index 91% rename from app/sephirah/internal/data/internal/ent/runtime.go rename to internal/data/internal/ent/runtime.go index 36fb4597..6f61852f 100644 --- a/app/sephirah/internal/data/internal/ent/runtime.go +++ b/internal/data/internal/ent/runtime.go @@ -5,34 +5,34 @@ package ent import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appbinary" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinstruntime" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/schema" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appbinary" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/appinstruntime" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfigaction" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/schema" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" ) // The init function reads all schema descriptors with runtime code diff --git a/internal/data/internal/ent/runtime/runtime.go b/internal/data/internal/ent/runtime/runtime.go new file mode 100644 index 00000000..475d4c6f --- /dev/null +++ b/internal/data/internal/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in github.com/tuihub/librarian/internal/data/internal/ent/runtime.go + +const ( + Version = "v0.14.3" // Version of ent codegen. + Sum = "h1:wokAV/kIlH9TeklJWGGS7AYJdVckr0DloWjIcO9iIIQ=" // Sum of ent codegen. +) diff --git a/app/sephirah/internal/data/internal/ent/schema/account.go b/internal/data/internal/ent/schema/account.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/account.go rename to internal/data/internal/ent/schema/account.go diff --git a/app/sephirah/internal/data/internal/ent/schema/app.go b/internal/data/internal/ent/schema/app.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/app.go rename to internal/data/internal/ent/schema/app.go diff --git a/app/sephirah/internal/data/internal/ent/schema/app_binary.go b/internal/data/internal/ent/schema/app_binary.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/app_binary.go rename to internal/data/internal/ent/schema/app_binary.go diff --git a/app/sephirah/internal/data/internal/ent/schema/app_info.go b/internal/data/internal/ent/schema/app_info.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/app_info.go rename to internal/data/internal/ent/schema/app_info.go diff --git a/app/sephirah/internal/data/internal/ent/schema/app_inst.go b/internal/data/internal/ent/schema/app_inst.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/app_inst.go rename to internal/data/internal/ent/schema/app_inst.go diff --git a/app/sephirah/internal/data/internal/ent/schema/app_inst_run_time.go b/internal/data/internal/ent/schema/app_inst_run_time.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/app_inst_run_time.go rename to internal/data/internal/ent/schema/app_inst_run_time.go diff --git a/app/sephirah/internal/data/internal/ent/schema/device_info.go b/internal/data/internal/ent/schema/device_info.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/device_info.go rename to internal/data/internal/ent/schema/device_info.go diff --git a/app/sephirah/internal/data/internal/ent/schema/feed.go b/internal/data/internal/ent/schema/feed.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/feed.go rename to internal/data/internal/ent/schema/feed.go diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go b/internal/data/internal/ent/schema/feed_action_set.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/feed_action_set.go rename to internal/data/internal/ent/schema/feed_action_set.go diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_config.go b/internal/data/internal/ent/schema/feed_config.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/feed_config.go rename to internal/data/internal/ent/schema/feed_config.go diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_config_action.go b/internal/data/internal/ent/schema/feed_config_action.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/feed_config_action.go rename to internal/data/internal/ent/schema/feed_config_action.go diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_item.go b/internal/data/internal/ent/schema/feed_item.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/feed_item.go rename to internal/data/internal/ent/schema/feed_item.go diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_item_collection.go b/internal/data/internal/ent/schema/feed_item_collection.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/feed_item_collection.go rename to internal/data/internal/ent/schema/feed_item_collection.go diff --git a/app/sephirah/internal/data/internal/ent/schema/file.go b/internal/data/internal/ent/schema/file.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/file.go rename to internal/data/internal/ent/schema/file.go diff --git a/app/sephirah/internal/data/internal/ent/schema/image.go b/internal/data/internal/ent/schema/image.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/image.go rename to internal/data/internal/ent/schema/image.go diff --git a/app/sephirah/internal/data/internal/ent/schema/notify_flow.go b/internal/data/internal/ent/schema/notify_flow.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/notify_flow.go rename to internal/data/internal/ent/schema/notify_flow.go diff --git a/app/sephirah/internal/data/internal/ent/schema/notify_flow_source.go b/internal/data/internal/ent/schema/notify_flow_source.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/notify_flow_source.go rename to internal/data/internal/ent/schema/notify_flow_source.go diff --git a/app/sephirah/internal/data/internal/ent/schema/notify_flow_taget.go b/internal/data/internal/ent/schema/notify_flow_taget.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/notify_flow_taget.go rename to internal/data/internal/ent/schema/notify_flow_taget.go diff --git a/app/sephirah/internal/data/internal/ent/schema/notify_source.go b/internal/data/internal/ent/schema/notify_source.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/notify_source.go rename to internal/data/internal/ent/schema/notify_source.go diff --git a/app/sephirah/internal/data/internal/ent/schema/notify_target.go b/internal/data/internal/ent/schema/notify_target.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/notify_target.go rename to internal/data/internal/ent/schema/notify_target.go diff --git a/app/sephirah/internal/data/internal/ent/schema/porter_context.go b/internal/data/internal/ent/schema/porter_context.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/porter_context.go rename to internal/data/internal/ent/schema/porter_context.go diff --git a/app/sephirah/internal/data/internal/ent/schema/porter_instance.go b/internal/data/internal/ent/schema/porter_instance.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/porter_instance.go rename to internal/data/internal/ent/schema/porter_instance.go diff --git a/app/sephirah/internal/data/internal/ent/schema/schema.go b/internal/data/internal/ent/schema/schema.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/schema.go rename to internal/data/internal/ent/schema/schema.go diff --git a/app/sephirah/internal/data/internal/ent/schema/system_notification.go b/internal/data/internal/ent/schema/system_notification.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/system_notification.go rename to internal/data/internal/ent/schema/system_notification.go diff --git a/app/sephirah/internal/data/internal/ent/schema/tag.go b/internal/data/internal/ent/schema/tag.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/tag.go rename to internal/data/internal/ent/schema/tag.go diff --git a/app/sephirah/internal/data/internal/ent/schema/user.go b/internal/data/internal/ent/schema/user.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/user.go rename to internal/data/internal/ent/schema/user.go diff --git a/app/sephirah/internal/data/internal/ent/schema/user_device.go b/internal/data/internal/ent/schema/user_device.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/user_device.go rename to internal/data/internal/ent/schema/user_device.go diff --git a/app/sephirah/internal/data/internal/ent/schema/user_session.go b/internal/data/internal/ent/schema/user_session.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/schema/user_session.go rename to internal/data/internal/ent/schema/user_session.go diff --git a/app/sephirah/internal/data/internal/ent/systemnotification.go b/internal/data/internal/ent/systemnotification.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/systemnotification.go rename to internal/data/internal/ent/systemnotification.go index 39572a0f..f8458e59 100644 --- a/app/sephirah/internal/data/internal/ent/systemnotification.go +++ b/internal/data/internal/ent/systemnotification.go @@ -9,7 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/systemnotification/systemnotification.go b/internal/data/internal/ent/systemnotification/systemnotification.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/systemnotification/systemnotification.go rename to internal/data/internal/ent/systemnotification/systemnotification.go diff --git a/app/sephirah/internal/data/internal/ent/systemnotification/where.go b/internal/data/internal/ent/systemnotification/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/systemnotification/where.go rename to internal/data/internal/ent/systemnotification/where.go index c07a9fda..97e6bc37 100644 --- a/app/sephirah/internal/data/internal/ent/systemnotification/where.go +++ b/internal/data/internal/ent/systemnotification/where.go @@ -6,7 +6,7 @@ import ( "time" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/systemnotification_create.go b/internal/data/internal/ent/systemnotification_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/systemnotification_create.go rename to internal/data/internal/ent/systemnotification_create.go index 5b1351c7..8da2ff73 100644 --- a/app/sephirah/internal/data/internal/ent/systemnotification_create.go +++ b/internal/data/internal/ent/systemnotification_create.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/systemnotification_delete.go b/internal/data/internal/ent/systemnotification_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/systemnotification_delete.go rename to internal/data/internal/ent/systemnotification_delete.go index 08d0b8cb..e214b1c8 100644 --- a/app/sephirah/internal/data/internal/ent/systemnotification_delete.go +++ b/internal/data/internal/ent/systemnotification_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" ) // SystemNotificationDelete is the builder for deleting a SystemNotification entity. diff --git a/app/sephirah/internal/data/internal/ent/systemnotification_query.go b/internal/data/internal/ent/systemnotification_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/systemnotification_query.go rename to internal/data/internal/ent/systemnotification_query.go index 2cb205a0..2798a33d 100644 --- a/app/sephirah/internal/data/internal/ent/systemnotification_query.go +++ b/internal/data/internal/ent/systemnotification_query.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/systemnotification_update.go b/internal/data/internal/ent/systemnotification_update.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/systemnotification_update.go rename to internal/data/internal/ent/systemnotification_update.go index 8bf545b4..f62581e9 100644 --- a/app/sephirah/internal/data/internal/ent/systemnotification_update.go +++ b/internal/data/internal/ent/systemnotification_update.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/tag.go b/internal/data/internal/ent/tag.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/tag.go rename to internal/data/internal/ent/tag.go index 1e41a8b0..f0fc3975 100644 --- a/app/sephirah/internal/data/internal/ent/tag.go +++ b/internal/data/internal/ent/tag.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/tag/tag.go b/internal/data/internal/ent/tag/tag.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/tag/tag.go rename to internal/data/internal/ent/tag/tag.go diff --git a/app/sephirah/internal/data/internal/ent/tag/where.go b/internal/data/internal/ent/tag/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/tag/where.go rename to internal/data/internal/ent/tag/where.go index d0ce2648..32b0e083 100644 --- a/app/sephirah/internal/data/internal/ent/tag/where.go +++ b/internal/data/internal/ent/tag/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/tag_create.go b/internal/data/internal/ent/tag_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/tag_create.go rename to internal/data/internal/ent/tag_create.go index ca736f9c..cd786d51 100644 --- a/app/sephirah/internal/data/internal/ent/tag_create.go +++ b/internal/data/internal/ent/tag_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/tag_delete.go b/internal/data/internal/ent/tag_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/tag_delete.go rename to internal/data/internal/ent/tag_delete.go index 661ac8da..437a89b7 100644 --- a/app/sephirah/internal/data/internal/ent/tag_delete.go +++ b/internal/data/internal/ent/tag_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" ) // TagDelete is the builder for deleting a Tag entity. diff --git a/app/sephirah/internal/data/internal/ent/tag_query.go b/internal/data/internal/ent/tag_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/tag_query.go rename to internal/data/internal/ent/tag_query.go index 74b18aad..5bba0c05 100644 --- a/app/sephirah/internal/data/internal/ent/tag_query.go +++ b/internal/data/internal/ent/tag_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/tag_update.go b/internal/data/internal/ent/tag_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/tag_update.go rename to internal/data/internal/ent/tag_update.go index 729af7b4..aa1b2b5c 100644 --- a/app/sephirah/internal/data/internal/ent/tag_update.go +++ b/internal/data/internal/ent/tag_update.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/tx.go b/internal/data/internal/ent/tx.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/tx.go rename to internal/data/internal/ent/tx.go diff --git a/app/sephirah/internal/data/internal/ent/user.go b/internal/data/internal/ent/user.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/user.go rename to internal/data/internal/ent/user.go index c5eb7a55..d63f88e9 100644 --- a/app/sephirah/internal/data/internal/ent/user.go +++ b/internal/data/internal/ent/user.go @@ -9,7 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/user/user.go b/internal/data/internal/ent/user/user.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/user/user.go rename to internal/data/internal/ent/user/user.go diff --git a/app/sephirah/internal/data/internal/ent/user/where.go b/internal/data/internal/ent/user/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/user/where.go rename to internal/data/internal/ent/user/where.go index 9c59acef..1bda701a 100644 --- a/app/sephirah/internal/data/internal/ent/user/where.go +++ b/internal/data/internal/ent/user/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/user_create.go b/internal/data/internal/ent/user_create.go similarity index 96% rename from app/sephirah/internal/data/internal/ent/user_create.go rename to internal/data/internal/ent/user_create.go index 1d18a894..208525f2 100644 --- a/app/sephirah/internal/data/internal/ent/user_create.go +++ b/internal/data/internal/ent/user_create.go @@ -11,23 +11,23 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/user_delete.go b/internal/data/internal/ent/user_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/user_delete.go rename to internal/data/internal/ent/user_delete.go index e3651572..87367ee5 100644 --- a/app/sephirah/internal/data/internal/ent/user_delete.go +++ b/internal/data/internal/ent/user_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" ) // UserDelete is the builder for deleting a User entity. diff --git a/app/sephirah/internal/data/internal/ent/user_query.go b/internal/data/internal/ent/user_query.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/user_query.go rename to internal/data/internal/ent/user_query.go index 26d5b71f..3fe0b5bf 100644 --- a/app/sephirah/internal/data/internal/ent/user_query.go +++ b/internal/data/internal/ent/user_query.go @@ -12,24 +12,24 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/user_update.go b/internal/data/internal/ent/user_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/user_update.go rename to internal/data/internal/ent/user_update.go index 7c576cf0..825ec3fc 100644 --- a/app/sephirah/internal/data/internal/ent/user_update.go +++ b/internal/data/internal/ent/user_update.go @@ -11,24 +11,24 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/app" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/appinst" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/file" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/image" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/tag" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/app" + "github.com/tuihub/librarian/internal/data/internal/ent/appinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/appinst" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/file" + "github.com/tuihub/librarian/internal/data/internal/ent/image" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifysource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/tag" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/userdevice.go b/internal/data/internal/ent/userdevice.go similarity index 96% rename from app/sephirah/internal/data/internal/ent/userdevice.go rename to internal/data/internal/ent/userdevice.go index 29a6fd41..90517dad 100644 --- a/app/sephirah/internal/data/internal/ent/userdevice.go +++ b/internal/data/internal/ent/userdevice.go @@ -9,9 +9,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/userdevice/userdevice.go b/internal/data/internal/ent/userdevice/userdevice.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/userdevice/userdevice.go rename to internal/data/internal/ent/userdevice/userdevice.go diff --git a/app/sephirah/internal/data/internal/ent/userdevice/where.go b/internal/data/internal/ent/userdevice/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/userdevice/where.go rename to internal/data/internal/ent/userdevice/where.go index 40d76ecc..0bf62043 100644 --- a/app/sephirah/internal/data/internal/ent/userdevice/where.go +++ b/internal/data/internal/ent/userdevice/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/userdevice_create.go b/internal/data/internal/ent/userdevice_create.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/userdevice_create.go rename to internal/data/internal/ent/userdevice_create.go index 31b6285c..f5ff1130 100644 --- a/app/sephirah/internal/data/internal/ent/userdevice_create.go +++ b/internal/data/internal/ent/userdevice_create.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/userdevice_delete.go b/internal/data/internal/ent/userdevice_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/userdevice_delete.go rename to internal/data/internal/ent/userdevice_delete.go index af4b919c..4dc22f6d 100644 --- a/app/sephirah/internal/data/internal/ent/userdevice_delete.go +++ b/internal/data/internal/ent/userdevice_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" ) // UserDeviceDelete is the builder for deleting a UserDevice entity. diff --git a/app/sephirah/internal/data/internal/ent/userdevice_query.go b/internal/data/internal/ent/userdevice_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/userdevice_query.go rename to internal/data/internal/ent/userdevice_query.go index d41e366a..33a91b34 100644 --- a/app/sephirah/internal/data/internal/ent/userdevice_query.go +++ b/internal/data/internal/ent/userdevice_query.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/userdevice_update.go b/internal/data/internal/ent/userdevice_update.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/userdevice_update.go rename to internal/data/internal/ent/userdevice_update.go index 1f6510a5..47aba610 100644 --- a/app/sephirah/internal/data/internal/ent/userdevice_update.go +++ b/internal/data/internal/ent/userdevice_update.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/usersession.go b/internal/data/internal/ent/usersession.go similarity index 97% rename from app/sephirah/internal/data/internal/ent/usersession.go rename to internal/data/internal/ent/usersession.go index 201aa3d5..e38069e6 100644 --- a/app/sephirah/internal/data/internal/ent/usersession.go +++ b/internal/data/internal/ent/usersession.go @@ -9,8 +9,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/usersession/usersession.go b/internal/data/internal/ent/usersession/usersession.go similarity index 100% rename from app/sephirah/internal/data/internal/ent/usersession/usersession.go rename to internal/data/internal/ent/usersession/usersession.go diff --git a/app/sephirah/internal/data/internal/ent/usersession/where.go b/internal/data/internal/ent/usersession/where.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/usersession/where.go rename to internal/data/internal/ent/usersession/where.go index 416da51f..f1ca82c8 100644 --- a/app/sephirah/internal/data/internal/ent/usersession/where.go +++ b/internal/data/internal/ent/usersession/where.go @@ -7,7 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/usersession_create.go b/internal/data/internal/ent/usersession_create.go similarity index 99% rename from app/sephirah/internal/data/internal/ent/usersession_create.go rename to internal/data/internal/ent/usersession_create.go index 06a50078..e9e284b0 100644 --- a/app/sephirah/internal/data/internal/ent/usersession_create.go +++ b/internal/data/internal/ent/usersession_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/usersession_delete.go b/internal/data/internal/ent/usersession_delete.go similarity index 93% rename from app/sephirah/internal/data/internal/ent/usersession_delete.go rename to internal/data/internal/ent/usersession_delete.go index 27209ee9..ba741712 100644 --- a/app/sephirah/internal/data/internal/ent/usersession_delete.go +++ b/internal/data/internal/ent/usersession_delete.go @@ -8,8 +8,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" ) // UserSessionDelete is the builder for deleting a UserSession entity. diff --git a/app/sephirah/internal/data/internal/ent/usersession_query.go b/internal/data/internal/ent/usersession_query.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/usersession_query.go rename to internal/data/internal/ent/usersession_query.go index 468b3aa7..1a3c16ec 100644 --- a/app/sephirah/internal/data/internal/ent/usersession_query.go +++ b/internal/data/internal/ent/usersession_query.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/internal/ent/usersession_update.go b/internal/data/internal/ent/usersession_update.go similarity index 98% rename from app/sephirah/internal/data/internal/ent/usersession_update.go rename to internal/data/internal/ent/usersession_update.go index f6885d60..92e5922d 100644 --- a/app/sephirah/internal/data/internal/ent/usersession_update.go +++ b/internal/data/internal/ent/usersession_update.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/predicate" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" ) diff --git a/app/sephirah/internal/data/netzach.go b/internal/data/netzach.go similarity index 93% rename from app/sephirah/internal/data/netzach.go rename to internal/data/netzach.go index d91fcc73..8fe613c9 100644 --- a/app/sephirah/internal/data/netzach.go +++ b/internal/data/netzach.go @@ -4,15 +4,15 @@ import ( "context" "fmt" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflow" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowsource" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/systemnotification" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/biz/biznetzach" + "github.com/tuihub/librarian/internal/data/internal/converter" + "github.com/tuihub/librarian/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowsource" + "github.com/tuihub/librarian/internal/data/internal/ent/notifyflowtarget" + "github.com/tuihub/librarian/internal/data/internal/ent/notifytarget" + "github.com/tuihub/librarian/internal/data/internal/ent/systemnotification" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelnetzach" diff --git a/app/sephirah/internal/data/tiphereth.go b/internal/data/tiphereth.go similarity index 95% rename from app/sephirah/internal/data/tiphereth.go rename to internal/data/tiphereth.go index f0e076ca..37573f2b 100644 --- a/app/sephirah/internal/data/tiphereth.go +++ b/internal/data/tiphereth.go @@ -4,19 +4,20 @@ import ( "context" "errors" - "entgo.io/ent/dialect/sql" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/account" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/deviceinfo" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/portercontext" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/biz/biztiphereth" + "github.com/tuihub/librarian/internal/data/internal/converter" + "github.com/tuihub/librarian/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent/account" + "github.com/tuihub/librarian/internal/data/internal/ent/deviceinfo" + "github.com/tuihub/librarian/internal/data/internal/ent/portercontext" + "github.com/tuihub/librarian/internal/data/internal/ent/porterinstance" + "github.com/tuihub/librarian/internal/data/internal/ent/user" + "github.com/tuihub/librarian/internal/data/internal/ent/userdevice" + "github.com/tuihub/librarian/internal/data/internal/ent/usersession" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelsupervisor" + + "entgo.io/ent/dialect/sql" ) type tipherethRepo struct { diff --git a/app/sephirah/internal/data/yesod.go b/internal/data/yesod.go similarity index 96% rename from app/sephirah/internal/data/yesod.go rename to internal/data/yesod.go index f6384c84..d4449055 100644 --- a/app/sephirah/internal/data/yesod.go +++ b/internal/data/yesod.go @@ -4,15 +4,15 @@ import ( "context" "time" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/converter" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditem" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feeditemcollection" - "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/biz/bizyesod" + "github.com/tuihub/librarian/internal/data/internal/converter" + "github.com/tuihub/librarian/internal/data/internal/ent" + "github.com/tuihub/librarian/internal/data/internal/ent/feed" + "github.com/tuihub/librarian/internal/data/internal/ent/feedactionset" + "github.com/tuihub/librarian/internal/data/internal/ent/feedconfig" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditem" + "github.com/tuihub/librarian/internal/data/internal/ent/feeditemcollection" + "github.com/tuihub/librarian/internal/data/internal/ent/user" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" diff --git a/internal/model/tiphereth.go b/internal/model/tiphereth.go index b9d3c43f..e55da6e1 100644 --- a/internal/model/tiphereth.go +++ b/internal/model/tiphereth.go @@ -5,13 +5,11 @@ import ( ) type User struct { - ID InternalID - Username string - Password string - Type UserType - Status UserStatus - CreatedAt time.Time - UpdatedAt time.Time + ID InternalID + Username string + Password string + Type UserType + Status UserStatus } type UserStatus int diff --git a/internal/service/angelaweb/internal/api/handler.go b/internal/service/angelaweb/internal/api/handler.go index e30dbe6c..0fcc59b3 100644 --- a/internal/service/angelaweb/internal/api/handler.go +++ b/internal/service/angelaweb/internal/api/handler.go @@ -1,9 +1,10 @@ package api import ( - "github.com/gofiber/fiber/v2" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + + "github.com/gofiber/fiber/v2" "gorm.io/gorm" ) diff --git a/internal/service/angelaweb/internal/api/login.go b/internal/service/angelaweb/internal/api/login.go index ad4ecbd2..2202fab5 100644 --- a/internal/service/angelaweb/internal/api/login.go +++ b/internal/service/angelaweb/internal/api/login.go @@ -1,11 +1,13 @@ package api import ( - "github.com/gofiber/fiber/v2" + "time" + "github.com/tuihub/librarian/internal/lib/libauth" model2 "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" - "time" + + "github.com/gofiber/fiber/v2" ) func (h *Handler) Login(c *fiber.Ctx) error { diff --git a/internal/service/angelaweb/internal/api/user.go b/internal/service/angelaweb/internal/api/user.go index 3aac6bc0..da0017d4 100644 --- a/internal/service/angelaweb/internal/api/user.go +++ b/internal/service/angelaweb/internal/api/user.go @@ -1,8 +1,9 @@ package api import ( - "github.com/gofiber/fiber/v2" "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + + "github.com/gofiber/fiber/v2" ) func (h *Handler) ListUsers(c *fiber.Ctx) error { diff --git a/internal/service/angelaweb/internal/model/model.go b/internal/service/angelaweb/internal/model/model.go index c7597d62..92edebe4 100644 --- a/internal/service/angelaweb/internal/model/model.go +++ b/internal/service/angelaweb/internal/model/model.go @@ -5,8 +5,8 @@ import ( ) type User struct { - ID uint `json:"id" gorm:"primarykey"` - Username string `json:"username" gorm:"unique"` + ID uint `gorm:"primarykey" json:"id"` + Username string `gorm:"unique" json:"username"` Password string `json:"-"` // 不在JSON中显示密码 Email string `json:"email"` Role string `json:"role"` diff --git a/internal/service/angelaweb/internal/page/page.go b/internal/service/angelaweb/internal/page/page.go index 23e4ef02..8ccbda80 100644 --- a/internal/service/angelaweb/internal/page/page.go +++ b/internal/service/angelaweb/internal/page/page.go @@ -1,8 +1,9 @@ package page import ( - "github.com/gofiber/fiber/v2" "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + + "github.com/gofiber/fiber/v2" "gorm.io/gorm" ) diff --git a/internal/service/sephirah/chesed.go b/internal/service/sephirah/chesed.go index da96477a..4d724eb9 100644 --- a/internal/service/sephirah/chesed.go +++ b/internal/service/sephirah/chesed.go @@ -2,10 +2,10 @@ package sephirah import ( "context" - "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelchesed" + converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" @@ -15,7 +15,7 @@ import ( func (s *LibrarianSephirahServiceService) UploadImage(ctx context.Context, req *pb.UploadImageRequest) ( *pb.UploadImageResponse, error) { - fm := converter.ToBizFileMetadata(req.GetFileMetadata()) + fm := converter2.ToBizFileMetadata(req.GetFileMetadata()) if fm == nil { return nil, pb.ErrorErrorReasonBadRequest("app required") } @@ -42,7 +42,7 @@ func (s *LibrarianSephirahServiceService) ListImages(ctx context.Context, req *p } return &pb.ListImagesResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Ids: converter.ToPBInternalIDList(res), + Ids: converter2.ToPBInternalIDList(res), }, nil } func (s *LibrarianSephirahServiceService) SearchImages(ctx context.Context, @@ -53,7 +53,7 @@ func (s *LibrarianSephirahServiceService) SearchImages(ctx context.Context, } return &pb.SearchImagesResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(len(res))}, - Ids: converter.ToPBInternalIDList(res), + Ids: converter2.ToPBInternalIDList(res), }, nil } func (s *LibrarianSephirahServiceService) GetImage(ctx context.Context, req *pb.GetImageRequest) ( @@ -62,7 +62,7 @@ func (s *LibrarianSephirahServiceService) GetImage(ctx context.Context, req *pb. } func (s *LibrarianSephirahServiceService) DownloadImage(ctx context.Context, req *pb.DownloadImageRequest) ( *pb.DownloadImageResponse, error) { - token, err := s.c.DownloadImage(ctx, converter.ToBizInternalID(req.GetId())) + token, err := s.c.DownloadImage(ctx, converter2.ToBizInternalID(req.GetId())) if err != nil { return nil, err } diff --git a/internal/service/sephirah/internal/converter/biz_to_pb.go b/internal/service/sephirah/converter/biz_to_pb.go similarity index 100% rename from internal/service/sephirah/internal/converter/biz_to_pb.go rename to internal/service/sephirah/converter/biz_to_pb.go diff --git a/internal/service/sephirah/internal/converter/converter.go b/internal/service/sephirah/converter/converter.go similarity index 100% rename from internal/service/sephirah/internal/converter/converter.go rename to internal/service/sephirah/converter/converter.go diff --git a/internal/service/sephirah/internal/converter/generated.go b/internal/service/sephirah/converter/generated.go similarity index 100% rename from internal/service/sephirah/internal/converter/generated.go rename to internal/service/sephirah/converter/generated.go diff --git a/internal/service/sephirah/internal/converter/pb_to_biz.go b/internal/service/sephirah/converter/pb_to_biz.go similarity index 100% rename from internal/service/sephirah/internal/converter/pb_to_biz.go rename to internal/service/sephirah/converter/pb_to_biz.go diff --git a/internal/service/sephirah/gebura.go b/internal/service/sephirah/gebura.go index 218f1c9f..24fea432 100644 --- a/internal/service/sephirah/gebura.go +++ b/internal/service/sephirah/gebura.go @@ -2,9 +2,9 @@ package sephirah import ( "context" - "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" + converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" @@ -19,12 +19,12 @@ func (s *LibrarianSephirahServiceService) CreateAppInfo(ctx context.Context, req if appInfo == nil { return nil, pb.ErrorErrorReasonBadRequest("appInfo info required") } - a, err := s.g.CreateAppInfo(ctx, converter.ToBizAppInfo(req.GetAppInfo())) + a, err := s.g.CreateAppInfo(ctx, converter2.ToBizAppInfo(req.GetAppInfo())) if err != nil { return nil, err } return &pb.CreateAppInfoResponse{ - Id: converter.ToPBInternalID(a.ID), + Id: converter2.ToPBInternalID(a.ID), }, nil } func (s *LibrarianSephirahServiceService) UpdateAppInfo(ctx context.Context, req *pb.UpdateAppInfoRequest) ( @@ -34,7 +34,7 @@ func (s *LibrarianSephirahServiceService) UpdateAppInfo(ctx context.Context, req if appInfo == nil || appInfo.GetId() == nil { return nil, pb.ErrorErrorReasonBadRequest("appInfo and internal_id required") } - err := s.g.UpdateAppInfo(ctx, converter.ToBizAppInfo(req.GetAppInfo())) + err := s.g.UpdateAppInfo(ctx, converter2.ToBizAppInfo(req.GetAppInfo())) if err != nil { return nil, err } @@ -46,8 +46,8 @@ func (s *LibrarianSephirahServiceService) ListAppInfos(ctx context.Context, req a, total, err := s.g.ListAppInfos(ctx, model.ToBizPaging(req.GetPaging()), req.GetSourceFilter(), - converter.ToBizAppTypeList(req.GetTypeFilter()), - converter.ToBizInternalIDList(req.GetIdFilter()), + converter2.ToBizAppTypeList(req.GetTypeFilter()), + converter2.ToBizInternalIDList(req.GetIdFilter()), req.GetContainDetails(), ) if err != nil { @@ -55,19 +55,19 @@ func (s *LibrarianSephirahServiceService) ListAppInfos(ctx context.Context, req } return &pb.ListAppInfosResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - AppInfos: converter.ToPBAppInfoList(a), + AppInfos: converter2.ToPBAppInfoList(a), }, nil } func (s *LibrarianSephirahServiceService) MergeAppInfos(ctx context.Context, req *pb.MergeAppInfosRequest) ( *pb.MergeAppInfosResponse, error, ) { - info := converter.ToBizAppInfo(req.GetBase()) + info := converter2.ToBizAppInfo(req.GetBase()) if info == nil { return nil, pb.ErrorErrorReasonBadRequest("base required") } err := s.g.MergeAppInfos(ctx, *info, - converter.ToBizInternalID(req.GetMerged()), + converter2.ToBizInternalID(req.GetMerged()), ) if err != nil { return nil, err @@ -77,11 +77,11 @@ func (s *LibrarianSephirahServiceService) MergeAppInfos(ctx context.Context, req func (s *LibrarianSephirahServiceService) SyncAppInfos(ctx context.Context, req *pb.SyncAppInfosRequest) ( *pb.SyncAppInfosResponse, error, ) { - apps, err := s.g.SyncAppInfos(ctx, converter.ToBizAppInfoIDList(req.GetAppInfoIds()), req.GetWaitData()) + apps, err := s.g.SyncAppInfos(ctx, converter2.ToBizAppInfoIDList(req.GetAppInfoIds()), req.GetWaitData()) if err != nil { return nil, err } - return &pb.SyncAppInfosResponse{AppInfos: converter.ToPBAppInfoList(apps)}, nil + return &pb.SyncAppInfosResponse{AppInfos: converter2.ToPBAppInfoList(apps)}, nil } func (s *LibrarianSephirahServiceService) SearchAppInfos(ctx context.Context, req *pb.SearchAppInfosRequest) ( *pb.SearchAppInfosResponse, error, @@ -95,7 +95,7 @@ func (s *LibrarianSephirahServiceService) SearchAppInfos(ctx context.Context, re } return &pb.SearchAppInfosResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - AppInfos: converter.ToPBAppInfoMixedList(infos), + AppInfos: converter2.ToPBAppInfoMixedList(infos), }, nil } func (s *LibrarianSephirahServiceService) SearchNewAppInfos(ctx context.Context, req *pb.SearchNewAppInfosRequest) ( @@ -111,36 +111,36 @@ func (s *LibrarianSephirahServiceService) SearchNewAppInfos(ctx context.Context, } return &pb.SearchNewAppInfosResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - AppInfos: converter.ToPBAppInfoList(infos), + AppInfos: converter2.ToPBAppInfoList(infos), }, nil } func (s *LibrarianSephirahServiceService) GetAppInfo(ctx context.Context, req *pb.GetAppInfoRequest) ( *pb.GetAppInfoResponse, error, ) { - res, err := s.g.GetAppInfo(ctx, converter.ToBizInternalID(req.GetAppInfoId())) + res, err := s.g.GetAppInfo(ctx, converter2.ToBizInternalID(req.GetAppInfoId())) if err != nil { return nil, err } - return &pb.GetAppInfoResponse{AppInfo: converter.ToPBAppInfo(res)}, nil + return &pb.GetAppInfoResponse{AppInfo: converter2.ToPBAppInfo(res)}, nil } func (s *LibrarianSephirahServiceService) GetBoundAppInfos(ctx context.Context, req *pb.GetBoundAppInfosRequest) ( *pb.GetBoundAppInfosResponse, error, ) { - al, err := s.g.GetBoundAppInfos(ctx, converter.ToBizInternalID(req.GetAppInfoId())) + al, err := s.g.GetBoundAppInfos(ctx, converter2.ToBizInternalID(req.GetAppInfoId())) if err != nil { return nil, err } - return &pb.GetBoundAppInfosResponse{AppInfos: converter.ToPBAppInfoList(al)}, nil + return &pb.GetBoundAppInfosResponse{AppInfos: converter2.ToPBAppInfoList(al)}, nil } func (s *LibrarianSephirahServiceService) PurchaseAppInfo(ctx context.Context, req *pb.PurchaseAppInfoRequest) ( *pb.PurchaseAppInfoResponse, error, ) { - id, err := s.g.PurchaseAppInfo(ctx, converter.ToBizAppInfoID(req.GetAppInfoId())) + id, err := s.g.PurchaseAppInfo(ctx, converter2.ToBizAppInfoID(req.GetAppInfoId())) if err != nil { return nil, err } return &pb.PurchaseAppInfoResponse{ - Id: converter.ToPBInternalID(id), + Id: converter2.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) GetPurchasedAppInfos( @@ -154,7 +154,7 @@ func (s *LibrarianSephirahServiceService) GetPurchasedAppInfos( return nil, err } return &pb.GetPurchasedAppInfosResponse{ - AppInfos: converter.ToPBAppInfoMixedList(infos), + AppInfos: converter2.ToPBAppInfoMixedList(infos), }, nil } @@ -162,17 +162,17 @@ func (s *LibrarianSephirahServiceService) CreateApp( ctx context.Context, req *pb.CreateAppRequest, ) (*pb.CreateAppResponse, error) { - ap, err := s.g.CreateApp(ctx, converter.ToBizApp(req.GetApp())) + ap, err := s.g.CreateApp(ctx, converter2.ToBizApp(req.GetApp())) if err != nil { return nil, err } - return &pb.CreateAppResponse{Id: converter.ToPBInternalID(ap.ID)}, nil + return &pb.CreateAppResponse{Id: converter2.ToPBInternalID(ap.ID)}, nil } func (s *LibrarianSephirahServiceService) UpdateApp( ctx context.Context, req *pb.UpdateAppRequest, ) (*pb.UpdateAppResponse, error) { - err := s.g.UpdateApp(ctx, converter.ToBizApp(req.GetApp())) + err := s.g.UpdateApp(ctx, converter2.ToBizApp(req.GetApp())) if err != nil { return nil, err } @@ -184,16 +184,16 @@ func (s *LibrarianSephirahServiceService) ListApps( ) (*pb.ListAppsResponse, error) { ap, total, err := s.g.ListApps(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizInternalIDList(req.GetOwnerIdFilter()), - converter.ToBizInternalIDList(req.GetAssignedAppInfoIdFilter()), - converter.ToBizInternalIDList(req.GetIdFilter()), + converter2.ToBizInternalIDList(req.GetOwnerIdFilter()), + converter2.ToBizInternalIDList(req.GetAssignedAppInfoIdFilter()), + converter2.ToBizInternalIDList(req.GetIdFilter()), ) if err != nil { return nil, err } return &pb.ListAppsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - Apps: converter.ToPBAppList(ap), + Apps: converter2.ToPBAppList(ap), }, nil } func (s *LibrarianSephirahServiceService) AssignApp( @@ -201,8 +201,8 @@ func (s *LibrarianSephirahServiceService) AssignApp( req *pb.AssignAppRequest, ) (*pb.AssignAppResponse, error) { err := s.g.AssignApp(ctx, - converter.ToBizInternalID(req.GetAppId()), - converter.ToBizInternalID(req.GetAppInfoId()), + converter2.ToBizInternalID(req.GetAppId()), + converter2.ToBizInternalID(req.GetAppInfoId()), ) if err != nil { return nil, err @@ -213,7 +213,7 @@ func (s *LibrarianSephirahServiceService) UnAssignApp( ctx context.Context, req *pb.UnAssignAppRequest, ) (*pb.UnAssignAppResponse, error) { - err := s.g.UnAssignApp(ctx, converter.ToBizInternalID(req.GetAppId())) + err := s.g.UnAssignApp(ctx, converter2.ToBizInternalID(req.GetAppId())) if err != nil { return nil, err } diff --git a/internal/service/sephirah/librariansephirahservice.go b/internal/service/sephirah/librariansephirahservice.go index b7f7f353..40e00dfc 100644 --- a/internal/service/sephirah/librariansephirahservice.go +++ b/internal/service/sephirah/librariansephirahservice.go @@ -2,7 +2,6 @@ package sephirah import ( "context" - "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "time" "github.com/tuihub/librarian/internal/biz/bizangela" @@ -15,6 +14,7 @@ import ( "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" + "github.com/tuihub/librarian/internal/service/sephirah/converter" "github.com/tuihub/librarian/internal/service/supervisor" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" diff --git a/internal/service/sephirah/netzach.go b/internal/service/sephirah/netzach.go index 0ab98fef..a01b0743 100644 --- a/internal/service/sephirah/netzach.go +++ b/internal/service/sephirah/netzach.go @@ -2,26 +2,26 @@ package sephirah import ( "context" - "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" + converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) func (s *LibrarianSephirahServiceService) CreateNotifyTarget(ctx context.Context, req *pb.CreateNotifyTargetRequest) ( *pb.CreateNotifyTargetResponse, error) { - id, err := s.n.CreateNotifyTarget(ctx, converter.ToBizNotifyTarget(req.GetTarget())) + id, err := s.n.CreateNotifyTarget(ctx, converter2.ToBizNotifyTarget(req.GetTarget())) if err != nil { return nil, err } return &pb.CreateNotifyTargetResponse{ - Id: converter.ToPBInternalID(id), + Id: converter2.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) UpdateNotifyTarget(ctx context.Context, req *pb.UpdateNotifyTargetRequest) ( *pb.UpdateNotifyTargetResponse, error) { - err := s.n.UpdateNotifyTarget(ctx, converter.ToBizNotifyTarget(req.GetTarget())) + err := s.n.UpdateNotifyTarget(ctx, converter2.ToBizNotifyTarget(req.GetTarget())) if err != nil { return nil, err } @@ -31,30 +31,30 @@ func (s *LibrarianSephirahServiceService) ListNotifyTargets(ctx context.Context, *pb.ListNotifyTargetsResponse, error) { t, total, err := s.n.ListNotifyTargets(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizInternalIDList(req.GetIdFilter()), - converter.ToBizNotifyTargetStatusList(req.GetStatusFilter()), + converter2.ToBizInternalIDList(req.GetIdFilter()), + converter2.ToBizNotifyTargetStatusList(req.GetStatusFilter()), ) if err != nil { return nil, err } return &pb.ListNotifyTargetsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Targets: converter.ToPBNotifyTargetList(t), + Targets: converter2.ToPBNotifyTargetList(t), }, nil } func (s *LibrarianSephirahServiceService) CreateNotifyFlow(ctx context.Context, req *pb.CreateNotifyFlowRequest) ( *pb.CreateNotifyFlowResponse, error) { - id, err := s.n.CreateNotifyFlow(ctx, converter.ToBizNotifyFlow(req.GetFlow())) + id, err := s.n.CreateNotifyFlow(ctx, converter2.ToBizNotifyFlow(req.GetFlow())) if err != nil { return nil, err } return &pb.CreateNotifyFlowResponse{ - Id: converter.ToPBInternalID(id), + Id: converter2.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) UpdateNotifyFlow(ctx context.Context, req *pb.UpdateNotifyFlowRequest) ( *pb.UpdateNotifyFlowResponse, error) { - err := s.n.UpdateNotifyFlow(ctx, converter.ToBizNotifyFlow(req.GetFlow())) + err := s.n.UpdateNotifyFlow(ctx, converter2.ToBizNotifyFlow(req.GetFlow())) if err != nil { return nil, err } @@ -64,29 +64,29 @@ func (s *LibrarianSephirahServiceService) ListNotifyFlows(ctx context.Context, r *pb.ListNotifyFlowsResponse, error) { res, total, err := s.n.ListNotifyFlows(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizInternalIDList(req.GetIdFilter()), + converter2.ToBizInternalIDList(req.GetIdFilter()), ) if err != nil { return nil, err } return &pb.ListNotifyFlowsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Flows: converter.ToPBNotifyFlowList(res), + Flows: converter2.ToPBNotifyFlowList(res), }, nil } func (s *LibrarianSephirahServiceService) ListSystemNotifications(ctx context.Context, req *pb.ListSystemNotificationsRequest) ( *pb.ListSystemNotificationsResponse, error) { res, total, err := s.n.ListSystemNotifications(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizSystemNotificationTypeList(req.GetTypeFilter()), - converter.ToBizSystemNotificationLevelList(req.GetLevelFilter()), - converter.ToBizSystemNotificationStatusList(req.GetStatusFilter()), + converter2.ToBizSystemNotificationTypeList(req.GetTypeFilter()), + converter2.ToBizSystemNotificationLevelList(req.GetLevelFilter()), + converter2.ToBizSystemNotificationStatusList(req.GetStatusFilter()), ) if err != nil { return nil, err } return &pb.ListSystemNotificationsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Notifications: converter.ToPBSystemNotificationList(res), + Notifications: converter2.ToPBSystemNotificationList(res), }, nil } diff --git a/internal/service/sephirah/porter.go b/internal/service/sephirah/porter.go index 9a9273c7..2f0ee482 100644 --- a/internal/service/sephirah/porter.go +++ b/internal/service/sephirah/porter.go @@ -2,9 +2,9 @@ package sephirah import ( "context" - "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" + converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" ) @@ -13,7 +13,7 @@ func (s *LibrarianSephirahServiceService) PorterGetNotifyTargetItems( req *pb.PorterGetNotifyTargetItemsRequest, ) (*pb.PorterGetNotifyTargetItemsResponse, error) { fr, items, err := s.a.PorterGetNotifyTargetItems(ctx, - converter.ToBizInternalID(req.GetId()), + converter2.ToBizInternalID(req.GetId()), model.ToBizPaging(req.GetPaging()), ) if err != nil { @@ -21,7 +21,7 @@ func (s *LibrarianSephirahServiceService) PorterGetNotifyTargetItems( } return &pb.PorterGetNotifyTargetItemsResponse{ Paging: nil, - Destination: converter.ToPBFeatureRequest(fr), - Items: converter.ToPBFeedItemList(items), + Destination: converter2.ToPBFeatureRequest(fr), + Items: converter2.ToPBFeedItemList(items), }, nil } diff --git a/internal/service/sephirah/tiphereth.go b/internal/service/sephirah/tiphereth.go index 52310975..30621591 100644 --- a/internal/service/sephirah/tiphereth.go +++ b/internal/service/sephirah/tiphereth.go @@ -2,12 +2,12 @@ package sephirah import ( "context" - "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "time" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelsupervisor" + converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) @@ -18,7 +18,7 @@ func (s *LibrarianSephirahServiceService) GetToken(ctx context.Context, req *pb. accessToken, refreshToken, err := s.t.GetToken(ctx, req.GetUsername(), req.GetPassword(), - converter.ToBizInternalIDPtr(req.GetDeviceId()), + converter2.ToBizInternalIDPtr(req.GetDeviceId()), ) if err != nil { logger.Infof("GetToken failed: %s", err.Error()) @@ -34,7 +34,7 @@ func (s *LibrarianSephirahServiceService) RefreshToken(ctx context.Context, req ) { var deviceID *model.InternalID if req.GetDeviceId() != nil { - id := converter.ToBizInternalID(req.GetDeviceId()) + id := converter2.ToBizInternalID(req.GetDeviceId()) deviceID = &id } accessToken, refreshToken, err := s.t.RefreshToken(ctx, deviceID) @@ -53,7 +53,7 @@ func (s *LibrarianSephirahServiceService) AcquireUserToken(ctx context.Context, if req.GetUserId() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - token, err := s.t.AcquireUserToken(ctx, converter.ToBizInternalID(req.GetUserId())) + token, err := s.t.AcquireUserToken(ctx, converter2.ToBizInternalID(req.GetUserId())) if err != nil { return nil, err } @@ -99,12 +99,12 @@ func (s *LibrarianSephirahServiceService) RegisterDevice(ctx context.Context, re return nil, pb.ErrorErrorReasonBadRequest("") } localID := req.GetClientLocalId() - id, err := s.t.RegisterDevice(ctx, converter.ToBizDeviceInfo(req.GetDeviceInfo()), &localID) + id, err := s.t.RegisterDevice(ctx, converter2.ToBizDeviceInfo(req.GetDeviceInfo()), &localID) if err != nil { return nil, err } return &pb.RegisterDeviceResponse{ - DeviceId: converter.ToPBInternalID(id), + DeviceId: converter2.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) ListRegisteredDevices( @@ -118,7 +118,7 @@ func (s *LibrarianSephirahServiceService) ListRegisteredDevices( return nil, err } return &pb.ListRegisteredDevicesResponse{ - Devices: converter.ToPBDeviceInfoList(devices), + Devices: converter2.ToPBDeviceInfoList(devices), }, nil } func (s *LibrarianSephirahServiceService) ListUserSessions(ctx context.Context, req *pb.ListUserSessionsRequest) ( @@ -129,7 +129,7 @@ func (s *LibrarianSephirahServiceService) ListUserSessions(ctx context.Context, return nil, err } return &pb.ListUserSessionsResponse{ - Sessions: converter.ToPBUserSessionList(sessions), + Sessions: converter2.ToPBUserSessionList(sessions), }, nil } func (s *LibrarianSephirahServiceService) DeleteUserSession(ctx context.Context, req *pb.DeleteUserSessionRequest) ( @@ -138,7 +138,7 @@ func (s *LibrarianSephirahServiceService) DeleteUserSession(ctx context.Context, if req.GetSessionId() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - err := s.t.DeleteUserSession(ctx, converter.ToBizInternalID(req.GetSessionId())) + err := s.t.DeleteUserSession(ctx, converter2.ToBizInternalID(req.GetSessionId())) if err != nil { return nil, err } @@ -150,12 +150,12 @@ func (s *LibrarianSephirahServiceService) CreateUser(ctx context.Context, req *p if req.GetUser() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - id, err := s.t.CreateUser(ctx, converter.ToBizUser(req.GetUser())) + id, err := s.t.CreateUser(ctx, converter2.ToBizUser(req.GetUser())) if err != nil { return nil, err } return &pb.CreateUserResponse{ - Id: converter.ToPBInternalID(*id), + Id: converter2.ToPBInternalID(*id), }, nil } func (s *LibrarianSephirahServiceService) UpdateUser(ctx context.Context, req *pb.UpdateUserRequest) ( @@ -164,7 +164,7 @@ func (s *LibrarianSephirahServiceService) UpdateUser(ctx context.Context, req *p if req.GetUser() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - err := s.t.UpdateUser(ctx, converter.ToBizUser(req.GetUser()), req.GetPassword()) + err := s.t.UpdateUser(ctx, converter2.ToBizUser(req.GetUser()), req.GetPassword()) if err != nil { return nil, err } @@ -178,25 +178,25 @@ func (s *LibrarianSephirahServiceService) ListUsers(ctx context.Context, req *pb } u, total, err := s.t.ListUsers(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToLibAuthUserTypeList(req.GetTypeFilter()), - converter.ToBizUserStatusList(req.GetStatusFilter()), + converter2.ToLibAuthUserTypeList(req.GetTypeFilter()), + converter2.ToBizUserStatusList(req.GetStatusFilter()), ) if err != nil { return nil, err } return &pb.ListUsersResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Users: converter.ToPBUserList(u), + Users: converter2.ToPBUserList(u), }, nil } func (s *LibrarianSephirahServiceService) GetUser(ctx context.Context, req *pb.GetUserRequest) ( *pb.GetUserResponse, error, ) { - u, err := s.t.GetUser(ctx, converter.ToBizInternalIDPtr(req.GetId())) + u, err := s.t.GetUser(ctx, converter2.ToBizInternalIDPtr(req.GetId())) if err != nil { return nil, err } - return &pb.GetUserResponse{User: converter.ToPBUser(u)}, nil + return &pb.GetUserResponse{User: converter2.ToPBUser(u)}, nil } func (s *LibrarianSephirahServiceService) LinkAccount(ctx context.Context, req *pb.LinkAccountRequest) ( *pb.LinkAccountResponse, error, @@ -216,7 +216,7 @@ func (s *LibrarianSephirahServiceService) LinkAccount(ctx context.Context, req * if err != nil { return nil, err } - return &pb.LinkAccountResponse{AccountId: converter.ToPBInternalID(a.ID)}, nil + return &pb.LinkAccountResponse{AccountId: converter2.ToPBInternalID(a.ID)}, nil } func (s *LibrarianSephirahServiceService) UnLinkAccount(ctx context.Context, req *pb.UnLinkAccountRequest) ( *pb.UnLinkAccountResponse, error, @@ -241,13 +241,13 @@ func (s *LibrarianSephirahServiceService) ListLinkAccounts(ctx context.Context, *pb.ListLinkAccountsResponse, error, ) { res, err := s.t.ListLinkAccounts(ctx, - converter.ToBizInternalID(req.GetUserId()), + converter2.ToBizInternalID(req.GetUserId()), ) if err != nil { return nil, err } return &pb.ListLinkAccountsResponse{ - Accounts: converter.ToPBAccountList(res), + Accounts: converter2.ToPBAccountList(res), }, nil } @@ -274,7 +274,7 @@ func (s *LibrarianSephirahServiceService) ListPorters(ctx context.Context, req * } return &pb.ListPortersResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Porters: converter.ToPBPorterList(res), + Porters: converter2.ToPBPorterList(res), }, nil } @@ -285,8 +285,8 @@ func (s *LibrarianSephirahServiceService) UpdatePorterStatus(ctx context.Context return nil, pb.ErrorErrorReasonBadRequest("") } if err := s.t.UpdatePorterStatus(ctx, - converter.ToBizInternalID(req.GetPorterId()), - converter.ToBizUserStatus(req.GetStatus()), + converter2.ToBizInternalID(req.GetPorterId()), + converter2.ToBizUserStatus(req.GetStatus()), ); err != nil { return nil, err } @@ -301,13 +301,13 @@ func (s *LibrarianSephirahServiceService) CreatePorterContext( return nil, pb.ErrorErrorReasonBadRequest("") } id, err := s.t.CreatePorterContext(ctx, - converter.ToBizPorterContext(req.GetContext()), + converter2.ToBizPorterContext(req.GetContext()), ) if err != nil { return nil, err } return &pb.CreatePorterContextResponse{ - ContextId: converter.ToPBInternalID(id), + ContextId: converter2.ToPBInternalID(id), }, nil } @@ -335,7 +335,7 @@ func (s *LibrarianSephirahServiceService) ListPorterContexts( //nolint:dupl //no } return &pb.ListPorterContextsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Contexts: converter.ToPBPorterContextList(res), + Contexts: converter2.ToPBPorterContextList(res), }, nil } @@ -347,7 +347,7 @@ func (s *LibrarianSephirahServiceService) UpdatePorterContext( return nil, pb.ErrorErrorReasonBadRequest("") } if err := s.t.UpdatePorterContext(ctx, - converter.ToBizPorterContext(req.GetContext()), + converter2.ToBizPorterContext(req.GetContext()), ); err != nil { return nil, err } @@ -363,13 +363,13 @@ func (s *LibrarianSephirahServiceService) ListPorterGroups( } groups, total, err := s.t.ListPorterGroups(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizUserStatusList(req.GetStatusFilter()), + converter2.ToBizUserStatusList(req.GetStatusFilter()), ) if err != nil { return nil, err } return &pb.ListPorterGroupsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - PorterGroups: converter.ToPBPorterGroupList(groups), + PorterGroups: converter2.ToPBPorterGroupList(groups), }, nil } diff --git a/internal/service/sephirah/yesod.go b/internal/service/sephirah/yesod.go index 0815377c..130c5437 100644 --- a/internal/service/sephirah/yesod.go +++ b/internal/service/sephirah/yesod.go @@ -2,9 +2,9 @@ package sephirah import ( "context" - "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/model" + converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) @@ -13,19 +13,19 @@ func (s *LibrarianSephirahServiceService) CreateFeedConfig( ctx context.Context, req *pb.CreateFeedConfigRequest, ) (*pb.CreateFeedConfigResponse, error) { - id, err := s.y.CreateFeedConfig(ctx, converter.ToBizFeedConfig(req.GetConfig())) + id, err := s.y.CreateFeedConfig(ctx, converter2.ToBizFeedConfig(req.GetConfig())) if err != nil { return nil, err } return &pb.CreateFeedConfigResponse{ - Id: converter.ToPBInternalID(id), + Id: converter2.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) UpdateFeedConfig( ctx context.Context, req *pb.UpdateFeedConfigRequest, ) (*pb.UpdateFeedConfigResponse, error) { - err := s.y.UpdateFeedConfig(ctx, converter.ToBizFeedConfig(req.GetConfig())) + err := s.y.UpdateFeedConfig(ctx, converter2.ToBizFeedConfig(req.GetConfig())) if err != nil { return nil, err } @@ -40,8 +40,8 @@ func (s *LibrarianSephirahServiceService) ListFeedConfigs( } feeds, total, err := s.y.ListFeeds(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizInternalIDList(req.GetIdFilter()), - converter.ToBizFeedConfigStatusList(req.GetStatusFilter()), + converter2.ToBizInternalIDList(req.GetIdFilter()), + converter2.ToBizFeedConfigStatusList(req.GetStatusFilter()), req.GetCategoryFilter(), ) if err != nil { @@ -49,26 +49,26 @@ func (s *LibrarianSephirahServiceService) ListFeedConfigs( } return &pb.ListFeedConfigsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - FeedsWithConfig: converter.ToPBFeedWithConfigList(feeds), + FeedsWithConfig: converter2.ToPBFeedWithConfigList(feeds), }, nil } func (s *LibrarianSephirahServiceService) CreateFeedActionSet( ctx context.Context, req *pb.CreateFeedActionSetRequest, ) (*pb.CreateFeedActionSetResponse, error) { - id, err := s.y.CreateFeedActionSet(ctx, converter.ToBizFeedActionSet(req.GetActionSet())) + id, err := s.y.CreateFeedActionSet(ctx, converter2.ToBizFeedActionSet(req.GetActionSet())) if err != nil { return nil, err } return &pb.CreateFeedActionSetResponse{ - Id: converter.ToPBInternalID(id), + Id: converter2.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) UpdateFeedActionSet( ctx context.Context, req *pb.UpdateFeedActionSetRequest, ) (*pb.UpdateFeedActionSetResponse, error) { - err := s.y.UpdateFeedActionSet(ctx, converter.ToBizFeedActionSet(req.GetActionSet())) + err := s.y.UpdateFeedActionSet(ctx, converter2.ToBizFeedActionSet(req.GetActionSet())) if err != nil { return nil, err } @@ -89,7 +89,7 @@ func (s *LibrarianSephirahServiceService) ListFeedActionSets( } return &pb.ListFeedActionSetsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - ActionSets: converter.ToPBFeedActionSetList(actions), + ActionSets: converter2.ToPBFeedActionSetList(actions), }, nil } func (s *LibrarianSephirahServiceService) ListFeedCategories( @@ -122,10 +122,10 @@ func (s *LibrarianSephirahServiceService) ListFeedItems( } items, total, err := s.y.ListFeedItems(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizInternalIDList(req.GetFeedIdFilter()), + converter2.ToBizInternalIDList(req.GetFeedIdFilter()), req.GetAuthorFilter(), req.GetPublishPlatformFilter(), - converter.ToBizTimeRange(req.GetPublishTimeRange()), + converter2.ToBizTimeRange(req.GetPublishTimeRange()), req.GetCategoryFilter(), ) if err != nil { @@ -133,7 +133,7 @@ func (s *LibrarianSephirahServiceService) ListFeedItems( } return &pb.ListFeedItemsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - Items: converter.ToPBFeedItemDigestList(items), + Items: converter2.ToPBFeedItemDigestList(items), }, nil } func (s *LibrarianSephirahServiceService) GroupFeedItems( @@ -141,11 +141,11 @@ func (s *LibrarianSephirahServiceService) GroupFeedItems( req *pb.GroupFeedItemsRequest, ) (*pb.GroupFeedItemsResponse, error) { itemMap, err := s.y.GroupFeedItems(ctx, - converter.ToBizGroupFeedItemsBy(req.GetPublishTimeAggregation().GetAggregationType()), - converter.ToBizInternalIDList(req.GetFeedIdFilter()), + converter2.ToBizGroupFeedItemsBy(req.GetPublishTimeAggregation().GetAggregationType()), + converter2.ToBizInternalIDList(req.GetFeedIdFilter()), req.GetAuthorFilter(), req.GetPublishPlatformFilter(), - converter.ToBizTimeRange(req.GetPublishTimeAggregation().GetTimeRange()), + converter2.ToBizTimeRange(req.GetPublishTimeAggregation().GetTimeRange()), int(req.GetGroupSize()), req.GetCategoryFilter(), ) @@ -155,8 +155,8 @@ func (s *LibrarianSephirahServiceService) GroupFeedItems( res := make([]*pb.GroupFeedItemsResponse_FeedItemsGroup, 0, len(itemMap)) for timeRange, items := range itemMap { res = append(res, &pb.GroupFeedItemsResponse_FeedItemsGroup{ - TimeRange: converter.ToPBTimeRange(&timeRange), - Items: converter.ToPBFeedItemDigestList(items), + TimeRange: converter2.ToPBTimeRange(&timeRange), + Items: converter2.ToPBFeedItemDigestList(items), }) } return &pb.GroupFeedItemsResponse{Groups: res}, nil @@ -165,12 +165,12 @@ func (s *LibrarianSephirahServiceService) GetFeedItem( ctx context.Context, req *pb.GetFeedItemRequest, ) (*pb.GetFeedItemResponse, error) { - item, err := s.y.GetFeedItem(ctx, converter.ToBizInternalID(req.GetId())) + item, err := s.y.GetFeedItem(ctx, converter2.ToBizInternalID(req.GetId())) if err != nil { return nil, err } return &pb.GetFeedItemResponse{ - Item: converter.ToPBFeedItem(item), + Item: converter2.ToPBFeedItem(item), }, nil } @@ -178,12 +178,12 @@ func (s *LibrarianSephirahServiceService) GetBatchFeedItems( ctx context.Context, req *pb.GetBatchFeedItemsRequest, ) (*pb.GetBatchFeedItemsResponse, error) { - items, err := s.y.GetFeedItems(ctx, converter.ToBizInternalIDList(req.GetIds())) + items, err := s.y.GetFeedItems(ctx, converter2.ToBizInternalIDList(req.GetIds())) if err != nil { return nil, err } return &pb.GetBatchFeedItemsResponse{ - Items: converter.ToPBFeedItemList(items), + Items: converter2.ToPBFeedItemList(items), }, nil } @@ -191,7 +191,7 @@ func (s *LibrarianSephirahServiceService) ReadFeedItem( ctx context.Context, req *pb.ReadFeedItemRequest, ) (*pb.ReadFeedItemResponse, error) { - err := s.y.ReadFeedItem(ctx, converter.ToBizInternalID(req.GetId())) + err := s.y.ReadFeedItem(ctx, converter2.ToBizInternalID(req.GetId())) if err != nil { return nil, err } @@ -202,7 +202,7 @@ func (s *LibrarianSephirahServiceService) CreateFeedItemCollection( ctx context.Context, req *pb.CreateFeedItemCollectionRequest, ) (*pb.CreateFeedItemCollectionResponse, error) { - _, err := s.y.CreateFeedItemCollection(ctx, converter.ToBizFeedItemCollection(req.GetCollection())) + _, err := s.y.CreateFeedItemCollection(ctx, converter2.ToBizFeedItemCollection(req.GetCollection())) if err != nil { return nil, err } @@ -213,7 +213,7 @@ func (s *LibrarianSephirahServiceService) UpdateFeedItemCollection( ctx context.Context, req *pb.UpdateFeedItemCollectionRequest, ) (*pb.UpdateFeedItemCollectionResponse, error) { - err := s.y.UpdateFeedItemCollection(ctx, converter.ToBizFeedItemCollection(req.GetCollection())) + err := s.y.UpdateFeedItemCollection(ctx, converter2.ToBizFeedItemCollection(req.GetCollection())) if err != nil { return nil, err } @@ -229,7 +229,7 @@ func (s *LibrarianSephirahServiceService) ListFeedItemCollections( } collections, total, err := s.y.ListFeedItemCollections(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizInternalIDList(req.GetIdFilter()), + converter2.ToBizInternalIDList(req.GetIdFilter()), req.GetCategoryFilter(), ) if err != nil { @@ -237,7 +237,7 @@ func (s *LibrarianSephirahServiceService) ListFeedItemCollections( } return &pb.ListFeedItemCollectionsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - Collections: converter.ToPBFeedItemCollectionList(collections), + Collections: converter2.ToPBFeedItemCollectionList(collections), }, nil } @@ -246,8 +246,8 @@ func (s *LibrarianSephirahServiceService) AddFeedItemToCollection( req *pb.AddFeedItemToCollectionRequest, ) (*pb.AddFeedItemToCollectionResponse, error) { err := s.y.AddFeedItemToCollection(ctx, - converter.ToBizInternalID(req.GetCollectionId()), - converter.ToBizInternalID(req.GetFeedItemId()), + converter2.ToBizInternalID(req.GetCollectionId()), + converter2.ToBizInternalID(req.GetFeedItemId()), ) if err != nil { return nil, err @@ -261,8 +261,8 @@ func (s *LibrarianSephirahServiceService) RemoveFeedItemFromCollection( ) (*pb.RemoveFeedItemFromCollectionResponse, error) { err := s.y.RemoveFeedItemFromCollection( ctx, - converter.ToBizInternalID(req.GetCollectionId()), - converter.ToBizInternalID(req.GetFeedItemId()), + converter2.ToBizInternalID(req.GetCollectionId()), + converter2.ToBizInternalID(req.GetFeedItemId()), ) if err != nil { return nil, err @@ -279,17 +279,17 @@ func (s *LibrarianSephirahServiceService) ListFeedItemsInCollection( } items, total, err := s.y.ListFeedItemsInCollection(ctx, model.ToBizPaging(req.GetPaging()), - converter.ToBizInternalIDList(req.GetCollectionIdFilter()), + converter2.ToBizInternalIDList(req.GetCollectionIdFilter()), req.GetAuthorFilter(), req.GetPublishPlatformFilter(), req.GetCategoryFilter(), - converter.ToBizTimeRange(req.GetPublishTimeRange()), + converter2.ToBizTimeRange(req.GetPublishTimeRange()), ) if err != nil { return nil, err } return &pb.ListFeedItemsInCollectionResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - Items: converter.ToPBFeedItemDigestList(items), + Items: converter2.ToPBFeedItemDigestList(items), }, nil } diff --git a/internal/service/supervisor/supervisor.go b/internal/service/supervisor/supervisor.go index ecbbef36..4b8402b8 100644 --- a/internal/service/supervisor/supervisor.go +++ b/internal/service/supervisor/supervisor.go @@ -18,6 +18,7 @@ import ( "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" "github.com/google/uuid" diff --git a/internal/service/supervisor/task.go b/internal/service/supervisor/task.go index 792b5427..25f81f17 100644 --- a/internal/service/supervisor/task.go +++ b/internal/service/supervisor/task.go @@ -3,12 +3,12 @@ package supervisor import ( "context" "fmt" - "github.com/tuihub/librarian/internal/service/sephirah/internal/converter" "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtype" "github.com/tuihub/librarian/internal/model/modelsupervisor" + "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" ) From 6724d45f031efbc3b07860a5e03ae5ed0267636d Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 22 Mar 2025 00:37:32 +0800 Subject: [PATCH 12/19] feat: draft angela web --- app/sephirah/Dockerfile | 24 ---- app/sephirah/cmd/sephirah/main.go | 77 ----------- app/sephirah/cmd/sephirah/wire.go | 60 --------- app/sephirah/configs/config.yaml | 24 ---- app/sephirah/pkg/service/service.go | 6 - app/sephirah/pkg/service/wire.go | 50 ------- app/sephirah/pkg/service/wire_gen.go | 123 ------------------ cmd/librarian/wire_gen.go | 102 --------------- go.mod | 4 - go.sum | 15 --- cmd/librarian/main.go => main.go | 0 cmd/librarian/wire.go => wire.go | 12 +- .../cmd/sephirah/wire_gen.go => wire_gen.go | 62 +++++---- 13 files changed, 47 insertions(+), 512 deletions(-) delete mode 100644 app/sephirah/Dockerfile delete mode 100644 app/sephirah/cmd/sephirah/main.go delete mode 100644 app/sephirah/cmd/sephirah/wire.go delete mode 100644 app/sephirah/configs/config.yaml delete mode 100644 app/sephirah/pkg/service/service.go delete mode 100644 app/sephirah/pkg/service/wire.go delete mode 100644 app/sephirah/pkg/service/wire_gen.go delete mode 100644 cmd/librarian/wire_gen.go rename cmd/librarian/main.go => main.go (100%) rename cmd/librarian/wire.go => wire.go (79%) rename app/sephirah/cmd/sephirah/wire_gen.go => wire_gen.go (68%) diff --git a/app/sephirah/Dockerfile b/app/sephirah/Dockerfile deleted file mode 100644 index 42c9c132..00000000 --- a/app/sephirah/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM golang:1.16 AS builder - -COPY . /src -WORKDIR /src - -RUN GOPROXY=https://goproxy.cn make build - -FROM debian:stable-slim - -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - netbase \ - && rm -rf /var/lib/apt/lists/ \ - && apt-get autoremove -y && apt-get autoclean -y - -COPY --from=builder /src/bin /app - -WORKDIR /app - -EXPOSE 8000 -EXPOSE 9000 -VOLUME /data/conf - -CMD ["./server", "-conf", "/data/conf"] diff --git a/app/sephirah/cmd/sephirah/main.go b/app/sephirah/cmd/sephirah/main.go deleted file mode 100644 index bd8bb884..00000000 --- a/app/sephirah/cmd/sephirah/main.go +++ /dev/null @@ -1,77 +0,0 @@ -package main - -import ( - "os" - - "github.com/tuihub/librarian/internal/conf" - "github.com/tuihub/librarian/internal/lib/libapp" - "github.com/tuihub/librarian/internal/lib/libcron" - "github.com/tuihub/librarian/internal/lib/libmq" - - "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/registry" - "github.com/go-kratos/kratos/v2/transport/grpc" - "github.com/go-kratos/kratos/v2/transport/http" -) - -// go build -ldflags "-X main.version=x.y.z". -var ( - // name is the name of the compiled software. - name = "sephirah" //nolint:gochecknoglobals //TODO - // version is the version of the compiled software. - version string - - id, _ = os.Hostname() //nolint:gochecknoglobals //TODO - - // date is the build date of the compiled software. - date string //nolint:gochecknoglobals //TODO - - // version is the proto version of the compiled software. - protoVersion string //nolint:gochecknoglobals //TODO -) - -func newApp(gs *grpc.Server, hs *http.Server, mq *libmq.MQ, cron *libcron.Cron, r registry.Registrar) *kratos.App { - return kratos.New( - kratos.ID(id+name), - kratos.Name(name), - kratos.Version(version), - kratos.Metadata(map[string]string{}), - kratos.Server(gs, hs, mq, cron), - kratos.Registrar(r), - ) -} - -func main() { - appSettings, err := libapp.NewAppSettings(id, name, version, protoVersion, date) - if err != nil { - panic(err) - } - - var bc conf.Sephirah - err = appSettings.LoadConfig(&bc) - if err != nil { - panic(err) - } - - app, cleanup, err := wireApp( - bc.GetServer(), - bc.GetDatabase(), - bc.GetS3(), - bc.GetPorter(), - bc.GetAuth(), - bc.GetMq(), - bc.GetCache(), - bc.GetConsul(), - bc.GetSearch(), - appSettings, - ) - if err != nil { - panic(err) - } - defer cleanup() - - // start and wait for stop signal - if err = app.Run(); err != nil { - panic(err) - } -} diff --git a/app/sephirah/cmd/sephirah/wire.go b/app/sephirah/cmd/sephirah/wire.go deleted file mode 100644 index 8a788b42..00000000 --- a/app/sephirah/cmd/sephirah/wire.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build wireinject - -// The build tag makes sure the stub is not built in the final build. - -package main - -import ( - "github.com/tuihub/librarian/internal/biz" - globalclient "github.com/tuihub/librarian/internal/client" - "github.com/tuihub/librarian/internal/client/client" - "github.com/tuihub/librarian/internal/conf" - "github.com/tuihub/librarian/internal/data" - "github.com/tuihub/librarian/internal/lib/libapp" - "github.com/tuihub/librarian/internal/lib/libauth" - "github.com/tuihub/librarian/internal/lib/libcache" - "github.com/tuihub/librarian/internal/lib/libcron" - "github.com/tuihub/librarian/internal/lib/libidgenerator" - "github.com/tuihub/librarian/internal/lib/libmq" - "github.com/tuihub/librarian/internal/lib/libobserve" - "github.com/tuihub/librarian/internal/lib/libsearch" - "github.com/tuihub/librarian/internal/server" - "github.com/tuihub/librarian/internal/service/sephirah" - "github.com/tuihub/librarian/internal/service/supervisor" - - "github.com/go-kratos/kratos/v2" - "github.com/google/wire" -) - -// wireApp init kratos application. -func wireApp( - *conf.SephirahServer, - *conf.Database, - *conf.S3, - *conf.Porter, - *conf.Auth, - *conf.MQ, - *conf.Cache, - *conf.Consul, - *conf.Search, - *libapp.Settings, -) (*kratos.App, func(), error) { - panic(wire.Build( - server.ProviderSet, - globalclient.ProviderSet, - data.ProviderSet, - biz.ProviderSet, - client.ProviderSet, - supervisor.ProviderSet, - sephirah.ProviderSet, - libauth.ProviderSet, - libmq.ProviderSet, - libcron.ProviderSet, - libcache.ProviderSet, - libobserve.ProviderSet, - libapp.ProviderSet, - libidgenerator.ProviderSet, - libsearch.ProviderSet, - newApp, - )) -} diff --git a/app/sephirah/configs/config.yaml b/app/sephirah/configs/config.yaml deleted file mode 100644 index 47bb6ea9..00000000 --- a/app/sephirah/configs/config.yaml +++ /dev/null @@ -1,24 +0,0 @@ -server: - grpc: - addr: 0.0.0.0:10000 - timeout: 1s - grpc_web: - addr: 0.0.0.0:10010 - timeout: 1s -data: - database: - driver: postgres - host: localhost - port: 5432 - dbname: librarian - user: librarian - password: librarian - no_ssl: true -auth: - salt: test - issuer: test - jwt_secret: test -cache: - driver: memory -mq: - driver: memory \ No newline at end of file diff --git a/app/sephirah/pkg/service/service.go b/app/sephirah/pkg/service/service.go deleted file mode 100644 index 03bcaba9..00000000 --- a/app/sephirah/pkg/service/service.go +++ /dev/null @@ -1,6 +0,0 @@ -package service - -import "github.com/google/wire" - -// ProviderSet is data providers. -var ProviderSet = wire.NewSet(NewSephirahService) diff --git a/app/sephirah/pkg/service/wire.go b/app/sephirah/pkg/service/wire.go deleted file mode 100644 index cc6650b8..00000000 --- a/app/sephirah/pkg/service/wire.go +++ /dev/null @@ -1,50 +0,0 @@ -//go:build wireinject - -// The build tag makes sure the stub is not built in the final build. - -package service - -import ( - "github.com/tuihub/librarian/internal/biz" - "github.com/tuihub/librarian/internal/client/client" - "github.com/tuihub/librarian/internal/conf" - "github.com/tuihub/librarian/internal/data" - "github.com/tuihub/librarian/internal/lib/libapp" - "github.com/tuihub/librarian/internal/lib/libauth" - "github.com/tuihub/librarian/internal/lib/libcache" - "github.com/tuihub/librarian/internal/lib/libcron" - "github.com/tuihub/librarian/internal/lib/libidgenerator" - "github.com/tuihub/librarian/internal/lib/libmq" - "github.com/tuihub/librarian/internal/lib/libsearch" - "github.com/tuihub/librarian/internal/service/sephirah" - "github.com/tuihub/librarian/internal/service/supervisor" - miner "github.com/tuihub/protos/pkg/librarian/miner/v1" - - pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" - - "github.com/google/wire" -) - -func NewSephirahService( - *conf.SephirahServer, - *conf.Database, - *conf.S3, - *conf.Porter, - *conf.Consul, - *libauth.Auth, - *libmq.MQ, - *libcron.Cron, - libcache.Store, - *libapp.Settings, - *libidgenerator.IDGenerator, - libsearch.Search, - miner.LibrarianMinerServiceClient, -) (pb.LibrarianSephirahServiceServer, func(), error) { - panic(wire.Build( - data.ProviderSet, - biz.ProviderSet, - client.ProviderSet, - supervisor.ProviderSet, - sephirah.ProviderSet, - )) -} diff --git a/app/sephirah/pkg/service/wire_gen.go b/app/sephirah/pkg/service/wire_gen.go deleted file mode 100644 index 33925f16..00000000 --- a/app/sephirah/pkg/service/wire_gen.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by Wire. DO NOT EDIT. - -//go:generate go run -mod=mod github.com/google/wire/cmd/wire -//go:build !wireinject -// +build !wireinject - -package service - -import ( - bizangela2 "github.com/tuihub/librarian/internal/biz/bizangela" - "github.com/tuihub/librarian/internal/biz/bizbinah" - "github.com/tuihub/librarian/internal/biz/bizchesed" - "github.com/tuihub/librarian/internal/biz/bizgebura" - biznetzach2 "github.com/tuihub/librarian/internal/biz/biznetzach" - "github.com/tuihub/librarian/internal/biz/biztiphereth" - "github.com/tuihub/librarian/internal/biz/bizyesod" - "github.com/tuihub/librarian/internal/client/client" - "github.com/tuihub/librarian/internal/conf" - "github.com/tuihub/librarian/internal/data" - data2 "github.com/tuihub/librarian/internal/data" - "github.com/tuihub/librarian/internal/lib/libapp" - "github.com/tuihub/librarian/internal/lib/libauth" - "github.com/tuihub/librarian/internal/lib/libcache" - "github.com/tuihub/librarian/internal/lib/libcron" - "github.com/tuihub/librarian/internal/lib/libidgenerator" - "github.com/tuihub/librarian/internal/lib/libmq" - "github.com/tuihub/librarian/internal/lib/libsearch" - "github.com/tuihub/librarian/internal/service/sephirah" - "github.com/tuihub/librarian/internal/service/supervisor" - "github.com/tuihub/protos/pkg/librarian/miner/v1" - v1_2 "github.com/tuihub/protos/pkg/librarian/sephirah/v1" -) - -// Injectors from wire.go: - -func NewSephirahService(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *conf.S3, porter *conf.Porter, consul *conf.Consul, auth *libauth.Auth, mq *libmq.MQ, cron *libcron.Cron, store libcache.Store, settings *libapp.Settings, idGenerator *libidgenerator.IDGenerator, search libsearch.Search, librarianMinerServiceClient v1.LibrarianMinerServiceClient) (v1_2.LibrarianSephirahServiceServer, func(), error) { - entClient, cleanup, err := data.NewSQLClient(database, settings) - if err != nil { - return nil, nil, err - } - dataData := data.NewData(entClient) - angelaRepo := data.NewAngelaRepo(dataData) - librarianPorterServiceClient, err := client.NewPorterClient(consul, porter, settings) - if err != nil { - cleanup() - return nil, nil, err - } - clientPorter, err := client.NewPorter(librarianPorterServiceClient, consul, porter) - if err != nil { - cleanup() - return nil, nil, err - } - netzachRepo := data.NewNetzachRepo(dataData) - topic := biznetzach2.NewSystemNotificationTopic(netzachRepo, idGenerator) - tipherethRepo := data2.NewTipherethRepo(dataData) - libcacheMap := biztiphereth.NewPorterInstanceCache(tipherethRepo, store) - map2 := biztiphereth.NewPorterContextCache(tipherethRepo, store) - supervisorSupervisor, err := supervisor.NewSupervisor(porter, mq, auth, clientPorter, topic, libcacheMap, map2) - if err != nil { - cleanup() - return nil, nil, err - } - geburaRepo := data.NewGeburaRepo(dataData) - angelaBase, err := bizangela2.NewAngelaBase(angelaRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, search, idGenerator) - if err != nil { - cleanup() - return nil, nil, err - } - map3 := bizangela2.NewAppInfoCache(geburaRepo, store) - libmqTopic := bizangela2.NewUpdateAppInfoIndexTopic(angelaBase) - topic2 := bizangela2.NewPullAppInfoTopic(angelaBase, map3, libmqTopic) - topic3 := bizangela2.NewPullAccountAppInfoRelationTopic(angelaBase, topic2) - topic4 := bizangela2.NewPullAccountTopic(angelaBase, topic3) - map4 := bizangela2.NewNotifyFlowCache(netzachRepo, store) - map5 := bizangela2.NewFeedToNotifyFlowCache(netzachRepo, store) - map6 := bizangela2.NewNotifyTargetCache(netzachRepo, store) - topic5 := bizangela2.NewNotifyPushTopic(angelaBase, map6) - topic6 := bizangela2.NewNotifyRouterTopic(angelaBase, map4, map5, topic5) - topic7 := bizangela2.NewFeedItemPostprocessTopic(angelaBase, topic6, topic) - topic8 := bizangela2.NewPullFeedTopic(angelaBase, topic7, topic) - angela, err := bizangela2.NewAngela(angelaBase, mq, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) - if err != nil { - cleanup() - return nil, nil, err - } - key := biztiphereth.NewUserCountCache(tipherethRepo, store) - tiphereth, err := biztiphereth.NewTiphereth(settings, tipherethRepo, auth, supervisorSupervisor, idGenerator, search, topic4, cron, key, libcacheMap) - if err != nil { - cleanup() - return nil, nil, err - } - gebura := bizgebura.NewGebura(geburaRepo, auth, idGenerator, search, librarianPorterServiceClient, supervisorSupervisor, libmqTopic, topic2, map3) - binahRepo, err := data.NewBinahRepo(s3) - if err != nil { - cleanup() - return nil, nil, err - } - controlBlock := bizbinah.NewControlBlock(auth) - binah := bizbinah.NewBinah(binahRepo, controlBlock, auth) - yesodRepo := data.NewYesodRepo(dataData) - map7 := bizyesod.NewFeedOwnerCache(yesodRepo, store) - yesod, err := bizyesod.NewYesod(yesodRepo, supervisorSupervisor, cron, idGenerator, search, topic8, topic, map7) - if err != nil { - cleanup() - return nil, nil, err - } - netzach, err := biznetzach2.NewNetzach(netzachRepo, supervisorSupervisor, idGenerator, search, mq, map5, map4, map6, topic) - if err != nil { - cleanup() - return nil, nil, err - } - chesedRepo := data.NewChesedRepo(dataData) - map8 := bizchesed.NewImageCache(store) - chesed, err := bizchesed.NewChesed(chesedRepo, binahRepo, idGenerator, search, cron, librarianPorterServiceClient, librarianMinerServiceClient, controlBlock, map8) - if err != nil { - cleanup() - return nil, nil, err - } - librarianSephirahServiceServer := sephirah.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, auth, sephirahServer) - return librarianSephirahServiceServer, func() { - cleanup() - }, nil -} diff --git a/cmd/librarian/wire_gen.go b/cmd/librarian/wire_gen.go deleted file mode 100644 index 59507bf6..00000000 --- a/cmd/librarian/wire_gen.go +++ /dev/null @@ -1,102 +0,0 @@ -// Code generated by Wire. DO NOT EDIT. - -//go:generate go run -mod=mod github.com/google/wire/cmd/wire -//go:build !wireinject -// +build !wireinject - -package main - -import ( - "github.com/go-kratos/kratos/v2" - "github.com/tuihub/librarian/app/miner/pkg/service" - service2 "github.com/tuihub/librarian/app/sephirah/pkg/service" - "github.com/tuihub/librarian/internal/conf" - "github.com/tuihub/librarian/internal/inprocgrpc" - "github.com/tuihub/librarian/internal/lib/libapp" - "github.com/tuihub/librarian/internal/lib/libauth" - "github.com/tuihub/librarian/internal/lib/libcache" - "github.com/tuihub/librarian/internal/lib/libcron" - "github.com/tuihub/librarian/internal/lib/libidgenerator" - "github.com/tuihub/librarian/internal/lib/libmq" - "github.com/tuihub/librarian/internal/lib/libobserve" - "github.com/tuihub/librarian/internal/lib/libsearch" - "github.com/tuihub/librarian/internal/server" -) - -// Injectors from wire.go: - -// wireApp init kratos application. -func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDiscovery, sephirahServer *conf.SephirahServer, database *conf.Database, s3 *conf.S3, porter *conf.Porter, miner_Data *conf.Miner_Data, auth *conf.Auth, mq *conf.MQ, cache *conf.Cache, consul *conf.Consul, search *conf.Search, settings *libapp.Settings) (*kratos.App, func(), error) { - libauthAuth, err := libauth.NewAuth(auth) - if err != nil { - return nil, nil, err - } - builtInObserver, err := libobserve.NewBuiltInObserver() - if err != nil { - return nil, nil, err - } - libmqMQ, cleanup, err := libmq.NewMQ(mq, database, cache, settings, builtInObserver) - if err != nil { - return nil, nil, err - } - cron, err := libcron.NewCron() - if err != nil { - cleanup() - return nil, nil, err - } - store, err := libcache.NewStore(cache) - if err != nil { - cleanup() - return nil, nil, err - } - idGenerator := libidgenerator.NewIDGenerator() - libsearchSearch, err := libsearch.NewSearch(search, settings) - if err != nil { - cleanup() - return nil, nil, err - } - librarianMinerServiceServer, cleanup2, err := service.NewMinerService(miner_Data, settings) - if err != nil { - cleanup() - return nil, nil, err - } - inprocClients := inprocgrpc.NewInprocClients(librarianMinerServiceServer) - librarianMinerServiceClient, err := minerClientSelector(librarian_EnableServiceDiscovery, consul, inprocClients, settings) - if err != nil { - cleanup2() - cleanup() - return nil, nil, err - } - librarianSephirahServiceServer, cleanup3, err := service2.NewSephirahService(sephirahServer, database, s3, porter, consul, libauthAuth, libmqMQ, cron, store, settings, idGenerator, libsearchSearch, librarianMinerServiceClient) - if err != nil { - cleanup2() - cleanup() - return nil, nil, err - } - grpcServer, err := server.NewGRPCServer(sephirahServer, libauthAuth, librarianSephirahServiceServer, settings, builtInObserver) - if err != nil { - cleanup3() - cleanup2() - cleanup() - return nil, nil, err - } - httpServer, err := server.NewGrpcWebServer(grpcServer, sephirahServer, libauthAuth, settings, builtInObserver) - if err != nil { - cleanup3() - cleanup2() - cleanup() - return nil, nil, err - } - app, err := newApp(grpcServer, httpServer, libmqMQ, cron, builtInObserver, consul) - if err != nil { - cleanup3() - cleanup2() - cleanup() - return nil, nil, err - } - return app, func() { - cleanup3() - cleanup2() - cleanup() - }, nil -} diff --git a/go.mod b/go.mod index 7eec3f57..4dfb744b 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250210091908-15168b5a1b7d github.com/go-kratos/kratos/v2 v2.8.3 - github.com/gofiber/contrib/jwt v1.0.10 github.com/gofiber/fiber/v2 v2.52.6 github.com/gofiber/template/html/v2 v2.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 @@ -65,7 +64,6 @@ require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.5-20250130201111-63bb56e20495.1 // indirect cel.dev/expr v0.19.1 // indirect dario.cat/mergo v1.0.0 // indirect - github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect github.com/Rican7/retry v0.3.1 // indirect github.com/RoaringBitmap/roaring v1.9.3 // indirect github.com/agext/levenshtein v1.2.3 // indirect @@ -102,7 +100,6 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/dave/jennifer v1.6.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect @@ -138,7 +135,6 @@ require ( github.com/jhump/protoreflect v1.15.1 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect - github.com/jmattheis/goverter v1.5.0 // indirect github.com/jonboulle/clockwork v0.5.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect diff --git a/go.sum b/go.sum index e2e4af91..e0203528 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,6 @@ github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20O github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/MicahParks/keyfunc/v2 v2.1.0 h1:6ZXKb9Rp6qp1bDbJefnG7cTH8yMN1IC/4nf+GVjO99k= -github.com/MicahParks/keyfunc/v2 v2.1.0/go.mod h1:rW42fi+xgLJ2FRRXAfNx9ZA8WpD4OeE/yHVMteCkw9k= github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8= github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU= github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc= @@ -157,8 +155,6 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/dave/jennifer v1.6.0 h1:MQ/6emI2xM7wt0tJzJzyUik2Q3Tcn2eE0vtYgh4GPVI= -github.com/dave/jennifer v1.6.0/go.mod h1:AxTG893FiZKqxy3FP1kL80VMshSMuz2G+EgvszgGRnk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -264,8 +260,6 @@ github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/gofiber/contrib/jwt v1.0.10 h1:/ilGepl6i0Bntl0Zcd+lAzagY8BiS1+fEiAj32HMApk= -github.com/gofiber/contrib/jwt v1.0.10/go.mod h1:1qBENE6sZ6PPT4xIpBzx1VxeyROQO7sj48OlM1I9qdU= github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI= github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc= @@ -412,8 +406,6 @@ github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmK github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= -github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E= github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= @@ -443,8 +435,6 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jmattheis/goverter v1.5.0 h1:3ANt/y+OzmB63Kw55ejYPv0J44RqNY781zNETVgi8WQ= -github.com/jmattheis/goverter v1.5.0/go.mod h1:iVIl/4qItWjWj2g3vjouGoYensJbRqDHpzlEVMHHFeY= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -574,8 +564,6 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -684,10 +672,7 @@ github.com/sony/sonyflake v1.2.0 h1:Pfr3A+ejSg+0SPqpoAmQgEtNDAhc2G1SUYk205qVMLQ= github.com/sony/sonyflake v1.2.0/go.mod h1:LORtCywH/cq10ZbyfhKrHYgAUGH7mOBa76enV9txy/Y= github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= diff --git a/cmd/librarian/main.go b/main.go similarity index 100% rename from cmd/librarian/main.go rename to main.go diff --git a/cmd/librarian/wire.go b/wire.go similarity index 79% rename from cmd/librarian/wire.go rename to wire.go index 353f9220..8a52d957 100644 --- a/cmd/librarian/wire.go +++ b/wire.go @@ -6,8 +6,10 @@ package main import ( minerService "github.com/tuihub/librarian/app/miner/pkg/service" - sephirahService "github.com/tuihub/librarian/app/sephirah/pkg/service" + "github.com/tuihub/librarian/internal/biz" + "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/inprocgrpc" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" @@ -18,6 +20,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libobserve" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/server" + "github.com/tuihub/librarian/internal/service/sephirah" + "github.com/tuihub/librarian/internal/service/supervisor" "github.com/go-kratos/kratos/v2" "github.com/google/wire" @@ -40,8 +44,12 @@ func wireApp( ) (*kratos.App, func(), error) { panic( wire.Build( - sephirahService.ProviderSet, minerService.ProviderSet, + data.ProviderSet, + biz.ProviderSet, + client.ProviderSet, + supervisor.ProviderSet, + sephirah.ProviderSet, server.ProviderSet, inprocgrpc.ProviderSet, libauth.ProviderSet, diff --git a/app/sephirah/cmd/sephirah/wire_gen.go b/wire_gen.go similarity index 68% rename from app/sephirah/cmd/sephirah/wire_gen.go rename to wire_gen.go index f07a5fe4..39e16641 100644 --- a/app/sephirah/cmd/sephirah/wire_gen.go +++ b/wire_gen.go @@ -8,18 +8,18 @@ package main import ( "github.com/go-kratos/kratos/v2" - bizangela2 "github.com/tuihub/librarian/internal/biz/bizangela" + "github.com/tuihub/librarian/app/miner/pkg/service" + "github.com/tuihub/librarian/internal/biz/bizangela" "github.com/tuihub/librarian/internal/biz/bizbinah" "github.com/tuihub/librarian/internal/biz/bizchesed" "github.com/tuihub/librarian/internal/biz/bizgebura" - biznetzach2 "github.com/tuihub/librarian/internal/biz/biznetzach" + "github.com/tuihub/librarian/internal/biz/biznetzach" "github.com/tuihub/librarian/internal/biz/biztiphereth" "github.com/tuihub/librarian/internal/biz/bizyesod" - client2 "github.com/tuihub/librarian/internal/client" "github.com/tuihub/librarian/internal/client/client" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/data" - data2 "github.com/tuihub/librarian/internal/data" + "github.com/tuihub/librarian/internal/inprocgrpc" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" @@ -36,7 +36,7 @@ import ( // Injectors from wire.go: // wireApp init kratos application. -func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *conf.S3, porter *conf.Porter, auth *conf.Auth, mq *conf.MQ, cache *conf.Cache, consul *conf.Consul, search *conf.Search, settings *libapp.Settings) (*kratos.App, func(), error) { +func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDiscovery, sephirahServer *conf.SephirahServer, database *conf.Database, s3 *conf.S3, porter *conf.Porter, miner_Data *conf.Miner_Data, auth *conf.Auth, mq *conf.MQ, cache *conf.Cache, consul *conf.Consul, search *conf.Search, settings *libapp.Settings) (*kratos.App, func(), error) { libauthAuth, err := libauth.NewAuth(auth) if err != nil { return nil, nil, err @@ -71,8 +71,8 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c } netzachRepo := data.NewNetzachRepo(dataData) idGenerator := libidgenerator.NewIDGenerator() - topic := biznetzach2.NewSystemNotificationTopic(netzachRepo, idGenerator) - tipherethRepo := data2.NewTipherethRepo(dataData) + topic := biznetzach.NewSystemNotificationTopic(netzachRepo, idGenerator) + tipherethRepo := data.NewTipherethRepo(dataData) store, err := libcache.NewStore(cache) if err != nil { cleanup2() @@ -94,25 +94,25 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c cleanup() return nil, nil, err } - angelaBase, err := bizangela2.NewAngelaBase(angelaRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, libsearchSearch, idGenerator) + angelaBase, err := bizangela.NewAngelaBase(angelaRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, libsearchSearch, idGenerator) if err != nil { cleanup2() cleanup() return nil, nil, err } - map3 := bizangela2.NewAppInfoCache(geburaRepo, store) - libmqTopic := bizangela2.NewUpdateAppInfoIndexTopic(angelaBase) - topic2 := bizangela2.NewPullAppInfoTopic(angelaBase, map3, libmqTopic) - topic3 := bizangela2.NewPullAccountAppInfoRelationTopic(angelaBase, topic2) - topic4 := bizangela2.NewPullAccountTopic(angelaBase, topic3) - map4 := bizangela2.NewNotifyFlowCache(netzachRepo, store) - map5 := bizangela2.NewFeedToNotifyFlowCache(netzachRepo, store) - map6 := bizangela2.NewNotifyTargetCache(netzachRepo, store) - topic5 := bizangela2.NewNotifyPushTopic(angelaBase, map6) - topic6 := bizangela2.NewNotifyRouterTopic(angelaBase, map4, map5, topic5) - topic7 := bizangela2.NewFeedItemPostprocessTopic(angelaBase, topic6, topic) - topic8 := bizangela2.NewPullFeedTopic(angelaBase, topic7, topic) - angela, err := bizangela2.NewAngela(angelaBase, libmqMQ, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) + map3 := bizangela.NewAppInfoCache(geburaRepo, store) + libmqTopic := bizangela.NewUpdateAppInfoIndexTopic(angelaBase) + topic2 := bizangela.NewPullAppInfoTopic(angelaBase, map3, libmqTopic) + topic3 := bizangela.NewPullAccountAppInfoRelationTopic(angelaBase, topic2) + topic4 := bizangela.NewPullAccountTopic(angelaBase, topic3) + map4 := bizangela.NewNotifyFlowCache(netzachRepo, store) + map5 := bizangela.NewFeedToNotifyFlowCache(netzachRepo, store) + map6 := bizangela.NewNotifyTargetCache(netzachRepo, store) + topic5 := bizangela.NewNotifyPushTopic(angelaBase, map6) + topic6 := bizangela.NewNotifyRouterTopic(angelaBase, map4, map5, topic5) + topic7 := bizangela.NewFeedItemPostprocessTopic(angelaBase, topic6, topic) + topic8 := bizangela.NewPullFeedTopic(angelaBase, topic7, topic) + angela, err := bizangela.NewAngela(angelaBase, libmqMQ, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) if err != nil { cleanup2() cleanup() @@ -148,22 +148,31 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c cleanup() return nil, nil, err } - netzach, err := biznetzach2.NewNetzach(netzachRepo, supervisorSupervisor, idGenerator, libsearchSearch, libmqMQ, map5, map4, map6, topic) + netzach, err := biznetzach.NewNetzach(netzachRepo, supervisorSupervisor, idGenerator, libsearchSearch, libmqMQ, map5, map4, map6, topic) if err != nil { cleanup2() cleanup() return nil, nil, err } chesedRepo := data.NewChesedRepo(dataData) - librarianMinerServiceClient, err := client2.NewMinerClient(consul, settings) + librarianMinerServiceServer, cleanup3, err := service.NewMinerService(miner_Data, settings) if err != nil { cleanup2() cleanup() return nil, nil, err } + inprocClients := inprocgrpc.NewInprocClients(librarianMinerServiceServer) + librarianMinerServiceClient, err := minerClientSelector(librarian_EnableServiceDiscovery, consul, inprocClients, settings) + if err != nil { + cleanup3() + cleanup2() + cleanup() + return nil, nil, err + } map8 := bizchesed.NewImageCache(store) chesed, err := bizchesed.NewChesed(chesedRepo, binahRepo, idGenerator, libsearchSearch, cron, librarianPorterServiceClient, librarianMinerServiceClient, controlBlock, map8) if err != nil { + cleanup3() cleanup2() cleanup() return nil, nil, err @@ -171,24 +180,27 @@ func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *c librarianSephirahServiceServer := sephirah.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, libauthAuth, sephirahServer) grpcServer, err := server.NewGRPCServer(sephirahServer, libauthAuth, librarianSephirahServiceServer, settings, builtInObserver) if err != nil { + cleanup3() cleanup2() cleanup() return nil, nil, err } httpServer, err := server.NewGrpcWebServer(grpcServer, sephirahServer, libauthAuth, settings, builtInObserver) if err != nil { + cleanup3() cleanup2() cleanup() return nil, nil, err } - registrar, err := libapp.NewRegistrar(consul) + app, err := newApp(grpcServer, httpServer, libmqMQ, cron, builtInObserver, consul) if err != nil { + cleanup3() cleanup2() cleanup() return nil, nil, err } - app := newApp(grpcServer, httpServer, libmqMQ, cron, registrar) return app, func() { + cleanup3() cleanup2() cleanup() }, nil From 8cbb7db38fc9706820b8027f6e95fa87861b184c Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 22 Mar 2025 01:04:27 +0800 Subject: [PATCH 13/19] feat: delete repo interface --- internal/biz/biz.go | 4 +- internal/biz/bizangela/angela.go | 125 ------------------ internal/biz/bizchesed/chesed.go | 13 +- internal/biz/bizgebura/app_info.go | 12 +- internal/biz/bizgebura/gebura.go | 47 ++----- .../biz/{bizangela => bizkether}/account.go | 22 +-- internal/biz/{bizangela => bizkether}/app.go | 20 +-- internal/biz/{bizangela => bizkether}/feed.go | 22 +-- .../biz/{bizangela => bizkether}/index.go | 12 +- internal/biz/bizkether/kether.go | 105 +++++++++++++++ .../biz/{bizangela => bizkether}/notify.go | 42 +++--- .../biz/{bizangela => bizkether}/porter.go | 4 +- internal/biz/biznetzach/netzach.go | 31 +---- internal/biz/biznetzach/system.go | 3 +- internal/biz/biztiphereth/tiphereth.go | 44 +----- internal/biz/bizyesod/yesod.go | 39 +----- internal/data/chesed.go | 17 ++- internal/data/data.go | 2 +- internal/data/gebura.go | 47 ++++--- internal/data/{angela.go => kether.go} | 63 +++++---- internal/data/netzach.go | 29 ++-- internal/data/tiphereth.go | 61 +++++---- internal/data/yesod.go | 49 ++++--- .../modelkether.go} | 2 +- .../service/sephirah/converter/biz_to_pb.go | 2 +- .../service/sephirah/converter/generated.go | 114 ++++++++-------- .../service/sephirah/converter/pb_to_biz.go | 2 +- .../sephirah/librariansephirahservice.go | 6 +- wire_gen.go | 34 ++--- 29 files changed, 414 insertions(+), 559 deletions(-) delete mode 100644 internal/biz/bizangela/angela.go rename internal/biz/{bizangela => bizkether}/account.go (85%) rename internal/biz/{bizangela => bizkether}/app.go (84%) rename internal/biz/{bizangela => bizkether}/feed.go (92%) rename internal/biz/{bizangela => bizkether}/index.go (70%) create mode 100644 internal/biz/bizkether/kether.go rename internal/biz/{bizangela => bizkether}/notify.go (84%) rename internal/biz/{bizangela => bizkether}/porter.go (89%) rename internal/data/{angela.go => kether.go} (84%) rename internal/model/{modelangela/modelangela.go => modelkether/modelkether.go} (97%) diff --git a/internal/biz/biz.go b/internal/biz/biz.go index c461ebfa..e0c04e3d 100644 --- a/internal/biz/biz.go +++ b/internal/biz/biz.go @@ -1,10 +1,10 @@ package biz import ( - "github.com/tuihub/librarian/internal/biz/bizangela" "github.com/tuihub/librarian/internal/biz/bizbinah" "github.com/tuihub/librarian/internal/biz/bizchesed" "github.com/tuihub/librarian/internal/biz/bizgebura" + "github.com/tuihub/librarian/internal/biz/bizkether" "github.com/tuihub/librarian/internal/biz/biznetzach" "github.com/tuihub/librarian/internal/biz/biztiphereth" "github.com/tuihub/librarian/internal/biz/bizyesod" @@ -14,7 +14,7 @@ import ( // ProviderSet is biz providers. var ProviderSet = wire.NewSet( - bizangela.ProviderSet, + bizkether.ProviderSet, biztiphereth.ProviderSet, bizgebura.NewGebura, bizbinah.ProviderSet, diff --git a/internal/biz/bizangela/angela.go b/internal/biz/bizangela/angela.go deleted file mode 100644 index e6cc2956..00000000 --- a/internal/biz/bizangela/angela.go +++ /dev/null @@ -1,125 +0,0 @@ -package bizangela - -import ( - "context" - - "github.com/tuihub/librarian/internal/biz/bizgebura" - "github.com/tuihub/librarian/internal/lib/libidgenerator" - "github.com/tuihub/librarian/internal/lib/libmq" - "github.com/tuihub/librarian/internal/lib/libsearch" - "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelangela" - "github.com/tuihub/librarian/internal/model/modelfeed" - "github.com/tuihub/librarian/internal/model/modelgebura" - "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modelyesod" - "github.com/tuihub/librarian/internal/service/supervisor" - porter "github.com/tuihub/protos/pkg/librarian/porter/v1" - - "github.com/google/wire" -) - -var ProviderSet = wire.NewSet( - NewAngela, - NewAngelaBase, - NewPullAccountTopic, - NewPullAccountAppInfoRelationTopic, - NewPullAppInfoTopic, - NewAppInfoCache, - NewPullFeedTopic, - NewNotifyRouterTopic, - NewNotifyPushTopic, - NewFeedToNotifyFlowCache, - NewNotifyFlowCache, - NewNotifyTargetCache, - NewFeedItemPostprocessTopic, - NewUpdateAppInfoIndexTopic, -) - -type Angela struct { - AngelaBase - mq *libmq.MQ -} -type AngelaBase struct { - repo AngelaRepo - supv *supervisor.Supervisor - g bizgebura.GeburaRepo - porter porter.LibrarianPorterServiceClient - search libsearch.Search - id *libidgenerator.IDGenerator -} - -type AngelaRepo interface { - UpsertAccount(context.Context, model.Account) error - UpsertAppInfo(context.Context, *modelgebura.AppInfo, *modelgebura.AppInfo) error - UpsertAppInfos(context.Context, []*modelgebura.AppInfo) error - AccountPurchaseAppInfos(context.Context, model.InternalID, []model.InternalID) error - UpsertFeed(context.Context, *modelfeed.Feed) error - CheckNewFeedItems(context.Context, []*modelfeed.Item, model.InternalID) ([]string, error) - UpsertFeedItems(context.Context, []*modelfeed.Item, model.InternalID) error - UpdateFeedPullStatus(context.Context, *modelyesod.FeedConfig) error - GetFeedItem(context.Context, model.InternalID) (*modelfeed.Item, error) - GetFeedActions(context.Context, model.InternalID) ([]*modelyesod.FeedActionSet, error) - GetNotifyTargetItems(context.Context, model.InternalID, model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) - AddFeedItemsToCollection(context.Context, model.InternalID, []model.InternalID) error -} - -func NewAngelaBase( - repo AngelaRepo, - supv *supervisor.Supervisor, - g bizgebura.GeburaRepo, - pClient porter.LibrarianPorterServiceClient, - search libsearch.Search, - id *libidgenerator.IDGenerator, -) (*AngelaBase, error) { - return &AngelaBase{ - repo: repo, - supv: supv, - g: g, - porter: pClient, - search: search, - id: id, - }, nil -} - -func NewAngela( - base *AngelaBase, - mq *libmq.MQ, - pullAccountInfo *libmq.Topic[model.PullAccountInfo], - pullAccountAppInfoRelation *libmq.Topic[modelangela.PullAccountAppInfoRelation], - pullAppInfo *libmq.Topic[modelangela.PullAppInfo], - pullFeed *libmq.Topic[modelyesod.PullFeed], - notifyRouter *libmq.Topic[modelangela.NotifyRouter], - notifyPush *libmq.Topic[modelangela.NotifyPush], - itemPostprocess *libmq.Topic[modelangela.FeedItemPostprocess], - updateAppIndex *libmq.Topic[modelangela.UpdateAppInfoIndex], -) (*Angela, error) { - if err := mq.RegisterTopic(pullAccountInfo); err != nil { - return nil, err - } - if err := mq.RegisterTopic(pullAccountAppInfoRelation); err != nil { - return nil, err - } - if err := mq.RegisterTopic(pullAppInfo); err != nil { - return nil, err - } - if err := mq.RegisterTopic(pullFeed); err != nil { - return nil, err - } - if err := mq.RegisterTopic(notifyRouter); err != nil { - return nil, err - } - if err := mq.RegisterTopic(notifyPush); err != nil { - return nil, err - } - if err := mq.RegisterTopic(itemPostprocess); err != nil { - return nil, err - } - if err := mq.RegisterTopic(updateAppIndex); err != nil { - return nil, err - } - return &Angela{ - AngelaBase: *base, - mq: mq, - }, nil -} diff --git a/internal/biz/bizchesed/chesed.go b/internal/biz/bizchesed/chesed.go index 8816249f..27300ff4 100644 --- a/internal/biz/bizchesed/chesed.go +++ b/internal/biz/bizchesed/chesed.go @@ -7,6 +7,7 @@ import ( "github.com/tuihub/librarian/internal/biz/bizbinah" "github.com/tuihub/librarian/internal/biz/bizutils" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libcron" @@ -29,16 +30,8 @@ var ProviderSet = wire.NewSet( NewImageCache, ) -type ChesedRepo interface { - CreateImage(context.Context, model.InternalID, *modelchesed.Image) error - ListImages(context.Context, model.InternalID, model.Paging) ([]*modelchesed.Image, int64, error) - ListImageNeedScan(context.Context) ([]*modelchesed.Image, error) - SetImageStatus(context.Context, model.InternalID, modelchesed.ImageStatus) error - GetImage(context.Context, model.InternalID, model.InternalID) (*modelchesed.Image, error) -} - type Chesed struct { - repo ChesedRepo + repo *data.ChesedRepo b bizbinah.BinahRepo id *libidgenerator.IDGenerator search libsearch.Search @@ -51,7 +44,7 @@ type Chesed struct { } func NewChesed( - repo ChesedRepo, + repo *data.ChesedRepo, b bizbinah.BinahRepo, id *libidgenerator.IDGenerator, search libsearch.Search, diff --git a/internal/biz/bizgebura/app_info.go b/internal/biz/bizgebura/app_info.go index fe8fa543..13954f2d 100644 --- a/internal/biz/bizgebura/app_info.go +++ b/internal/biz/bizgebura/app_info.go @@ -9,8 +9,8 @@ import ( "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelkether" "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" @@ -37,7 +37,7 @@ func (g *Gebura) CreateAppInfo( if err = g.repo.CreateAppInfo(ctx, appInfo); err != nil { return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error()) } - _ = g.updateAppInfoIndex.Publish(ctx, modelangela.UpdateAppInfoIndex{IDs: []model.InternalID{appInfo.ID}}) + _ = g.updateAppInfoIndex.Publish(ctx, modelkether.UpdateAppInfoIndex{IDs: []model.InternalID{appInfo.ID}}) return appInfo, nil } @@ -50,7 +50,7 @@ func (g *Gebura) UpdateAppInfo(ctx context.Context, appInfo *modelgebura.AppInfo if err != nil { return pb.ErrorErrorReasonUnspecified("%s", err.Error()) } - _ = g.updateAppInfoIndex.Publish(ctx, modelangela.UpdateAppInfoIndex{IDs: []model.InternalID{appInfo.ID}}) + _ = g.updateAppInfoIndex.Publish(ctx, modelkether.UpdateAppInfoIndex{IDs: []model.InternalID{appInfo.ID}}) return nil } @@ -82,7 +82,7 @@ func (g *Gebura) MergeAppInfos(ctx context.Context, base modelgebura.AppInfo, me if err := g.repo.MergeAppInfos(ctx, base, merged); err != nil { return pb.ErrorErrorReasonUnspecified("%s", err) } - _ = g.updateAppInfoIndex.Publish(ctx, modelangela.UpdateAppInfoIndex{IDs: []model.InternalID{base.ID}}) + _ = g.updateAppInfoIndex.Publish(ctx, modelkether.UpdateAppInfoIndex{IDs: []model.InternalID{base.ID}}) return nil } @@ -104,7 +104,7 @@ func (g *Gebura) SyncAppInfos( continue } if wait { - err = g.pullAppInfo.LocalCall(ctx, modelangela.PullAppInfo{ + err = g.pullAppInfo.LocalCall(ctx, modelkether.PullAppInfo{ ID: ids[i], AppInfoID: *infoID, IgnoreRateLimit: false, @@ -119,7 +119,7 @@ func (g *Gebura) SyncAppInfos( } appInfos = append(appInfos, app) } else { - _ = g.pullAppInfo.Publish(ctx, modelangela.PullAppInfo{ + _ = g.pullAppInfo.Publish(ctx, modelkether.PullAppInfo{ ID: ids[i], AppInfoID: *infoID, IgnoreRateLimit: false, diff --git a/internal/biz/bizgebura/gebura.go b/internal/biz/bizgebura/gebura.go index 230337f5..2b245904 100644 --- a/internal/biz/bizgebura/gebura.go +++ b/internal/biz/bizgebura/gebura.go @@ -2,16 +2,15 @@ package bizgebura import ( "context" - "time" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libidgenerator" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libsearch" - "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelkether" "github.com/tuihub/librarian/internal/service/supervisor" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" @@ -22,57 +21,27 @@ type ReportAppPackageHandler interface { Handle(context.Context, []*modelgebura.AppBinary) *errors.Error } -type GeburaRepo interface { - CreateAppInfo(context.Context, *modelgebura.AppInfo) error - CreateAppInfoOrGet(context.Context, *modelgebura.AppInfo) (*modelgebura.AppInfo, error) - UpdateAppInfo(context.Context, *modelgebura.AppInfo) error - ListAppInfos(context.Context, model.Paging, []string, []modelgebura.AppType, - []model.InternalID, bool) ([]*modelgebura.AppInfo, int64, error) - MergeAppInfos(context.Context, modelgebura.AppInfo, model.InternalID) error - GetAppInfo(context.Context, modelgebura.AppInfoID) (*modelgebura.AppInfo, error) - GetBoundAppInfos(context.Context, model.InternalID) ([]*modelgebura.AppInfo, error) - GetBatchBoundAppInfos(context.Context, []model.InternalID) ([]*modelgebura.BoundAppInfos, error) - PurchaseAppInfo(context.Context, model.InternalID, - *modelgebura.AppInfoID, func(ctx2 context.Context) error) (model.InternalID, error) - GetPurchasedAppInfos(context.Context, model.InternalID, string) ([]*modelgebura.BoundAppInfos, error) - - CreateApp(context.Context, model.InternalID, *modelgebura.App) error - UpdateApp(context.Context, model.InternalID, *modelgebura.App) error - ListApps(context.Context, model.Paging, []model.InternalID, []model.InternalID, - []model.InternalID, bool) ([]*modelgebura.App, int, error) - AssignApp(context.Context, model.InternalID, model.InternalID, model.InternalID) error - // ListAppPackageBinaryChecksumOfOneSource(context.Context, modelgebura.AppPackageSource, - // model.InternalID) ([]string, error) - UnAssignApp(context.Context, model.InternalID, model.InternalID) error - AddAppInstRunTime(context.Context, model.InternalID, model.InternalID, *model.TimeRange) error - SumAppInstRunTime(context.Context, model.InternalID, model.InternalID, *model.TimeRange) (time.Duration, error) - CreateAppInst(context.Context, model.InternalID, *modelgebura.AppInst) error - UpdateAppInst(context.Context, model.InternalID, *modelgebura.AppInst) error - ListAppInsts(context.Context, model.InternalID, model.Paging, []model.InternalID, - []model.InternalID, []model.InternalID) ([]*modelgebura.AppInst, int, error) -} - type Gebura struct { auth *libauth.Auth - repo GeburaRepo + repo *data.GeburaRepo id *libidgenerator.IDGenerator search libsearch.Search porter porter.LibrarianPorterServiceClient supv *supervisor.Supervisor - updateAppInfoIndex *libmq.Topic[modelangela.UpdateAppInfoIndex] - pullAppInfo *libmq.Topic[modelangela.PullAppInfo] + updateAppInfoIndex *libmq.Topic[modelkether.UpdateAppInfoIndex] + pullAppInfo *libmq.Topic[modelkether.PullAppInfo] appInfoCache *libcache.Map[modelgebura.AppInfoID, modelgebura.AppInfo] } func NewGebura( - repo GeburaRepo, + repo *data.GeburaRepo, auth *libauth.Auth, id *libidgenerator.IDGenerator, search libsearch.Search, pClient porter.LibrarianPorterServiceClient, supv *supervisor.Supervisor, - updateAppIndex *libmq.Topic[modelangela.UpdateAppInfoIndex], - pullAppInfo *libmq.Topic[modelangela.PullAppInfo], + updateAppIndex *libmq.Topic[modelkether.UpdateAppInfoIndex], + pullAppInfo *libmq.Topic[modelkether.PullAppInfo], appInfoCache *libcache.Map[modelgebura.AppInfoID, modelgebura.AppInfo], ) *Gebura { return &Gebura{ diff --git a/internal/biz/bizangela/account.go b/internal/biz/bizkether/account.go similarity index 85% rename from internal/biz/bizangela/account.go rename to internal/biz/bizkether/account.go index 1edfd13e..9386b576 100644 --- a/internal/biz/bizangela/account.go +++ b/internal/biz/bizkether/account.go @@ -1,4 +1,4 @@ -package bizangela +package bizkether import ( "context" @@ -6,16 +6,16 @@ import ( "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelkether" "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) func NewPullAccountTopic( - a *AngelaBase, - sr *libmq.Topic[modelangela.PullAccountAppInfoRelation], + a *KetherBase, + sr *libmq.Topic[modelkether.PullAccountAppInfoRelation], ) *libmq.Topic[model.PullAccountInfo] { return libmq.NewTopic[model.PullAccountInfo]( "PullAccountInfo", @@ -46,7 +46,7 @@ func NewPullAccountTopic( return err } return sr. - Publish(ctx, modelangela.PullAccountAppInfoRelation{ + Publish(ctx, modelkether.PullAccountAppInfoRelation{ ID: info.ID, Platform: info.Platform, PlatformAccountID: info.PlatformAccountID, @@ -56,12 +56,12 @@ func NewPullAccountTopic( } func NewPullAccountAppInfoRelationTopic( - a *AngelaBase, - sa *libmq.Topic[modelangela.PullAppInfo], -) *libmq.Topic[modelangela.PullAccountAppInfoRelation] { - return libmq.NewTopic[modelangela.PullAccountAppInfoRelation]( + a *KetherBase, + sa *libmq.Topic[modelkether.PullAppInfo], +) *libmq.Topic[modelkether.PullAccountAppInfoRelation] { + return libmq.NewTopic[modelkether.PullAccountAppInfoRelation]( "PullAccountAppInfoRelation", - func(ctx context.Context, r *modelangela.PullAccountAppInfoRelation) error { + func(ctx context.Context, r *modelkether.PullAccountAppInfoRelation) error { if !a.supv.HasAccountPlatform(r.Platform) { return nil } @@ -103,7 +103,7 @@ func NewPullAccountAppInfoRelationTopic( return err } for _, info := range infos { - _ = sa.Publish(ctx, modelangela.PullAppInfo{ + _ = sa.Publish(ctx, modelkether.PullAppInfo{ ID: info.ID, AppInfoID: modelgebura.AppInfoID{ Internal: false, diff --git a/internal/biz/bizangela/app.go b/internal/biz/bizkether/app.go similarity index 84% rename from internal/biz/bizangela/app.go rename to internal/biz/bizkether/app.go index 2b39ef60..ccb36e9e 100644 --- a/internal/biz/bizangela/app.go +++ b/internal/biz/bizkether/app.go @@ -1,30 +1,30 @@ -package bizangela +package bizkether import ( "context" "strconv" "time" - "github.com/tuihub/librarian/internal/biz/bizgebura" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelgebura" + "github.com/tuihub/librarian/internal/model/modelkether" "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) func NewPullAppInfoTopic( - a *AngelaBase, + a *KetherBase, infoCache *libcache.Map[modelgebura.AppInfoID, modelgebura.AppInfo], - updateAppInfoIndex *libmq.Topic[modelangela.UpdateAppInfoIndex], -) *libmq.Topic[modelangela.PullAppInfo] { - return libmq.NewTopic[modelangela.PullAppInfo]( + updateAppInfoIndex *libmq.Topic[modelkether.UpdateAppInfoIndex], +) *libmq.Topic[modelkether.PullAppInfo] { + return libmq.NewTopic[modelkether.PullAppInfo]( "PullAppInfo", - func(ctx context.Context, r *modelangela.PullAppInfo) error { + func(ctx context.Context, r *modelkether.PullAppInfo) error { if !a.supv.HasAppInfoSource(r.AppInfoID.Source) { return nil } @@ -70,14 +70,14 @@ func NewPullAppInfoTopic( return err } _ = infoCache.Delete(ctx, r.AppInfoID) - _ = updateAppInfoIndex.Publish(ctx, modelangela.UpdateAppInfoIndex{IDs: []model.InternalID{id}}) + _ = updateAppInfoIndex.Publish(ctx, modelkether.UpdateAppInfoIndex{IDs: []model.InternalID{id}}) return nil }, ) } func NewAppInfoCache( - g bizgebura.GeburaRepo, + g *data.GeburaRepo, store libcache.Store, ) *libcache.Map[modelgebura.AppInfoID, modelgebura.AppInfo] { return libcache.NewMap[modelgebura.AppInfoID, modelgebura.AppInfo]( diff --git a/internal/biz/bizangela/feed.go b/internal/biz/bizkether/feed.go similarity index 92% rename from internal/biz/bizangela/feed.go rename to internal/biz/bizkether/feed.go index c293029d..d24dab95 100644 --- a/internal/biz/bizangela/feed.go +++ b/internal/biz/bizkether/feed.go @@ -1,4 +1,4 @@ -package bizangela +package bizkether import ( "context" @@ -9,8 +9,8 @@ import ( "github.com/tuihub/librarian/internal/biz/bizyesod" "github.com/tuihub/librarian/internal/lib/libmq" - "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelkether" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelyesod" "github.com/tuihub/librarian/internal/service/sephirah/converter" @@ -18,8 +18,8 @@ import ( ) func NewPullFeedTopic( //nolint:gocognit // TODO - a *AngelaBase, - parse *libmq.Topic[modelangela.FeedItemPostprocess], + a *KetherBase, + parse *libmq.Topic[modelkether.FeedItemPostprocess], systemNotify *libmq.Topic[modelnetzach.SystemNotify], ) *libmq.Topic[modelyesod.PullFeed] { return libmq.NewTopic[modelyesod.PullFeed]( @@ -94,7 +94,7 @@ func NewPullFeedTopic( //nolint:gocognit // TODO // Queue FeedItemPostprocess for _, item := range feed.Items { if slices.Contains(newItemGUIDs, item.GUID) { - err = parse.Publish(ctx, modelangela.FeedItemPostprocess{ + err = parse.Publish(ctx, modelkether.FeedItemPostprocess{ FeedID: feed.ID, Item: item, SystemNotify: p.SystemNotify, @@ -110,13 +110,13 @@ func NewPullFeedTopic( //nolint:gocognit // TODO } func NewFeedItemPostprocessTopic( //nolint:gocognit // TODO - a *AngelaBase, - notify *libmq.Topic[modelangela.NotifyRouter], + a *KetherBase, + notify *libmq.Topic[modelkether.NotifyRouter], systemNotify *libmq.Topic[modelnetzach.SystemNotify], -) *libmq.Topic[modelangela.FeedItemPostprocess] { - return libmq.NewTopic[modelangela.FeedItemPostprocess]( +) *libmq.Topic[modelkether.FeedItemPostprocess] { + return libmq.NewTopic[modelkether.FeedItemPostprocess]( "FeedItemPostprocess", - func(ctx context.Context, p *modelangela.FeedItemPostprocess) error { + func(ctx context.Context, p *modelkether.FeedItemPostprocess) error { notifyMsg := p.SystemNotify if notifyMsg == nil { notifyMsg = new(modelnetzach.SystemNotify) @@ -195,7 +195,7 @@ func NewFeedItemPostprocessTopic( //nolint:gocognit // TODO notifyMsg.Notification.Content = fmt.Sprintf("UpsertFeedItems failed: %s", err.Error()) return err } - _ = notify.Publish(ctx, modelangela.NotifyRouter{ + _ = notify.Publish(ctx, modelkether.NotifyRouter{ FeedID: p.FeedID, Messages: []*modelfeed.Item{item}, }) diff --git a/internal/biz/bizangela/index.go b/internal/biz/bizkether/index.go similarity index 70% rename from internal/biz/bizangela/index.go rename to internal/biz/bizkether/index.go index e7014339..ebc552fd 100644 --- a/internal/biz/bizangela/index.go +++ b/internal/biz/bizkether/index.go @@ -1,19 +1,19 @@ -package bizangela +package bizkether import ( "context" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libsearch" - "github.com/tuihub/librarian/internal/model/modelangela" + "github.com/tuihub/librarian/internal/model/modelkether" ) func NewUpdateAppInfoIndexTopic( - a *AngelaBase, -) *libmq.Topic[modelangela.UpdateAppInfoIndex] { - return libmq.NewTopic[modelangela.UpdateAppInfoIndex]( + a *KetherBase, +) *libmq.Topic[modelkether.UpdateAppInfoIndex] { + return libmq.NewTopic[modelkether.UpdateAppInfoIndex]( "UpdateAppInfoIndex", - func(ctx context.Context, r *modelangela.UpdateAppInfoIndex) error { + func(ctx context.Context, r *modelkether.UpdateAppInfoIndex) error { infos, err := a.g.GetBatchBoundAppInfos(ctx, r.IDs) if err != nil { return err diff --git a/internal/biz/bizkether/kether.go b/internal/biz/bizkether/kether.go new file mode 100644 index 00000000..57d17c86 --- /dev/null +++ b/internal/biz/bizkether/kether.go @@ -0,0 +1,105 @@ +package bizkether + +import ( + "github.com/tuihub/librarian/internal/data" + "github.com/tuihub/librarian/internal/lib/libidgenerator" + "github.com/tuihub/librarian/internal/lib/libmq" + "github.com/tuihub/librarian/internal/lib/libsearch" + "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/model/modelkether" + "github.com/tuihub/librarian/internal/model/modelyesod" + "github.com/tuihub/librarian/internal/service/supervisor" + porter "github.com/tuihub/protos/pkg/librarian/porter/v1" + + "github.com/google/wire" +) + +var ProviderSet = wire.NewSet( + NewKether, + NewKetherBase, + NewPullAccountTopic, + NewPullAccountAppInfoRelationTopic, + NewPullAppInfoTopic, + NewAppInfoCache, + NewPullFeedTopic, + NewNotifyRouterTopic, + NewNotifyPushTopic, + NewFeedToNotifyFlowCache, + NewNotifyFlowCache, + NewNotifyTargetCache, + NewFeedItemPostprocessTopic, + NewUpdateAppInfoIndexTopic, +) + +type Kether struct { + KetherBase + mq *libmq.MQ +} +type KetherBase struct { + repo *data.KetherRepo + supv *supervisor.Supervisor + g *data.GeburaRepo + porter porter.LibrarianPorterServiceClient + search libsearch.Search + id *libidgenerator.IDGenerator +} + +func NewKetherBase( + repo *data.KetherRepo, + supv *supervisor.Supervisor, + g *data.GeburaRepo, + pClient porter.LibrarianPorterServiceClient, + search libsearch.Search, + id *libidgenerator.IDGenerator, +) (*KetherBase, error) { + return &KetherBase{ + repo: repo, + supv: supv, + g: g, + porter: pClient, + search: search, + id: id, + }, nil +} + +func NewKether( + base *KetherBase, + mq *libmq.MQ, + pullAccountInfo *libmq.Topic[model.PullAccountInfo], + pullAccountAppInfoRelation *libmq.Topic[modelkether.PullAccountAppInfoRelation], + pullAppInfo *libmq.Topic[modelkether.PullAppInfo], + pullFeed *libmq.Topic[modelyesod.PullFeed], + notifyRouter *libmq.Topic[modelkether.NotifyRouter], + notifyPush *libmq.Topic[modelkether.NotifyPush], + itemPostprocess *libmq.Topic[modelkether.FeedItemPostprocess], + updateAppIndex *libmq.Topic[modelkether.UpdateAppInfoIndex], +) (*Kether, error) { + if err := mq.RegisterTopic(pullAccountInfo); err != nil { + return nil, err + } + if err := mq.RegisterTopic(pullAccountAppInfoRelation); err != nil { + return nil, err + } + if err := mq.RegisterTopic(pullAppInfo); err != nil { + return nil, err + } + if err := mq.RegisterTopic(pullFeed); err != nil { + return nil, err + } + if err := mq.RegisterTopic(notifyRouter); err != nil { + return nil, err + } + if err := mq.RegisterTopic(notifyPush); err != nil { + return nil, err + } + if err := mq.RegisterTopic(itemPostprocess); err != nil { + return nil, err + } + if err := mq.RegisterTopic(updateAppIndex); err != nil { + return nil, err + } + return &Kether{ + KetherBase: *base, + mq: mq, + }, nil +} diff --git a/internal/biz/bizangela/notify.go b/internal/biz/bizkether/notify.go similarity index 84% rename from internal/biz/bizangela/notify.go rename to internal/biz/bizkether/notify.go index cbcd28b5..a29e6d83 100644 --- a/internal/biz/bizangela/notify.go +++ b/internal/biz/bizkether/notify.go @@ -1,4 +1,4 @@ -package bizangela +package bizkether import ( "context" @@ -6,27 +6,27 @@ import ( "strconv" "strings" - "github.com/tuihub/librarian/internal/biz/biznetzach" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelangela" "github.com/tuihub/librarian/internal/model/modelfeed" + "github.com/tuihub/librarian/internal/model/modelkether" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/service/sephirah/converter" porter "github.com/tuihub/protos/pkg/librarian/porter/v1" ) func NewNotifyRouterTopic( //nolint:gocognit // TODO - a *AngelaBase, + a *KetherBase, flowMap *libcache.Map[model.InternalID, modelnetzach.NotifyFlow], - feedToFlowMap *libcache.Map[model.InternalID, modelangela.FeedToNotifyFlowValue], - push *libmq.Topic[modelangela.NotifyPush], -) *libmq.Topic[modelangela.NotifyRouter] { - return libmq.NewTopic[modelangela.NotifyRouter]( + feedToFlowMap *libcache.Map[model.InternalID, modelkether.FeedToNotifyFlowValue], + push *libmq.Topic[modelkether.NotifyPush], +) *libmq.Topic[modelkether.NotifyRouter] { + return libmq.NewTopic[modelkether.NotifyRouter]( "NotifyRouter", - func(ctx context.Context, r *modelangela.NotifyRouter) error { + func(ctx context.Context, r *modelkether.NotifyRouter) error { flowIDs, err := feedToFlowMap.Get(ctx, r.FeedID) if err != nil { return err @@ -63,7 +63,7 @@ func NewNotifyRouterTopic( //nolint:gocognit // TODO if target == nil { continue } - err = push.Publish(ctx, modelangela.NotifyPush{ + err = push.Publish(ctx, modelkether.NotifyPush{ Target: *target, Messages: applyFilter(messages, target.Filter.IncludeKeywords, target.Filter.ExcludeKeywords), }) @@ -82,12 +82,12 @@ func NewNotifyRouterTopic( //nolint:gocognit // TODO } func NewNotifyPushTopic( - a *AngelaBase, + a *KetherBase, targetMap *libcache.Map[model.InternalID, modelnetzach.NotifyTarget], -) *libmq.Topic[modelangela.NotifyPush] { - return libmq.NewTopic[modelangela.NotifyPush]( +) *libmq.Topic[modelkether.NotifyPush] { + return libmq.NewTopic[modelkether.NotifyPush]( "NotifyPush", - func(ctx context.Context, p *modelangela.NotifyPush) error { + func(ctx context.Context, p *modelkether.NotifyPush) error { target, err := targetMap.Get(ctx, p.Target.TargetID) if err != nil { return err @@ -115,21 +115,21 @@ func NewNotifyPushTopic( // NewFeedToNotifyFlowCache Cache-Aside Pattern. func NewFeedToNotifyFlowCache( - n biznetzach.NetzachRepo, + n *data.NetzachRepo, store libcache.Store, -) *libcache.Map[model.InternalID, modelangela.FeedToNotifyFlowValue] { - return libcache.NewMap[model.InternalID, modelangela.FeedToNotifyFlowValue]( +) *libcache.Map[model.InternalID, modelkether.FeedToNotifyFlowValue] { + return libcache.NewMap[model.InternalID, modelkether.FeedToNotifyFlowValue]( store, "FeedToNotifyFlow", func(k model.InternalID) string { return strconv.FormatInt(int64(k), 10) }, - func(ctx context.Context, id model.InternalID) (*modelangela.FeedToNotifyFlowValue, error) { + func(ctx context.Context, id model.InternalID) (*modelkether.FeedToNotifyFlowValue, error) { res, err := n.GetNotifyFlowIDsWithFeed(ctx, id) if err != nil { return nil, err } - return (*modelangela.FeedToNotifyFlowValue)(&res), nil + return (*modelkether.FeedToNotifyFlowValue)(&res), nil }, libcache.WithExpiration(libtime.SevenDays), ) @@ -137,7 +137,7 @@ func NewFeedToNotifyFlowCache( // NewNotifyFlowCache Cache-Aside Pattern. func NewNotifyFlowCache( - n biznetzach.NetzachRepo, + n *data.NetzachRepo, store libcache.Store, ) *libcache.Map[model.InternalID, modelnetzach.NotifyFlow] { return libcache.NewMap[model.InternalID, modelnetzach.NotifyFlow]( @@ -159,7 +159,7 @@ func NewNotifyFlowCache( // NewNotifyTargetCache Cache-Aside Pattern. func NewNotifyTargetCache( - n biznetzach.NetzachRepo, + n *data.NetzachRepo, store libcache.Store, ) *libcache.Map[model.InternalID, modelnetzach.NotifyTarget] { return libcache.NewMap[model.InternalID, modelnetzach.NotifyTarget]( diff --git a/internal/biz/bizangela/porter.go b/internal/biz/bizkether/porter.go similarity index 89% rename from internal/biz/bizangela/porter.go rename to internal/biz/bizkether/porter.go index 195a8993..16622248 100644 --- a/internal/biz/bizangela/porter.go +++ b/internal/biz/bizkether/porter.go @@ -1,4 +1,4 @@ -package bizangela +package bizkether import ( "context" @@ -10,7 +10,7 @@ import ( "github.com/tuihub/librarian/internal/model/modelsupervisor" ) -func (a *Angela) PorterGetNotifyTargetItems(ctx context.Context, id model.InternalID, paging model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) { +func (a *Kether) PorterGetNotifyTargetItems(ctx context.Context, id model.InternalID, paging model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) { claims := libauth.FromContextAssertUserType(ctx, model.UserTypePorter) if claims == nil { return nil, nil, bizutils.NoPermissionError() diff --git a/internal/biz/biznetzach/netzach.go b/internal/biz/biznetzach/netzach.go index c8dbaf08..0e08304a 100644 --- a/internal/biz/biznetzach/netzach.go +++ b/internal/biz/biznetzach/netzach.go @@ -4,6 +4,7 @@ import ( "context" "github.com/tuihub/librarian/internal/biz/bizutils" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libidgenerator" @@ -11,7 +12,7 @@ import ( "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelangela" + "github.com/tuihub/librarian/internal/model/modelkether" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/service/supervisor" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" @@ -25,43 +26,23 @@ var ProviderSet = wire.NewSet( NewSystemNotificationTopic, ) -type NetzachRepo interface { - CreateNotifyTarget(context.Context, model.InternalID, *modelnetzach.NotifyTarget) error - UpdateNotifyTarget(context.Context, model.InternalID, *modelnetzach.NotifyTarget) error - ListNotifyTargets(context.Context, model.Paging, model.InternalID, []model.InternalID, - []modelnetzach.NotifyTargetStatus) ( - []*modelnetzach.NotifyTarget, int64, error) - GetNotifyTarget(context.Context, model.InternalID) (*modelnetzach.NotifyTarget, error) - CreateNotifyFlow(context.Context, model.InternalID, *modelnetzach.NotifyFlow) error - UpdateNotifyFlow(context.Context, model.InternalID, *modelnetzach.NotifyFlow) error - ListNotifyFlows(context.Context, model.Paging, model.InternalID, []model.InternalID) ( - []*modelnetzach.NotifyFlow, int64, error) - GetNotifyFlow(context.Context, model.InternalID) (*modelnetzach.NotifyFlow, error) - GetNotifyFlowIDsWithFeed(context.Context, model.InternalID) ([]model.InternalID, error) - - UpsertSystemNotification(context.Context, model.InternalID, *modelnetzach.SystemNotification) error - ListSystemNotifications(context.Context, model.Paging, *model.InternalID, []modelnetzach.SystemNotificationType, - []modelnetzach.SystemNotificationLevel, []modelnetzach.SystemNotificationStatus) ( - []*modelnetzach.SystemNotification, int64, error) -} - type Netzach struct { - repo NetzachRepo + repo *data.NetzachRepo supv *supervisor.Supervisor id *libidgenerator.IDGenerator search libsearch.Search - notifySourceCache *libcache.Map[model.InternalID, modelangela.FeedToNotifyFlowValue] + notifySourceCache *libcache.Map[model.InternalID, modelkether.FeedToNotifyFlowValue] notifyFlowCache *libcache.Map[model.InternalID, modelnetzach.NotifyFlow] notifyTargetCache *libcache.Map[model.InternalID, modelnetzach.NotifyTarget] } func NewNetzach( - repo NetzachRepo, + repo *data.NetzachRepo, supv *supervisor.Supervisor, id *libidgenerator.IDGenerator, search libsearch.Search, mq *libmq.MQ, - notifySourceCache *libcache.Map[model.InternalID, modelangela.FeedToNotifyFlowValue], + notifySourceCache *libcache.Map[model.InternalID, modelkether.FeedToNotifyFlowValue], notifyFlowCache *libcache.Map[model.InternalID, modelnetzach.NotifyFlow], notifyTargetCache *libcache.Map[model.InternalID, modelnetzach.NotifyTarget], systemNotification *libmq.Topic[modelnetzach.SystemNotify], diff --git a/internal/biz/biznetzach/system.go b/internal/biz/biznetzach/system.go index 26bf841b..6b213fa0 100644 --- a/internal/biz/biznetzach/system.go +++ b/internal/biz/biznetzach/system.go @@ -3,13 +3,14 @@ package biznetzach import ( "context" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libidgenerator" "github.com/tuihub/librarian/internal/lib/libmq" "github.com/tuihub/librarian/internal/model/modelnetzach" ) func NewSystemNotificationTopic( - repo NetzachRepo, + repo *data.NetzachRepo, idGenerator *libidgenerator.IDGenerator, ) *libmq.Topic[modelnetzach.SystemNotify] { return libmq.NewTopic[modelnetzach.SystemNotify]( diff --git a/internal/biz/biztiphereth/tiphereth.go b/internal/biz/biztiphereth/tiphereth.go index 8e41ab64..4c06fd2e 100644 --- a/internal/biz/biztiphereth/tiphereth.go +++ b/internal/biz/biztiphereth/tiphereth.go @@ -4,6 +4,7 @@ import ( "context" "strconv" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/libcache" @@ -27,43 +28,10 @@ var ProviderSet = wire.NewSet( NewPorterContextCache, ) -type TipherethRepo interface { - FetchUserByPassword(context.Context, string, string) (*model.User, error) - CreateUser(context.Context, *model.User, model.InternalID) error - UpdateUser(context.Context, *model.User, string) error - ListUsers(context.Context, model.Paging, []model.InternalID, - []model.UserType, []model.UserStatus, []model.InternalID, - model.InternalID) ([]*model.User, int64, error) - GetUserCount(context.Context) (int, error) - LinkAccount(context.Context, model.Account, model.InternalID) (model.InternalID, error) - UnLinkAccount(context.Context, model.Account, model.InternalID) error - ListLinkAccounts(context.Context, model.InternalID) ([]*model.Account, error) - GetUser(context.Context, model.InternalID) (*model.User, error) - UpsertPorters(context.Context, []*modelsupervisor.PorterInstance) error - ListPorters(context.Context, model.Paging) ([]*modelsupervisor.PorterInstance, int64, error) - FetchPorterByAddress(context.Context, string) (*modelsupervisor.PorterInstance, error) - UpdatePorterStatus(context.Context, model.InternalID, - model.UserStatus) (*modelsupervisor.PorterInstance, error) - CreatePorterContext(context.Context, model.InternalID, *modelsupervisor.PorterContext) error - GetEnabledPorterContexts(context.Context) ([]*modelsupervisor.PorterContext, error) - ListPorterContexts(context.Context, model.InternalID, model.Paging) ([]*modelsupervisor.PorterContext, int64, error) - UpdatePorterContext(context.Context, model.InternalID, *modelsupervisor.PorterContext) error - FetchPorterContext(context.Context, model.InternalID) (*modelsupervisor.PorterContext, error) - CreateDevice(context.Context, model.InternalID, *model.DeviceInfo, *string) (model.InternalID, error) - ListUserSessions(context.Context, model.InternalID) ([]*model.UserSession, error) - DeleteUserSession(context.Context, model.InternalID, model.InternalID) error - FetchDeviceInfo(context.Context, model.InternalID) (*model.DeviceInfo, error) - CreateUserSession(context.Context, *model.UserSession) error - FetchUserSession(context.Context, model.InternalID, string) (*model.UserSession, error) - UpdateUserSession(context.Context, *model.UserSession) error - ListDevices(context.Context, model.InternalID) ([]*model.DeviceInfo, error) - ListPorterGroups(context.Context, []model.UserStatus) ([]*modelsupervisor.PorterGroup, error) -} - type Tiphereth struct { app *libapp.Settings auth *libauth.Auth - repo TipherethRepo + repo *data.TipherethRepo supv *supervisor.Supervisor id *libidgenerator.IDGenerator search libsearch.Search @@ -74,7 +42,7 @@ type Tiphereth struct { func NewTiphereth( app *libapp.Settings, - repo TipherethRepo, + repo *data.TipherethRepo, auth *libauth.Auth, supv *supervisor.Supervisor, id *libidgenerator.IDGenerator, @@ -156,7 +124,7 @@ func (t *Tiphereth) CreateConfiguredAdmin() { } func NewUserCountCache( - t TipherethRepo, + t *data.TipherethRepo, store libcache.Store, ) *libcache.Key[model.UserCount] { return libcache.NewKey[model.UserCount]( @@ -174,7 +142,7 @@ func NewUserCountCache( } func NewPorterInstanceCache( - t TipherethRepo, + t *data.TipherethRepo, store libcache.Store, ) *libcache.Map[string, modelsupervisor.PorterInstance] { return libcache.NewMap[string, modelsupervisor.PorterInstance]( @@ -191,7 +159,7 @@ func NewPorterInstanceCache( } func NewPorterContextCache( - t TipherethRepo, + t *data.TipherethRepo, store libcache.Store, ) *libcache.Map[model.InternalID, modelsupervisor.PorterContext] { return libcache.NewMap[model.InternalID, modelsupervisor.PorterContext]( diff --git a/internal/biz/bizyesod/yesod.go b/internal/biz/bizyesod/yesod.go index 88f26eeb..c416d5cc 100644 --- a/internal/biz/bizyesod/yesod.go +++ b/internal/biz/bizyesod/yesod.go @@ -6,6 +6,7 @@ import ( "strconv" "time" + "github.com/tuihub/librarian/internal/data" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/lib/libcron" "github.com/tuihub/librarian/internal/lib/libidgenerator" @@ -14,7 +15,6 @@ import ( "github.com/tuihub/librarian/internal/lib/libtime" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelfeed" "github.com/tuihub/librarian/internal/model/modelnetzach" "github.com/tuihub/librarian/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model/modelyesod" @@ -28,39 +28,8 @@ var ProviderSet = wire.NewSet( NewFeedOwnerCache, ) -type YesodRepo interface { - CreateFeedConfig(context.Context, model.InternalID, *modelyesod.FeedConfig) error - UpdateFeedConfig(context.Context, model.InternalID, *modelyesod.FeedConfig) error - ListFeedCategories(context.Context, model.InternalID) ([]string, error) - ListFeedPlatforms(context.Context, model.InternalID) ([]string, error) - ListFeedConfigNeedPull(context.Context, []string, []modelyesod.FeedConfigStatus, - modelyesod.ListFeedOrder, time.Time, int) ([]*modelyesod.FeedConfig, error) - UpdateFeedConfigAsInQueue(context.Context, model.InternalID) error - ListFeedConfigs(context.Context, model.InternalID, model.Paging, []model.InternalID, - []modelyesod.FeedConfigStatus, []string) ([]*modelyesod.FeedWithConfig, int, error) - ListFeedItems(context.Context, model.InternalID, model.Paging, []model.InternalID, - []string, []string, *model.TimeRange, []string) ([]*modelyesod.FeedItemDigest, int, error) - GroupFeedItems(context.Context, model.InternalID, []model.TimeRange, []model.InternalID, - []string, []string, int, []string) ( - map[model.TimeRange][]*modelyesod.FeedItemDigest, error) - GetFeedItems(context.Context, model.InternalID, []model.InternalID) ([]*modelfeed.Item, error) - ReadFeedItem(context.Context, model.InternalID, model.InternalID) error - CreateFeedItemCollection(context.Context, model.InternalID, *modelyesod.FeedItemCollection) error - UpdateFeedItemCollection(context.Context, model.InternalID, *modelyesod.FeedItemCollection) error - ListFeedItemCollections(context.Context, model.InternalID, model.Paging, []model.InternalID, - []string) ([]*modelyesod.FeedItemCollection, int, error) - AddFeedItemToCollection(context.Context, model.InternalID, model.InternalID, model.InternalID) error - RemoveFeedItemFromCollection(context.Context, model.InternalID, model.InternalID, model.InternalID) error - ListFeedItemsInCollection(context.Context, model.InternalID, model.Paging, []model.InternalID, []string, - []string, []string, *model.TimeRange) ([]*modelyesod.FeedItemDigest, int, error) - GetFeedOwner(context.Context, model.InternalID) (*model.User, error) - CreateFeedActionSet(context.Context, model.InternalID, *modelyesod.FeedActionSet) error - UpdateFeedActionSet(context.Context, model.InternalID, *modelyesod.FeedActionSet) error - ListFeedActionSets(context.Context, model.InternalID, model.Paging) ([]*modelyesod.FeedActionSet, int, error) -} - type Yesod struct { - repo YesodRepo + repo *data.YesodRepo supv *supervisor.Supervisor id *libidgenerator.IDGenerator search libsearch.Search @@ -71,7 +40,7 @@ type Yesod struct { } func NewYesod( - repo YesodRepo, + repo *data.YesodRepo, supv *supervisor.Supervisor, cron *libcron.Cron, id *libidgenerator.IDGenerator, @@ -157,7 +126,7 @@ func (y *Yesod) PullFeeds(ctx context.Context) error { } func NewFeedOwnerCache( - repo YesodRepo, + repo *data.YesodRepo, store libcache.Store, ) *libcache.Map[modelyesod.FeedConfig, model.User] { return libcache.NewMap[modelyesod.FeedConfig, model.User]( diff --git a/internal/data/chesed.go b/internal/data/chesed.go index 92ca728a..665ae0a7 100644 --- a/internal/data/chesed.go +++ b/internal/data/chesed.go @@ -3,7 +3,6 @@ package data import ( "context" - "github.com/tuihub/librarian/internal/biz/bizchesed" "github.com/tuihub/librarian/internal/data/internal/converter" "github.com/tuihub/librarian/internal/data/internal/ent/image" "github.com/tuihub/librarian/internal/data/internal/ent/user" @@ -11,18 +10,18 @@ import ( "github.com/tuihub/librarian/internal/model/modelchesed" ) -type chesedRepo struct { +type ChesedRepo struct { data *Data } // NewChesedRepo . -func NewChesedRepo(data *Data) bizchesed.ChesedRepo { - return &chesedRepo{ +func NewChesedRepo(data *Data) *ChesedRepo { + return &ChesedRepo{ data: data, } } -func (c chesedRepo) CreateImage(ctx context.Context, userID model.InternalID, image *modelchesed.Image) error { +func (c *ChesedRepo) CreateImage(ctx context.Context, userID model.InternalID, image *modelchesed.Image) error { return c.data.db.Image.Create(). SetID(image.ID). SetName(image.Name). @@ -33,7 +32,7 @@ func (c chesedRepo) CreateImage(ctx context.Context, userID model.InternalID, im Exec(ctx) } -func (c chesedRepo) ListImages(ctx context.Context, userID model.InternalID, paging model.Paging) ( +func (c *ChesedRepo) ListImages(ctx context.Context, userID model.InternalID, paging model.Paging) ( []*modelchesed.Image, int64, error) { q := c.data.db.Image.Query(). Where( @@ -53,7 +52,7 @@ func (c chesedRepo) ListImages(ctx context.Context, userID model.InternalID, pag return converter.ToBizImageList(res), int64(total), nil } -func (c chesedRepo) ListImageNeedScan(ctx context.Context) ([]*modelchesed.Image, error) { +func (c *ChesedRepo) ListImageNeedScan(ctx context.Context) ([]*modelchesed.Image, error) { res, err := c.data.db.Image.Query(). Where(image.StatusEQ(image.StatusUploaded)). Limit(10). //nolint:mnd //TODO @@ -64,13 +63,13 @@ func (c chesedRepo) ListImageNeedScan(ctx context.Context) ([]*modelchesed.Image return converter.ToBizImageList(res), nil } -func (c chesedRepo) SetImageStatus(ctx context.Context, id model.InternalID, status modelchesed.ImageStatus) error { +func (c *ChesedRepo) SetImageStatus(ctx context.Context, id model.InternalID, status modelchesed.ImageStatus) error { return c.data.db.Image.UpdateOneID(id). SetStatus(converter.ToEntImageStatus(status)). Exec(ctx) } -func (c chesedRepo) GetImage(ctx context.Context, userID model.InternalID, id model.InternalID) ( +func (c *ChesedRepo) GetImage(ctx context.Context, userID model.InternalID, id model.InternalID) ( *modelchesed.Image, error) { res, err := c.data.db.Image.Query(). Where( diff --git a/internal/data/data.go b/internal/data/data.go index fd3a252a..6ff1ad37 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -29,7 +29,7 @@ var ProviderSet = wire.NewSet( NewYesodRepo, NewNetzachRepo, NewChesedRepo, - NewAngelaRepo, + NewKetherRepo, NewBinahRepo, ) diff --git a/internal/data/gebura.go b/internal/data/gebura.go index 6b759303..e74f56e9 100644 --- a/internal/data/gebura.go +++ b/internal/data/gebura.go @@ -5,7 +5,6 @@ import ( "errors" "time" - "github.com/tuihub/librarian/internal/biz/bizgebura" "github.com/tuihub/librarian/internal/data/internal/converter" "github.com/tuihub/librarian/internal/data/internal/ent" "github.com/tuihub/librarian/internal/data/internal/ent/app" @@ -17,18 +16,18 @@ import ( "github.com/tuihub/librarian/internal/model/modelgebura" ) -type geburaRepo struct { +type GeburaRepo struct { data *Data } // NewGeburaRepo . -func NewGeburaRepo(data *Data) bizgebura.GeburaRepo { - return &geburaRepo{ +func NewGeburaRepo(data *Data) *GeburaRepo { + return &GeburaRepo{ data: data, } } -func (g geburaRepo) CreateAppInfo(ctx context.Context, a *modelgebura.AppInfo) error { +func (g *GeburaRepo) CreateAppInfo(ctx context.Context, a *modelgebura.AppInfo) error { if a.Details == nil { a.Details = new(modelgebura.AppInfoDetails) } @@ -53,7 +52,7 @@ func (g geburaRepo) CreateAppInfo(ctx context.Context, a *modelgebura.AppInfo) e return q.Exec(ctx) } -func (g geburaRepo) CreateAppInfoOrGet(ctx context.Context, a *modelgebura.AppInfo) (*modelgebura.AppInfo, error) { +func (g *GeburaRepo) CreateAppInfoOrGet(ctx context.Context, a *modelgebura.AppInfo) (*modelgebura.AppInfo, error) { err := g.CreateAppInfo(ctx, a) if err == nil { return a, nil @@ -72,7 +71,7 @@ func (g geburaRepo) CreateAppInfoOrGet(ctx context.Context, a *modelgebura.AppIn return nil, err } -func (g geburaRepo) UpdateAppInfo(ctx context.Context, a *modelgebura.AppInfo) error { +func (g *GeburaRepo) UpdateAppInfo(ctx context.Context, a *modelgebura.AppInfo) error { q := g.data.db.AppInfo.Update(). Where( appinfo.IDEQ(a.ID), @@ -97,7 +96,7 @@ func (g geburaRepo) UpdateAppInfo(ctx context.Context, a *modelgebura.AppInfo) e return q.Exec(ctx) } -func (g geburaRepo) ListAppInfos( +func (g *GeburaRepo) ListAppInfos( ctx context.Context, paging model.Paging, sources []string, @@ -149,7 +148,7 @@ func (g geburaRepo) ListAppInfos( return infos, int64(total), nil } -func (g geburaRepo) MergeAppInfos(ctx context.Context, base modelgebura.AppInfo, merged model.InternalID) error { +func (g *GeburaRepo) MergeAppInfos(ctx context.Context, base modelgebura.AppInfo, merged model.InternalID) error { err := g.data.WithTx(ctx, func(tx *ent.Tx) error { baseAppInfo := converter.ToEntAppInfo(base) err := tx.AppInfo.UpdateOne(&baseAppInfo).Exec(ctx) @@ -194,7 +193,7 @@ func (g geburaRepo) MergeAppInfos(ctx context.Context, base modelgebura.AppInfo, return err } -func (g geburaRepo) GetAppInfo(ctx context.Context, id modelgebura.AppInfoID) (*modelgebura.AppInfo, error) { +func (g *GeburaRepo) GetAppInfo(ctx context.Context, id modelgebura.AppInfoID) (*modelgebura.AppInfo, error) { res, err := g.data.db.AppInfo.Query(). Where( appinfo.InternalEQ(id.Internal), @@ -208,7 +207,7 @@ func (g geburaRepo) GetAppInfo(ctx context.Context, id modelgebura.AppInfoID) (* return converter.ToBizAppInfo(res), nil } -func (g geburaRepo) GetBoundAppInfos(ctx context.Context, id model.InternalID) ([]*modelgebura.AppInfo, error) { +func (g *GeburaRepo) GetBoundAppInfos(ctx context.Context, id model.InternalID) ([]*modelgebura.AppInfo, error) { a, err := g.data.db.AppInfo.Get(ctx, id) if err != nil { return nil, err @@ -224,7 +223,7 @@ func (g geburaRepo) GetBoundAppInfos(ctx context.Context, id model.InternalID) ( return converter.ToBizAppInfoList(append(externalApps, internalApp)), nil } -func (g geburaRepo) GetBatchBoundAppInfos( +func (g *GeburaRepo) GetBatchBoundAppInfos( ctx context.Context, ids []model.InternalID, ) ([]*modelgebura.BoundAppInfos, error) { @@ -254,7 +253,7 @@ func (g geburaRepo) GetBatchBoundAppInfos( return res, nil } -func (g geburaRepo) PurchaseAppInfo( +func (g *GeburaRepo) PurchaseAppInfo( ctx context.Context, userID model.InternalID, appID *modelgebura.AppInfoID, @@ -295,7 +294,7 @@ func (g geburaRepo) PurchaseAppInfo( return a.Edges.BindInternal.ID, err } -func (g geburaRepo) GetPurchasedAppInfos( +func (g *GeburaRepo) GetPurchasedAppInfos( ctx context.Context, id model.InternalID, source string, @@ -326,7 +325,7 @@ func (g geburaRepo) GetPurchasedAppInfos( return res, nil } -func (g geburaRepo) CreateApp(ctx context.Context, userID model.InternalID, ap *modelgebura.App) error { +func (g *GeburaRepo) CreateApp(ctx context.Context, userID model.InternalID, ap *modelgebura.App) error { q := g.data.db.App.Create(). SetOwnerID(userID). SetID(ap.ID). @@ -336,7 +335,7 @@ func (g geburaRepo) CreateApp(ctx context.Context, userID model.InternalID, ap * return q.Exec(ctx) } -func (g geburaRepo) UpdateApp(ctx context.Context, ownerID model.InternalID, ap *modelgebura.App) error { +func (g *GeburaRepo) UpdateApp(ctx context.Context, ownerID model.InternalID, ap *modelgebura.App) error { q := g.data.db.App.Update(). Where( app.IDEQ(ap.ID), @@ -348,7 +347,7 @@ func (g geburaRepo) UpdateApp(ctx context.Context, ownerID model.InternalID, ap return q.Exec(ctx) } -func (g geburaRepo) ListApps( +func (g *GeburaRepo) ListApps( ctx context.Context, paging model.Paging, ownerIDs []model.InternalID, @@ -390,7 +389,7 @@ func (g geburaRepo) ListApps( return res, total, nil } -func (g geburaRepo) AssignApp( +func (g *GeburaRepo) AssignApp( ctx context.Context, userID model.InternalID, appID model.InternalID, @@ -406,7 +405,7 @@ func (g geburaRepo) AssignApp( return err } -func (g geburaRepo) UnAssignApp( +func (g *GeburaRepo) UnAssignApp( ctx context.Context, userID model.InternalID, appID model.InternalID, @@ -436,7 +435,7 @@ func (g geburaRepo) UnAssignApp( // Strings(ctx) //} -func (g geburaRepo) CreateAppInst(ctx context.Context, ownerID model.InternalID, inst *modelgebura.AppInst) error { +func (g *GeburaRepo) CreateAppInst(ctx context.Context, ownerID model.InternalID, inst *modelgebura.AppInst) error { _, err := g.data.db.App.Query().Where( app.IDEQ(inst.AppID), app.HasOwnerWith(user.IDEQ(ownerID)), @@ -452,7 +451,7 @@ func (g geburaRepo) CreateAppInst(ctx context.Context, ownerID model.InternalID, return q.Exec(ctx) } -func (g geburaRepo) UpdateAppInst(ctx context.Context, ownerID model.InternalID, inst *modelgebura.AppInst) error { +func (g *GeburaRepo) UpdateAppInst(ctx context.Context, ownerID model.InternalID, inst *modelgebura.AppInst) error { _, err := g.data.db.App.Query().Where( app.IDEQ(inst.AppID), app.HasOwnerWith(user.IDEQ(ownerID)), @@ -469,7 +468,7 @@ func (g geburaRepo) UpdateAppInst(ctx context.Context, ownerID model.InternalID, return q.Exec(ctx) } -func (g geburaRepo) ListAppInsts( +func (g *GeburaRepo) ListAppInsts( ctx context.Context, ownerID model.InternalID, paging model.Paging, @@ -501,7 +500,7 @@ func (g geburaRepo) ListAppInsts( return converter.ToBizAppInstList(insts), total, nil } -func (g geburaRepo) AddAppInstRunTime( +func (g *GeburaRepo) AddAppInstRunTime( ctx context.Context, userID model.InternalID, instID model.InternalID, @@ -515,7 +514,7 @@ func (g geburaRepo) AddAppInstRunTime( Exec(ctx) } -func (g geburaRepo) SumAppInstRunTime( +func (g *GeburaRepo) SumAppInstRunTime( ctx context.Context, userID model.InternalID, instID model.InternalID, diff --git a/internal/data/angela.go b/internal/data/kether.go similarity index 84% rename from internal/data/angela.go rename to internal/data/kether.go index 602ea303..4c6a9839 100644 --- a/internal/data/angela.go +++ b/internal/data/kether.go @@ -4,7 +4,6 @@ import ( "context" "time" - "github.com/tuihub/librarian/internal/biz/bizangela" "github.com/tuihub/librarian/internal/data/internal/converter" "github.com/tuihub/librarian/internal/data/internal/ent" "github.com/tuihub/librarian/internal/data/internal/ent/account" @@ -24,19 +23,19 @@ import ( "entgo.io/ent/dialect/sql" ) -type angelaRepo struct { +type KetherRepo struct { data *Data } -// NewAngelaRepo . -func NewAngelaRepo(data *Data) bizangela.AngelaRepo { - return &angelaRepo{ +// NewKetherRepo . +func NewKetherRepo(data *Data) *KetherRepo { + return &KetherRepo{ data: data, } } -func (a *angelaRepo) UpsertAccount(ctx context.Context, acc model.Account) error { - return a.data.db.Account.Create(). +func (k *KetherRepo) UpsertAccount(ctx context.Context, acc model.Account) error { + return k.data.db.Account.Create(). SetID(acc.ID). SetPlatform(acc.Platform). SetPlatformAccountID(acc.PlatformAccountID). @@ -54,10 +53,10 @@ func (a *angelaRepo) UpsertAccount(ctx context.Context, acc model.Account) error Exec(ctx) } -func (a *angelaRepo) UpsertAppInfo( //nolint:gocognit //TODO +func (k *KetherRepo) UpsertAppInfo( //nolint:gocognit //TODO ctx context.Context, ap *modelgebura.AppInfo, internal *modelgebura.AppInfo, ) error { - return a.data.WithTx(ctx, func(tx *ent.Tx) error { + return k.data.WithTx(ctx, func(tx *ent.Tx) error { q := tx.AppInfo.Create(). SetID(ap.ID). SetInternal(ap.Internal). @@ -136,13 +135,13 @@ func (a *angelaRepo) UpsertAppInfo( //nolint:gocognit //TODO }) } -func (a *angelaRepo) UpsertAppInfos(ctx context.Context, al []*modelgebura.AppInfo) error { +func (k *KetherRepo) UpsertAppInfos(ctx context.Context, al []*modelgebura.AppInfo) error { apps := make([]*ent.AppInfoCreate, len(al)) for i, ap := range al { if ap.Details == nil { ap.Details = new(modelgebura.AppInfoDetails) } - apps[i] = a.data.db.AppInfo.Create(). + apps[i] = k.data.db.AppInfo.Create(). SetID(ap.ID). SetInternal(ap.Internal). SetSource(ap.Source). @@ -163,7 +162,7 @@ func (a *angelaRepo) UpsertAppInfos(ctx context.Context, al []*modelgebura.AppIn SetVersion(ap.Details.Version) } } - return a.data.db.AppInfo. + return k.data.db.AppInfo. CreateBulk(apps...). OnConflict( sql.ConflictColumns(appinfo.FieldSource, appinfo.FieldSourceAppID), @@ -174,10 +173,10 @@ func (a *angelaRepo) UpsertAppInfos(ctx context.Context, al []*modelgebura.AppIn Exec(ctx) } -func (a *angelaRepo) AccountPurchaseAppInfos( +func (k *KetherRepo) AccountPurchaseAppInfos( ctx context.Context, id model.InternalID, ids []model.InternalID, ) error { - return a.data.WithTx(ctx, func(tx *ent.Tx) error { + return k.data.WithTx(ctx, func(tx *ent.Tx) error { appIDs, err := tx.App.Query().Where( app.IDIn(ids...), ). @@ -185,15 +184,15 @@ func (a *angelaRepo) AccountPurchaseAppInfos( if err != nil { return err } - return a.data.db.Account. + return k.data.db.Account. UpdateOneID(id). AddPurchasedAppIDs(appIDs...). Exec(ctx) }) } -func (a *angelaRepo) UpsertFeed(ctx context.Context, f *modelfeed.Feed) error { - return a.data.WithTx(ctx, func(tx *ent.Tx) error { +func (k *KetherRepo) UpsertFeed(ctx context.Context, f *modelfeed.Feed) error { + return k.data.WithTx(ctx, func(tx *ent.Tx) error { conf, err := tx.FeedConfig.Query(). Where(feedconfig.IDEQ(f.ID)). Only(ctx) @@ -218,12 +217,12 @@ func (a *angelaRepo) UpsertFeed(ctx context.Context, f *modelfeed.Feed) error { }) } -func (a *angelaRepo) CheckNewFeedItems(ctx context.Context, items []*modelfeed.Item, feedID model.InternalID) ([]string, error) { +func (k *KetherRepo) CheckNewFeedItems(ctx context.Context, items []*modelfeed.Item, feedID model.InternalID) ([]string, error) { guids := make([]string, 0, len(items)) for _, item := range items { guids = append(guids, item.GUID) } - existItems, err := a.data.db.FeedItem.Query().Where( + existItems, err := k.data.db.FeedItem.Query().Where( feeditem.FeedID(feedID), feeditem.GUIDIn(guids...), ).Select(feeditem.FieldGUID).All(ctx) @@ -243,14 +242,14 @@ func (a *angelaRepo) CheckNewFeedItems(ctx context.Context, items []*modelfeed.I return res, nil } -func (a *angelaRepo) UpsertFeedItems( +func (k *KetherRepo) UpsertFeedItems( ctx context.Context, items []*modelfeed.Item, feedID model.InternalID, ) error { il := make([]*ent.FeedItemCreate, len(items)) for i, item := range items { - il[i] = a.data.db.FeedItem.Create(). + il[i] = k.data.db.FeedItem.Create(). SetFeedID(feedID). SetID(item.ID). SetTitle(item.Title). @@ -273,7 +272,7 @@ func (a *angelaRepo) UpsertFeedItems( il[i].SetPublishedParsed(time.Now()) } } - return a.data.db.FeedItem.CreateBulk(il...). + return k.data.db.FeedItem.CreateBulk(il...). OnConflict( sql.ConflictColumns(feeditem.FieldFeedID, feeditem.FieldGUID), // @@ -286,8 +285,8 @@ func (a *angelaRepo) UpsertFeedItems( ).Exec(ctx) } -func (a *angelaRepo) UpdateFeedPullStatus(ctx context.Context, conf *modelyesod.FeedConfig) error { - c, err := a.data.db.FeedConfig.Query().Where(feedconfig.IDEQ(conf.ID)).Only(ctx) +func (k *KetherRepo) UpdateFeedPullStatus(ctx context.Context, conf *modelyesod.FeedConfig) error { + c, err := k.data.db.FeedConfig.Query().Where(feedconfig.IDEQ(conf.ID)).Only(ctx) if err != nil { return err } @@ -299,16 +298,16 @@ func (a *angelaRepo) UpdateFeedPullStatus(ctx context.Context, conf *modelyesod. Exec(ctx) } -func (a *angelaRepo) GetFeedItem(ctx context.Context, id model.InternalID) (*modelfeed.Item, error) { - item, err := a.data.db.FeedItem.Get(ctx, id) +func (k *KetherRepo) GetFeedItem(ctx context.Context, id model.InternalID) (*modelfeed.Item, error) { + item, err := k.data.db.FeedItem.Get(ctx, id) if err != nil { return nil, err } return converter.ToBizFeedItem(item), nil } -func (a *angelaRepo) GetFeedActions(ctx context.Context, id model.InternalID) ([]*modelyesod.FeedActionSet, error) { - actions, err := a.data.db.FeedActionSet.Query(). +func (k *KetherRepo) GetFeedActions(ctx context.Context, id model.InternalID) ([]*modelyesod.FeedActionSet, error) { + actions, err := k.data.db.FeedActionSet.Query(). Where(feedactionset.HasFeedConfigWith(feedconfig.IDEQ(id))). All(ctx) if err != nil { @@ -317,10 +316,10 @@ func (a *angelaRepo) GetFeedActions(ctx context.Context, id model.InternalID) ([ return converter.ToBizFeedActionSetList(actions), nil } -func (a *angelaRepo) GetNotifyTargetItems(ctx context.Context, id model.InternalID, paging model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) { +func (k *KetherRepo) GetNotifyTargetItems(ctx context.Context, id model.InternalID, paging model.Paging) (*modelsupervisor.FeatureRequest, []*modelfeed.Item, error) { var fr *modelsupervisor.FeatureRequest var it []*modelfeed.Item - err := a.data.WithTx(ctx, func(tx *ent.Tx) error { + err := k.data.WithTx(ctx, func(tx *ent.Tx) error { target, err := tx.NotifyTarget.Get(ctx, id) if err != nil { return err @@ -347,12 +346,12 @@ func (a *angelaRepo) GetNotifyTargetItems(ctx context.Context, id model.Internal return fr, it, nil } -func (a *angelaRepo) AddFeedItemsToCollection( +func (k *KetherRepo) AddFeedItemsToCollection( ctx context.Context, collectionID model.InternalID, itemIDs []model.InternalID, ) error { - return a.data.db.FeedItemCollection.UpdateOneID(collectionID). + return k.data.db.FeedItemCollection.UpdateOneID(collectionID). AddFeedItemIDs(itemIDs...). Exec(ctx) } diff --git a/internal/data/netzach.go b/internal/data/netzach.go index 8fe613c9..43915262 100644 --- a/internal/data/netzach.go +++ b/internal/data/netzach.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/tuihub/librarian/internal/biz/biznetzach" "github.com/tuihub/librarian/internal/data/internal/converter" "github.com/tuihub/librarian/internal/data/internal/ent" "github.com/tuihub/librarian/internal/data/internal/ent/notifyflow" @@ -19,17 +18,17 @@ import ( "entgo.io/ent/dialect/sql" ) -type netzachRepo struct { +type NetzachRepo struct { data *Data } -func NewNetzachRepo(data *Data) biznetzach.NetzachRepo { - return &netzachRepo{ +func NewNetzachRepo(data *Data) *NetzachRepo { + return &NetzachRepo{ data: data, } } -func (n *netzachRepo) CreateNotifyTarget(ctx context.Context, id model.InternalID, t *modelnetzach.NotifyTarget) error { +func (n *NetzachRepo) CreateNotifyTarget(ctx context.Context, id model.InternalID, t *modelnetzach.NotifyTarget) error { q := n.data.db.NotifyTarget.Create(). SetOwnerID(id). SetID(t.ID). @@ -40,7 +39,7 @@ func (n *netzachRepo) CreateNotifyTarget(ctx context.Context, id model.InternalI return q.Exec(ctx) } -func (n *netzachRepo) UpdateNotifyTarget( +func (n *NetzachRepo) UpdateNotifyTarget( ctx context.Context, userID model.InternalID, t *modelnetzach.NotifyTarget, @@ -64,7 +63,7 @@ func (n *netzachRepo) UpdateNotifyTarget( return q.Exec(ctx) } -func (n *netzachRepo) ListNotifyTargets( +func (n *NetzachRepo) ListNotifyTargets( ctx context.Context, paging model.Paging, userID model.InternalID, @@ -94,7 +93,7 @@ func (n *netzachRepo) ListNotifyTargets( return converter.ToBizNotifyTargetList(res), int64(total), nil } -func (n *netzachRepo) GetNotifyTarget(ctx context.Context, id model.InternalID) (*modelnetzach.NotifyTarget, error) { +func (n *NetzachRepo) GetNotifyTarget(ctx context.Context, id model.InternalID) (*modelnetzach.NotifyTarget, error) { res, err := n.data.db.NotifyTarget.Query().Where(notifytarget.IDEQ(id)).Only(ctx) if err != nil { return nil, err @@ -102,7 +101,7 @@ func (n *netzachRepo) GetNotifyTarget(ctx context.Context, id model.InternalID) return converter.ToBizNotifyTarget(res), nil } -func (n *netzachRepo) CreateNotifyFlow(ctx context.Context, userID model.InternalID, f *modelnetzach.NotifyFlow) error { +func (n *NetzachRepo) CreateNotifyFlow(ctx context.Context, userID model.InternalID, f *modelnetzach.NotifyFlow) error { err := n.data.WithTx(ctx, func(tx *ent.Tx) error { err := tx.NotifyFlow.Create(). SetID(f.ID). @@ -157,7 +156,7 @@ func (n *netzachRepo) CreateNotifyFlow(ctx context.Context, userID model.Interna return nil } -func (n *netzachRepo) UpdateNotifyFlow( //nolint:gocognit // TODO +func (n *NetzachRepo) UpdateNotifyFlow( //nolint:gocognit // TODO ctx context.Context, userID model.InternalID, f *modelnetzach.NotifyFlow, @@ -228,7 +227,7 @@ func (n *netzachRepo) UpdateNotifyFlow( //nolint:gocognit // TODO return nil } -func (n *netzachRepo) ListNotifyFlows( +func (n *NetzachRepo) ListNotifyFlows( ctx context.Context, paging model.Paging, userID model.InternalID, @@ -260,7 +259,7 @@ func (n *netzachRepo) ListNotifyFlows( return res, int64(total), nil } -func (n *netzachRepo) GetNotifyFlow(ctx context.Context, id model.InternalID) (*modelnetzach.NotifyFlow, error) { +func (n *NetzachRepo) GetNotifyFlow(ctx context.Context, id model.InternalID) (*modelnetzach.NotifyFlow, error) { res, err := n.data.db.NotifyFlow.Query(). Where(notifyflow.IDEQ(id)). WithNotifyFlowSource(). @@ -272,7 +271,7 @@ func (n *netzachRepo) GetNotifyFlow(ctx context.Context, id model.InternalID) (* return converter.ToBizNotifyFlowExtend(res), nil } -func (n *netzachRepo) GetNotifyFlowIDsWithFeed(ctx context.Context, id model.InternalID) ([]model.InternalID, error) { +func (n *NetzachRepo) GetNotifyFlowIDsWithFeed(ctx context.Context, id model.InternalID) ([]model.InternalID, error) { ids, err := n.data.db.NotifyFlow.Query().Where( notifyflow.HasNotifyFlowSourceWith(notifyflowsource.NotifySourceIDEQ(id)), ).IDs(ctx) @@ -282,7 +281,7 @@ func (n *netzachRepo) GetNotifyFlowIDsWithFeed(ctx context.Context, id model.Int return ids, nil } -func (n *netzachRepo) UpsertSystemNotification( +func (n *NetzachRepo) UpsertSystemNotification( ctx context.Context, userID model.InternalID, notification *modelnetzach.SystemNotification, @@ -311,7 +310,7 @@ func (n *netzachRepo) UpsertSystemNotification( ).Exec(ctx) } -func (n *netzachRepo) ListSystemNotifications(ctx context.Context, paging model.Paging, userID *model.InternalID, types []modelnetzach.SystemNotificationType, levels []modelnetzach.SystemNotificationLevel, statuses []modelnetzach.SystemNotificationStatus) ([]*modelnetzach.SystemNotification, int64, error) { +func (n *NetzachRepo) ListSystemNotifications(ctx context.Context, paging model.Paging, userID *model.InternalID, types []modelnetzach.SystemNotificationType, levels []modelnetzach.SystemNotificationLevel, statuses []modelnetzach.SystemNotificationStatus) ([]*modelnetzach.SystemNotification, int64, error) { q := n.data.db.SystemNotification.Query(). Order(ent.Desc(systemnotification.FieldUpdatedAt)) if userID != nil { diff --git a/internal/data/tiphereth.go b/internal/data/tiphereth.go index 37573f2b..11972b23 100644 --- a/internal/data/tiphereth.go +++ b/internal/data/tiphereth.go @@ -4,7 +4,6 @@ import ( "context" "errors" - "github.com/tuihub/librarian/internal/biz/biztiphereth" "github.com/tuihub/librarian/internal/data/internal/converter" "github.com/tuihub/librarian/internal/data/internal/ent" "github.com/tuihub/librarian/internal/data/internal/ent/account" @@ -20,18 +19,18 @@ import ( "entgo.io/ent/dialect/sql" ) -type tipherethRepo struct { +type TipherethRepo struct { data *Data } // NewTipherethRepo . -func NewTipherethRepo(data *Data) biztiphereth.TipherethRepo { - return &tipherethRepo{ +func NewTipherethRepo(data *Data) *TipherethRepo { + return &TipherethRepo{ data: data, } } -func (t tipherethRepo) FetchUserByPassword( +func (t *TipherethRepo) FetchUserByPassword( ctx context.Context, username, password string, ) (*model.User, error) { @@ -45,7 +44,7 @@ func (t tipherethRepo) FetchUserByPassword( return converter.ToBizUser(u), nil } -func (t tipherethRepo) CreateDevice( +func (t *TipherethRepo) CreateDevice( ctx context.Context, userID model.InternalID, info *model.DeviceInfo, @@ -86,7 +85,7 @@ func (t tipherethRepo) CreateDevice( return res, nil } -func (t tipherethRepo) FetchDeviceInfo( +func (t *TipherethRepo) FetchDeviceInfo( ctx context.Context, deviceID model.InternalID, ) (*model.DeviceInfo, error) { @@ -97,7 +96,7 @@ func (t tipherethRepo) FetchDeviceInfo( return converter.ToBizDeviceInfo(res), nil } -func (t tipherethRepo) ListDevices(ctx context.Context, id model.InternalID) ([]*model.DeviceInfo, error) { +func (t *TipherethRepo) ListDevices(ctx context.Context, id model.InternalID) ([]*model.DeviceInfo, error) { devices, err := t.data.db.DeviceInfo.Query().Where( deviceinfo.HasUserWith(user.IDEQ(id)), ).All(ctx) @@ -107,7 +106,7 @@ func (t tipherethRepo) ListDevices(ctx context.Context, id model.InternalID) ([] return converter.ToBizDeviceInfoList(devices), nil } -func (t tipherethRepo) CreateUserSession(ctx context.Context, session *model.UserSession) error { +func (t *TipherethRepo) CreateUserSession(ctx context.Context, session *model.UserSession) error { return t.data.WithTx(ctx, func(tx *ent.Tx) error { q := tx.UserSession.Create(). SetID(session.ID). @@ -144,7 +143,7 @@ func (t tipherethRepo) CreateUserSession(ctx context.Context, session *model.Use }) } -func (t tipherethRepo) FetchUserSession( +func (t *TipherethRepo) FetchUserSession( ctx context.Context, userID model.InternalID, token string, @@ -163,7 +162,7 @@ func (t tipherethRepo) FetchUserSession( return res, nil } -func (t tipherethRepo) ListUserSessions( +func (t *TipherethRepo) ListUserSessions( ctx context.Context, id model.InternalID, ) ([]*model.UserSession, error) { @@ -183,7 +182,7 @@ func (t tipherethRepo) ListUserSessions( return res, nil } -func (t tipherethRepo) UpdateUserSession(ctx context.Context, session *model.UserSession) error { +func (t *TipherethRepo) UpdateUserSession(ctx context.Context, session *model.UserSession) error { return t.data.WithTx(ctx, func(tx *ent.Tx) error { q := tx.UserSession.UpdateOneID(session.ID). SetRefreshToken(session.RefreshToken). @@ -203,7 +202,7 @@ func (t tipherethRepo) UpdateUserSession(ctx context.Context, session *model.Use }) } -func (t tipherethRepo) DeleteUserSession( +func (t *TipherethRepo) DeleteUserSession( ctx context.Context, userID model.InternalID, sessionID model.InternalID, @@ -213,7 +212,7 @@ func (t tipherethRepo) DeleteUserSession( ).Exec(ctx) } -func (t tipherethRepo) CreateUser(ctx context.Context, u *model.User, c model.InternalID) error { +func (t *TipherethRepo) CreateUser(ctx context.Context, u *model.User, c model.InternalID) error { q := t.data.db.User.Create(). SetID(u.ID). SetUsername(u.Username). @@ -224,7 +223,7 @@ func (t tipherethRepo) CreateUser(ctx context.Context, u *model.User, c model.In return q.Exec(ctx) } -func (t tipherethRepo) UpdateUser(ctx context.Context, u *model.User, password string) error { +func (t *TipherethRepo) UpdateUser(ctx context.Context, u *model.User, password string) error { q := t.data.db.User.Update(). Where(user.IDEQ(u.ID)) if u.Username != "" { @@ -242,7 +241,7 @@ func (t tipherethRepo) UpdateUser(ctx context.Context, u *model.User, password s return q.Exec(ctx) } -func (t tipherethRepo) ListUsers( +func (t *TipherethRepo) ListUsers( ctx context.Context, paging model.Paging, ids []model.InternalID, @@ -278,7 +277,7 @@ func (t tipherethRepo) ListUsers( return converter.ToBizUserList(u), int64(count), nil } -func (t tipherethRepo) GetUser(ctx context.Context, id model.InternalID) (*model.User, error) { +func (t *TipherethRepo) GetUser(ctx context.Context, id model.InternalID) (*model.User, error) { u, err := t.data.db.User.Get(ctx, id) if err != nil { return nil, err @@ -286,11 +285,11 @@ func (t tipherethRepo) GetUser(ctx context.Context, id model.InternalID) (*model return converter.ToBizUser(u), nil } -func (t tipherethRepo) GetUserCount(ctx context.Context) (int, error) { +func (t *TipherethRepo) GetUserCount(ctx context.Context) (int, error) { return t.data.db.User.Query().Count(ctx) } -func (t tipherethRepo) LinkAccount( +func (t *TipherethRepo) LinkAccount( ctx context.Context, a model.Account, userID model.InternalID, @@ -346,7 +345,7 @@ func (t tipherethRepo) LinkAccount( return accountID, nil } -func (t tipherethRepo) UnLinkAccount(ctx context.Context, a model.Account, u model.InternalID) error { +func (t *TipherethRepo) UnLinkAccount(ctx context.Context, a model.Account, u model.InternalID) error { return t.data.db.Account.Update().Where( account.PlatformEQ(a.Platform), account.PlatformAccountIDEQ(a.PlatformAccountID), @@ -356,7 +355,7 @@ func (t tipherethRepo) UnLinkAccount(ctx context.Context, a model.Account, u mod Exec(ctx) } -func (t tipherethRepo) ListLinkAccounts( +func (t *TipherethRepo) ListLinkAccounts( ctx context.Context, userID model.InternalID, ) ([]*model.Account, error) { @@ -371,7 +370,7 @@ func (t tipherethRepo) ListLinkAccounts( return converter.ToBizAccountList(a), nil } -func (t tipherethRepo) UpsertPorters(ctx context.Context, il []*modelsupervisor.PorterInstance) error { +func (t *TipherethRepo) UpsertPorters(ctx context.Context, il []*modelsupervisor.PorterInstance) error { instances := make([]*ent.PorterInstanceCreate, len(il)) for i, instance := range il { if instance.BinarySummary == nil { @@ -405,7 +404,7 @@ func (t tipherethRepo) UpsertPorters(ctx context.Context, il []*modelsupervisor. Exec(ctx) } -func (t tipherethRepo) ListPorters( +func (t *TipherethRepo) ListPorters( ctx context.Context, paging model.Paging, ) ([]*modelsupervisor.PorterInstance, int64, error) { @@ -424,7 +423,7 @@ func (t tipherethRepo) ListPorters( return converter.ToBizPorterList(p), int64(count), nil } -func (t tipherethRepo) UpdatePorterStatus( +func (t *TipherethRepo) UpdatePorterStatus( ctx context.Context, id model.InternalID, status model.UserStatus, @@ -440,7 +439,7 @@ func (t tipherethRepo) UpdatePorterStatus( return converter.ToBizPorter(pi), nil } -func (t tipherethRepo) FetchPorterByAddress(ctx context.Context, address string) (*modelsupervisor.PorterInstance, error) { +func (t *TipherethRepo) FetchPorterByAddress(ctx context.Context, address string) (*modelsupervisor.PorterInstance, error) { p, err := t.data.db.PorterInstance.Query().Where( porterinstance.AddressEQ(address), ).Only(ctx) @@ -450,7 +449,7 @@ func (t tipherethRepo) FetchPorterByAddress(ctx context.Context, address string) return converter.ToBizPorter(p), nil } -func (t tipherethRepo) CreatePorterContext( +func (t *TipherethRepo) CreatePorterContext( ctx context.Context, userID model.InternalID, context *modelsupervisor.PorterContext, @@ -467,7 +466,7 @@ func (t tipherethRepo) CreatePorterContext( Exec(ctx) } -func (t tipherethRepo) ListPorterContexts( +func (t *TipherethRepo) ListPorterContexts( ctx context.Context, userID model.InternalID, paging model.Paging, @@ -489,7 +488,7 @@ func (t tipherethRepo) ListPorterContexts( return converter.ToBizPorterContextList(p), int64(count), nil } -func (t tipherethRepo) UpdatePorterContext( +func (t *TipherethRepo) UpdatePorterContext( ctx context.Context, userID model.InternalID, context *modelsupervisor.PorterContext, @@ -505,7 +504,7 @@ func (t tipherethRepo) UpdatePorterContext( Exec(ctx) } -func (t tipherethRepo) ListPorterGroups( +func (t *TipherethRepo) ListPorterGroups( ctx context.Context, status []model.UserStatus, ) ([]*modelsupervisor.PorterGroup, error) { @@ -560,7 +559,7 @@ func (t tipherethRepo) ListPorterGroups( return pg, nil } -func (t tipherethRepo) FetchPorterContext( +func (t *TipherethRepo) FetchPorterContext( ctx context.Context, id model.InternalID, ) (*modelsupervisor.PorterContext, error) { @@ -571,7 +570,7 @@ func (t tipherethRepo) FetchPorterContext( return converter.ToBizPorterContext(res), nil } -func (t tipherethRepo) GetEnabledPorterContexts( +func (t *TipherethRepo) GetEnabledPorterContexts( ctx context.Context, ) ([]*modelsupervisor.PorterContext, error) { pc, err := t.data.db.PorterContext.Query().Where( diff --git a/internal/data/yesod.go b/internal/data/yesod.go index d4449055..af654085 100644 --- a/internal/data/yesod.go +++ b/internal/data/yesod.go @@ -4,7 +4,6 @@ import ( "context" "time" - "github.com/tuihub/librarian/internal/biz/bizyesod" "github.com/tuihub/librarian/internal/data/internal/converter" "github.com/tuihub/librarian/internal/data/internal/ent" "github.com/tuihub/librarian/internal/data/internal/ent/feed" @@ -19,18 +18,18 @@ import ( "github.com/tuihub/librarian/internal/model/modelyesod" ) -type yesodRepo struct { +type YesodRepo struct { data *Data } // NewYesodRepo . -func NewYesodRepo(data *Data) bizyesod.YesodRepo { - return &yesodRepo{ +func NewYesodRepo(data *Data) *YesodRepo { + return &YesodRepo{ data: data, } } -func (y *yesodRepo) CreateFeedConfig(ctx context.Context, owner model.InternalID, c *modelyesod.FeedConfig) error { +func (y *YesodRepo) CreateFeedConfig(ctx context.Context, owner model.InternalID, c *modelyesod.FeedConfig) error { return y.data.WithTx(ctx, func(tx *ent.Tx) error { err := tx.FeedConfig.Create(). SetOwnerID(owner). @@ -59,7 +58,7 @@ func (y *yesodRepo) CreateFeedConfig(ctx context.Context, owner model.InternalID }) } -func (y *yesodRepo) UpdateFeedConfig(ctx context.Context, userID model.InternalID, c *modelyesod.FeedConfig) error { +func (y *YesodRepo) UpdateFeedConfig(ctx context.Context, userID model.InternalID, c *modelyesod.FeedConfig) error { return y.data.WithTx(ctx, func(tx *ent.Tx) error { q := tx.FeedConfig.Update(). Where( @@ -106,13 +105,13 @@ func (y *yesodRepo) UpdateFeedConfig(ctx context.Context, userID model.InternalI // UpdateFeedConfigAsInQueue set SetNextPullBeginAt to one day later to avoid repeat queue. // While pull success, UpsertFeed will set correct value. // While pull failed, server will retry task next day. -func (y *yesodRepo) UpdateFeedConfigAsInQueue(ctx context.Context, id model.InternalID) error { +func (y *YesodRepo) UpdateFeedConfigAsInQueue(ctx context.Context, id model.InternalID) error { q := y.data.db.FeedConfig.UpdateOneID(id). SetNextPullBeginAt(time.Now().Add(libtime.Day)) return q.Exec(ctx) } -func (y *yesodRepo) ListFeedConfigNeedPull(ctx context.Context, sources []string, +func (y *YesodRepo) ListFeedConfigNeedPull(ctx context.Context, sources []string, statuses []modelyesod.FeedConfigStatus, order modelyesod.ListFeedOrder, pullTime time.Time, i int) ([]*modelyesod.FeedConfig, error) { q := y.data.db.FeedConfig.Query() @@ -134,7 +133,7 @@ func (y *yesodRepo) ListFeedConfigNeedPull(ctx context.Context, sources []string return converter.ToBizFeedConfigList(feedConfigs), nil } -func (y *yesodRepo) ListFeedConfigs( +func (y *YesodRepo) ListFeedConfigs( ctx context.Context, userID model.InternalID, paging model.Paging, @@ -193,7 +192,7 @@ func (y *yesodRepo) ListFeedConfigs( return res, total, nil } -func (y *yesodRepo) ListFeedCategories(ctx context.Context, id model.InternalID) ([]string, error) { +func (y *YesodRepo) ListFeedCategories(ctx context.Context, id model.InternalID) ([]string, error) { res, err := y.data.db.FeedConfig.Query(). Where( feedconfig.HasOwnerWith(user.IDEQ(id)), @@ -207,7 +206,7 @@ func (y *yesodRepo) ListFeedCategories(ctx context.Context, id model.InternalID) return res, nil } -func (y *yesodRepo) ListFeedPlatforms(ctx context.Context, id model.InternalID) ([]string, error) { +func (y *YesodRepo) ListFeedPlatforms(ctx context.Context, id model.InternalID) ([]string, error) { res, err := y.data.db.FeedItem.Query(). Where( feeditem.HasFeedWith(feed.HasConfigWith(feedconfig.HasOwnerWith(user.IDEQ(id)))), @@ -221,7 +220,7 @@ func (y *yesodRepo) ListFeedPlatforms(ctx context.Context, id model.InternalID) return res, nil } -func (y *yesodRepo) ListFeedItems( +func (y *YesodRepo) ListFeedItems( ctx context.Context, userID model.InternalID, paging model.Paging, @@ -285,7 +284,7 @@ func (y *yesodRepo) ListFeedItems( return res, total, nil } -func (y *yesodRepo) GroupFeedItems( //nolint:gocognit //TODO +func (y *YesodRepo) GroupFeedItems( //nolint:gocognit //TODO ctx context.Context, userID model.InternalID, groups []model.TimeRange, @@ -347,7 +346,7 @@ func (y *yesodRepo) GroupFeedItems( //nolint:gocognit //TODO return res, nil } -func (y *yesodRepo) GetFeedItems( +func (y *YesodRepo) GetFeedItems( ctx context.Context, userID model.InternalID, ids []model.InternalID, @@ -376,13 +375,13 @@ func (y *yesodRepo) GetFeedItems( return res, nil } -func (y *yesodRepo) ReadFeedItem(ctx context.Context, userID model.InternalID, id model.InternalID) error { +func (y *YesodRepo) ReadFeedItem(ctx context.Context, userID model.InternalID, id model.InternalID) error { return y.data.db.FeedItem.UpdateOneID(id).Where( feeditem.HasFeedWith(feed.HasConfigWith(feedconfig.HasOwnerWith(user.IDEQ(userID)))), ).AddReadCount(1).Exec(ctx) } -func (y *yesodRepo) CreateFeedItemCollection( +func (y *YesodRepo) CreateFeedItemCollection( ctx context.Context, ownerID model.InternalID, collection *modelyesod.FeedItemCollection, @@ -396,7 +395,7 @@ func (y *yesodRepo) CreateFeedItemCollection( Exec(ctx) } -func (y *yesodRepo) UpdateFeedItemCollection( +func (y *YesodRepo) UpdateFeedItemCollection( ctx context.Context, ownerID model.InternalID, collection *modelyesod.FeedItemCollection, @@ -409,7 +408,7 @@ func (y *yesodRepo) UpdateFeedItemCollection( Exec(ctx) } -func (y *yesodRepo) ListFeedItemCollections( +func (y *YesodRepo) ListFeedItemCollections( ctx context.Context, ownerID model.InternalID, paging model.Paging, @@ -450,7 +449,7 @@ func (y *yesodRepo) ListFeedItemCollections( return res, total, nil } -func (y *yesodRepo) AddFeedItemToCollection( +func (y *YesodRepo) AddFeedItemToCollection( ctx context.Context, ownerID model.InternalID, collectionID model.InternalID, @@ -462,7 +461,7 @@ func (y *yesodRepo) AddFeedItemToCollection( Exec(ctx) } -func (y *yesodRepo) RemoveFeedItemFromCollection( +func (y *YesodRepo) RemoveFeedItemFromCollection( ctx context.Context, ownerID model.InternalID, collectionID model.InternalID, @@ -474,7 +473,7 @@ func (y *yesodRepo) RemoveFeedItemFromCollection( Exec(ctx) } -func (y *yesodRepo) ListFeedItemsInCollection( +func (y *YesodRepo) ListFeedItemsInCollection( ctx context.Context, ownerID model.InternalID, paging model.Paging, @@ -536,7 +535,7 @@ func (y *yesodRepo) ListFeedItemsInCollection( return res, total, nil } -func (y *yesodRepo) GetFeedOwner(ctx context.Context, id model.InternalID) (*model.User, error) { +func (y *YesodRepo) GetFeedOwner(ctx context.Context, id model.InternalID) (*model.User, error) { only, err := y.data.db.FeedConfig.Query().Where(feedconfig.IDEQ(id)).QueryOwner().Only(ctx) if err != nil { return nil, err @@ -544,7 +543,7 @@ func (y *yesodRepo) GetFeedOwner(ctx context.Context, id model.InternalID) (*mod return converter.ToBizUser(only), nil } -func (y *yesodRepo) CreateFeedActionSet(ctx context.Context, id model.InternalID, set *modelyesod.FeedActionSet) error { +func (y *YesodRepo) CreateFeedActionSet(ctx context.Context, id model.InternalID, set *modelyesod.FeedActionSet) error { return y.data.db.FeedActionSet.Create(). SetOwnerID(id). SetID(set.ID). @@ -554,7 +553,7 @@ func (y *yesodRepo) CreateFeedActionSet(ctx context.Context, id model.InternalID Exec(ctx) } -func (y *yesodRepo) UpdateFeedActionSet(ctx context.Context, id model.InternalID, set *modelyesod.FeedActionSet) error { +func (y *YesodRepo) UpdateFeedActionSet(ctx context.Context, id model.InternalID, set *modelyesod.FeedActionSet) error { return y.data.db.FeedActionSet.UpdateOneID(set.ID). Where(feedactionset.HasOwnerWith(user.IDEQ(id))). SetName(set.Name). @@ -563,7 +562,7 @@ func (y *yesodRepo) UpdateFeedActionSet(ctx context.Context, id model.InternalID Exec(ctx) } -func (y *yesodRepo) ListFeedActionSets(ctx context.Context, id model.InternalID, paging model.Paging) ([]*modelyesod.FeedActionSet, int, error) { +func (y *YesodRepo) ListFeedActionSets(ctx context.Context, id model.InternalID, paging model.Paging) ([]*modelyesod.FeedActionSet, int, error) { var res []*modelyesod.FeedActionSet var total int err := y.data.WithTx(ctx, func(tx *ent.Tx) error { diff --git a/internal/model/modelangela/modelangela.go b/internal/model/modelkether/modelkether.go similarity index 97% rename from internal/model/modelangela/modelangela.go rename to internal/model/modelkether/modelkether.go index ad2773f4..9207ba02 100644 --- a/internal/model/modelangela/modelangela.go +++ b/internal/model/modelkether/modelkether.go @@ -1,4 +1,4 @@ -package modelangela +package modelkether import ( "github.com/tuihub/librarian/internal/model" diff --git a/internal/service/sephirah/converter/biz_to_pb.go b/internal/service/sephirah/converter/biz_to_pb.go index 427a4705..7e60f402 100644 --- a/internal/service/sephirah/converter/biz_to_pb.go +++ b/internal/service/sephirah/converter/biz_to_pb.go @@ -19,7 +19,7 @@ import ( // goverter:converter // goverter:output:format function // goverter:output:file ./generated.go -// goverter:output:package github.com/tuihub/librarian/internal/service/sephirah/internal/converter +// goverter:output:package github.com/tuihub/librarian/internal/service/sephirah/converter // goverter:matchIgnoreCase // goverter:ignoreUnexported // goverter:extend ToPBInternalID diff --git a/internal/service/sephirah/converter/generated.go b/internal/service/sephirah/converter/generated.go index 9e01ee91..c926ec45 100644 --- a/internal/service/sephirah/converter/generated.go +++ b/internal/service/sephirah/converter/generated.go @@ -5,12 +5,12 @@ package converter import ( model "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/model/modelbinah" + modelbinah "github.com/tuihub/librarian/internal/model/modelbinah" modelfeed "github.com/tuihub/librarian/internal/model/modelfeed" - "github.com/tuihub/librarian/internal/model/modelgebura" - "github.com/tuihub/librarian/internal/model/modelnetzach" - "github.com/tuihub/librarian/internal/model/modelsupervisor" - "github.com/tuihub/librarian/internal/model/modelyesod" + modelgebura "github.com/tuihub/librarian/internal/model/modelgebura" + modelnetzach "github.com/tuihub/librarian/internal/model/modelnetzach" + modelsupervisor "github.com/tuihub/librarian/internal/model/modelsupervisor" + modelyesod "github.com/tuihub/librarian/internal/model/modelyesod" v11 "github.com/tuihub/protos/pkg/librarian/sephirah/v1" v1 "github.com/tuihub/protos/pkg/librarian/v1" timestamppb "google.golang.org/protobuf/types/known/timestamppb" @@ -163,19 +163,19 @@ func ToBizAppTypeList(source []v1.AppType) []modelgebura.AppType { return modelgeburaAppTypeList } func ToBizDeviceInfo(source *v11.DeviceInfo) *model.DeviceInfo { - var pModeltipherethDeviceInfo *model.DeviceInfo + var pModelDeviceInfo *model.DeviceInfo if source != nil { - var modeltipherethDeviceInfo model.DeviceInfo - modeltipherethDeviceInfo.ID = ToBizInternalID((*source).DeviceId) - modeltipherethDeviceInfo.DeviceName = (*source).DeviceName - modeltipherethDeviceInfo.SystemType = ToBizSystemType((*source).SystemType) - modeltipherethDeviceInfo.SystemVersion = (*source).SystemVersion - modeltipherethDeviceInfo.ClientName = (*source).ClientName - modeltipherethDeviceInfo.ClientSourceCodeAddress = (*source).ClientSourceCodeAddress - modeltipherethDeviceInfo.ClientVersion = (*source).ClientVersion - pModeltipherethDeviceInfo = &modeltipherethDeviceInfo + var modelDeviceInfo model.DeviceInfo + modelDeviceInfo.ID = ToBizInternalID((*source).DeviceId) + modelDeviceInfo.DeviceName = (*source).DeviceName + modelDeviceInfo.SystemType = ToBizSystemType((*source).SystemType) + modelDeviceInfo.SystemVersion = (*source).SystemVersion + modelDeviceInfo.ClientName = (*source).ClientName + modelDeviceInfo.ClientSourceCodeAddress = (*source).ClientSourceCodeAddress + modelDeviceInfo.ClientVersion = (*source).ClientVersion + pModelDeviceInfo = &modelDeviceInfo } - return pModeltipherethDeviceInfo + return pModelDeviceInfo } func ToBizFeatureFlag(source *v1.FeatureFlag) *modelsupervisor.FeatureFlag { var pModelsupervisorFeatureFlag *modelsupervisor.FeatureFlag @@ -678,26 +678,26 @@ func ToBizSystemNotificationTypeList(source []v11.SystemNotificationType) []mode return modelnetzachSystemNotificationTypeList } func ToBizSystemType(source v11.SystemType) model.SystemType { - var modeltipherethSystemType model.SystemType + var modelSystemType model.SystemType switch source { case v11.SystemType_SYSTEM_TYPE_ANDROID: - modeltipherethSystemType = model.SystemTypeAndroid + modelSystemType = model.SystemTypeAndroid case v11.SystemType_SYSTEM_TYPE_IOS: - modeltipherethSystemType = model.SystemTypeIOS + modelSystemType = model.SystemTypeIOS case v11.SystemType_SYSTEM_TYPE_LINUX: - modeltipherethSystemType = model.SystemTypeLinux + modelSystemType = model.SystemTypeLinux case v11.SystemType_SYSTEM_TYPE_MACOS: - modeltipherethSystemType = model.SystemTypeMacOS + modelSystemType = model.SystemTypeMacOS case v11.SystemType_SYSTEM_TYPE_UNSPECIFIED: - modeltipherethSystemType = model.SystemTypeUnspecified + modelSystemType = model.SystemTypeUnspecified case v11.SystemType_SYSTEM_TYPE_WEB: - modeltipherethSystemType = model.SystemTypeWeb + modelSystemType = model.SystemTypeWeb case v11.SystemType_SYSTEM_TYPE_WINDOWS: - modeltipherethSystemType = model.SystemTypeWindows + modelSystemType = model.SystemTypeWindows default: - modeltipherethSystemType = model.SystemTypeUnspecified + modelSystemType = model.SystemTypeUnspecified } - return modeltipherethSystemType + return modelSystemType } func ToBizTimeRange(source *v1.TimeRange) *model.TimeRange { var pModelTimeRange *model.TimeRange @@ -710,69 +710,69 @@ func ToBizTimeRange(source *v1.TimeRange) *model.TimeRange { return pModelTimeRange } func ToBizUser(source *v11.User) *model.User { - var pModeltipherethUser *model.User + var pModelUser *model.User if source != nil { - var modeltipherethUser model.User - modeltipherethUser.ID = ToBizInternalID((*source).Id) - modeltipherethUser.Username = (*source).Username - modeltipherethUser.Password = (*source).Password - modeltipherethUser.Type = ToLibAuthUserType((*source).Type) - modeltipherethUser.Status = ToBizUserStatus((*source).Status) - pModeltipherethUser = &modeltipherethUser + var modelUser model.User + modelUser.ID = ToBizInternalID((*source).Id) + modelUser.Username = (*source).Username + modelUser.Password = (*source).Password + modelUser.Type = ToLibAuthUserType((*source).Type) + modelUser.Status = ToBizUserStatus((*source).Status) + pModelUser = &modelUser } - return pModeltipherethUser + return pModelUser } func ToBizUserStatus(source v11.UserStatus) model.UserStatus { - var modeltipherethUserStatus model.UserStatus + var modelUserStatus model.UserStatus switch source { case v11.UserStatus_USER_STATUS_ACTIVE: - modeltipherethUserStatus = model.UserStatusActive + modelUserStatus = model.UserStatusActive case v11.UserStatus_USER_STATUS_BLOCKED: - modeltipherethUserStatus = model.UserStatusBlocked + modelUserStatus = model.UserStatusBlocked case v11.UserStatus_USER_STATUS_UNSPECIFIED: - modeltipherethUserStatus = model.UserStatusUnspecified + modelUserStatus = model.UserStatusUnspecified default: - modeltipherethUserStatus = model.UserStatusUnspecified + modelUserStatus = model.UserStatusUnspecified } - return modeltipherethUserStatus + return modelUserStatus } func ToBizUserStatusList(source []v11.UserStatus) []model.UserStatus { - var modeltipherethUserStatusList []model.UserStatus + var modelUserStatusList []model.UserStatus if source != nil { - modeltipherethUserStatusList = make([]model.UserStatus, len(source)) + modelUserStatusList = make([]model.UserStatus, len(source)) for i := 0; i < len(source); i++ { - modeltipherethUserStatusList[i] = ToBizUserStatus(source[i]) + modelUserStatusList[i] = ToBizUserStatus(source[i]) } } - return modeltipherethUserStatusList + return modelUserStatusList } func ToLibAuthUserType(source v11.UserType) model.UserType { - var libauthUserType model.UserType + var modelUserType model.UserType switch source { case v11.UserType_USER_TYPE_ADMIN: - libauthUserType = model.UserTypeAdmin + modelUserType = model.UserTypeAdmin case v11.UserType_USER_TYPE_NORMAL: - libauthUserType = model.UserTypeNormal + modelUserType = model.UserTypeNormal case v11.UserType_USER_TYPE_PORTER: - libauthUserType = model.UserTypePorter + modelUserType = model.UserTypePorter case v11.UserType_USER_TYPE_SENTINEL: - libauthUserType = model.UserTypeSentinel + modelUserType = model.UserTypeSentinel case v11.UserType_USER_TYPE_UNSPECIFIED: - libauthUserType = model.UserTypeUnspecified + modelUserType = model.UserTypeUnspecified default: - libauthUserType = model.UserTypeUnspecified + modelUserType = model.UserTypeUnspecified } - return libauthUserType + return modelUserType } func ToLibAuthUserTypeList(source []v11.UserType) []model.UserType { - var libauthUserTypeList []model.UserType + var modelUserTypeList []model.UserType if source != nil { - libauthUserTypeList = make([]model.UserType, len(source)) + modelUserTypeList = make([]model.UserType, len(source)) for i := 0; i < len(source); i++ { - libauthUserTypeList[i] = ToLibAuthUserType(source[i]) + modelUserTypeList[i] = ToLibAuthUserType(source[i]) } } - return libauthUserTypeList + return modelUserTypeList } func pTimestamppbTimestampToPTimeTime(source *timestamppb.Timestamp) *time.Time { var pTimeTime *time.Time diff --git a/internal/service/sephirah/converter/pb_to_biz.go b/internal/service/sephirah/converter/pb_to_biz.go index 3f7cb1ba..24ec7ea6 100644 --- a/internal/service/sephirah/converter/pb_to_biz.go +++ b/internal/service/sephirah/converter/pb_to_biz.go @@ -20,7 +20,7 @@ import ( // goverter:converter // goverter:output:format function // goverter:output:file ./generated.go -// goverter:output:package github.com/tuihub/librarian/internal/service/sephirah/internal/converter +// goverter:output:package github.com/tuihub/librarian/internal/service/sephirah/converter // goverter:matchIgnoreCase // goverter:ignoreUnexported // goverter:extend ToBizInternalID diff --git a/internal/service/sephirah/librariansephirahservice.go b/internal/service/sephirah/librariansephirahservice.go index 40e00dfc..d58cede6 100644 --- a/internal/service/sephirah/librariansephirahservice.go +++ b/internal/service/sephirah/librariansephirahservice.go @@ -4,10 +4,10 @@ import ( "context" "time" - "github.com/tuihub/librarian/internal/biz/bizangela" "github.com/tuihub/librarian/internal/biz/bizbinah" "github.com/tuihub/librarian/internal/biz/bizchesed" "github.com/tuihub/librarian/internal/biz/bizgebura" + "github.com/tuihub/librarian/internal/biz/bizkether" "github.com/tuihub/librarian/internal/biz/biznetzach" "github.com/tuihub/librarian/internal/biz/biztiphereth" "github.com/tuihub/librarian/internal/biz/bizyesod" @@ -24,7 +24,7 @@ import ( type LibrarianSephirahServiceService struct { pb.UnimplementedLibrarianSephirahServiceServer - a *bizangela.Angela + a *bizkether.Kether t *biztiphereth.Tiphereth g *bizgebura.Gebura b *bizbinah.Binah @@ -38,7 +38,7 @@ type LibrarianSephirahServiceService struct { } func NewLibrarianSephirahServiceService( - a *bizangela.Angela, + a *bizkether.Kether, t *biztiphereth.Tiphereth, g *bizgebura.Gebura, b *bizbinah.Binah, diff --git a/wire_gen.go b/wire_gen.go index 39e16641..a4795665 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -9,10 +9,10 @@ package main import ( "github.com/go-kratos/kratos/v2" "github.com/tuihub/librarian/app/miner/pkg/service" - "github.com/tuihub/librarian/internal/biz/bizangela" "github.com/tuihub/librarian/internal/biz/bizbinah" "github.com/tuihub/librarian/internal/biz/bizchesed" "github.com/tuihub/librarian/internal/biz/bizgebura" + "github.com/tuihub/librarian/internal/biz/bizkether" "github.com/tuihub/librarian/internal/biz/biznetzach" "github.com/tuihub/librarian/internal/biz/biztiphereth" "github.com/tuihub/librarian/internal/biz/bizyesod" @@ -46,7 +46,7 @@ func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDisco return nil, nil, err } dataData := data.NewData(entClient) - angelaRepo := data.NewAngelaRepo(dataData) + ketherRepo := data.NewKetherRepo(dataData) builtInObserver, err := libobserve.NewBuiltInObserver() if err != nil { cleanup() @@ -94,25 +94,25 @@ func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDisco cleanup() return nil, nil, err } - angelaBase, err := bizangela.NewAngelaBase(angelaRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, libsearchSearch, idGenerator) + ketherBase, err := bizkether.NewKetherBase(ketherRepo, supervisorSupervisor, geburaRepo, librarianPorterServiceClient, libsearchSearch, idGenerator) if err != nil { cleanup2() cleanup() return nil, nil, err } - map3 := bizangela.NewAppInfoCache(geburaRepo, store) - libmqTopic := bizangela.NewUpdateAppInfoIndexTopic(angelaBase) - topic2 := bizangela.NewPullAppInfoTopic(angelaBase, map3, libmqTopic) - topic3 := bizangela.NewPullAccountAppInfoRelationTopic(angelaBase, topic2) - topic4 := bizangela.NewPullAccountTopic(angelaBase, topic3) - map4 := bizangela.NewNotifyFlowCache(netzachRepo, store) - map5 := bizangela.NewFeedToNotifyFlowCache(netzachRepo, store) - map6 := bizangela.NewNotifyTargetCache(netzachRepo, store) - topic5 := bizangela.NewNotifyPushTopic(angelaBase, map6) - topic6 := bizangela.NewNotifyRouterTopic(angelaBase, map4, map5, topic5) - topic7 := bizangela.NewFeedItemPostprocessTopic(angelaBase, topic6, topic) - topic8 := bizangela.NewPullFeedTopic(angelaBase, topic7, topic) - angela, err := bizangela.NewAngela(angelaBase, libmqMQ, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) + map3 := bizkether.NewAppInfoCache(geburaRepo, store) + libmqTopic := bizkether.NewUpdateAppInfoIndexTopic(ketherBase) + topic2 := bizkether.NewPullAppInfoTopic(ketherBase, map3, libmqTopic) + topic3 := bizkether.NewPullAccountAppInfoRelationTopic(ketherBase, topic2) + topic4 := bizkether.NewPullAccountTopic(ketherBase, topic3) + map4 := bizkether.NewNotifyFlowCache(netzachRepo, store) + map5 := bizkether.NewFeedToNotifyFlowCache(netzachRepo, store) + map6 := bizkether.NewNotifyTargetCache(netzachRepo, store) + topic5 := bizkether.NewNotifyPushTopic(ketherBase, map6) + topic6 := bizkether.NewNotifyRouterTopic(ketherBase, map4, map5, topic5) + topic7 := bizkether.NewFeedItemPostprocessTopic(ketherBase, topic6, topic) + topic8 := bizkether.NewPullFeedTopic(ketherBase, topic7, topic) + kether, err := bizkether.NewKether(ketherBase, libmqMQ, topic4, topic3, topic2, topic8, topic6, topic5, topic7, libmqTopic) if err != nil { cleanup2() cleanup() @@ -177,7 +177,7 @@ func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDisco cleanup() return nil, nil, err } - librarianSephirahServiceServer := sephirah.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, libauthAuth, sephirahServer) + librarianSephirahServiceServer := sephirah.NewLibrarianSephirahServiceService(kether, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, libauthAuth, sephirahServer) grpcServer, err := server.NewGRPCServer(sephirahServer, libauthAuth, librarianSephirahServiceServer, settings, builtInObserver) if err != nil { cleanup3() From bd48b865a692744f0e92cb8b147315b7f2808ddc Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 22 Mar 2025 03:26:52 +0800 Subject: [PATCH 14/19] feat: draft angela web --- go.mod | 9 +-- go.sum | 10 +-- internal/biz/biztiphereth/user.go | 5 +- internal/data/tiphereth.go | 1 - .../lib/libapp/inherent_settings_debug.go | 2 +- .../lib/libapp/inherent_settings_default.go | 2 +- internal/lib/libauth/jwt.go | 67 ++++++++++++++- internal/lib/libauth/jwt_test.go | 16 ++++ internal/service/angelaweb/angela_web.go | 42 ++++++++-- internal/service/angelaweb/angela_web_test.go | 56 ------------- .../service/angelaweb/internal/api/handler.go | 27 ++++--- .../service/angelaweb/internal/api/login.go | 33 +++----- .../service/angelaweb/internal/api/model.go | 9 +++ .../service/angelaweb/internal/api/user.go | 81 +++++++++---------- .../service/angelaweb/internal/model/model.go | 23 ------ .../service/angelaweb/internal/page/page.go | 56 +++++++++---- .../service/angelaweb/internal/util/util.go | 13 +++ internal/service/angelaweb/routes.go | 16 ++-- internal/service/sephirah/chesed.go | 10 +-- internal/service/sephirah/gebura.go | 60 +++++++------- internal/service/sephirah/netzach.go | 32 ++++---- internal/service/sephirah/porter.go | 8 +- internal/service/sephirah/tiphereth.go | 58 ++++++------- internal/service/sephirah/yesod.go | 70 ++++++++-------- main.go | 4 +- wire.go | 2 + wire_gen.go | 4 +- 27 files changed, 384 insertions(+), 332 deletions(-) create mode 100644 internal/lib/libauth/jwt_test.go delete mode 100644 internal/service/angelaweb/angela_web_test.go create mode 100644 internal/service/angelaweb/internal/api/model.go delete mode 100644 internal/service/angelaweb/internal/model/model.go create mode 100644 internal/service/angelaweb/internal/util/util.go diff --git a/go.mod b/go.mod index 4dfb744b..02c1afbc 100644 --- a/go.mod +++ b/go.mod @@ -34,8 +34,8 @@ require ( github.com/meilisearch/meilisearch-go v0.31.0 github.com/minio/minio-go/v7 v7.0.87 github.com/redis/go-redis/v9 v9.7.1 + github.com/samber/lo v1.49.1 github.com/sony/sonyflake v1.2.0 - github.com/stretchr/testify v1.10.0 github.com/tuihub/protos v0.4.25 go.opentelemetry.io/otel v1.34.0 go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.10.0 @@ -55,8 +55,6 @@ require ( google.golang.org/grpc v1.70.0 google.golang.org/protobuf v1.36.5 gopkg.in/natefinch/lumberjack.v2 v2.2.1 - gorm.io/driver/sqlite v1.5.7 - gorm.io/gorm v1.25.12 ) require ( @@ -100,7 +98,6 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -133,8 +130,6 @@ require ( github.com/hashicorp/hcl/v2 v2.16.1 // indirect github.com/hashicorp/serf v0.10.1 // indirect github.com/jhump/protoreflect v1.15.1 // indirect - github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.5 // indirect github.com/jonboulle/clockwork v0.5.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -156,7 +151,6 @@ require ( github.com/mschoch/smat v0.2.0 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect @@ -167,6 +161,7 @@ require ( github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sony/gobreaker v1.0.0 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect diff --git a/go.sum b/go.sum index e0203528..87012b60 100644 --- a/go.sum +++ b/go.sum @@ -431,10 +431,6 @@ github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7 github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= -github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= -github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= -github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -646,6 +642,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 h1:GHRpF1pTW19a8tTFrMLUcfWwyC0pnifVo2ClaLq+hP8= github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8= +github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew= +github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -1076,10 +1074,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I= -gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4= -gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= -gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/biz/biztiphereth/user.go b/internal/biz/biztiphereth/user.go index cb38c38c..c97d9d3c 100644 --- a/internal/biz/biztiphereth/user.go +++ b/internal/biz/biztiphereth/user.go @@ -16,7 +16,7 @@ import ( "github.com/go-kratos/kratos/v2/errors" ) -func (t *Tiphereth) CreateUser(ctx context.Context, user *model.User) (*model.InternalID, *errors.Error) { +func (t *Tiphereth) CreateUser(ctx context.Context, user *model.User) (*model.User, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() @@ -54,8 +54,7 @@ func (t *Tiphereth) CreateUser(ctx context.Context, user *model.User) (*model.In return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error()) } _ = t.userCountCache.Delete(ctx) - res := user.ID - return &res, nil + return user, nil } func (t *Tiphereth) UpdateUser( diff --git a/internal/data/tiphereth.go b/internal/data/tiphereth.go index 11972b23..17c60dfb 100644 --- a/internal/data/tiphereth.go +++ b/internal/data/tiphereth.go @@ -23,7 +23,6 @@ type TipherethRepo struct { data *Data } -// NewTipherethRepo . func NewTipherethRepo(data *Data) *TipherethRepo { return &TipherethRepo{ data: data, diff --git a/internal/lib/libapp/inherent_settings_debug.go b/internal/lib/libapp/inherent_settings_debug.go index 8cf825cf..2e4bc8df 100644 --- a/internal/lib/libapp/inherent_settings_debug.go +++ b/internal/lib/libapp/inherent_settings_debug.go @@ -8,6 +8,6 @@ func getInherentSettings() InherentSettings { return InherentSettings{ EnablePanicRecovery: false, LogLevel: libzap.DebugLevel, - DefaultConfPath: "../../configs/config.yaml", + DefaultConfPath: "./configs/config.yaml", } } diff --git a/internal/lib/libapp/inherent_settings_default.go b/internal/lib/libapp/inherent_settings_default.go index 57ddf4d5..9a141193 100644 --- a/internal/lib/libapp/inherent_settings_default.go +++ b/internal/lib/libapp/inherent_settings_default.go @@ -8,6 +8,6 @@ func getInherentSettings() InherentSettings { return InherentSettings{ EnablePanicRecovery: true, LogLevel: libzap.InfoLevel, - DefaultConfPath: "../../configs/config.yaml", + DefaultConfPath: "./configs/config.yaml", } } diff --git a/internal/lib/libauth/jwt.go b/internal/lib/libauth/jwt.go index 4c7d05bb..b6cde3ef 100644 --- a/internal/lib/libauth/jwt.go +++ b/internal/lib/libauth/jwt.go @@ -3,6 +3,7 @@ package libauth import ( "context" "fmt" + "net/http" "strings" "time" @@ -62,8 +63,17 @@ func RawFromContext(ctx context.Context) string { return "" } +func RawToContext(ctx context.Context, token string) context.Context { + return transport.NewServerContext(ctx, &Transport{ + kind: "", + endpoint: "", + operation: "", + reqHeader: newTokenHeader("Authorization", fmt.Sprintf("Bearer %s", token)), + }) +} + func ValidateString(tokenString string, keyFunc jwtv5.Keyfunc) (bool, error) { - token, err := jwtv5.ParseWithClaims(tokenString, &Claims{}, keyFunc) + token, err := jwtv5.ParseWithClaims(tokenString, new(Claims), keyFunc) if err != nil { return false, err } @@ -120,3 +130,58 @@ func (a *Auth) GenerateToken( token, err := tokenClaims.SignedString(a.generateSecret(claimsType)) return token, err } + +type headerCarrier http.Header + +func (hc headerCarrier) Get(key string) string { return http.Header(hc).Get(key) } + +func (hc headerCarrier) Set(key string, value string) { http.Header(hc).Set(key, value) } + +func (hc headerCarrier) Add(key string, value string) { http.Header(hc).Add(key, value) } + +// Keys lists the keys stored in this carrier. +func (hc headerCarrier) Keys() []string { + keys := make([]string, 0, len(hc)) + for k := range http.Header(hc) { + keys = append(keys, k) + } + return keys +} + +// Values returns a slice value associated with the passed key. +func (hc headerCarrier) Values(key string) []string { + return http.Header(hc).Values(key) +} + +func newTokenHeader(headerKey string, token string) *headerCarrier { + header := &headerCarrier{} + header.Set(headerKey, token) + return header +} + +type Transport struct { + kind transport.Kind + endpoint string + operation string + reqHeader transport.Header +} + +func (tr *Transport) Kind() transport.Kind { + return tr.kind +} + +func (tr *Transport) Endpoint() string { + return tr.endpoint +} + +func (tr *Transport) Operation() string { + return tr.operation +} + +func (tr *Transport) RequestHeader() transport.Header { + return tr.reqHeader +} + +func (tr *Transport) ReplyHeader() transport.Header { + return nil +} diff --git a/internal/lib/libauth/jwt_test.go b/internal/lib/libauth/jwt_test.go new file mode 100644 index 00000000..57a1a95b --- /dev/null +++ b/internal/lib/libauth/jwt_test.go @@ -0,0 +1,16 @@ +package libauth_test + +import ( + "context" + "testing" + + "github.com/tuihub/librarian/internal/lib/libauth" +) + +func Test_RawToContext(t *testing.T) { + token := "abcd" + ctx := context.Background() + if token != libauth.RawFromContext(libauth.RawToContext(ctx, token)) { + t.Error("RawToContext failed") + } +} diff --git a/internal/service/angelaweb/angela_web.go b/internal/service/angelaweb/angela_web.go index a8423589..d797dde2 100644 --- a/internal/service/angelaweb/angela_web.go +++ b/internal/service/angelaweb/angela_web.go @@ -2,14 +2,24 @@ package angelaweb import ( "context" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/html/v2" + "embed" + "github.com/gofiber/fiber/v2/middleware/logger" + "net/http" + + "github.com/tuihub/librarian/internal/biz/biztiphereth" "github.com/tuihub/librarian/internal/lib/libauth" + "github.com/tuihub/librarian/internal/lib/libcache" + "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" - "gorm.io/gorm" + + "github.com/gofiber/fiber/v2" + "github.com/gofiber/template/html/v2" + "github.com/google/wire" ) +var ProviderSet = wire.NewSet(NewAngelaWeb) + type AngelaWeb struct { apiHandler *api.Handler pageBuilder *page.Builder @@ -17,17 +27,33 @@ type AngelaWeb struct { app *fiber.App } -func NewAngelaWeb(db *gorm.DB, auth *libauth.Auth) *AngelaWeb { - viewsEngine := html.New("./view", ".html") +// Embed view +// +//go:embed view/* +var embedDirView embed.FS + +// Embed static +// +//go:embed static/* +var embedDirStatic embed.FS - app := fiber.New(fiber.Config{ +func NewAngelaWeb( + auth *libauth.Auth, + t *biztiphereth.Tiphereth, + userCountCache *libcache.Key[model.UserCount], +) *AngelaWeb { + viewsEngine := html.NewFileSystem(http.FS(embedDirView), ".html") + + app := fiber.New(fiber.Config{ //nolint:exhaustruct // no need Views: viewsEngine, ViewsLayout: "layout/default", }) + app.Use(logger.New()) + res := &AngelaWeb{ - apiHandler: api.NewHandler(db, auth), - pageBuilder: page.NewBuilder(db), + apiHandler: api.NewHandler(t, userCountCache), + pageBuilder: page.NewBuilder(t, userCountCache), auth: auth, app: app, } diff --git a/internal/service/angelaweb/angela_web_test.go b/internal/service/angelaweb/angela_web_test.go deleted file mode 100644 index ea648d84..00000000 --- a/internal/service/angelaweb/angela_web_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package angelaweb - -import ( - "context" - "github.com/tuihub/librarian/internal/conf" - "github.com/tuihub/librarian/internal/lib/libauth" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/api" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" - "golang.org/x/crypto/bcrypt" - "testing" - - "github.com/stretchr/testify/assert" - "gorm.io/driver/sqlite" - "gorm.io/gorm" -) - -func Test_AngelaWeb(t *testing.T) { - auth, err := libauth.NewAuth(&conf.Auth{ - PasswordSalt: "", - JwtIssuer: "", - JwtSecret: "", - }) - db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{}) - if err != nil { - t.Fatal(err) - } - - admin := model.User{ - Username: "admin", - Password: "admin123", - Email: "admin@example.com", - Role: "admin", - } - hashedPassword, err := bcrypt.GenerateFromPassword([]byte(admin.Password), bcrypt.DefaultCost) - if err != nil { - t.Fatal(err) - } - admin.Password = string(hashedPassword) - err = db.AutoMigrate(&admin) - if err != nil { - t.Fatal(err) - } - err = db.Create(&admin).Error - if err != nil { - t.Fatal(err) - } - - handler := api.NewHandler(db, auth) - builder := page.NewBuilder(db) - angelaWeb := NewAngelaWeb(handler, builder, auth) - - err = angelaWeb.Start(context.Background()) - - assert.NoError(t, err) -} diff --git a/internal/service/angelaweb/internal/api/handler.go b/internal/service/angelaweb/internal/api/handler.go index 0fcc59b3..9d5e3f97 100644 --- a/internal/service/angelaweb/internal/api/handler.go +++ b/internal/service/angelaweb/internal/api/handler.go @@ -1,29 +1,34 @@ package api import ( - "github.com/tuihub/librarian/internal/lib/libauth" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + "net/http" + + "github.com/tuihub/librarian/internal/biz/biztiphereth" + "github.com/tuihub/librarian/internal/lib/libcache" + "github.com/tuihub/librarian/internal/model" "github.com/gofiber/fiber/v2" - "gorm.io/gorm" ) type Handler struct { - db *gorm.DB - auth *libauth.Auth + t *biztiphereth.Tiphereth + userCountCache *libcache.Key[model.UserCount] } -func NewHandler(db *gorm.DB, auth *libauth.Auth) *Handler { +func NewHandler( + t *biztiphereth.Tiphereth, + userCountCache *libcache.Key[model.UserCount], +) *Handler { return &Handler{ - db: db, - auth: auth, + t: t, + userCountCache: userCountCache, } } func (h *Handler) GetDashboardStats(c *fiber.Ctx) error { - var userCount int64 - if err := h.db.Model(&model.User{}).Count(&userCount).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error fetching stats"}) + userCount, err := h.userCountCache.Get(c.Context()) + if err != nil { + return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": "Error fetching stats"}) } return c.JSON(fiber.Map{"user_count": userCount}) } diff --git a/internal/service/angelaweb/internal/api/login.go b/internal/service/angelaweb/internal/api/login.go index 2202fab5..ba5158b3 100644 --- a/internal/service/angelaweb/internal/api/login.go +++ b/internal/service/angelaweb/internal/api/login.go @@ -1,43 +1,28 @@ package api import ( + "net/http" "time" - "github.com/tuihub/librarian/internal/lib/libauth" - model2 "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/util" "github.com/gofiber/fiber/v2" ) func (h *Handler) Login(c *fiber.Ctx) error { - var req model.LoginRequest + var req LoginRequest if err := c.BodyParser(&req); err != nil { - return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + return c.Status(http.StatusBadRequest).JSON(fiber.Map{"message": "Invalid request"}) } - var user model.User - if err := h.db.Where("username = ?", req.Username).First(&user).Error; err != nil { - return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) - } - - hashedPassword, err := h.auth.GeneratePassword(req.Password) - if err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) - } - - if hashedPassword != user.Password { - return c.Status(401).JSON(fiber.Map{"message": "Invalid credentials"}) - } - - token, err := h.auth.GenerateToken(model2.InternalID(user.ID), 0, libauth.ClaimsTypeAccessToken, model2.UserTypeAdmin, nil, 24*time.Hour) + accessToken, _, err := h.t.GetToken(util.BizContext(c), req.Username, req.Password, nil) if err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error generating token"}) + return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": err.Message}) } - c.Cookie(&fiber.Cookie{ + c.Cookie(&fiber.Cookie{ //nolint:exhaustruct // no need Name: "access_token", - Value: token, + Value: string(accessToken), Expires: time.Now().Add(24 * time.Hour), HTTPOnly: true, Secure: true, @@ -45,5 +30,5 @@ func (h *Handler) Login(c *fiber.Ctx) error { Path: "/", }) - return c.JSON(model.LoginResponse{}) + return c.JSON(LoginResponse{}) } diff --git a/internal/service/angelaweb/internal/api/model.go b/internal/service/angelaweb/internal/api/model.go new file mode 100644 index 00000000..556d8dba --- /dev/null +++ b/internal/service/angelaweb/internal/api/model.go @@ -0,0 +1,9 @@ +package api + +type LoginRequest struct { + Username string `json:"username"` + Password string `json:"password"` +} + +type LoginResponse struct { +} diff --git a/internal/service/angelaweb/internal/api/user.go b/internal/service/angelaweb/internal/api/user.go index da0017d4..ff9e2c70 100644 --- a/internal/service/angelaweb/internal/api/user.go +++ b/internal/service/angelaweb/internal/api/user.go @@ -1,80 +1,71 @@ package api import ( - "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + "net/http" + "strconv" + + "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/util" "github.com/gofiber/fiber/v2" + "github.com/samber/lo" ) func (h *Handler) ListUsers(c *fiber.Ctx) error { - var users []model.User - if err := h.db.Find(&users).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error fetching users"}) + users, _, err := h.t.ListUsers(util.BizContext(c), model.Paging{ + PageSize: 1, + PageNum: 20, + }, nil, nil) + if err != nil { + return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": "Error fetching users"}) } return c.JSON(users) } func (h *Handler) GetUser(c *fiber.Ctx) error { - id := c.Params("id") - var user model.User - if err := h.db.First(&user, id).Error; err != nil { - return c.Status(404).JSON(fiber.Map{"message": "User not found"}) + idStr := c.Params("id") + id, err := strconv.ParseInt(idStr, 10, 64) + if err != nil { + return c.Status(http.StatusBadRequest).JSON(fiber.Map{"message": "Invalid ID"}) + } + user, err := h.t.GetUser(util.BizContext(c), lo.ToPtr(model.InternalID(id))) + if err != nil { + return c.Status(http.StatusNotFound).JSON(fiber.Map{"message": "User not found"}) } return c.JSON(user) } func (h *Handler) CreateUser(c *fiber.Ctx) error { - var user model.User - if err := c.BodyParser(&user); err != nil { - return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + var user *model.User + if err := c.BodyParser(user); err != nil { + return c.Status(http.StatusBadRequest).JSON(fiber.Map{"message": "Invalid request"}) } - // 加密密码 - hashedPassword, err := h.auth.GeneratePassword(user.Password) + var err error + user, err = h.t.CreateUser(util.BizContext(c), user) if err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) + return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": err.Error()}) } - user.Password = hashedPassword - if err := h.db.Create(&user).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error creating user"}) - } return c.JSON(user) } func (h *Handler) UpdateUser(c *fiber.Ctx) error { - id := c.Params("id") - var updates model.User - if err := c.BodyParser(&updates); err != nil { - return c.Status(400).JSON(fiber.Map{"message": "Invalid request"}) + idStr := c.Params("id") + id, err := strconv.ParseInt(idStr, 10, 64) + if err != nil { + return c.Status(http.StatusBadRequest).JSON(fiber.Map{"message": "Invalid ID"}) } - var user model.User - if err := h.db.First(&user, id).Error; err != nil { - return c.Status(404).JSON(fiber.Map{"message": "User not found"}) + if err = c.BodyParser(&user); err != nil { + return c.Status(http.StatusBadRequest).JSON(fiber.Map{"message": "Invalid request"}) } + user.ID = model.InternalID(id) - // 如果提供了新密码,则加密 - if updates.Password != "" { - hashedPassword, err := h.auth.GeneratePassword(user.Password) - if err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error processing password"}) - } - updates.Password = hashedPassword - } else { - updates.Password = user.Password + err = h.t.UpdateUser(util.BizContext(c), &user, "") + if err != nil { + return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": err.Error()}) } - if err := h.db.Model(&user).Updates(updates).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error updating user"}) - } return c.JSON(user) } - -func (h *Handler) DeleteUser(c *fiber.Ctx) error { - id := c.Params("id") - if err := h.db.Delete(&model.User{}, id).Error; err != nil { - return c.Status(500).JSON(fiber.Map{"message": "Error deleting user"}) - } - return c.JSON(fiber.Map{"message": "User deleted"}) -} diff --git a/internal/service/angelaweb/internal/model/model.go b/internal/service/angelaweb/internal/model/model.go deleted file mode 100644 index 92edebe4..00000000 --- a/internal/service/angelaweb/internal/model/model.go +++ /dev/null @@ -1,23 +0,0 @@ -package model - -import ( - "time" -) - -type User struct { - ID uint `gorm:"primarykey" json:"id"` - Username string `gorm:"unique" json:"username"` - Password string `json:"-"` // 不在JSON中显示密码 - Email string `json:"email"` - Role string `json:"role"` - CreatedAt time.Time `json:"created_at"` -} - -type LoginRequest struct { - Username string `json:"username"` - Password string `json:"password"` -} - -type LoginResponse struct { - Token string `json:"token"` -} diff --git a/internal/service/angelaweb/internal/page/page.go b/internal/service/angelaweb/internal/page/page.go index 8ccbda80..c7cd8580 100644 --- a/internal/service/angelaweb/internal/page/page.go +++ b/internal/service/angelaweb/internal/page/page.go @@ -1,18 +1,31 @@ package page import ( - "github.com/tuihub/librarian/internal/service/angelaweb/internal/model" + "net/http" + "strconv" + + "github.com/tuihub/librarian/internal/biz/biztiphereth" + "github.com/tuihub/librarian/internal/lib/libcache" + "github.com/tuihub/librarian/internal/model" + "github.com/tuihub/librarian/internal/service/angelaweb/internal/util" "github.com/gofiber/fiber/v2" - "gorm.io/gorm" + "github.com/samber/lo" ) type Builder struct { - db *gorm.DB + t *biztiphereth.Tiphereth + userCountCache *libcache.Key[model.UserCount] } -func NewBuilder(db *gorm.DB) *Builder { - return &Builder{db: db} +func NewBuilder( + t *biztiphereth.Tiphereth, + userCountCache *libcache.Key[model.UserCount], +) *Builder { + return &Builder{ + t: t, + userCountCache: userCountCache, + } } func (b *Builder) Login(c *fiber.Ctx) error { @@ -22,9 +35,9 @@ func (b *Builder) Login(c *fiber.Ctx) error { } func (b *Builder) Dashboard(c *fiber.Ctx) error { - var userCount int64 - if err := b.db.Model(&model.User{}).Count(&userCount).Error; err != nil { - return c.Status(500).SendString("Error fetching dashboard data") + userCount, err := b.userCountCache.Get(util.BizContext(c)) + if err != nil { + return c.Status(http.StatusInternalServerError).SendString("Error fetching dashboard data") } return c.Render("dashboard", fiber.Map{ @@ -34,9 +47,13 @@ func (b *Builder) Dashboard(c *fiber.Ctx) error { } func (b *Builder) UserList(c *fiber.Ctx) error { - var users []model.User - if err := b.db.Find(&users).Error; err != nil { - return c.Status(500).SendString("Error fetching users") + users, _, err := b.t.ListUsers(util.BizContext(c), model.Paging{ + PageNum: 1, + PageSize: 20, + }, nil, nil) + + if err != nil { + return c.Status(http.StatusInternalServerError).SendString("Error fetching users") } return c.Render("user", fiber.Map{ @@ -46,18 +63,23 @@ func (b *Builder) UserList(c *fiber.Ctx) error { } func (b *Builder) UserForm(c *fiber.Ctx) error { - id := c.Params("id") - var user model.User + idStr := c.Params("id") + var user *model.User var title string var action string var method string - if id != "" { - if err := b.db.First(&user, id).Error; err != nil { - return c.Status(404).SendString("User not found") + if idStr != "" { + id, err := strconv.ParseInt(idStr, 10, 64) + if err != nil { + return c.Status(http.StatusBadRequest).SendString("Invalid ID") + } + user, err = b.t.GetUser(util.BizContext(c), lo.ToPtr(model.InternalID(id))) + if err != nil { + return c.Status(http.StatusNotFound).SendString("User not found") } title = "编辑用户" - action = "/api/users/" + id + action = "/api/users/" + idStr method = "PUT" } else { title = "创建用户" diff --git a/internal/service/angelaweb/internal/util/util.go b/internal/service/angelaweb/internal/util/util.go new file mode 100644 index 00000000..984e7172 --- /dev/null +++ b/internal/service/angelaweb/internal/util/util.go @@ -0,0 +1,13 @@ +package util + +import ( + "context" + + "github.com/tuihub/librarian/internal/lib/libauth" + + "github.com/gofiber/fiber/v2" +) + +func BizContext(c *fiber.Ctx) context.Context { + return libauth.RawToContext(c.Context(), c.Cookies("access_token")) +} diff --git a/internal/service/angelaweb/routes.go b/internal/service/angelaweb/routes.go index 580a7344..ee173161 100644 --- a/internal/service/angelaweb/routes.go +++ b/internal/service/angelaweb/routes.go @@ -1,10 +1,13 @@ package angelaweb import ( + "github.com/gofiber/fiber/v2/middleware/filesystem" + "github.com/tuihub/librarian/internal/lib/libauth" + "net/http" + "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" "github.com/gofiber/fiber/v2/middleware/keyauth" - "github.com/tuihub/librarian/internal/lib/libauth" ) func (a *AngelaWeb) newValidator() func(ctx *fiber.Ctx, s string) (bool, error) { @@ -15,7 +18,11 @@ func (a *AngelaWeb) newValidator() func(ctx *fiber.Ctx, s string) (bool, error) func (a *AngelaWeb) setupRoutes() { // 静态文件 - a.app.Static("/static", "./static") + a.app.Use("/static", filesystem.New(filesystem.Config{ + Root: http.FS(embedDirStatic), + PathPrefix: "static", + Browse: true, + })) // CORS a.app.Use(cors.New()) @@ -24,7 +31,7 @@ func (a *AngelaWeb) setupRoutes() { api := a.app.Group("/api") api.Post("/login", a.apiHandler.Login) - api.Use(keyauth.New(keyauth.Config{ + api.Use(keyauth.New(keyauth.Config{ //nolint:exhaustruct // no need KeyLookup: "cookie:access_token", Validator: a.newValidator(), })) @@ -34,7 +41,6 @@ func (a *AngelaWeb) setupRoutes() { api.Post("/users", a.apiHandler.CreateUser) api.Get("/users/:id", a.apiHandler.GetUser) api.Put("/users/:id", a.apiHandler.UpdateUser) - api.Delete("/users/:id", a.apiHandler.DeleteUser) api.Get("/dashboard/stats", a.apiHandler.GetDashboardStats) // 页面路由 @@ -42,7 +48,7 @@ func (a *AngelaWeb) setupRoutes() { // 受保护的页面路由 auth := a.app.Group("/") - auth.Use(keyauth.New(keyauth.Config{ + auth.Use(keyauth.New(keyauth.Config{ //nolint:exhaustruct // no need KeyLookup: "cookie:access_token", Validator: a.newValidator(), })) diff --git a/internal/service/sephirah/chesed.go b/internal/service/sephirah/chesed.go index 4d724eb9..578c2740 100644 --- a/internal/service/sephirah/chesed.go +++ b/internal/service/sephirah/chesed.go @@ -5,7 +5,7 @@ import ( "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelchesed" - converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" + "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" @@ -15,7 +15,7 @@ import ( func (s *LibrarianSephirahServiceService) UploadImage(ctx context.Context, req *pb.UploadImageRequest) ( *pb.UploadImageResponse, error) { - fm := converter2.ToBizFileMetadata(req.GetFileMetadata()) + fm := converter.ToBizFileMetadata(req.GetFileMetadata()) if fm == nil { return nil, pb.ErrorErrorReasonBadRequest("app required") } @@ -42,7 +42,7 @@ func (s *LibrarianSephirahServiceService) ListImages(ctx context.Context, req *p } return &pb.ListImagesResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Ids: converter2.ToPBInternalIDList(res), + Ids: converter.ToPBInternalIDList(res), }, nil } func (s *LibrarianSephirahServiceService) SearchImages(ctx context.Context, @@ -53,7 +53,7 @@ func (s *LibrarianSephirahServiceService) SearchImages(ctx context.Context, } return &pb.SearchImagesResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(len(res))}, - Ids: converter2.ToPBInternalIDList(res), + Ids: converter.ToPBInternalIDList(res), }, nil } func (s *LibrarianSephirahServiceService) GetImage(ctx context.Context, req *pb.GetImageRequest) ( @@ -62,7 +62,7 @@ func (s *LibrarianSephirahServiceService) GetImage(ctx context.Context, req *pb. } func (s *LibrarianSephirahServiceService) DownloadImage(ctx context.Context, req *pb.DownloadImageRequest) ( *pb.DownloadImageResponse, error) { - token, err := s.c.DownloadImage(ctx, converter2.ToBizInternalID(req.GetId())) + token, err := s.c.DownloadImage(ctx, converter.ToBizInternalID(req.GetId())) if err != nil { return nil, err } diff --git a/internal/service/sephirah/gebura.go b/internal/service/sephirah/gebura.go index 24fea432..d38b5555 100644 --- a/internal/service/sephirah/gebura.go +++ b/internal/service/sephirah/gebura.go @@ -4,7 +4,7 @@ import ( "context" "github.com/tuihub/librarian/internal/model" - converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" + "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" @@ -19,12 +19,12 @@ func (s *LibrarianSephirahServiceService) CreateAppInfo(ctx context.Context, req if appInfo == nil { return nil, pb.ErrorErrorReasonBadRequest("appInfo info required") } - a, err := s.g.CreateAppInfo(ctx, converter2.ToBizAppInfo(req.GetAppInfo())) + a, err := s.g.CreateAppInfo(ctx, converter.ToBizAppInfo(req.GetAppInfo())) if err != nil { return nil, err } return &pb.CreateAppInfoResponse{ - Id: converter2.ToPBInternalID(a.ID), + Id: converter.ToPBInternalID(a.ID), }, nil } func (s *LibrarianSephirahServiceService) UpdateAppInfo(ctx context.Context, req *pb.UpdateAppInfoRequest) ( @@ -34,7 +34,7 @@ func (s *LibrarianSephirahServiceService) UpdateAppInfo(ctx context.Context, req if appInfo == nil || appInfo.GetId() == nil { return nil, pb.ErrorErrorReasonBadRequest("appInfo and internal_id required") } - err := s.g.UpdateAppInfo(ctx, converter2.ToBizAppInfo(req.GetAppInfo())) + err := s.g.UpdateAppInfo(ctx, converter.ToBizAppInfo(req.GetAppInfo())) if err != nil { return nil, err } @@ -46,8 +46,8 @@ func (s *LibrarianSephirahServiceService) ListAppInfos(ctx context.Context, req a, total, err := s.g.ListAppInfos(ctx, model.ToBizPaging(req.GetPaging()), req.GetSourceFilter(), - converter2.ToBizAppTypeList(req.GetTypeFilter()), - converter2.ToBizInternalIDList(req.GetIdFilter()), + converter.ToBizAppTypeList(req.GetTypeFilter()), + converter.ToBizInternalIDList(req.GetIdFilter()), req.GetContainDetails(), ) if err != nil { @@ -55,19 +55,19 @@ func (s *LibrarianSephirahServiceService) ListAppInfos(ctx context.Context, req } return &pb.ListAppInfosResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - AppInfos: converter2.ToPBAppInfoList(a), + AppInfos: converter.ToPBAppInfoList(a), }, nil } func (s *LibrarianSephirahServiceService) MergeAppInfos(ctx context.Context, req *pb.MergeAppInfosRequest) ( *pb.MergeAppInfosResponse, error, ) { - info := converter2.ToBizAppInfo(req.GetBase()) + info := converter.ToBizAppInfo(req.GetBase()) if info == nil { return nil, pb.ErrorErrorReasonBadRequest("base required") } err := s.g.MergeAppInfos(ctx, *info, - converter2.ToBizInternalID(req.GetMerged()), + converter.ToBizInternalID(req.GetMerged()), ) if err != nil { return nil, err @@ -77,11 +77,11 @@ func (s *LibrarianSephirahServiceService) MergeAppInfos(ctx context.Context, req func (s *LibrarianSephirahServiceService) SyncAppInfos(ctx context.Context, req *pb.SyncAppInfosRequest) ( *pb.SyncAppInfosResponse, error, ) { - apps, err := s.g.SyncAppInfos(ctx, converter2.ToBizAppInfoIDList(req.GetAppInfoIds()), req.GetWaitData()) + apps, err := s.g.SyncAppInfos(ctx, converter.ToBizAppInfoIDList(req.GetAppInfoIds()), req.GetWaitData()) if err != nil { return nil, err } - return &pb.SyncAppInfosResponse{AppInfos: converter2.ToPBAppInfoList(apps)}, nil + return &pb.SyncAppInfosResponse{AppInfos: converter.ToPBAppInfoList(apps)}, nil } func (s *LibrarianSephirahServiceService) SearchAppInfos(ctx context.Context, req *pb.SearchAppInfosRequest) ( *pb.SearchAppInfosResponse, error, @@ -95,7 +95,7 @@ func (s *LibrarianSephirahServiceService) SearchAppInfos(ctx context.Context, re } return &pb.SearchAppInfosResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - AppInfos: converter2.ToPBAppInfoMixedList(infos), + AppInfos: converter.ToPBAppInfoMixedList(infos), }, nil } func (s *LibrarianSephirahServiceService) SearchNewAppInfos(ctx context.Context, req *pb.SearchNewAppInfosRequest) ( @@ -111,36 +111,36 @@ func (s *LibrarianSephirahServiceService) SearchNewAppInfos(ctx context.Context, } return &pb.SearchNewAppInfosResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - AppInfos: converter2.ToPBAppInfoList(infos), + AppInfos: converter.ToPBAppInfoList(infos), }, nil } func (s *LibrarianSephirahServiceService) GetAppInfo(ctx context.Context, req *pb.GetAppInfoRequest) ( *pb.GetAppInfoResponse, error, ) { - res, err := s.g.GetAppInfo(ctx, converter2.ToBizInternalID(req.GetAppInfoId())) + res, err := s.g.GetAppInfo(ctx, converter.ToBizInternalID(req.GetAppInfoId())) if err != nil { return nil, err } - return &pb.GetAppInfoResponse{AppInfo: converter2.ToPBAppInfo(res)}, nil + return &pb.GetAppInfoResponse{AppInfo: converter.ToPBAppInfo(res)}, nil } func (s *LibrarianSephirahServiceService) GetBoundAppInfos(ctx context.Context, req *pb.GetBoundAppInfosRequest) ( *pb.GetBoundAppInfosResponse, error, ) { - al, err := s.g.GetBoundAppInfos(ctx, converter2.ToBizInternalID(req.GetAppInfoId())) + al, err := s.g.GetBoundAppInfos(ctx, converter.ToBizInternalID(req.GetAppInfoId())) if err != nil { return nil, err } - return &pb.GetBoundAppInfosResponse{AppInfos: converter2.ToPBAppInfoList(al)}, nil + return &pb.GetBoundAppInfosResponse{AppInfos: converter.ToPBAppInfoList(al)}, nil } func (s *LibrarianSephirahServiceService) PurchaseAppInfo(ctx context.Context, req *pb.PurchaseAppInfoRequest) ( *pb.PurchaseAppInfoResponse, error, ) { - id, err := s.g.PurchaseAppInfo(ctx, converter2.ToBizAppInfoID(req.GetAppInfoId())) + id, err := s.g.PurchaseAppInfo(ctx, converter.ToBizAppInfoID(req.GetAppInfoId())) if err != nil { return nil, err } return &pb.PurchaseAppInfoResponse{ - Id: converter2.ToPBInternalID(id), + Id: converter.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) GetPurchasedAppInfos( @@ -154,7 +154,7 @@ func (s *LibrarianSephirahServiceService) GetPurchasedAppInfos( return nil, err } return &pb.GetPurchasedAppInfosResponse{ - AppInfos: converter2.ToPBAppInfoMixedList(infos), + AppInfos: converter.ToPBAppInfoMixedList(infos), }, nil } @@ -162,17 +162,17 @@ func (s *LibrarianSephirahServiceService) CreateApp( ctx context.Context, req *pb.CreateAppRequest, ) (*pb.CreateAppResponse, error) { - ap, err := s.g.CreateApp(ctx, converter2.ToBizApp(req.GetApp())) + ap, err := s.g.CreateApp(ctx, converter.ToBizApp(req.GetApp())) if err != nil { return nil, err } - return &pb.CreateAppResponse{Id: converter2.ToPBInternalID(ap.ID)}, nil + return &pb.CreateAppResponse{Id: converter.ToPBInternalID(ap.ID)}, nil } func (s *LibrarianSephirahServiceService) UpdateApp( ctx context.Context, req *pb.UpdateAppRequest, ) (*pb.UpdateAppResponse, error) { - err := s.g.UpdateApp(ctx, converter2.ToBizApp(req.GetApp())) + err := s.g.UpdateApp(ctx, converter.ToBizApp(req.GetApp())) if err != nil { return nil, err } @@ -184,16 +184,16 @@ func (s *LibrarianSephirahServiceService) ListApps( ) (*pb.ListAppsResponse, error) { ap, total, err := s.g.ListApps(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizInternalIDList(req.GetOwnerIdFilter()), - converter2.ToBizInternalIDList(req.GetAssignedAppInfoIdFilter()), - converter2.ToBizInternalIDList(req.GetIdFilter()), + converter.ToBizInternalIDList(req.GetOwnerIdFilter()), + converter.ToBizInternalIDList(req.GetAssignedAppInfoIdFilter()), + converter.ToBizInternalIDList(req.GetIdFilter()), ) if err != nil { return nil, err } return &pb.ListAppsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - Apps: converter2.ToPBAppList(ap), + Apps: converter.ToPBAppList(ap), }, nil } func (s *LibrarianSephirahServiceService) AssignApp( @@ -201,8 +201,8 @@ func (s *LibrarianSephirahServiceService) AssignApp( req *pb.AssignAppRequest, ) (*pb.AssignAppResponse, error) { err := s.g.AssignApp(ctx, - converter2.ToBizInternalID(req.GetAppId()), - converter2.ToBizInternalID(req.GetAppInfoId()), + converter.ToBizInternalID(req.GetAppId()), + converter.ToBizInternalID(req.GetAppInfoId()), ) if err != nil { return nil, err @@ -213,7 +213,7 @@ func (s *LibrarianSephirahServiceService) UnAssignApp( ctx context.Context, req *pb.UnAssignAppRequest, ) (*pb.UnAssignAppResponse, error) { - err := s.g.UnAssignApp(ctx, converter2.ToBizInternalID(req.GetAppId())) + err := s.g.UnAssignApp(ctx, converter.ToBizInternalID(req.GetAppId())) if err != nil { return nil, err } diff --git a/internal/service/sephirah/netzach.go b/internal/service/sephirah/netzach.go index a01b0743..74036957 100644 --- a/internal/service/sephirah/netzach.go +++ b/internal/service/sephirah/netzach.go @@ -4,24 +4,24 @@ import ( "context" "github.com/tuihub/librarian/internal/model" - converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" + "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) func (s *LibrarianSephirahServiceService) CreateNotifyTarget(ctx context.Context, req *pb.CreateNotifyTargetRequest) ( *pb.CreateNotifyTargetResponse, error) { - id, err := s.n.CreateNotifyTarget(ctx, converter2.ToBizNotifyTarget(req.GetTarget())) + id, err := s.n.CreateNotifyTarget(ctx, converter.ToBizNotifyTarget(req.GetTarget())) if err != nil { return nil, err } return &pb.CreateNotifyTargetResponse{ - Id: converter2.ToPBInternalID(id), + Id: converter.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) UpdateNotifyTarget(ctx context.Context, req *pb.UpdateNotifyTargetRequest) ( *pb.UpdateNotifyTargetResponse, error) { - err := s.n.UpdateNotifyTarget(ctx, converter2.ToBizNotifyTarget(req.GetTarget())) + err := s.n.UpdateNotifyTarget(ctx, converter.ToBizNotifyTarget(req.GetTarget())) if err != nil { return nil, err } @@ -31,30 +31,30 @@ func (s *LibrarianSephirahServiceService) ListNotifyTargets(ctx context.Context, *pb.ListNotifyTargetsResponse, error) { t, total, err := s.n.ListNotifyTargets(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizInternalIDList(req.GetIdFilter()), - converter2.ToBizNotifyTargetStatusList(req.GetStatusFilter()), + converter.ToBizInternalIDList(req.GetIdFilter()), + converter.ToBizNotifyTargetStatusList(req.GetStatusFilter()), ) if err != nil { return nil, err } return &pb.ListNotifyTargetsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Targets: converter2.ToPBNotifyTargetList(t), + Targets: converter.ToPBNotifyTargetList(t), }, nil } func (s *LibrarianSephirahServiceService) CreateNotifyFlow(ctx context.Context, req *pb.CreateNotifyFlowRequest) ( *pb.CreateNotifyFlowResponse, error) { - id, err := s.n.CreateNotifyFlow(ctx, converter2.ToBizNotifyFlow(req.GetFlow())) + id, err := s.n.CreateNotifyFlow(ctx, converter.ToBizNotifyFlow(req.GetFlow())) if err != nil { return nil, err } return &pb.CreateNotifyFlowResponse{ - Id: converter2.ToPBInternalID(id), + Id: converter.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) UpdateNotifyFlow(ctx context.Context, req *pb.UpdateNotifyFlowRequest) ( *pb.UpdateNotifyFlowResponse, error) { - err := s.n.UpdateNotifyFlow(ctx, converter2.ToBizNotifyFlow(req.GetFlow())) + err := s.n.UpdateNotifyFlow(ctx, converter.ToBizNotifyFlow(req.GetFlow())) if err != nil { return nil, err } @@ -64,29 +64,29 @@ func (s *LibrarianSephirahServiceService) ListNotifyFlows(ctx context.Context, r *pb.ListNotifyFlowsResponse, error) { res, total, err := s.n.ListNotifyFlows(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizInternalIDList(req.GetIdFilter()), + converter.ToBizInternalIDList(req.GetIdFilter()), ) if err != nil { return nil, err } return &pb.ListNotifyFlowsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Flows: converter2.ToPBNotifyFlowList(res), + Flows: converter.ToPBNotifyFlowList(res), }, nil } func (s *LibrarianSephirahServiceService) ListSystemNotifications(ctx context.Context, req *pb.ListSystemNotificationsRequest) ( *pb.ListSystemNotificationsResponse, error) { res, total, err := s.n.ListSystemNotifications(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizSystemNotificationTypeList(req.GetTypeFilter()), - converter2.ToBizSystemNotificationLevelList(req.GetLevelFilter()), - converter2.ToBizSystemNotificationStatusList(req.GetStatusFilter()), + converter.ToBizSystemNotificationTypeList(req.GetTypeFilter()), + converter.ToBizSystemNotificationLevelList(req.GetLevelFilter()), + converter.ToBizSystemNotificationStatusList(req.GetStatusFilter()), ) if err != nil { return nil, err } return &pb.ListSystemNotificationsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Notifications: converter2.ToPBSystemNotificationList(res), + Notifications: converter.ToPBSystemNotificationList(res), }, nil } diff --git a/internal/service/sephirah/porter.go b/internal/service/sephirah/porter.go index 2f0ee482..8ddd37ba 100644 --- a/internal/service/sephirah/porter.go +++ b/internal/service/sephirah/porter.go @@ -4,7 +4,7 @@ import ( "context" "github.com/tuihub/librarian/internal/model" - converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" + "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" ) @@ -13,7 +13,7 @@ func (s *LibrarianSephirahServiceService) PorterGetNotifyTargetItems( req *pb.PorterGetNotifyTargetItemsRequest, ) (*pb.PorterGetNotifyTargetItemsResponse, error) { fr, items, err := s.a.PorterGetNotifyTargetItems(ctx, - converter2.ToBizInternalID(req.GetId()), + converter.ToBizInternalID(req.GetId()), model.ToBizPaging(req.GetPaging()), ) if err != nil { @@ -21,7 +21,7 @@ func (s *LibrarianSephirahServiceService) PorterGetNotifyTargetItems( } return &pb.PorterGetNotifyTargetItemsResponse{ Paging: nil, - Destination: converter2.ToPBFeatureRequest(fr), - Items: converter2.ToPBFeedItemList(items), + Destination: converter.ToPBFeatureRequest(fr), + Items: converter.ToPBFeedItemList(items), }, nil } diff --git a/internal/service/sephirah/tiphereth.go b/internal/service/sephirah/tiphereth.go index 30621591..91091684 100644 --- a/internal/service/sephirah/tiphereth.go +++ b/internal/service/sephirah/tiphereth.go @@ -7,7 +7,7 @@ import ( "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelsupervisor" - converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" + "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) @@ -18,7 +18,7 @@ func (s *LibrarianSephirahServiceService) GetToken(ctx context.Context, req *pb. accessToken, refreshToken, err := s.t.GetToken(ctx, req.GetUsername(), req.GetPassword(), - converter2.ToBizInternalIDPtr(req.GetDeviceId()), + converter.ToBizInternalIDPtr(req.GetDeviceId()), ) if err != nil { logger.Infof("GetToken failed: %s", err.Error()) @@ -34,7 +34,7 @@ func (s *LibrarianSephirahServiceService) RefreshToken(ctx context.Context, req ) { var deviceID *model.InternalID if req.GetDeviceId() != nil { - id := converter2.ToBizInternalID(req.GetDeviceId()) + id := converter.ToBizInternalID(req.GetDeviceId()) deviceID = &id } accessToken, refreshToken, err := s.t.RefreshToken(ctx, deviceID) @@ -53,7 +53,7 @@ func (s *LibrarianSephirahServiceService) AcquireUserToken(ctx context.Context, if req.GetUserId() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - token, err := s.t.AcquireUserToken(ctx, converter2.ToBizInternalID(req.GetUserId())) + token, err := s.t.AcquireUserToken(ctx, converter.ToBizInternalID(req.GetUserId())) if err != nil { return nil, err } @@ -99,12 +99,12 @@ func (s *LibrarianSephirahServiceService) RegisterDevice(ctx context.Context, re return nil, pb.ErrorErrorReasonBadRequest("") } localID := req.GetClientLocalId() - id, err := s.t.RegisterDevice(ctx, converter2.ToBizDeviceInfo(req.GetDeviceInfo()), &localID) + id, err := s.t.RegisterDevice(ctx, converter.ToBizDeviceInfo(req.GetDeviceInfo()), &localID) if err != nil { return nil, err } return &pb.RegisterDeviceResponse{ - DeviceId: converter2.ToPBInternalID(id), + DeviceId: converter.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) ListRegisteredDevices( @@ -118,7 +118,7 @@ func (s *LibrarianSephirahServiceService) ListRegisteredDevices( return nil, err } return &pb.ListRegisteredDevicesResponse{ - Devices: converter2.ToPBDeviceInfoList(devices), + Devices: converter.ToPBDeviceInfoList(devices), }, nil } func (s *LibrarianSephirahServiceService) ListUserSessions(ctx context.Context, req *pb.ListUserSessionsRequest) ( @@ -129,7 +129,7 @@ func (s *LibrarianSephirahServiceService) ListUserSessions(ctx context.Context, return nil, err } return &pb.ListUserSessionsResponse{ - Sessions: converter2.ToPBUserSessionList(sessions), + Sessions: converter.ToPBUserSessionList(sessions), }, nil } func (s *LibrarianSephirahServiceService) DeleteUserSession(ctx context.Context, req *pb.DeleteUserSessionRequest) ( @@ -138,7 +138,7 @@ func (s *LibrarianSephirahServiceService) DeleteUserSession(ctx context.Context, if req.GetSessionId() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - err := s.t.DeleteUserSession(ctx, converter2.ToBizInternalID(req.GetSessionId())) + err := s.t.DeleteUserSession(ctx, converter.ToBizInternalID(req.GetSessionId())) if err != nil { return nil, err } @@ -150,12 +150,12 @@ func (s *LibrarianSephirahServiceService) CreateUser(ctx context.Context, req *p if req.GetUser() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - id, err := s.t.CreateUser(ctx, converter2.ToBizUser(req.GetUser())) + user, err := s.t.CreateUser(ctx, converter.ToBizUser(req.GetUser())) if err != nil { return nil, err } return &pb.CreateUserResponse{ - Id: converter2.ToPBInternalID(*id), + Id: converter.ToPBInternalID(user.ID), }, nil } func (s *LibrarianSephirahServiceService) UpdateUser(ctx context.Context, req *pb.UpdateUserRequest) ( @@ -164,7 +164,7 @@ func (s *LibrarianSephirahServiceService) UpdateUser(ctx context.Context, req *p if req.GetUser() == nil { return nil, pb.ErrorErrorReasonBadRequest("") } - err := s.t.UpdateUser(ctx, converter2.ToBizUser(req.GetUser()), req.GetPassword()) + err := s.t.UpdateUser(ctx, converter.ToBizUser(req.GetUser()), req.GetPassword()) if err != nil { return nil, err } @@ -178,25 +178,25 @@ func (s *LibrarianSephirahServiceService) ListUsers(ctx context.Context, req *pb } u, total, err := s.t.ListUsers(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToLibAuthUserTypeList(req.GetTypeFilter()), - converter2.ToBizUserStatusList(req.GetStatusFilter()), + converter.ToLibAuthUserTypeList(req.GetTypeFilter()), + converter.ToBizUserStatusList(req.GetStatusFilter()), ) if err != nil { return nil, err } return &pb.ListUsersResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Users: converter2.ToPBUserList(u), + Users: converter.ToPBUserList(u), }, nil } func (s *LibrarianSephirahServiceService) GetUser(ctx context.Context, req *pb.GetUserRequest) ( *pb.GetUserResponse, error, ) { - u, err := s.t.GetUser(ctx, converter2.ToBizInternalIDPtr(req.GetId())) + u, err := s.t.GetUser(ctx, converter.ToBizInternalIDPtr(req.GetId())) if err != nil { return nil, err } - return &pb.GetUserResponse{User: converter2.ToPBUser(u)}, nil + return &pb.GetUserResponse{User: converter.ToPBUser(u)}, nil } func (s *LibrarianSephirahServiceService) LinkAccount(ctx context.Context, req *pb.LinkAccountRequest) ( *pb.LinkAccountResponse, error, @@ -216,7 +216,7 @@ func (s *LibrarianSephirahServiceService) LinkAccount(ctx context.Context, req * if err != nil { return nil, err } - return &pb.LinkAccountResponse{AccountId: converter2.ToPBInternalID(a.ID)}, nil + return &pb.LinkAccountResponse{AccountId: converter.ToPBInternalID(a.ID)}, nil } func (s *LibrarianSephirahServiceService) UnLinkAccount(ctx context.Context, req *pb.UnLinkAccountRequest) ( *pb.UnLinkAccountResponse, error, @@ -241,13 +241,13 @@ func (s *LibrarianSephirahServiceService) ListLinkAccounts(ctx context.Context, *pb.ListLinkAccountsResponse, error, ) { res, err := s.t.ListLinkAccounts(ctx, - converter2.ToBizInternalID(req.GetUserId()), + converter.ToBizInternalID(req.GetUserId()), ) if err != nil { return nil, err } return &pb.ListLinkAccountsResponse{ - Accounts: converter2.ToPBAccountList(res), + Accounts: converter.ToPBAccountList(res), }, nil } @@ -274,7 +274,7 @@ func (s *LibrarianSephirahServiceService) ListPorters(ctx context.Context, req * } return &pb.ListPortersResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Porters: converter2.ToPBPorterList(res), + Porters: converter.ToPBPorterList(res), }, nil } @@ -285,8 +285,8 @@ func (s *LibrarianSephirahServiceService) UpdatePorterStatus(ctx context.Context return nil, pb.ErrorErrorReasonBadRequest("") } if err := s.t.UpdatePorterStatus(ctx, - converter2.ToBizInternalID(req.GetPorterId()), - converter2.ToBizUserStatus(req.GetStatus()), + converter.ToBizInternalID(req.GetPorterId()), + converter.ToBizUserStatus(req.GetStatus()), ); err != nil { return nil, err } @@ -301,13 +301,13 @@ func (s *LibrarianSephirahServiceService) CreatePorterContext( return nil, pb.ErrorErrorReasonBadRequest("") } id, err := s.t.CreatePorterContext(ctx, - converter2.ToBizPorterContext(req.GetContext()), + converter.ToBizPorterContext(req.GetContext()), ) if err != nil { return nil, err } return &pb.CreatePorterContextResponse{ - ContextId: converter2.ToPBInternalID(id), + ContextId: converter.ToPBInternalID(id), }, nil } @@ -335,7 +335,7 @@ func (s *LibrarianSephirahServiceService) ListPorterContexts( //nolint:dupl //no } return &pb.ListPorterContextsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - Contexts: converter2.ToPBPorterContextList(res), + Contexts: converter.ToPBPorterContextList(res), }, nil } @@ -347,7 +347,7 @@ func (s *LibrarianSephirahServiceService) UpdatePorterContext( return nil, pb.ErrorErrorReasonBadRequest("") } if err := s.t.UpdatePorterContext(ctx, - converter2.ToBizPorterContext(req.GetContext()), + converter.ToBizPorterContext(req.GetContext()), ); err != nil { return nil, err } @@ -363,13 +363,13 @@ func (s *LibrarianSephirahServiceService) ListPorterGroups( } groups, total, err := s.t.ListPorterGroups(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizUserStatusList(req.GetStatusFilter()), + converter.ToBizUserStatusList(req.GetStatusFilter()), ) if err != nil { return nil, err } return &pb.ListPorterGroupsResponse{ Paging: &librarian.PagingResponse{TotalSize: total}, - PorterGroups: converter2.ToPBPorterGroupList(groups), + PorterGroups: converter.ToPBPorterGroupList(groups), }, nil } diff --git a/internal/service/sephirah/yesod.go b/internal/service/sephirah/yesod.go index 130c5437..3848ec0a 100644 --- a/internal/service/sephirah/yesod.go +++ b/internal/service/sephirah/yesod.go @@ -4,7 +4,7 @@ import ( "context" "github.com/tuihub/librarian/internal/model" - converter2 "github.com/tuihub/librarian/internal/service/sephirah/converter" + "github.com/tuihub/librarian/internal/service/sephirah/converter" pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" librarian "github.com/tuihub/protos/pkg/librarian/v1" ) @@ -13,19 +13,19 @@ func (s *LibrarianSephirahServiceService) CreateFeedConfig( ctx context.Context, req *pb.CreateFeedConfigRequest, ) (*pb.CreateFeedConfigResponse, error) { - id, err := s.y.CreateFeedConfig(ctx, converter2.ToBizFeedConfig(req.GetConfig())) + id, err := s.y.CreateFeedConfig(ctx, converter.ToBizFeedConfig(req.GetConfig())) if err != nil { return nil, err } return &pb.CreateFeedConfigResponse{ - Id: converter2.ToPBInternalID(id), + Id: converter.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) UpdateFeedConfig( ctx context.Context, req *pb.UpdateFeedConfigRequest, ) (*pb.UpdateFeedConfigResponse, error) { - err := s.y.UpdateFeedConfig(ctx, converter2.ToBizFeedConfig(req.GetConfig())) + err := s.y.UpdateFeedConfig(ctx, converter.ToBizFeedConfig(req.GetConfig())) if err != nil { return nil, err } @@ -40,8 +40,8 @@ func (s *LibrarianSephirahServiceService) ListFeedConfigs( } feeds, total, err := s.y.ListFeeds(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizInternalIDList(req.GetIdFilter()), - converter2.ToBizFeedConfigStatusList(req.GetStatusFilter()), + converter.ToBizInternalIDList(req.GetIdFilter()), + converter.ToBizFeedConfigStatusList(req.GetStatusFilter()), req.GetCategoryFilter(), ) if err != nil { @@ -49,26 +49,26 @@ func (s *LibrarianSephirahServiceService) ListFeedConfigs( } return &pb.ListFeedConfigsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - FeedsWithConfig: converter2.ToPBFeedWithConfigList(feeds), + FeedsWithConfig: converter.ToPBFeedWithConfigList(feeds), }, nil } func (s *LibrarianSephirahServiceService) CreateFeedActionSet( ctx context.Context, req *pb.CreateFeedActionSetRequest, ) (*pb.CreateFeedActionSetResponse, error) { - id, err := s.y.CreateFeedActionSet(ctx, converter2.ToBizFeedActionSet(req.GetActionSet())) + id, err := s.y.CreateFeedActionSet(ctx, converter.ToBizFeedActionSet(req.GetActionSet())) if err != nil { return nil, err } return &pb.CreateFeedActionSetResponse{ - Id: converter2.ToPBInternalID(id), + Id: converter.ToPBInternalID(id), }, nil } func (s *LibrarianSephirahServiceService) UpdateFeedActionSet( ctx context.Context, req *pb.UpdateFeedActionSetRequest, ) (*pb.UpdateFeedActionSetResponse, error) { - err := s.y.UpdateFeedActionSet(ctx, converter2.ToBizFeedActionSet(req.GetActionSet())) + err := s.y.UpdateFeedActionSet(ctx, converter.ToBizFeedActionSet(req.GetActionSet())) if err != nil { return nil, err } @@ -89,7 +89,7 @@ func (s *LibrarianSephirahServiceService) ListFeedActionSets( } return &pb.ListFeedActionSetsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - ActionSets: converter2.ToPBFeedActionSetList(actions), + ActionSets: converter.ToPBFeedActionSetList(actions), }, nil } func (s *LibrarianSephirahServiceService) ListFeedCategories( @@ -122,10 +122,10 @@ func (s *LibrarianSephirahServiceService) ListFeedItems( } items, total, err := s.y.ListFeedItems(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizInternalIDList(req.GetFeedIdFilter()), + converter.ToBizInternalIDList(req.GetFeedIdFilter()), req.GetAuthorFilter(), req.GetPublishPlatformFilter(), - converter2.ToBizTimeRange(req.GetPublishTimeRange()), + converter.ToBizTimeRange(req.GetPublishTimeRange()), req.GetCategoryFilter(), ) if err != nil { @@ -133,7 +133,7 @@ func (s *LibrarianSephirahServiceService) ListFeedItems( } return &pb.ListFeedItemsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - Items: converter2.ToPBFeedItemDigestList(items), + Items: converter.ToPBFeedItemDigestList(items), }, nil } func (s *LibrarianSephirahServiceService) GroupFeedItems( @@ -141,11 +141,11 @@ func (s *LibrarianSephirahServiceService) GroupFeedItems( req *pb.GroupFeedItemsRequest, ) (*pb.GroupFeedItemsResponse, error) { itemMap, err := s.y.GroupFeedItems(ctx, - converter2.ToBizGroupFeedItemsBy(req.GetPublishTimeAggregation().GetAggregationType()), - converter2.ToBizInternalIDList(req.GetFeedIdFilter()), + converter.ToBizGroupFeedItemsBy(req.GetPublishTimeAggregation().GetAggregationType()), + converter.ToBizInternalIDList(req.GetFeedIdFilter()), req.GetAuthorFilter(), req.GetPublishPlatformFilter(), - converter2.ToBizTimeRange(req.GetPublishTimeAggregation().GetTimeRange()), + converter.ToBizTimeRange(req.GetPublishTimeAggregation().GetTimeRange()), int(req.GetGroupSize()), req.GetCategoryFilter(), ) @@ -155,8 +155,8 @@ func (s *LibrarianSephirahServiceService) GroupFeedItems( res := make([]*pb.GroupFeedItemsResponse_FeedItemsGroup, 0, len(itemMap)) for timeRange, items := range itemMap { res = append(res, &pb.GroupFeedItemsResponse_FeedItemsGroup{ - TimeRange: converter2.ToPBTimeRange(&timeRange), - Items: converter2.ToPBFeedItemDigestList(items), + TimeRange: converter.ToPBTimeRange(&timeRange), + Items: converter.ToPBFeedItemDigestList(items), }) } return &pb.GroupFeedItemsResponse{Groups: res}, nil @@ -165,12 +165,12 @@ func (s *LibrarianSephirahServiceService) GetFeedItem( ctx context.Context, req *pb.GetFeedItemRequest, ) (*pb.GetFeedItemResponse, error) { - item, err := s.y.GetFeedItem(ctx, converter2.ToBizInternalID(req.GetId())) + item, err := s.y.GetFeedItem(ctx, converter.ToBizInternalID(req.GetId())) if err != nil { return nil, err } return &pb.GetFeedItemResponse{ - Item: converter2.ToPBFeedItem(item), + Item: converter.ToPBFeedItem(item), }, nil } @@ -178,12 +178,12 @@ func (s *LibrarianSephirahServiceService) GetBatchFeedItems( ctx context.Context, req *pb.GetBatchFeedItemsRequest, ) (*pb.GetBatchFeedItemsResponse, error) { - items, err := s.y.GetFeedItems(ctx, converter2.ToBizInternalIDList(req.GetIds())) + items, err := s.y.GetFeedItems(ctx, converter.ToBizInternalIDList(req.GetIds())) if err != nil { return nil, err } return &pb.GetBatchFeedItemsResponse{ - Items: converter2.ToPBFeedItemList(items), + Items: converter.ToPBFeedItemList(items), }, nil } @@ -191,7 +191,7 @@ func (s *LibrarianSephirahServiceService) ReadFeedItem( ctx context.Context, req *pb.ReadFeedItemRequest, ) (*pb.ReadFeedItemResponse, error) { - err := s.y.ReadFeedItem(ctx, converter2.ToBizInternalID(req.GetId())) + err := s.y.ReadFeedItem(ctx, converter.ToBizInternalID(req.GetId())) if err != nil { return nil, err } @@ -202,7 +202,7 @@ func (s *LibrarianSephirahServiceService) CreateFeedItemCollection( ctx context.Context, req *pb.CreateFeedItemCollectionRequest, ) (*pb.CreateFeedItemCollectionResponse, error) { - _, err := s.y.CreateFeedItemCollection(ctx, converter2.ToBizFeedItemCollection(req.GetCollection())) + _, err := s.y.CreateFeedItemCollection(ctx, converter.ToBizFeedItemCollection(req.GetCollection())) if err != nil { return nil, err } @@ -213,7 +213,7 @@ func (s *LibrarianSephirahServiceService) UpdateFeedItemCollection( ctx context.Context, req *pb.UpdateFeedItemCollectionRequest, ) (*pb.UpdateFeedItemCollectionResponse, error) { - err := s.y.UpdateFeedItemCollection(ctx, converter2.ToBizFeedItemCollection(req.GetCollection())) + err := s.y.UpdateFeedItemCollection(ctx, converter.ToBizFeedItemCollection(req.GetCollection())) if err != nil { return nil, err } @@ -229,7 +229,7 @@ func (s *LibrarianSephirahServiceService) ListFeedItemCollections( } collections, total, err := s.y.ListFeedItemCollections(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizInternalIDList(req.GetIdFilter()), + converter.ToBizInternalIDList(req.GetIdFilter()), req.GetCategoryFilter(), ) if err != nil { @@ -237,7 +237,7 @@ func (s *LibrarianSephirahServiceService) ListFeedItemCollections( } return &pb.ListFeedItemCollectionsResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - Collections: converter2.ToPBFeedItemCollectionList(collections), + Collections: converter.ToPBFeedItemCollectionList(collections), }, nil } @@ -246,8 +246,8 @@ func (s *LibrarianSephirahServiceService) AddFeedItemToCollection( req *pb.AddFeedItemToCollectionRequest, ) (*pb.AddFeedItemToCollectionResponse, error) { err := s.y.AddFeedItemToCollection(ctx, - converter2.ToBizInternalID(req.GetCollectionId()), - converter2.ToBizInternalID(req.GetFeedItemId()), + converter.ToBizInternalID(req.GetCollectionId()), + converter.ToBizInternalID(req.GetFeedItemId()), ) if err != nil { return nil, err @@ -261,8 +261,8 @@ func (s *LibrarianSephirahServiceService) RemoveFeedItemFromCollection( ) (*pb.RemoveFeedItemFromCollectionResponse, error) { err := s.y.RemoveFeedItemFromCollection( ctx, - converter2.ToBizInternalID(req.GetCollectionId()), - converter2.ToBizInternalID(req.GetFeedItemId()), + converter.ToBizInternalID(req.GetCollectionId()), + converter.ToBizInternalID(req.GetFeedItemId()), ) if err != nil { return nil, err @@ -279,17 +279,17 @@ func (s *LibrarianSephirahServiceService) ListFeedItemsInCollection( } items, total, err := s.y.ListFeedItemsInCollection(ctx, model.ToBizPaging(req.GetPaging()), - converter2.ToBizInternalIDList(req.GetCollectionIdFilter()), + converter.ToBizInternalIDList(req.GetCollectionIdFilter()), req.GetAuthorFilter(), req.GetPublishPlatformFilter(), req.GetCategoryFilter(), - converter2.ToBizTimeRange(req.GetPublishTimeRange()), + converter.ToBizTimeRange(req.GetPublishTimeRange()), ) if err != nil { return nil, err } return &pb.ListFeedItemsInCollectionResponse{ Paging: &librarian.PagingResponse{TotalSize: int64(total)}, - Items: converter2.ToPBFeedItemDigestList(items), + Items: converter.ToPBFeedItemDigestList(items), }, nil } diff --git a/main.go b/main.go index 5cbdac1f..96dcd0c0 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "github.com/tuihub/librarian/internal/lib/libobserve" "github.com/tuihub/librarian/internal/lib/libsentry" "github.com/tuihub/librarian/internal/lib/libzap" + "github.com/tuihub/librarian/internal/service/angelaweb" miner "github.com/tuihub/protos/pkg/librarian/miner/v1" "github.com/go-kratos/kratos/v2" @@ -45,6 +46,7 @@ var ProviderSet = wire.NewSet( func newApp( gs *grpc.Server, hs *http.Server, + aw *angelaweb.AngelaWeb, mq *libmq.MQ, cron *libcron.Cron, obs *libobserve.BuiltInObserver, @@ -55,7 +57,7 @@ func newApp( kratos.Name(name), kratos.Version(version), kratos.Metadata(map[string]string{}), - kratos.Server(gs, hs, mq, cron, obs), + kratos.Server(gs, hs, aw, mq, cron, obs), } r, err := libapp.NewRegistrar(consul) if err == nil { diff --git a/wire.go b/wire.go index 8a52d957..ac474275 100644 --- a/wire.go +++ b/wire.go @@ -20,6 +20,7 @@ import ( "github.com/tuihub/librarian/internal/lib/libobserve" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/server" + "github.com/tuihub/librarian/internal/service/angelaweb" "github.com/tuihub/librarian/internal/service/sephirah" "github.com/tuihub/librarian/internal/service/supervisor" @@ -45,6 +46,7 @@ func wireApp( panic( wire.Build( minerService.ProviderSet, + angelaweb.ProviderSet, data.ProviderSet, biz.ProviderSet, client.ProviderSet, diff --git a/wire_gen.go b/wire_gen.go index a4795665..44b1e955 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -29,6 +29,7 @@ import ( "github.com/tuihub/librarian/internal/lib/libobserve" "github.com/tuihub/librarian/internal/lib/libsearch" "github.com/tuihub/librarian/internal/server" + "github.com/tuihub/librarian/internal/service/angelaweb" "github.com/tuihub/librarian/internal/service/sephirah" "github.com/tuihub/librarian/internal/service/supervisor" ) @@ -192,7 +193,8 @@ func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDisco cleanup() return nil, nil, err } - app, err := newApp(grpcServer, httpServer, libmqMQ, cron, builtInObserver, consul) + angelaWeb := angelaweb.NewAngelaWeb(libauthAuth, tiphereth, key) + app, err := newApp(grpcServer, httpServer, angelaWeb, libmqMQ, cron, builtInObserver, consul) if err != nil { cleanup3() cleanup2() From 93a23ddd0ce4fb31d0ea154f6c417fe13658cdb0 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 22 Mar 2025 04:17:08 +0800 Subject: [PATCH 15/19] feat: draft angela web --- internal/biz/biztiphereth/user.go | 18 +++++++-------- internal/data/tiphereth.go | 3 +-- internal/lib/libauth/jwt.go | 15 ++++++++++++ internal/service/angelaweb/angela_web.go | 3 ++- .../service/angelaweb/internal/api/handler.go | 2 +- .../service/angelaweb/internal/api/login.go | 6 ++--- .../service/angelaweb/internal/api/model.go | 3 +-- .../service/angelaweb/internal/api/user.go | 9 ++++---- .../service/angelaweb/internal/page/page.go | 7 +++--- .../service/angelaweb/internal/util/util.go | 13 ----------- internal/service/angelaweb/routes.go | 23 ++++--------------- .../service/angelaweb/token_middleware.go | 23 +++++++++++++++++++ internal/service/angelaweb/view/user.html | 6 +---- .../service/angelaweb/view/user_form.html | 15 ++---------- 14 files changed, 68 insertions(+), 78 deletions(-) delete mode 100644 internal/service/angelaweb/internal/util/util.go create mode 100644 internal/service/angelaweb/token_middleware.go diff --git a/internal/biz/biztiphereth/user.go b/internal/biz/biztiphereth/user.go index c97d9d3c..4c0a6047 100644 --- a/internal/biz/biztiphereth/user.go +++ b/internal/biz/biztiphereth/user.go @@ -13,10 +13,9 @@ import ( pb "github.com/tuihub/protos/pkg/librarian/sephirah/v1" "github.com/dchest/captcha" - "github.com/go-kratos/kratos/v2/errors" ) -func (t *Tiphereth) CreateUser(ctx context.Context, user *model.User) (*model.User, *errors.Error) { +func (t *Tiphereth) CreateUser(ctx context.Context, user *model.User) (*model.User, error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() @@ -59,7 +58,7 @@ func (t *Tiphereth) CreateUser(ctx context.Context, user *model.User) (*model.Us func (t *Tiphereth) UpdateUser( ctx context.Context, user *model.User, originPassword string, -) *errors.Error { +) error { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return bizutils.NoPermissionError() @@ -86,7 +85,6 @@ func (t *Tiphereth) UpdateUser( []model.UserType{model.UserTypeSentinel}, nil, nil, - claims.UserID, ) if err != nil || len(res) != 1 || res[0].ID != user.ID { return bizutils.NoPermissionError() @@ -114,20 +112,20 @@ func (t *Tiphereth) UpdateUser( func (t *Tiphereth) ListUsers( ctx context.Context, paging model.Paging, types []model.UserType, statuses []model.UserStatus, -) ([]*model.User, int64, *errors.Error) { - claims := libauth.FromContextAssertUserType(ctx) +) ([]*model.User, int64, error) { + claims := libauth.FromContextAssertUserType(ctx, model.UserTypeAdmin) if claims == nil { return nil, 0, bizutils.NoPermissionError() } var exclude []model.InternalID - users, total, err := t.repo.ListUsers(ctx, paging, nil, types, statuses, exclude, claims.UserID) + users, total, err := t.repo.ListUsers(ctx, paging, nil, types, statuses, exclude) if err != nil { return nil, 0, pb.ErrorErrorReasonUnspecified("%s", err.Error()) } return users, total, nil } -func (t *Tiphereth) GetUser(ctx context.Context, id *model.InternalID) (*model.User, *errors.Error) { +func (t *Tiphereth) GetUser(ctx context.Context, id *model.InternalID) (*model.User, error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, bizutils.NoPermissionError() @@ -150,7 +148,7 @@ func (t *Tiphereth) RegisterUser( username string, password string, captchaReq *model.CaptchaAns, -) (*model.CaptchaQue, string, *errors.Error) { +) (*model.CaptchaQue, string, error) { if t.app.EnvExist(libapp.EnvDemoMode) { return nil, "", pb.ErrorErrorReasonForbidden("server running in demo mode, register user is not allowed") } @@ -200,7 +198,7 @@ func (t *Tiphereth) RegisterUser( return nil, "TODO", nil // TODO: return refresh token } -func (t *Tiphereth) checkCapacity(ctx context.Context) *errors.Error { +func (t *Tiphereth) checkCapacity(ctx context.Context) error { if !t.app.EnvExist(libapp.EnvUserCapacity) { return nil } diff --git a/internal/data/tiphereth.go b/internal/data/tiphereth.go index 17c60dfb..213c3624 100644 --- a/internal/data/tiphereth.go +++ b/internal/data/tiphereth.go @@ -247,9 +247,8 @@ func (t *TipherethRepo) ListUsers( types []model.UserType, statuses []model.UserStatus, exclude []model.InternalID, - creator model.InternalID, ) ([]*model.User, int64, error) { - q := t.data.db.User.Query().Where(user.IDEQ(creator)).QueryCreatedUser() + q := t.data.db.User.Query() if len(ids) > 0 { q.Where(user.IDIn(ids...)) } diff --git a/internal/lib/libauth/jwt.go b/internal/lib/libauth/jwt.go index b6cde3ef..c1c3c36b 100644 --- a/internal/lib/libauth/jwt.go +++ b/internal/lib/libauth/jwt.go @@ -2,6 +2,7 @@ package libauth import ( "context" + "errors" "fmt" "net/http" "strings" @@ -80,11 +81,25 @@ func ValidateString(tokenString string, keyFunc jwtv5.Keyfunc) (bool, error) { return token.Valid, nil } +func FromString(tokenString string, keyFunc jwtv5.Keyfunc) (*Claims, error) { + token, err := jwtv5.ParseWithClaims(tokenString, new(Claims), keyFunc) + if err != nil { + return nil, err + } + if claims, ok := token.Claims.(*Claims); ok { + return claims, nil + } + return nil, errors.New("invalid claims type") +} + func FromContextAssertUserType(ctx context.Context, userTypes ...model.UserType) *Claims { if userTypes == nil { userTypes = []model.UserType{model.UserTypeAdmin, model.UserTypeNormal} } c := FromContext(ctx) + if c == nil { + return nil + } for _, ut := range userTypes { if c.UserType == ut { return c diff --git a/internal/service/angelaweb/angela_web.go b/internal/service/angelaweb/angela_web.go index d797dde2..4776c9e5 100644 --- a/internal/service/angelaweb/angela_web.go +++ b/internal/service/angelaweb/angela_web.go @@ -3,7 +3,6 @@ package angelaweb import ( "context" "embed" - "github.com/gofiber/fiber/v2/middleware/logger" "net/http" "github.com/tuihub/librarian/internal/biz/biztiphereth" @@ -14,6 +13,7 @@ import ( "github.com/tuihub/librarian/internal/service/angelaweb/internal/page" "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/logger" "github.com/gofiber/template/html/v2" "github.com/google/wire" ) @@ -43,6 +43,7 @@ func NewAngelaWeb( userCountCache *libcache.Key[model.UserCount], ) *AngelaWeb { viewsEngine := html.NewFileSystem(http.FS(embedDirView), ".html") + viewsEngine.Directory = "view" app := fiber.New(fiber.Config{ //nolint:exhaustruct // no need Views: viewsEngine, diff --git a/internal/service/angelaweb/internal/api/handler.go b/internal/service/angelaweb/internal/api/handler.go index 9d5e3f97..3333c3d6 100644 --- a/internal/service/angelaweb/internal/api/handler.go +++ b/internal/service/angelaweb/internal/api/handler.go @@ -26,7 +26,7 @@ func NewHandler( } func (h *Handler) GetDashboardStats(c *fiber.Ctx) error { - userCount, err := h.userCountCache.Get(c.Context()) + userCount, err := h.userCountCache.Get(c.UserContext()) if err != nil { return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": "Error fetching stats"}) } diff --git a/internal/service/angelaweb/internal/api/login.go b/internal/service/angelaweb/internal/api/login.go index ba5158b3..728f0cd6 100644 --- a/internal/service/angelaweb/internal/api/login.go +++ b/internal/service/angelaweb/internal/api/login.go @@ -4,7 +4,7 @@ import ( "net/http" "time" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/util" + "github.com/tuihub/librarian/internal/lib/libtime" "github.com/gofiber/fiber/v2" ) @@ -15,7 +15,7 @@ func (h *Handler) Login(c *fiber.Ctx) error { return c.Status(http.StatusBadRequest).JSON(fiber.Map{"message": "Invalid request"}) } - accessToken, _, err := h.t.GetToken(util.BizContext(c), req.Username, req.Password, nil) + accessToken, _, err := h.t.GetToken(c.UserContext(), req.Username, req.Password, nil) if err != nil { return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": err.Message}) } @@ -23,7 +23,7 @@ func (h *Handler) Login(c *fiber.Ctx) error { c.Cookie(&fiber.Cookie{ //nolint:exhaustruct // no need Name: "access_token", Value: string(accessToken), - Expires: time.Now().Add(24 * time.Hour), + Expires: time.Now().Add(libtime.Day), HTTPOnly: true, Secure: true, SameSite: "strict", diff --git a/internal/service/angelaweb/internal/api/model.go b/internal/service/angelaweb/internal/api/model.go index 556d8dba..6e153397 100644 --- a/internal/service/angelaweb/internal/api/model.go +++ b/internal/service/angelaweb/internal/api/model.go @@ -5,5 +5,4 @@ type LoginRequest struct { Password string `json:"password"` } -type LoginResponse struct { -} +type LoginResponse struct{} diff --git a/internal/service/angelaweb/internal/api/user.go b/internal/service/angelaweb/internal/api/user.go index ff9e2c70..ddd004fc 100644 --- a/internal/service/angelaweb/internal/api/user.go +++ b/internal/service/angelaweb/internal/api/user.go @@ -5,14 +5,13 @@ import ( "strconv" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/util" "github.com/gofiber/fiber/v2" "github.com/samber/lo" ) func (h *Handler) ListUsers(c *fiber.Ctx) error { - users, _, err := h.t.ListUsers(util.BizContext(c), model.Paging{ + users, _, err := h.t.ListUsers(c.UserContext(), model.Paging{ PageSize: 1, PageNum: 20, }, nil, nil) @@ -28,7 +27,7 @@ func (h *Handler) GetUser(c *fiber.Ctx) error { if err != nil { return c.Status(http.StatusBadRequest).JSON(fiber.Map{"message": "Invalid ID"}) } - user, err := h.t.GetUser(util.BizContext(c), lo.ToPtr(model.InternalID(id))) + user, err := h.t.GetUser(c.UserContext(), lo.ToPtr(model.InternalID(id))) if err != nil { return c.Status(http.StatusNotFound).JSON(fiber.Map{"message": "User not found"}) } @@ -42,7 +41,7 @@ func (h *Handler) CreateUser(c *fiber.Ctx) error { } var err error - user, err = h.t.CreateUser(util.BizContext(c), user) + user, err = h.t.CreateUser(c.UserContext(), user) if err != nil { return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": err.Error()}) } @@ -62,7 +61,7 @@ func (h *Handler) UpdateUser(c *fiber.Ctx) error { } user.ID = model.InternalID(id) - err = h.t.UpdateUser(util.BizContext(c), &user, "") + err = h.t.UpdateUser(c.UserContext(), &user, "") if err != nil { return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": err.Error()}) } diff --git a/internal/service/angelaweb/internal/page/page.go b/internal/service/angelaweb/internal/page/page.go index c7cd8580..6950e197 100644 --- a/internal/service/angelaweb/internal/page/page.go +++ b/internal/service/angelaweb/internal/page/page.go @@ -7,7 +7,6 @@ import ( "github.com/tuihub/librarian/internal/biz/biztiphereth" "github.com/tuihub/librarian/internal/lib/libcache" "github.com/tuihub/librarian/internal/model" - "github.com/tuihub/librarian/internal/service/angelaweb/internal/util" "github.com/gofiber/fiber/v2" "github.com/samber/lo" @@ -35,7 +34,7 @@ func (b *Builder) Login(c *fiber.Ctx) error { } func (b *Builder) Dashboard(c *fiber.Ctx) error { - userCount, err := b.userCountCache.Get(util.BizContext(c)) + userCount, err := b.userCountCache.Get(c.UserContext()) if err != nil { return c.Status(http.StatusInternalServerError).SendString("Error fetching dashboard data") } @@ -47,7 +46,7 @@ func (b *Builder) Dashboard(c *fiber.Ctx) error { } func (b *Builder) UserList(c *fiber.Ctx) error { - users, _, err := b.t.ListUsers(util.BizContext(c), model.Paging{ + users, _, err := b.t.ListUsers(c.UserContext(), model.Paging{ PageNum: 1, PageSize: 20, }, nil, nil) @@ -74,7 +73,7 @@ func (b *Builder) UserForm(c *fiber.Ctx) error { if err != nil { return c.Status(http.StatusBadRequest).SendString("Invalid ID") } - user, err = b.t.GetUser(util.BizContext(c), lo.ToPtr(model.InternalID(id))) + user, err = b.t.GetUser(c.UserContext(), lo.ToPtr(model.InternalID(id))) if err != nil { return c.Status(http.StatusNotFound).SendString("User not found") } diff --git a/internal/service/angelaweb/internal/util/util.go b/internal/service/angelaweb/internal/util/util.go deleted file mode 100644 index 984e7172..00000000 --- a/internal/service/angelaweb/internal/util/util.go +++ /dev/null @@ -1,13 +0,0 @@ -package util - -import ( - "context" - - "github.com/tuihub/librarian/internal/lib/libauth" - - "github.com/gofiber/fiber/v2" -) - -func BizContext(c *fiber.Ctx) context.Context { - return libauth.RawToContext(c.Context(), c.Cookies("access_token")) -} diff --git a/internal/service/angelaweb/routes.go b/internal/service/angelaweb/routes.go index ee173161..0b4b0a92 100644 --- a/internal/service/angelaweb/routes.go +++ b/internal/service/angelaweb/routes.go @@ -1,24 +1,15 @@ package angelaweb import ( - "github.com/gofiber/fiber/v2/middleware/filesystem" - "github.com/tuihub/librarian/internal/lib/libauth" "net/http" - "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" - "github.com/gofiber/fiber/v2/middleware/keyauth" + "github.com/gofiber/fiber/v2/middleware/filesystem" ) -func (a *AngelaWeb) newValidator() func(ctx *fiber.Ctx, s string) (bool, error) { - return func(ctx *fiber.Ctx, s string) (bool, error) { - return libauth.ValidateString(s, a.auth.KeyFunc(libauth.ClaimsTypeAccessToken)) - } -} - func (a *AngelaWeb) setupRoutes() { // 静态文件 - a.app.Use("/static", filesystem.New(filesystem.Config{ + a.app.Use("/static", filesystem.New(filesystem.Config{ //nolint: exhaustruct // no need Root: http.FS(embedDirStatic), PathPrefix: "static", Browse: true, @@ -31,10 +22,7 @@ func (a *AngelaWeb) setupRoutes() { api := a.app.Group("/api") api.Post("/login", a.apiHandler.Login) - api.Use(keyauth.New(keyauth.Config{ //nolint:exhaustruct // no need - KeyLookup: "cookie:access_token", - Validator: a.newValidator(), - })) + api.Use(tokenMiddleware(a.auth)) // 受保护的API路由 api.Get("/users", a.apiHandler.ListUsers) @@ -48,10 +36,7 @@ func (a *AngelaWeb) setupRoutes() { // 受保护的页面路由 auth := a.app.Group("/") - auth.Use(keyauth.New(keyauth.Config{ //nolint:exhaustruct // no need - KeyLookup: "cookie:access_token", - Validator: a.newValidator(), - })) + auth.Use(tokenMiddleware(a.auth)) auth.Get("/", a.pageBuilder.Dashboard) auth.Get("/users", a.pageBuilder.UserList) diff --git a/internal/service/angelaweb/token_middleware.go b/internal/service/angelaweb/token_middleware.go new file mode 100644 index 00000000..01dc0ab6 --- /dev/null +++ b/internal/service/angelaweb/token_middleware.go @@ -0,0 +1,23 @@ +package angelaweb + +import ( + "github.com/tuihub/librarian/internal/lib/libauth" + + "github.com/go-kratos/kratos/v2/middleware/auth/jwt" + "github.com/gofiber/fiber/v2" +) + +func tokenMiddleware(auth *libauth.Auth) fiber.Handler { + return func(c *fiber.Ctx) error { + accessToken := c.Cookies("access_token") + claims, err := libauth.FromString(accessToken, auth.KeyFunc(libauth.ClaimsTypeAccessToken)) + if err != nil { + return err + } + ctx := c.UserContext() + ctx = libauth.RawToContext(ctx, c.Cookies("access_token")) + ctx = jwt.NewContext(ctx, claims) + c.SetUserContext(ctx) + return c.Next() + } +} diff --git a/internal/service/angelaweb/view/user.html b/internal/service/angelaweb/view/user.html index 5d1f5dc8..729f9060 100644 --- a/internal/service/angelaweb/view/user.html +++ b/internal/service/angelaweb/view/user.html @@ -11,9 +11,7 @@

用户列表

ID 用户名 - 邮箱 角色 - 创建时间 操作 @@ -22,15 +20,13 @@

用户列表

{{.ID}} {{.Username}} - {{.Email}} - {{if eq .Role "admin"}} + {{if eq .Type 1}} 管理员 {{else}} 普通用户 {{end}} - {{.CreatedAt.Format "2006-01-02 15:04:05"}} -
- - -
-
name="role" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" > - - + +
From 288edd7b714bcf593981e8ce77ebbe3c7733edc7 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 22 Mar 2025 04:18:24 +0800 Subject: [PATCH 16/19] feat: draft angela web --- internal/service/angelaweb/internal/api/handler.go | 2 +- internal/service/angelaweb/internal/page/page.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/angelaweb/internal/api/handler.go b/internal/service/angelaweb/internal/api/handler.go index 3333c3d6..7bcdd3ee 100644 --- a/internal/service/angelaweb/internal/api/handler.go +++ b/internal/service/angelaweb/internal/api/handler.go @@ -30,5 +30,5 @@ func (h *Handler) GetDashboardStats(c *fiber.Ctx) error { if err != nil { return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": "Error fetching stats"}) } - return c.JSON(fiber.Map{"user_count": userCount}) + return c.JSON(fiber.Map{"user_count": userCount.Count}) } diff --git a/internal/service/angelaweb/internal/page/page.go b/internal/service/angelaweb/internal/page/page.go index 6950e197..d5bfe00f 100644 --- a/internal/service/angelaweb/internal/page/page.go +++ b/internal/service/angelaweb/internal/page/page.go @@ -41,7 +41,7 @@ func (b *Builder) Dashboard(c *fiber.Ctx) error { return c.Render("dashboard", fiber.Map{ "Title": "Dashboard", - "UserCount": userCount, + "UserCount": userCount.Count, }) } From cdb914b9e5249f0d25126224f57e7506dead636f Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 22 Mar 2025 15:08:12 +0800 Subject: [PATCH 17/19] feat: draft angela web --- README.md | 4 +- configs/.gitignore | 3 +- configs/example-for-single-node.toml | 39 +++++++++++++++++++ configs/example-for-single-node.yaml | 35 ----------------- configs/example-for-testing.toml | 28 +++++++++++++ configs/example-for-testing.yaml | 24 ------------ internal/data/tiphereth.go | 8 ++-- internal/lib/libapp/app.go | 2 +- .../lib/libapp/inherent_settings_debug.go | 2 +- .../lib/libapp/inherent_settings_default.go | 2 +- .../service/angelaweb/internal/api/user.go | 35 +++++++++++++++-- .../service/angelaweb/internal/page/page.go | 27 +++++++++++-- internal/service/angelaweb/view/user.html | 30 ++++++++++++++ tests/Makefile | 2 +- 14 files changed, 164 insertions(+), 77 deletions(-) create mode 100644 configs/example-for-single-node.toml delete mode 100644 configs/example-for-single-node.yaml create mode 100644 configs/example-for-testing.toml delete mode 100644 configs/example-for-testing.yaml diff --git a/README.md b/README.md index cccbb2f9..1613a854 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Config file is required. The config template is provided in [configs](configs) ### Command line arguments -- `config` path, eg: --conf config.yaml +- `config` path, eg: --conf config.toml - `data` path, eg: --data /opt/librarian/data ### Environment variables @@ -37,5 +37,5 @@ Config file is required. The config template is provided in [configs](configs) 1. Install [Go](https://golang.org/) 2. (Optional) Install [Docker](https://docs.docker.com/) and [Docker Compose](https://docs.docker.com/compose/) 3. (Optional) Deploy dependencies with [tests/docker-compose.yml](tests/docker-compose.yml) -4. Create the config file at [configs/config.yaml](configs/config.yaml) with templates. +4. Create the config file at [configs/config.toml](configs/config.toml) with templates. 5. Run `make run` to start the server diff --git a/configs/.gitignore b/configs/.gitignore index a5394700..e7bacb48 100644 --- a/configs/.gitignore +++ b/configs/.gitignore @@ -1 +1,2 @@ -config.yaml \ No newline at end of file +config.yaml +config.toml \ No newline at end of file diff --git a/configs/example-for-single-node.toml b/configs/example-for-single-node.toml new file mode 100644 index 00000000..57f2242e --- /dev/null +++ b/configs/example-for-single-node.toml @@ -0,0 +1,39 @@ +[server.grpc] +addr = "0.0.0.0:10000" +timeout = "1s" + +[server.grpc_web] +addr = "0.0.0.0:10001" +timeout = "1s" + +[database] +driver = "postgres" +host = "localhost" +port = 5432 +dbname = "librarian" +user = "librarian" +password = "librarian" +no_ssl = true + +[s3] +end_point = "127.0.0.1:9000" +access_key = "librarian" +secret_key = "librarian" +use_ssl = false + +[auth] +password_salt = "test" +jwt_issuer = "test" +jwt_secret = "test" + +[mq] +driver = "redis" + +[cache] +driver = "redis" +addr = "localhost:6379" + +[searcher.data.meilisearch] +addr = "http://localhost:7700" + +[miner.data] diff --git a/configs/example-for-single-node.yaml b/configs/example-for-single-node.yaml deleted file mode 100644 index 42ea01c4..00000000 --- a/configs/example-for-single-node.yaml +++ /dev/null @@ -1,35 +0,0 @@ -server: - grpc: - addr: 0.0.0.0:10000 - timeout: 1s - grpc_web: - addr: 0.0.0.0:10001 - timeout: 1s -database: - driver: postgres - host: localhost - port: 5432 - dbname: librarian - user: librarian - password: librarian - no_ssl: true -s3: - end_point: 127.0.0.1:9000 - access_key: librarian - secret_key: librarian - use_ssl: false -auth: - password_salt: test - jwt_issuer: test - jwt_secret: test -mq: - driver: redis -cache: - driver: redis - addr: localhost:6379 -searcher: - data: - meilisearch: - addr: "http://localhost:7700" -miner: - data: \ No newline at end of file diff --git a/configs/example-for-testing.toml b/configs/example-for-testing.toml new file mode 100644 index 00000000..fa8adf47 --- /dev/null +++ b/configs/example-for-testing.toml @@ -0,0 +1,28 @@ +[server.grpc] +addr = "0.0.0.0:10000" +timeout = "60s" + +[server.grpc_web] +addr = "0.0.0.0:10001" +timeout = "60s" + +[database] +driver = "memory" + +[s3] + +[auth] +password_salt = "test" +jwt_issuer = "test" +jwt_secret = "test" + +[mq] +driver = "memory" + +[cache] +driver = "memory" + +[searcher.data.bleve] +enable = "" + +[miner.data] diff --git a/configs/example-for-testing.yaml b/configs/example-for-testing.yaml deleted file mode 100644 index 939c51f7..00000000 --- a/configs/example-for-testing.yaml +++ /dev/null @@ -1,24 +0,0 @@ -server: - grpc: - addr: 0.0.0.0:10000 - timeout: 60s - grpc_web: - addr: 0.0.0.0:10001 - timeout: 60s -database: - driver: memory -s3: -auth: - password_salt: test - jwt_issuer: test - jwt_secret: test -mq: - driver: memory -cache: - driver: memory -searcher: - data: - bleve: - enable: -miner: - data: \ No newline at end of file diff --git a/internal/data/tiphereth.go b/internal/data/tiphereth.go index 213c3624..a53ae487 100644 --- a/internal/data/tiphereth.go +++ b/internal/data/tiphereth.go @@ -261,6 +261,10 @@ func (t *TipherethRepo) ListUsers( if len(exclude) > 0 { q.Where(user.IDNotIn(exclude...)) } + count, err := q.Count(ctx) + if err != nil { + return nil, 0, err + } u, err := q. Limit(paging.ToLimit()). Offset(paging.ToOffset()). @@ -268,10 +272,6 @@ func (t *TipherethRepo) ListUsers( if err != nil { return nil, 0, err } - count, err := q.Count(ctx) - if err != nil { - return nil, 0, err - } return converter.ToBizUserList(u), int64(count), nil } diff --git a/internal/lib/libapp/app.go b/internal/lib/libapp/app.go index 3435e00d..1b6ecba3 100644 --- a/internal/lib/libapp/app.go +++ b/internal/lib/libapp/app.go @@ -131,7 +131,7 @@ func checkDataPath(path string) error { func loadFlags() Flags { var confPath string var dataPath string - flag.StringVar(&confPath, "conf", "", "config path, eg: --conf config.yaml") + flag.StringVar(&confPath, "conf", "", "config path, eg: --conf config.toml") flag.StringVar(&dataPath, "data", ".", "data path, eg: --data /opt/librarian/data") flag.Parse() return Flags{ diff --git a/internal/lib/libapp/inherent_settings_debug.go b/internal/lib/libapp/inherent_settings_debug.go index 2e4bc8df..49250a8d 100644 --- a/internal/lib/libapp/inherent_settings_debug.go +++ b/internal/lib/libapp/inherent_settings_debug.go @@ -8,6 +8,6 @@ func getInherentSettings() InherentSettings { return InherentSettings{ EnablePanicRecovery: false, LogLevel: libzap.DebugLevel, - DefaultConfPath: "./configs/config.yaml", + DefaultConfPath: "./configs/config.toml", } } diff --git a/internal/lib/libapp/inherent_settings_default.go b/internal/lib/libapp/inherent_settings_default.go index 9a141193..2a32cb90 100644 --- a/internal/lib/libapp/inherent_settings_default.go +++ b/internal/lib/libapp/inherent_settings_default.go @@ -8,6 +8,6 @@ func getInherentSettings() InherentSettings { return InherentSettings{ EnablePanicRecovery: true, LogLevel: libzap.InfoLevel, - DefaultConfPath: "./configs/config.yaml", + DefaultConfPath: "./configs/config.toml", } } diff --git a/internal/service/angelaweb/internal/api/user.go b/internal/service/angelaweb/internal/api/user.go index ddd004fc..4dba14e2 100644 --- a/internal/service/angelaweb/internal/api/user.go +++ b/internal/service/angelaweb/internal/api/user.go @@ -11,14 +11,41 @@ import ( ) func (h *Handler) ListUsers(c *fiber.Ctx) error { - users, _, err := h.t.ListUsers(c.UserContext(), model.Paging{ - PageSize: 1, - PageNum: 20, + // Parse pagination parameters from query string + pageNum, err := strconv.Atoi(c.Query("page", "1")) + if err != nil || pageNum < 1 { + pageNum = 1 + } + + pageSize, err := strconv.Atoi(c.Query("pageSize", "10")) + if err != nil || pageSize < 1 { + pageSize = 10 + } + + users, total, err := h.t.ListUsers(c.UserContext(), model.Paging{ + PageNum: int64(pageNum), + PageSize: int64(pageSize), }, nil, nil) + if err != nil { return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"message": "Error fetching users"}) } - return c.JSON(users) + + // Calculate pagination information + totalPages := (int(total) + pageSize - 1) / pageSize + if totalPages == 0 { + totalPages = 1 + } + + return c.JSON(fiber.Map{ + "users": users, + "pagination": fiber.Map{ + "currentPage": pageNum, + "totalPages": totalPages, + "totalItems": total, + "pageSize": pageSize, + }, + }) } func (h *Handler) GetUser(c *fiber.Ctx) error { diff --git a/internal/service/angelaweb/internal/page/page.go b/internal/service/angelaweb/internal/page/page.go index d5bfe00f..afc379f0 100644 --- a/internal/service/angelaweb/internal/page/page.go +++ b/internal/service/angelaweb/internal/page/page.go @@ -46,18 +46,39 @@ func (b *Builder) Dashboard(c *fiber.Ctx) error { } func (b *Builder) UserList(c *fiber.Ctx) error { - users, _, err := b.t.ListUsers(c.UserContext(), model.Paging{ - PageNum: 1, - PageSize: 20, + pageNum, err := strconv.Atoi(c.Query("page", "1")) + if err != nil || pageNum < 1 { + pageNum = 1 + } + + pageSize := 1 // Users per page + + users, total, err := b.t.ListUsers(c.UserContext(), model.Paging{ + PageNum: int64(pageNum), + PageSize: int64(pageSize), }, nil, nil) if err != nil { return c.Status(http.StatusInternalServerError).SendString("Error fetching users") } + // Calculate pagination information + totalPages := (int(total) + pageSize - 1) / pageSize + if totalPages == 0 { + totalPages = 1 + } + return c.Render("user", fiber.Map{ "Title": "用户管理", "Users": users, + "Pagination": fiber.Map{ + "CurrentPage": pageNum, + "TotalPages": totalPages, + "HasPrev": pageNum > 1, + "HasNext": pageNum < totalPages, + "PrevPage": pageNum - 1, + "NextPage": pageNum + 1, + }, }) } diff --git a/internal/service/angelaweb/view/user.html b/internal/service/angelaweb/view/user.html index 729f9060..c3156412 100644 --- a/internal/service/angelaweb/view/user.html +++ b/internal/service/angelaweb/view/user.html @@ -51,6 +51,36 @@

用户列表

+ +{{if .Pagination}} +
+
+ 第 {{.Pagination.CurrentPage}} 页,共 {{.Pagination.TotalPages}} 页 +
+
+ {{if .Pagination.HasPrev}} + + 上一页 + + {{else}} + + {{end}} + + {{if .Pagination.HasNext}} + + 下一页 + + {{else}} + + {{end}} +
+
+{{end}} +