敏感词过滤
This commit is contained in:
@@ -3,7 +3,8 @@ package cms
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"regexp"
|
||||
"strings"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
|
||||
@@ -403,6 +404,11 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
}
|
||||
if err == nil {
|
||||
successList = batchedStoreSkuList
|
||||
} else {
|
||||
//handle error for sensitive words, if find, then insert to table sensitive_words
|
||||
if sensitiveWords := GetSensitiveWords(singleStoreHandler, err.Error()); sensitiveWords != "" {
|
||||
dao.InsertSensitiveWord(sensitiveWords)
|
||||
}
|
||||
}
|
||||
if len(successList) > 0 {
|
||||
updateStoreSku(dao.GetDB(), vendorID, successList, model.SyncFlagNewMask)
|
||||
@@ -569,3 +575,15 @@ func ClearRemoteStoreStuffAndSetNew(ctx *jxcontext.Context, parentTask tasksch.I
|
||||
}
|
||||
return rootTask.ID, err
|
||||
}
|
||||
|
||||
func GetSensitiveWords(singleStoreHandler partner.ISingleStoreStoreSkuHandler, str string) string {
|
||||
var regFindKeyWords = singleStoreHandler.GetRegexp()
|
||||
var subRegFindKeyWords = regexp.MustCompile(`[^\[\]\"\}]`)
|
||||
findResult := regFindKeyWords.FindStringSubmatch(str)
|
||||
if findResult != nil && len(findResult) > 1 {
|
||||
findSubResult := subRegFindKeyWords.FindAllString(findResult[1], -1)
|
||||
return strings.Join(findSubResult, "")
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user