Merge branch 'wavelet/main' into main

This commit is contained in:
ryan
2026-09-03 10:08:50 +08:00
24 changed files with 217 additions and 91 deletions
@@ -29,6 +29,7 @@ func (PublicConfigAdapter) PublicConfig(ctx context.Context) (map[string]string,
// SystemConfigServiceImpl implements contracts.SystemConfigService.
type SystemConfigServiceImpl struct{}
// GetByKey retrieves a system config by its unique key.
func (SystemConfigServiceImpl) GetByKey(ctx context.Context, key string) (contracts.SystemConfigDTO, error) {
cfg, err := repository.GetSystemConfigByKey(ctx, key)
if err != nil {
@@ -37,6 +38,7 @@ func (SystemConfigServiceImpl) GetByKey(ctx context.Context, key string) (contra
return toSystemConfigDTO(cfg), nil
}
// ListByKeys retrieves multiple system configs by their keys.
func (SystemConfigServiceImpl) ListByKeys(ctx context.Context, keys []string) (map[string]contracts.SystemConfigDTO, error) {
cfgs, err := repository.ListSystemConfigsByKeys(ctx, keys)
if err != nil {
@@ -49,6 +51,7 @@ func (SystemConfigServiceImpl) ListByKeys(ctx context.Context, keys []string) (m
return res, nil
}
// ListVisible returns all user-visible system configs.
func (SystemConfigServiceImpl) ListVisible(ctx context.Context) ([]contracts.SystemConfigDTO, error) {
cfgs, err := repository.ListVisibleSystemConfigs(ctx)
if err != nil {
@@ -61,6 +64,7 @@ func (SystemConfigServiceImpl) ListVisible(ctx context.Context) ([]contracts.Sys
return res, nil
}
// ListByType returns all system configs belonging to a specific configuration type.
func (SystemConfigServiceImpl) ListByType(ctx context.Context, configType string) ([]contracts.SystemConfigDTO, error) {
cfgs, err := repository.ListAdminSystemConfigs(ctx, configType)
if err != nil {
@@ -73,22 +77,27 @@ func (SystemConfigServiceImpl) ListByType(ctx context.Context, configType string
return res, nil
}
// GetIntByKey retrieves an integer system config value.
func (SystemConfigServiceImpl) GetIntByKey(ctx context.Context, key string) (int, error) {
return repository.GetIntByKey(ctx, key)
}
// GetBoolByKey retrieves a boolean system config value.
func (SystemConfigServiceImpl) GetBoolByKey(ctx context.Context, key string) (bool, error) {
return repository.GetBoolByKey(ctx, key)
}
// SaveOrUpdate persists or updates a system config key-value pair.
func (SystemConfigServiceImpl) SaveOrUpdate(ctx context.Context, key, value string) error {
return repository.SaveOrUpdateSystemConfig(ctx, key, value)
}
// InvalidateCache evicts the cache entry for the specified key.
func (SystemConfigServiceImpl) InvalidateCache(ctx context.Context, key string) error {
return repository.InvalidateSystemConfigCache(ctx, key)
}
// InvalidateAllCaches purges all system configuration cache entries.
func (SystemConfigServiceImpl) InvalidateAllCaches(ctx context.Context) error {
return repository.InvalidateAllSystemConfigCaches(ctx)
}
+9 -9
View File
@@ -69,15 +69,15 @@ func (s *uploadServiceImpl) RebuildStats(ctx context.Context) error {
func toUploadDTO(u *models.Upload) contracts.UploadDTO {
return contracts.UploadDTO{
ID: u.ID,
UserID: u.UserID,
FileName: u.FileName,
FilePath: u.FilePath,
MimeType: u.MimeType,
Size: u.FileSize,
Hash: u.Hash,
Status: string(u.Status),
Type: u.Type,
ID: u.ID,
UserID: u.UserID,
FileName: u.FileName,
FilePath: u.FilePath,
MimeType: u.MimeType,
Size: u.FileSize,
Hash: u.Hash,
Status: string(u.Status),
Type: u.Type,
Metadata: contracts.UploadMetadataDTO{
Width: u.Metadata.Width,
Height: u.Metadata.Height,