扣子配置
This commit is contained in:
parent
a6d7ec6349
commit
53344d1fc0
@ -127,6 +127,10 @@ public class CustomerDailyReportService {
|
|||||||
return new Caller(safeUserId, true, safeUserId, "企业微信管理员", "", "", "企业微信应用管理员",
|
return new Caller(safeUserId, true, safeUserId, "企业微信管理员", "", "", "企业微信应用管理员",
|
||||||
"", "WECOM_APP_ADMIN", "ALL_ORGANIZATION");
|
"", "WECOM_APP_ADMIN", "ALL_ORGANIZATION");
|
||||||
}
|
}
|
||||||
|
Caller directoryAdmin = resolveDirectoryAdmin(safeUserId);
|
||||||
|
if (directoryAdmin != null) {
|
||||||
|
return directoryAdmin;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Caller direct = jdbc.queryForObject("""
|
Caller direct = jdbc.queryForObject("""
|
||||||
SELECT COALESCE(NULLIF(u.user_id, ''), c.boss_user_id, '') user_id,
|
SELECT COALESCE(NULLIF(u.user_id, ''), c.boss_user_id, '') user_id,
|
||||||
@ -154,6 +158,24 @@ public class CustomerDailyReportService {
|
|||||||
.anyMatch(id -> id.trim().equalsIgnoreCase(wecomUserId));
|
.anyMatch(id -> id.trim().equalsIgnoreCase(wecomUserId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Caller resolveDirectoryAdmin(String wecomUserId) {
|
||||||
|
try {
|
||||||
|
return jdbc.queryForObject("""
|
||||||
|
SELECT employee_name, COALESCE(xuebang_account, '') xuebang_account,
|
||||||
|
COALESCE(primary_role_name, '') primary_role_name,
|
||||||
|
COALESCE(data_scope_type, '') data_scope_type
|
||||||
|
FROM employee_directory
|
||||||
|
WHERE LOWER(wecom_user_id) = LOWER(:wecomUserId)
|
||||||
|
AND (primary_role_code = 'GROUP_ADMIN' OR data_scope_type = 'ALL_ORGANIZATION')
|
||||||
|
LIMIT 1
|
||||||
|
""", Map.of("wecomUserId", wecomUserId), (rs, row) -> new Caller(
|
||||||
|
wecomUserId, true, rs.getString("xuebang_account"), rs.getString("employee_name"), "", "",
|
||||||
|
rs.getString("primary_role_name"), "", "EMPLOYEE_DIRECTORY_ADMIN", rs.getString("data_scope_type")));
|
||||||
|
} catch (EmptyResultDataAccessException ignored) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Caller resolveLegacy(String wecomUserId) {
|
private Caller resolveLegacy(String wecomUserId) {
|
||||||
Map<String, Object> legacy;
|
Map<String, Object> legacy;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public class CustomerDailyReportIntentHandler implements SemanticIntentHandler {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof org.springframework.web.server.ResponseStatusException status
|
if (e instanceof org.springframework.web.server.ResponseStatusException status
|
||||||
&& status.getStatusCode().value() == 403) {
|
&& status.getStatusCode().value() == 403) {
|
||||||
return "无权限查看:你的企业微信账号不在可查询的组织范围内。";
|
return "无权限查看:你的企业微信账号不在可查询的组织范围内。UserID:" + context.wecomUserId();
|
||||||
}
|
}
|
||||||
log.error("customer daily report intent failed wecomUserId={} range={}~{} err={}",
|
log.error("customer daily report intent failed wecomUserId={} range={}~{} err={}",
|
||||||
context.wecomUserId(), range.startDate(), range.endDate(), e.getMessage(), e);
|
context.wecomUserId(), range.startDate(), range.endDate(), e.getMessage(), e);
|
||||||
|
|||||||
@ -38,7 +38,7 @@ foundation:
|
|||||||
coze:
|
coze:
|
||||||
base-url: https://api.coze.cn
|
base-url: https://api.coze.cn
|
||||||
chat-path: /v1/workflows/chat
|
chat-path: /v1/workflows/chat
|
||||||
api-key: ${COZE_API_KEY:cztei_q6SLPbgARC2LugTaJNRUEsm8LhH4aFpWEy1C2vEyMIEiuSfpUnRS2cVSFAqjmkUtE}
|
api-key: cztei_lWf5IOm3zAkc1UumQc6wFcuDz32mHCuh7ETBRhoIanyupu6MgCfzc5eKHcKczkoXv
|
||||||
default-workflow: wecom-default
|
default-workflow: wecom-default
|
||||||
workflows:
|
workflows:
|
||||||
wecom-default:
|
wecom-default:
|
||||||
|
|||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.company.agentfoundation.integration.coze.service;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.config.FoundationProperties;
|
||||||
|
import com.company.agentfoundation.integration.coze.client.CozeWorkflowClient;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
class CozeWorkflowServiceTest {
|
||||||
|
@Test
|
||||||
|
void extractsAnswerContentFromCozeEventStream() {
|
||||||
|
FoundationProperties properties = new FoundationProperties();
|
||||||
|
properties.getCoze().setApiKey("test-key");
|
||||||
|
properties.getCoze().setDefaultWorkflow("wecom-default");
|
||||||
|
FoundationProperties.Coze.Workflow workflow = new FoundationProperties.Coze.Workflow();
|
||||||
|
workflow.setWorkflowId("7661923520095862811");
|
||||||
|
workflow.setAppId("7661851003527954473");
|
||||||
|
workflow.setParameters(new HashMap<>());
|
||||||
|
properties.getCoze().getWorkflows().put("wecom-default", workflow);
|
||||||
|
|
||||||
|
CozeWorkflowClient client = mock(CozeWorkflowClient.class);
|
||||||
|
when(client.chat(any())).thenReturn("""
|
||||||
|
event: conversation.message.completed
|
||||||
|
data: {"role":"assistant","type":"answer","content":"企业微信智能表格批量写入成功"}
|
||||||
|
|
||||||
|
event: conversation.chat.completed
|
||||||
|
data: {"status":"completed"}
|
||||||
|
|
||||||
|
event: done
|
||||||
|
data: {}
|
||||||
|
""");
|
||||||
|
|
||||||
|
CozeWorkflowService service = new CozeWorkflowService(properties, client, new ObjectMapper());
|
||||||
|
assertThat(service.chatDefault("同步测试表")).isEqualTo("企业微信智能表格批量写入成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user