fix: 增加检查,避免空指针

This commit is contained in:
cjy 2026-01-12 13:27:48 +08:00
parent dfc8ddb9b1
commit fac24b72ac

View File

@ -260,12 +260,23 @@ func processContentAndAutoTags(ctx *gin.Context, content string) (string, error)
)
if err != nil {
return content, err
} else if needMore && len(newTags) > 0 {
}
if resp == nil {
return content, nil
}
// 保存新生成的标签到数据库
if needMore && len(newTags) > 0 {
if saveErr := SaveTagsToDatabase(ctx, newTags, 4); saveErr != nil {
zap.L().Error("processContentAndAutoTags SaveTagsToDatabase failed", zap.Error(saveErr))
return content, errors.New("自动生成标签保存到数据库失败")
}
}
// 检查一下 resp.Post 是否为空
if resp.Post == "" {
return content, nil
}
return resp.Post, nil
}