社区feed流
This commit is contained in:
@@ -112,6 +112,8 @@ public class PasswordUtil {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -96,6 +96,8 @@ public class ServiceManager {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ public class AliyunConfig {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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对话分析工作流
|
||||
*/
|
||||
|
||||
@@ -195,6 +195,8 @@ public class AuthController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -334,6 +334,8 @@ public class MenuController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -304,6 +304,8 @@ public class RoleController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -310,6 +310,8 @@ public class UserRoleController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
src/main/java/com/rj/dto/CommunityFeedDTO.java
Normal file
16
src/main/java/com/rj/dto/CommunityFeedDTO.java
Normal 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;
|
||||
|
||||
}
|
||||
@@ -78,4 +78,6 @@ public class DifyWorkflowResponseDto {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,3 +23,5 @@ public interface CustomerProfileAnalysisMapper extends BaseMapper<CustomerProfil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ public class LoginResponse {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ public class AudioStatisticsScheduler {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析工作流响应并保存数据
|
||||
*/
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -44,3 +44,5 @@ public interface ICustomerProfileAnalysisService extends IService<CustomerProfil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -79,3 +79,5 @@ public class CustomerProfileAnalysisServiceImpl extends ServiceImpl<CustomerProf
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ public interface IMenuService extends IService<Menu> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ public interface IUserRoleService extends IService<UserRole> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user