Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5203822b32 | ||
|
|
a074446edb | ||
|
|
e10edc1b0d |
+2
-19
@@ -13,22 +13,5 @@ type AdsClickInfo struct {
|
||||
Location int64 `json:"location,omitempty" binding:"required"` // 位置ID
|
||||
}
|
||||
|
||||
type AdvitiseData struct {
|
||||
HomeList []proxy.AdvitiseInfo `json:"homeList" bson:"homeList"` // 首页列表
|
||||
DetailTopList []proxy.AdvitiseInfo `json:"detailTopList" bson:"detailTopList"` // 详情页顶部广告
|
||||
NineGridList []proxy.AdvitiseInfo `json:"nineGridList" bson:"nineGridList"` // 9宫格
|
||||
DetailbannerList []proxy.AdvitiseInfo `json:"detailbannerList" bson:"detailbannerList"` // 详情banner
|
||||
LaunchScreenList []proxy.AdvitiseInfo `json:"launchScreenList"` // 启动页广告
|
||||
FloatingList []proxy.AdvitiseInfo `json:"floatingList" bson:"floatingList"` // 悬浮小方块
|
||||
AList []proxy.AdvitiseInfo `json:"AList"` // 固定12广告位
|
||||
BList []proxy.AdvitiseInfo `json:"BList"` // 固定13广告位
|
||||
DialogList []proxy.AdvitiseInfo `json:"dialogList" bson:"dialogList"` // 弹窗广告
|
||||
BottomBanner []proxy.AdvitiseInfo `json:"bottomBanner" bson:"bottomBanner"` // 底部banner
|
||||
|
||||
VideoInfoList []proxy.AdvitiseInfo `json:"videoInfoList" bson:"videoInfoList"` // 视频详情
|
||||
DownList []proxy.AdvitiseInfo `json:"downList" bson:"downList"` // 底部广告
|
||||
FriendList []proxy.AdvitiseInfo `json:"friendList" bson:"friendList"` // 友链
|
||||
TitleList []proxy.AdvitiseInfo `json:"titleList" bson:"titleList"` // 标题广告
|
||||
PlayList []proxy.AdvitiseInfo `json:"playList" bson:"playList"` // 播放强制跳转
|
||||
PauseyList []proxy.AdvitiseInfo `json:"pauseyList" bson:"pauseyList"` // 暂停广告
|
||||
}
|
||||
// AdvitiseData 广告数据,直接使用媒资中心返回的结构
|
||||
type AdvitiseData = proxy.AdvitiseData
|
||||
|
||||
@@ -124,7 +124,7 @@ func UpdateAppListCache(ctx context.Context) {
|
||||
}
|
||||
// 广告位 A(code=12)
|
||||
if category.Code == 12 {
|
||||
for _, ad := range advitise.AList {
|
||||
for _, ad := range advitise.AppInfoAList {
|
||||
apps = append(apps, proto.AppInfoData{
|
||||
AdvitiseId: ad.Id,
|
||||
CategoryId: category.Id,
|
||||
@@ -137,7 +137,7 @@ func UpdateAppListCache(ctx context.Context) {
|
||||
}
|
||||
// 广告位 B(code=13)
|
||||
if category.Code == 13 {
|
||||
for _, ad := range advitise.BList {
|
||||
for _, ad := range advitise.AppInfoBList {
|
||||
apps = append(apps, proto.AppInfoData{
|
||||
AdvitiseId: ad.Id,
|
||||
CategoryId: category.Id,
|
||||
|
||||
@@ -1,97 +1,61 @@
|
||||
package configser
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"videoweb/app/api/proto"
|
||||
"videoweb/app/appg"
|
||||
"videoweb/pub/adcenter"
|
||||
"context"
|
||||
"net/http"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/netutil"
|
||||
"videoweb/pub/pubdef"
|
||||
"videoweb/pub/storage"
|
||||
"videoweb/pub/storage/proxy"
|
||||
)
|
||||
|
||||
// UpdateAdvitiseDataFromJt 从广告中心拉取福利页广告
|
||||
func UpdateAdvitiseDataFromJt() {
|
||||
// UpdateAdvitiseData 从媒资中心按 AppId 拉取广告,图片拼接 CDN 后写入缓存
|
||||
func UpdateAdvitiseData(ctx context.Context) {
|
||||
config := GetConfigInfo()
|
||||
var resp proto.AdvitiseData
|
||||
jtAds, err := adcenter.JtAdvertiseThreeServer(appg.Conf.AdCenter.ApiDomain, appg.Conf.AdCenter.MerchantCode, appg.Conf.AdCenter.AppCode, appg.Conf.AdCenter.AesKey)
|
||||
if err != nil {
|
||||
log.Error("JtAdvertiseThreeServer error occur", log.E(err))
|
||||
queryAdvitiseReq := &proxy.AppAdvitiseInfoReq{
|
||||
Id: pubdef.AppId,
|
||||
}
|
||||
advitiseResult, err := storage.QueryAdvitiseList(ctx, queryAdvitiseReq, "")
|
||||
if err != nil || advitiseResult.Code != http.StatusOK {
|
||||
if advitiseResult != nil {
|
||||
log.Warn("UpdateAdvitiseData.QueryAdvitiseList failed", log.Any("filter", queryAdvitiseReq), log.E(err), log.Any("respCode", advitiseResult.Code))
|
||||
} else {
|
||||
log.Warn("UpdateAdvitiseData.QueryAdvitiseList failed", log.Any("filter", queryAdvitiseReq), log.E(err))
|
||||
}
|
||||
return
|
||||
}
|
||||
adMap := make(map[string]adcenter.AdCacheInfo)
|
||||
for _, loc := range jtAds {
|
||||
pos, err := strconv.Atoi(loc.AdvertiseLocationCode)
|
||||
if err != nil {
|
||||
log.Error("广告位置代码错误,必须为数字", log.Any("code", loc.AdvertiseLocationCode))
|
||||
continue
|
||||
}
|
||||
//if pos < 100001 {
|
||||
// continue
|
||||
//}
|
||||
ads := make([]proxy.AdvitiseInfo, 0)
|
||||
for _, ad := range loc.AdDetailInfoList {
|
||||
//extra := ad.GetExtraData()
|
||||
ads = append(ads, proxy.AdvitiseInfo{
|
||||
Id: ad.AdvertiseCode,
|
||||
Location: int64(pos),
|
||||
Title: ad.AdvertiseName,
|
||||
Images: netutil.MergeURL(config.ImgCdn, ad.GetCoverLsj()),
|
||||
Link: ad.GetRealLink(),
|
||||
})
|
||||
adMap[ad.AdvertiseCode] = adcenter.AdCacheInfo{
|
||||
AdvertiseCode: ad.AdvertiseCode,
|
||||
CustomerCode: ad.CustomerCode,
|
||||
AdvertiseName: ad.AdvertiseName,
|
||||
AdvertiseUrl: ad.AdvertiseUrl,
|
||||
AdvertiseIcon: ad.AdvertiseIcon,
|
||||
AdvertiseType: ad.AdvertiseType,
|
||||
AdMode: ad.AdMode,
|
||||
AppCode: ad.AppCode,
|
||||
LocationType: ad.LocationType,
|
||||
AdvertiseDesc: ad.AdvertiseDesc,
|
||||
PageType: ad.PageType,
|
||||
StartTimeStamp: ad.StartTimeStamp,
|
||||
EndTimeStamp: ad.EndTimeStamp,
|
||||
Sort: ad.Sort,
|
||||
AdExtData: ad.AdExtData,
|
||||
DeptCode: loc.DeptCode,
|
||||
MerchantCode: loc.MerchantCode,
|
||||
AdvertiseLocationCode: loc.AdvertiseLocationCode,
|
||||
AdvertiseLocationName: loc.AdvertiseLocationName,
|
||||
DisplayMode: loc.DisplayMode,
|
||||
AdvertiseHeight: loc.AdvertiseHeight,
|
||||
AdvertiseWidth: loc.AdvertiseWidth,
|
||||
MaterialType: loc.MaterialType,
|
||||
AdLimit: loc.AdLimit,
|
||||
}
|
||||
}
|
||||
switch pos {
|
||||
case 1: //弹窗
|
||||
resp.DialogList = ads
|
||||
case 2: // 应用
|
||||
resp.DetailTopList = ads
|
||||
case 3: // 横幅
|
||||
resp.NineGridList = ads
|
||||
resp.DetailbannerList = ads
|
||||
|
||||
case 12:
|
||||
resp.AList = ads
|
||||
case 13:
|
||||
resp.BList = ads
|
||||
}
|
||||
data := advitiseResult.Data
|
||||
for _, list := range []*[]proxy.AdvitiseInfo{
|
||||
&data.DialogList,
|
||||
&data.HomeList,
|
||||
&data.VideoTopList,
|
||||
&data.VideoDownList,
|
||||
&data.HotAppList,
|
||||
&data.NewAppList,
|
||||
&data.MustAppList,
|
||||
&data.TitleAppList,
|
||||
&data.FriendList,
|
||||
&data.NineGridList,
|
||||
&data.VideoList,
|
||||
&data.StopList,
|
||||
&data.ForcedJumpList,
|
||||
&data.AppInfoAList,
|
||||
&data.AppInfoBList,
|
||||
} {
|
||||
mergeAdvitiseImages(*list, config.ImgCdn)
|
||||
}
|
||||
|
||||
CacheMgr.Lock.Lock()
|
||||
defer CacheMgr.Lock.Unlock()
|
||||
CacheMgr.Advitise = resp
|
||||
CacheMgr.AdvitiseMap = adMap
|
||||
CacheMgr.Advitise = data
|
||||
}
|
||||
|
||||
func GetAdvertiseLocation(adverId string) (res adcenter.AdCacheInfo) {
|
||||
CacheMgr.Lock.RLock()
|
||||
defer CacheMgr.Lock.RUnlock()
|
||||
if ad, ok := CacheMgr.AdvitiseMap[adverId]; ok {
|
||||
res = ad
|
||||
func mergeAdvitiseImages(list []proxy.AdvitiseInfo, cdn string) {
|
||||
for i := range list {
|
||||
if len(list[i].Images) > 0 {
|
||||
list[i].Images = netutil.MergeURL(cdn, list[i].Images)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"sync"
|
||||
"videoweb/app/api/proto"
|
||||
"videoweb/app/service/translationser"
|
||||
"videoweb/pub/adcenter"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/netutil"
|
||||
"videoweb/pub/common/srvdef"
|
||||
@@ -36,7 +35,6 @@ type CacheInfo struct {
|
||||
Lock sync.RWMutex // 读写锁
|
||||
Config proto.ConfigInfo // 系统配置缓存
|
||||
Advitise proto.AdvitiseData
|
||||
AdvitiseMap map[string]adcenter.AdCacheInfo
|
||||
TagCategoryList []proto.VideoTagCategoryData
|
||||
TotalHistory int64
|
||||
IpBlackMaps map[string]struct{}
|
||||
@@ -63,14 +61,14 @@ func Start() {
|
||||
ctx := context.Background()
|
||||
dataReport.StartSDKConfigCron()
|
||||
UpdateConfigInfo(ctx)
|
||||
UpdateAdvitiseDataFromJt()
|
||||
UpdateAdvitiseData(ctx)
|
||||
updateIpBlack()
|
||||
updateTagsCache()
|
||||
updateAppRichTexts()
|
||||
updateAnnouncements()
|
||||
_, _ = skdCron.AddFunc("0 */5 * * * ?", func() {
|
||||
UpdateConfigInfo(ctx)
|
||||
UpdateAdvitiseDataFromJt()
|
||||
UpdateAdvitiseData(ctx)
|
||||
updateIpBlack()
|
||||
updateTagsCache()
|
||||
updateAppRichTexts()
|
||||
|
||||
@@ -113,6 +113,19 @@ func IsSlugAllDigits(s string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// RandomSlugLength 随机 slug 长度
|
||||
const RandomSlugLength = 8
|
||||
|
||||
// MakeRandomSlug 生成唯一的随机 slug(8 位小写字母);exists 返回 true 表示已被占用。
|
||||
func MakeRandomSlug(exists func(string) bool) string {
|
||||
for {
|
||||
s := strings.ToLower(GetRandomLetters(RandomSlugLength))
|
||||
if !exists(s) {
|
||||
return s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MakeUniqueSlug 生成唯一 slug;exists 返回 true 表示已被占用。生成结果不能全是数字。
|
||||
func MakeUniqueSlug(source string, exists func(string) bool) string {
|
||||
pinyin := GetSlugInfo(source)
|
||||
|
||||
@@ -156,6 +156,30 @@ func QueryMedia(baseInfo *MediaQueryeReq, domain string) (result *VideoQueryResu
|
||||
return
|
||||
}
|
||||
|
||||
func QueryAdvitise(baseInfo *AppAdvitiseInfoReq, domain string) (result *AdvitiseQuerysResult, err error) {
|
||||
result = &AdvitiseQuerysResult{}
|
||||
paramJson, err := json.Marshal(baseInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(domain) == 0 {
|
||||
domain = DomainAddressRepair(domain, BucketVideoAddressV2)
|
||||
}
|
||||
url := domain
|
||||
if !strings.Contains(domain, "/media/web/app/advitise") {
|
||||
url = domain + "/media/web/app/advitise"
|
||||
}
|
||||
fr, err := http.Post(url, header, bytes.NewReader(paramJson))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal(fr.Data, result); err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func QueryMedias(baseInfo *MediaQueryesReq, domain string) (result *VideoQuerysResult, err error) {
|
||||
result = &VideoQuerysResult{
|
||||
Data: make([]MediaResp, 0),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"time"
|
||||
"videoweb/pub/models/videoinformationmod"
|
||||
@@ -425,6 +426,33 @@ type AdvitiseInfo struct {
|
||||
Images string `json:"images" bson:"images"` // 视频banner
|
||||
Link string `json:"link" bson:"link"` // 链接
|
||||
}
|
||||
|
||||
// UnmarshalJSON 兼容远端 id 返回数字或字符串两种格式,统一解析为字符串,避免大整数(雪花ID)在 JS 端丢精度
|
||||
func (a *AdvitiseInfo) UnmarshalJSON(data []byte) error {
|
||||
type alias AdvitiseInfo
|
||||
aux := &struct {
|
||||
Id json.RawMessage `json:"id"`
|
||||
*alias
|
||||
}{alias: (*alias)(a)}
|
||||
if err := json.Unmarshal(data, aux); err != nil {
|
||||
return err
|
||||
}
|
||||
raw := strings.TrimSpace(string(aux.Id))
|
||||
switch {
|
||||
case raw == "" || raw == "null":
|
||||
a.Id = ""
|
||||
case strings.HasPrefix(raw, `"`):
|
||||
var s string
|
||||
if err := json.Unmarshal([]byte(raw), &s); err != nil {
|
||||
return err
|
||||
}
|
||||
a.Id = s
|
||||
default:
|
||||
a.Id = raw
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type AdvitiseData struct {
|
||||
DialogList []AdvitiseInfo `json:"dialogList" bson:"dialogList"` // 弹窗广告
|
||||
HomeList []AdvitiseInfo `json:"homeList" bson:"homeList"` // 首页列表
|
||||
|
||||
@@ -29,6 +29,10 @@ func UploadImage(ctx context.Context, f *multipart.FileHeader, domain string) (p
|
||||
return proxy.UploadImg(f.Filename, buffer.Bytes(), domain)
|
||||
}
|
||||
|
||||
func QueryAdvitiseList(ctx context.Context, in *proxy.AppAdvitiseInfoReq, domain string) (*proxy.AdvitiseQuerysResult, error) {
|
||||
return proxy.QueryAdvitise(in, domain)
|
||||
}
|
||||
|
||||
func QueryMedias(ctx context.Context, in *proxy.MediaQueryesReq, domain string) (*proxy.VideoQuerysResult, error) {
|
||||
return proxy.QueryMedias(in, domain)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func AccLogin(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
accInfo, err := srv_mwacc.AccLogin(c, req.Acc, req.Pwd, req.Code)
|
||||
accInfo, err := srv_mwacc.AccLogin(c, req.Acc, req.Pwd)
|
||||
if err != nil || accInfo == nil {
|
||||
common.ServerJSON(c, err.Code, err.Msg)
|
||||
return
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
@@ -9,11 +9,9 @@ import (
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/common/utils"
|
||||
"videoweb/pub/google"
|
||||
"videoweb/pub/models/mwacc"
|
||||
"videoweb/web/webg"
|
||||
|
||||
"github.com/skip2/go-qrcode"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
@@ -78,8 +76,8 @@ func isCustomerServiceRole(ctx context.Context, acc *mwacc.MwAcc) bool {
|
||||
return strings.Contains(roleName, "客服")
|
||||
}
|
||||
|
||||
// 账号登录
|
||||
func AccLogin(ctx context.Context, acc string, pwd string, code string) (*mwacc.MwAcc, *srvdef.SrvErr) {
|
||||
// 账号登录(已取消谷歌验证,密码正确即登录)
|
||||
func AccLogin(ctx context.Context, acc string, pwd string) (*mwacc.MwAcc, *srvdef.SrvErr) {
|
||||
var data *mwacc.MwAcc
|
||||
res, dataErr := mwacc.FindOneAccByFilter(ctx, bson.M{
|
||||
mwacc.FN.MwAcc.Acc: acc,
|
||||
@@ -99,43 +97,18 @@ func AccLogin(ctx context.Context, acc string, pwd string, code string) (*mwacc.
|
||||
return data, srvdef.New(srvdef.AccountErrPasswordError, srvdef.AccountErrPasswordError.Msg(), "")
|
||||
}
|
||||
|
||||
if !res.IsBase32 {
|
||||
// 谷歌绑定二维码
|
||||
googleUrl := google.NewGoogleAuth().GetQrcode(acc, res.Base32)
|
||||
qrCodePNG, _ := qrcode.Encode(googleUrl, qrcode.Medium, 256)
|
||||
|
||||
bq := &mwacc.MwAcc{}
|
||||
bq.Qurl = qrCodePNG
|
||||
data = bq
|
||||
} else {
|
||||
// hf屏蔽
|
||||
if webg.Conf.RunMod == "prod" && (res.RoleId != 46761 && res.RoleId != 29601) {
|
||||
if code == "" {
|
||||
return data, srvdef.New(srvdef.ErrCaptcha, srvdef.ErrCaptcha.Msg(), "")
|
||||
}
|
||||
result, Verr := google.NewGoogleAuth().VerifyCode(res.Base32, code)
|
||||
if Verr != nil || !result {
|
||||
return data, srvdef.New(srvdef.ErrCaptchaInvalid, srvdef.ErrCaptchaInvalid.Msg(), "")
|
||||
}
|
||||
}
|
||||
// 通过验证,再次验证密码是否正确
|
||||
pwd := crypt.StrToMd5(pwd)
|
||||
if res.Pwd != pwd {
|
||||
return data, srvdef.New(srvdef.AccountErrPasswordError, srvdef.AccountErrPasswordError.Msg(), "")
|
||||
}
|
||||
getToken, err := generateToken(res.Id)
|
||||
if err != nil {
|
||||
return data, srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||
}
|
||||
_ = mwacc.UpOneAccByFilter(ctx, bson.M{
|
||||
mwacc.FN.MwAcc.Id: res.Id,
|
||||
}, bson.M{
|
||||
mwacc.FN.MwAcc.LastTime: time.Now(),
|
||||
})
|
||||
// 更新最近登录时间
|
||||
data = res
|
||||
data.Token = getToken
|
||||
getToken, err := generateToken(res.Id)
|
||||
if err != nil {
|
||||
return data, srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||
}
|
||||
// 更新最近登录时间
|
||||
_ = mwacc.UpOneAccByFilter(ctx, bson.M{
|
||||
mwacc.FN.MwAcc.Id: res.Id,
|
||||
}, bson.M{
|
||||
mwacc.FN.MwAcc.LastTime: time.Now(),
|
||||
})
|
||||
data = res
|
||||
data.Token = getToken
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user