Files
2026-10-26 16:28:14 +08:00

50 lines
998 B
Go

package srv_playlet
import (
"strings"
"videoweb/pub/common/playletcache"
"videoweb/pub/pubdef"
)
const (
defaultPageSize int64 = 10
maxPageSize int64 = 100
)
func normalizePage(pageNum, pageSize int64) (int64, int64) {
if pageNum <= 0 {
pageNum = 1
}
if pageSize <= 0 {
pageSize = defaultPageSize
}
if pageSize > maxPageSize {
pageSize = maxPageSize
}
return pageNum, pageSize
}
// normalizeSeoValue 规范化 SEO 字段,避免 keywords 为 null
func normalizeSeoValue(seo pubdef.SeoValue) pubdef.SeoValue {
seo.Title = strings.TrimSpace(seo.Title)
seo.Description = strings.TrimSpace(seo.Description)
if seo.Keyworld == nil {
seo.Keyworld = make([]string, 0)
return seo
}
words := make([]string, 0, len(seo.Keyworld))
for _, word := range seo.Keyworld {
word = strings.TrimSpace(word)
if word == "" {
continue
}
words = append(words, word)
}
seo.Keyworld = words
return seo
}
func clearAppPlayletHomeCache() {
playletcache.ClearHomeCache()
}