专题和短剧 slug 改为 8 位随机小写字母

后台新建/修改(未填 slug)和媒资入库时生成随机 slug,不再按标题拼音生成;标签、分类不变。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-29 11:26:03 +08:00
co-authored by Claude Opus 5.5
parent e10edc1b0d
commit a074446edb
3 changed files with 18 additions and 26 deletions
+1 -2
View File
@@ -1282,8 +1282,7 @@ func ensureImportedPlayletSlug(ctx context.Context, playlet *playletmod.Playlet)
if playlet == nil {
return srvdef.New(srvdef.ErrParamError, "短剧数据为空", "")
}
source := utils.SlugSourceFromKeywordsOrTitle(playlet.SeoInfo.Keyworld, playlet.Title)
playlet.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
playlet.Slug = utils.MakeRandomSlug(func(slug string) bool {
exist, _ := playletmod.FindOnePlaylet(ctx, bson.M{
playletmod.FN.Playlet.Slug: slug,
})
+4 -24
View File
@@ -47,8 +47,7 @@ func ensureThemeSlug(ctx context.Context, ac *playletthememod.PlayletTheme, excl
}
return nil
}
source := utils.SlugSourceFromKeywordsOrTitle(ac.SeoInfo.Keyworld, ac.Name)
ac.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
ac.Slug = utils.MakeRandomSlug(func(slug string) bool {
filter := bson.M{playletthememod.FN.PlayletTheme.Slug: slug}
if excludeId > 0 {
filter[playletthememod.FN.PlayletTheme.Id] = bson.M{"$ne": excludeId}
@@ -80,16 +79,7 @@ func prepareThemeSlugOnUpdate(ctx context.Context, id int64, info *playletthemem
}
return nil
}
name := info.Name
if req.Name != nil {
name = strings.TrimSpace(*req.Name)
}
keywords := info.SeoInfo.Keyworld
if req.SeoInfo != nil {
keywords = normalizeSeoValue(*req.SeoInfo).Keyworld
}
source := utils.SlugSourceFromKeywordsOrTitle(keywords, name)
newSlug := utils.MakeUniqueSlug(source, func(s string) bool {
newSlug := utils.MakeRandomSlug(func(s string) bool {
exist, _ := playletthememod.FindOnePlayletTheme(ctx, bson.M{
playletthememod.FN.PlayletTheme.Slug: s,
playletthememod.FN.PlayletTheme.Id: bson.M{"$ne": id},
@@ -185,8 +175,7 @@ func ensurePlayletSlug(ctx context.Context, ac *playletmod.Playlet, excludeId in
}
return nil
}
source := utils.SlugSourceFromKeywordsOrTitle(ac.SeoInfo.Keyworld, ac.Title)
ac.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
ac.Slug = utils.MakeRandomSlug(func(slug string) bool {
filter := bson.M{playletmod.FN.Playlet.Slug: slug}
if excludeId > 0 {
filter[playletmod.FN.Playlet.Id] = bson.M{"$ne": excludeId}
@@ -218,16 +207,7 @@ func preparePlayletSlugOnUpdate(ctx context.Context, id int64, info *playletmod.
}
return nil
}
title := info.Title
if req.Title != nil {
title = strings.TrimSpace(*req.Title)
}
keywords := info.SeoInfo.Keyworld
if req.SeoInfo != nil {
keywords = normalizeSeoValue(*req.SeoInfo).Keyworld
}
source := utils.SlugSourceFromKeywordsOrTitle(keywords, title)
newSlug := utils.MakeUniqueSlug(source, func(s string) bool {
newSlug := utils.MakeRandomSlug(func(s string) bool {
exist, _ := playletmod.FindOnePlaylet(ctx, bson.M{
playletmod.FN.Playlet.Slug: s,
playletmod.FN.Playlet.Id: bson.M{"$ne": id},