This commit is contained in:
2026-08-15 01:28:51 +08:00
parent 6698e59c3a
commit 2f165d3a45
26 changed files with 242 additions and 216 deletions
+16 -6
View File
@@ -16,20 +16,30 @@ type InitializationRepo interface {
ReloadConfig(context.Context) error
}
func (uc *SystemUsecase) IsInitialized(ctx context.Context) (bool, error) {
type SystemConfigUsecase struct{ repo InitializationRepo }
func NewSystemConfigUsecase(repo InitializationRepo) *SystemConfigUsecase {
return &SystemConfigUsecase{repo: repo}
}
func (uc *SystemConfigUsecase) IsInitialized(ctx context.Context) (bool, error) {
return uc.repo.IsInitialized(ctx)
}
func (uc *SystemUsecase) Initialize(ctx context.Context, config *DatabaseConfig) error {
func (uc *SystemConfigUsecase) Initialize(ctx context.Context, config *DatabaseConfig) error {
if config == nil || len(config.AdminPassword) < 6 {
return ErrInvalidCredentials
}
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 {
func (uc *SystemConfigUsecase) PersistConfig(ctx context.Context) error {
return uc.repo.PersistConfig(ctx)
}
func (uc *SystemConfigUsecase) PersistAdminConfig(ctx context.Context, value []byte) error {
return uc.repo.PersistAdminConfig(ctx, value)
}
func (uc *SystemUsecase) PersistRuntimeConfig(ctx context.Context, data, admin []byte) error {
func (uc *SystemConfigUsecase) PersistRuntimeConfig(ctx context.Context, data, admin []byte) error {
return uc.repo.PersistRuntimeConfig(ctx, data, admin)
}
func (uc *SystemUsecase) ReloadConfig(ctx context.Context) error { return uc.repo.ReloadConfig(ctx) }
func (uc *SystemConfigUsecase) ReloadConfig(ctx context.Context) error {
return uc.repo.ReloadConfig(ctx)
}