1
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
package com.ruoyi.web.controller.jarvis;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.jarvis.service.ISocialMediaService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 小红书/抖音内容生成Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-01-XX
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jarvis/social-media")
|
||||
public class SocialMediaController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISocialMediaService socialMediaService;
|
||||
|
||||
/**
|
||||
* 提取关键词
|
||||
*/
|
||||
@PostMapping("/extract-keywords")
|
||||
public AjaxResult extractKeywords(@RequestBody Map<String, Object> request)
|
||||
{
|
||||
try {
|
||||
String productName = (String) request.get("productName");
|
||||
if (productName == null || productName.trim().isEmpty()) {
|
||||
return AjaxResult.error("商品名称不能为空");
|
||||
}
|
||||
|
||||
Map<String, Object> result = socialMediaService.extractKeywords(productName);
|
||||
return AjaxResult.success(result);
|
||||
} catch (Exception e) {
|
||||
logger.error("提取关键词失败", e);
|
||||
return AjaxResult.error("提取关键词失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文案
|
||||
*/
|
||||
@PostMapping("/generate-content")
|
||||
public AjaxResult generateContent(@RequestBody Map<String, Object> request)
|
||||
{
|
||||
try {
|
||||
String productName = (String) request.get("productName");
|
||||
if (productName == null || productName.trim().isEmpty()) {
|
||||
return AjaxResult.error("商品名称不能为空");
|
||||
}
|
||||
|
||||
Object originalPriceObj = request.get("originalPrice");
|
||||
Object finalPriceObj = request.get("finalPrice");
|
||||
String keywords = (String) request.get("keywords");
|
||||
String style = (String) request.getOrDefault("style", "both");
|
||||
|
||||
Map<String, Object> result = socialMediaService.generateContent(
|
||||
productName, originalPriceObj, finalPriceObj, keywords, style
|
||||
);
|
||||
return AjaxResult.success(result);
|
||||
} catch (Exception e) {
|
||||
logger.error("生成文案失败", e);
|
||||
return AjaxResult.error("生成文案失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键生成完整内容(关键词 + 文案 + 图片)
|
||||
*/
|
||||
@Log(title = "小红书/抖音内容生成", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/generate-complete")
|
||||
public AjaxResult generateComplete(@RequestBody Map<String, Object> request)
|
||||
{
|
||||
try {
|
||||
String productImageUrl = (String) request.get("productImageUrl");
|
||||
String productName = (String) request.get("productName");
|
||||
if (productName == null || productName.trim().isEmpty()) {
|
||||
return AjaxResult.error("商品名称不能为空");
|
||||
}
|
||||
|
||||
Object originalPriceObj = request.get("originalPrice");
|
||||
Object finalPriceObj = request.get("finalPrice");
|
||||
String style = (String) request.getOrDefault("style", "both");
|
||||
|
||||
Map<String, Object> result = socialMediaService.generateCompleteContent(
|
||||
productImageUrl, productName, originalPriceObj, finalPriceObj, style
|
||||
);
|
||||
return AjaxResult.success(result);
|
||||
} catch (Exception e) {
|
||||
logger.error("生成完整内容失败", e);
|
||||
return AjaxResult.error("生成完整内容失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user