feat: complete Kra admin backend migration

This commit is contained in:
2026-08-14 00:28:37 +08:00
parent c4bf7ee03b
commit acba9624d7
88 changed files with 1765 additions and 8623 deletions
+12 -1
View File
@@ -36,7 +36,8 @@ type UserListFilter struct {
}
type DatabaseConfig struct {
Driver, Host, Port, User, Password, Name, Path, Config, AdminPassword string
Driver, Host, Port, User, Password, Name, Path, Config, Template, AdminPassword string
APIs []*API
}
type Authority struct {
@@ -64,6 +65,7 @@ type Menu struct {
TransitionType string
Children []*Menu
Buttons []*MenuButton
Parameters []*MenuParameter
}
type SystemRepo interface {
@@ -82,6 +84,8 @@ type SystemRepo interface {
SetUserSetting(context.Context, uint, map[string]any) error
ListAuthorities(context.Context) ([]*Authority, error)
PersistConfig(context.Context) error
PersistAdminConfig(context.Context, []byte) error
ReloadConfig(context.Context) error
}
type SystemUsecase struct {
@@ -103,6 +107,9 @@ func (uc *SystemUsecase) CacheSet(ctx context.Context, key, value string, expira
func (uc *SystemUsecase) CacheDelete(ctx context.Context, key string) error {
return uc.cache.Delete(ctx, key)
}
func (uc *SystemUsecase) CacheIncrement(ctx context.Context, key string, expiration time.Duration) (int64, error) {
return uc.cache.Increment(ctx, key, expiration)
}
func (uc *SystemUsecase) IsInitialized(ctx context.Context) (bool, error) {
return uc.repo.IsInitialized(ctx)
@@ -114,6 +121,10 @@ func (uc *SystemUsecase) Initialize(ctx context.Context, config *DatabaseConfig)
return uc.repo.Initialize(ctx, config)
}
func (uc *SystemUsecase) PersistConfig(ctx context.Context) error { return uc.repo.PersistConfig(ctx) }
func (uc *SystemUsecase) PersistAdminConfig(ctx context.Context, value []byte) error {
return uc.repo.PersistAdminConfig(ctx, value)
}
func (uc *SystemUsecase) ReloadConfig(ctx context.Context) error { return uc.repo.ReloadConfig(ctx) }
func (uc *SystemUsecase) Login(ctx context.Context, username, password string) (*User, error) {
u, err := uc.repo.FindUserByUsername(ctx, username)