feat: Sites feature backend
This commit is contained in:
1 parent
45fcbd890d
commit
a11338094e
98 files changed
+5365
-214
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package useCases
|
||||
|
||||
import (
|
||||
"RenewCMS/internal/domain/audit"
|
||||
"RenewCMS/internal/domain/image"
|
||||
"RenewCMS/internal/domain/site"
|
||||
"errors"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func siteTarget(s site.Site) audit.Target {
|
||||
return audit.NewTarget(audit.TargetSite, s.ID, s.Name)
|
||||
}
|
||||
|
||||
func ensureImageExists(images image.Repository, id *uint32) error {
|
||||
if id == nil {
|
||||
return nil
|
||||
}
|
||||
_, err := images.Get(*id)
|
||||
return err
|
||||
}
|
||||
|
||||
func isKeyTaken(sites site.Repository, key string) (bool, error) {
|
||||
_, err := sites.GetByKey(key)
|
||||
if errors.Is(err, site.ErrSiteNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
return err == nil, err
|
||||
}
|
||||
|
||||
func imageLabel(images image.Repository, id *uint32) string {
|
||||
if id == nil {
|
||||
return ""
|
||||
}
|
||||
found, err := images.Get(*id)
|
||||
if err != nil || found.Filename == "" {
|
||||
return strconv.FormatUint(uint64(*id), 10)
|
||||
}
|
||||
return found.Filename
|
||||
}
|
||||
|
||||
func localeLabel(locale *string) string {
|
||||
if locale == nil {
|
||||
return ""
|
||||
}
|
||||
return *locale
|
||||
}
|
||||
Reference in new issue
Block a user