This commit is contained in:
van
2026-04-04 16:39:43 +08:00
parent f0a3ce5afb
commit d151c1d425

View File

@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
/**
* 小红书/抖音提示词模板配置Controller
@@ -31,7 +33,10 @@ public class SocialMediaPromptController {
"keywords",
"content:xhs",
"content:douyin",
"content:both"
"content:both",
"xianyu:wenan_base",
"xianyu:jiaonixiadan_extra",
"xianyu:title_clean_regex"
};
// 模板说明
@@ -40,6 +45,9 @@ public class SocialMediaPromptController {
put("content:xhs", "小红书文案生成提示词模板\n占位符%s - 商品名称,%s - 价格信息,%s - 关键词信息");
put("content:douyin", "抖音文案生成提示词模板\n占位符%s - 商品名称,%s - 价格信息,%s - 关键词信息");
put("content:both", "通用文案生成提示词模板\n占位符%s - 商品名称,%s - 价格信息,%s - 关键词信息");
put("xianyu:wenan_base", "闲鱼文案·正文基础说明\n用于「一键代下」与「教你下单」两版文案中紧接在标题/型号行之后(纯文本,无占位符)");
put("xianyu:jiaonixiadan_extra", "闲鱼文案·教你下单版尾部附加说明\n接在「更新日期yyyy-MM-dd」之后纯文本");
put("xianyu:title_clean_regex", "闲鱼文案·标题/型号清洗正则\n从标题与型号备注中移除营销敏感片段须为 Java 正则,匹配到的内容会被删除");
}};
/**
@@ -145,6 +153,16 @@ public class SocialMediaPromptController {
response.put("msg", "Redis未配置无法保存模板");
return response;
}
if ("xianyu:title_clean_regex".equals(key)) {
try {
Pattern.compile(template.trim());
} catch (PatternSyntaxException e) {
response.put("code", 400);
response.put("msg", "正则表达式无效: " + e.getMessage());
return response;
}
}
String redisKey = REDIS_KEY_PREFIX + key;
redisTemplate.opsForValue().set(redisKey, template);