社区feed流

This commit is contained in:
spllzh
2025-09-25 19:48:57 +08:00
parent c8a3ea254e
commit 8286e68dd2
27 changed files with 136 additions and 17 deletions

View File

@@ -112,6 +112,8 @@ public class PasswordUtil {

View File

@@ -96,6 +96,8 @@ public class ServiceManager {

View File

@@ -74,6 +74,8 @@ public class AliyunConfig {

View File

@@ -1,5 +1,6 @@
package com.rj.controller;
import com.rj.dto.CommunityFeedDTO;
import com.rj.dto.DifyWorkflowRequestDto;
import com.rj.dto.DifyWorkflowResponseDto;
import com.rj.dto.CustomerProfileAnalysisRequestDto;
@@ -23,7 +24,7 @@ import java.util.Map;
*/
@Slf4j
@RestController
@RequestMapping("/api/dify")
@RequestMapping("/api/aicommunity")
@Tag(name = "Dify工作流", description = "Dify工作流API接口")
public class DifyWorkflowController {
@@ -81,6 +82,7 @@ public class DifyWorkflowController {
}
/**
* DCC对话分析工作流
*/

View File

@@ -195,6 +195,8 @@ public class AuthController {

View File

@@ -334,6 +334,8 @@ public class MenuController {

View File

@@ -304,6 +304,8 @@ public class RoleController {

View File

@@ -310,6 +310,8 @@ public class UserRoleController {

View File

@@ -0,0 +1,16 @@
package com.rj.dto;
import lombok.Data;
/**
* Author: 李中华 wx: spllzh
* Date: 2025/9/25 16:34
**/
@Data
public class CommunityFeedDTO {
String targetContent;
String targetId;
String targetType;
}

View File

@@ -78,4 +78,6 @@ public class DifyWorkflowResponseDto {

View File

@@ -23,3 +23,5 @@ public interface CustomerProfileAnalysisMapper extends BaseMapper<CustomerProfil

View File

@@ -61,6 +61,8 @@ public class LoginResponse {

View File

@@ -80,6 +80,8 @@ public class AudioStatisticsScheduler {

View File

@@ -44,6 +44,9 @@ public class DifyWorkflowService {
@Value("${dify.api.portrait-3in1-token}")// 客户画像 app-Tpz9ByHyj5X6QCNpPX53QoBt
private String portraitAllInToken;
@Value("${dify.api.ai-feed-token}")
private String aiFeedToken; // AI-Feed流社区优质内容评估
private final RestTemplate restTemplate;
@Autowired
@@ -200,6 +203,62 @@ public class DifyWorkflowService {
}
}
/**
* 调用 AI-Feed 流社区Feed流优质内容工作流
* 期望 inputs 参数包含targetContent、targetId、targetType
*/
public DifyWorkflowResponse callAiFeedWorkflow(DifyWorkflowRequest request) {
try {
String url = difyBaseUrl + workflowEndpoint;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Authorization", "Bearer " + aiFeedToken);
Map<String, Object> requestBody = new HashMap<>();
requestBody.put("inputs", request.getInputs());
requestBody.put("response_mode", "blocking");
requestBody.put("user", request.getUserId());
HttpEntity<Map<String, Object>> entity = new HttpEntity<>(requestBody, headers);
log.info("调用AI-Feed Dify工作流API: {}", url);
log.info("AI-Feed请求参数: {}", JSON.toJSONString(requestBody));
ResponseEntity<String> response = restTemplate.exchange(
url,
HttpMethod.POST,
entity,
String.class
);
log.info("AI-Feed Dify工作流响应状态: {}", response.getStatusCode());
log.info("AI-Feed Dify工作流响应内容: {}", response.getBody());
if (response.getStatusCode() == HttpStatus.OK) {
JSONObject responseJson = JSON.parseObject(response.getBody());
// AI-Feed 暂不做入库,直接返回
DifyWorkflowResponse result = new DifyWorkflowResponse();
if (responseJson.containsKey("data")) {
JSONObject data = responseJson.getJSONObject("data");
result.setWorkflowRunId(data.getString("workflow_run_id"));
result.setTaskId(data.getString("task_id"));
result.setData(data);
}
if (responseJson.containsKey("metadata")) {
result.setMetadata(responseJson.getJSONObject("metadata"));
}
return result;
} else {
throw new RuntimeException("AI-Feed Dify工作流调用失败状态码: " + response.getStatusCode());
}
} catch (Exception e) {
log.error("调用AI-Feed Dify工作流异常", e);
throw new RuntimeException("调用AI-Feed Dify工作流异常: " + e.getMessage(), e);
}
}
/**
* 解析工作流响应并保存数据
*/

View File

@@ -1,16 +0,0 @@
package com.rj.service.biz;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rj.entity.bz.DifyWorkflowAnalysis;
import com.rj.mapper.biz.DifyWorkflowAnalysisMapper;
import org.springframework.stereotype.Service;
/**
* Dify工作流分析结果服务实现类
*/
@Service
public class DifyWorkflowAnalysisServiceImpl extends ServiceImpl<DifyWorkflowAnalysisMapper, DifyWorkflowAnalysis>
implements IService<DifyWorkflowAnalysis> {
}

View File

@@ -44,3 +44,5 @@ public interface ICustomerProfileAnalysisService extends IService<CustomerProfil

View File

@@ -79,3 +79,5 @@ public class CustomerProfileAnalysisServiceImpl extends ServiceImpl<CustomerProf

View File

@@ -43,6 +43,8 @@ public interface IMenuService extends IService<Menu> {

View File

@@ -43,6 +43,8 @@ public interface IUserRoleService extends IService<UserRole> {

View File

@@ -47,6 +47,8 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM

View File

@@ -47,6 +47,8 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR

View File

@@ -47,6 +47,8 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i