diff --git a/.drone.yml b/.drone.yml
deleted file mode 100644
index 0efdb5b9..00000000
--- a/.drone.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-pipeline:
- build-contact-center:
- group: build
- image: plugins/docker
- context: contact-center
- dockerfile: contact-center/Dockerfile
- repo: chatopera/contact-center
- tags: develop
- secrets: [ docker_username, docker_password ]
-
- build-cc-switch:
- group: build
- image: plugins/docker
- context: cc-switch/app
- dockerfile: cc-switch/app/Dockerfile
- repo: chatopera/cc-switch
- tags: develop
- secrets: [ docker_username, docker_password ]
-
-branches: develop
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index f1331a46..11b7236c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ backups/
.env
build.gradle
.vscode/
+private
diff --git a/.vscode/sftp.json b/.vscode/sftp.json
deleted file mode 100644
index 56d10a59..00000000
--- a/.vscode/sftp.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "name": "sftp",
- "remotePath": "git/cosinee",
- "protocol": "sftp",
- "uploadOnSave": true,
- "port": 22,
- "profiles": {
- "gamera": {
- "name": "gamera",
- "host": "gamera",
- "username": "hain",
- "privateKeyPath": "/Users/hain/.ssh/id_rsa"
- }
- }
-}
diff --git a/README.md b/README.md
index 9477606e..c2f8db9f 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,247 @@
-# 春松客服企业版
+[](https://microbadger.com/images/chatopera/contact-center:develop "Get your own image badge on microbadger.com") [](https://microbadger.com/images/chatopera/contact-center:develop "Get your own version badge on microbadger.com") [](https://hub.docker.com/r/chatopera/contact-center/) [](https://hub.docker.com/r/chatopera/contact-center/) [](https://microbadger.com/images/chatopera/contact-center:develop "Get your own commit badge on microbadger.com")
-https://gitlab.chatopera.com/chatopera
+
+ 春松客服QQ交流群:185659917, 点击链接加入群聊
+
+
-## License
+# 春松客服: 全渠道智能客服
-Copyright 2019 北京华夏春松科技有限公司 . All rights reserved.
-This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.
+春松客服是帮助中小型企业快速而低成本的获得好用的智能客服系统。
+
+
+
+春松客服是 Chatopera 自主研发以及基于且增强其它开源软件的方式实现的,春松客服会不断增强客服系统的智能化,这包括利用自然语言处理、机器学习和语音识别等技术让客服工作更有效率、客服满意度更高、成本更低。
+
+**开源项目地址:** [https://github.com/chatopera/cosin](https://github.com/chatopera/cosin)
+
+**开发环境搭建:** [https://github.com/chatopera/cosin/wiki/春松客服:开发环境](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83)
+
+## 内容结构
+
+[产品演示](https://github.com/chatopera/cosin#%E4%BA%A7%E5%93%81%E6%BC%94%E7%A4%BA)
+
+[功能](https://github.com/chatopera/cosin#%E5%8A%9F%E8%83%BD)
+
+[开发文档](https://github.com/chatopera/cosin#%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3)
+
+[产品截图](https://github.com/chatopera/cosin#%E4%BA%A7%E5%93%81%E6%88%AA%E5%9B%BE)
+
+[产品体系](https://github.com/chatopera/cosin#%E4%BA%A7%E5%93%81%E4%BD%93%E7%B3%BB)
+
+[立即部署](https://github.com/chatopera/cosin#%E7%AB%8B%E5%8D%B3%E9%83%A8%E7%BD%B2)
+
+[鸣谢](https://github.com/chatopera/cosin#%E9%B8%A3%E8%B0%A2)
+
+[开源许可协议](https://github.com/chatopera/cosin#%E5%BC%80%E6%BA%90%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE)
+
+## 产品演示
+
+- 坐席工作台
+
+[http://cc.chatopera.com/](http://cc.chatopera.com/)
+
+| **登录账号** | **密码** |
+| ------------ | --------- |
+| admin | admin1234 |
+
+- 网页端访客程序
+
+[http://cc.chatopera.com/testclient.html](http://cc.chatopera.com/testclient.html)
+
+## 功能
+
+- 账号及组织机构管理:按组织、角色分配账号权限
+
+- 联系人管理:细粒度维护客户信息
+
+- 网页聊天组件:一分钟接入对话窗口
+
+- 坐席工作台:汇聚多渠道访客请求
+
+- 机器人客服:集成机器人平台服务,完成多轮对话和知识库问答
+
+- 外呼系统:自动外呼,手动外呼,监听和报表等
+
+ 《春松客服产品系列视频》
+
+
+
+ 序号 |
+ 内容 |
+ 腾讯视频 |
+ 百度网盘 |
+
+
+ No. 1 |
+ 产品概述 |
+ 观看 |
+ 下载 |
+
+
+ No. 2 |
+ 安装部署 |
+ 观看 |
+ 下载 |
+
+
+ No. 3 |
+ 功能演示 |
+ 观看 |
+ 下载 |
+
+
+ No. 4 |
+ 账号体系 |
+ 观看 |
+ 下载 |
+
+
+ No. 5 |
+ 客户关系管理 |
+ 观看 |
+ 下载 |
+
+
+ No. 6 |
+ 即时通信 |
+ 观看 |
+ 下载 |
+
+
+ No. 7 |
+ 呼叫中心 |
+ 观看 |
+ 下载 |
+
+
+ No. 8 |
+ 数据报表 |
+ 观看 |
+ 下载 |
+
+
+
+[_下载视频合集_](https://pan.baidu.com/s/1YH7d7nMm5wZQp7P8kID3KA)
+
+## 使用说明
+
+关于产品的具体使用说明,请参考[文档中心](https://docs.chatopera.com/omni-channel-customer-support-system.html)。
+
+## 来自真实用户的反馈
+
+```
+项目代码写的挺好的,容易维护,是不错的开源项目。
+```
+
+-- 海洋 (深圳银之杰项目经理)
+
+```
+Amazing! 要的就是这个效果。
+```
+
+-- 常经理 (某电器世界五百强企业)
+
+```
+我要在APP内集成,我看了好多项目了,就你们这个最好,基本就是一个商用化的项目。
+```
+
+-- Engine X (某二手车出售平台技术负责人)
+
+## 开发文档
+
+
+ 开发文档
+
+
+
+
+
+## 产品截图
+
+
+ 欢迎页
+
+
+
+
+ 坐席工作台
+
+
+
+
+ 坐席监控
+
+
+
+
+ 外呼计划
+
+
+
+
+ 通话记录
+
+
+
+
+ 集成客服机器人
+
+
+
+
+ 客服机器人应答
+
+
+
+
+ 更多功能,敬请期待 ...
+
+
+
+## 产品体系
+
+
+ 观看视频介绍
+
+
+
+
+
+## 立即部署
+
+- 企业版
+
+通过青云 AppCenter 部署,青云 AppCenter 是开发运维一体化(DevOps)管理企业应用的平台,Chatopera 的春松客服在 2018 年 10 月登录 AppCenter,并借助 PaaS 平台强大的计算能力实现计算节点集群、存储节点 HADR。从而保证了服务高可靠性、高性能、动态伸缩、一键备份和一键回滚等功能。
+
+青云 AppCenter 以其提供的资源秒级计算特点,企业使用 AppCenter 中的春松客服应用,可以按需付费,灵活升配和降配,Chatopera 也非常推荐客户使用青云服务。
+
+
+ 春松客服 on QingCloud
+
+
+
+
+
+更为详细的部署文档见[春松客服上架青云 AppCenter](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%E4%B8%8A%E6%9E%B6%E9%9D%92%E4%BA%91AppCenter)。
+
+- 社区版
+
+参考部署[开源社区版本文档](https://github.com/chatopera/cosin/wiki/%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%83%A8%E7%BD%B2)。
+
+## 鸣谢
+
+[优客服](https://gitee.com/beimigame/ukefu)
+
+[FreeSWITCH 中国社区](http://www.freeswitch.org.cn/)
+
+## 开源许可协议
+
+Copyright (2018) 北京华夏春松科技有限公司
+
+[Apache License Version 2.0](https://github.com/chatopera/cosin/blob/master/LICENSE)
+
+[![chatoper banner][co-banner-image]][co-url]
+
+[co-banner-image]: https://user-images.githubusercontent.com/3538629/42383104-da925942-8168-11e8-8195-868d5fcec170.png
+[co-url]: https://www.chatopera.com
diff --git a/cc-chatbot/.gitignore b/cc-chatbot/.gitignore
deleted file mode 100644
index f5d7ffde..00000000
--- a/cc-chatbot/.gitignore
+++ /dev/null
@@ -1,18 +0,0 @@
-*.swp
-*.swo
-*.sublime-*
-*.pyc
-jmeter.log
-__pycache__
-tmp/
-node_modules/
-sftp-config.json
-.DS_Store
-*.iml
-*.ipr
-*.iws
-*.idea
-~$*.xls*
-~$*.ppt*
-~$*.doc*
-app/target/
diff --git a/cc-chatbot/README.md b/cc-chatbot/README.md
deleted file mode 100644
index d0185eda..00000000
--- a/cc-chatbot/README.md
+++ /dev/null
@@ -1,73 +0,0 @@
-# cc-chatbot
-Chatopera智能问答引擎的Java SDK.
-https://docs.chatopera.com/
-
-支持
-
-* 创建聊天机器人
-* 查询聊天机器人列表
-* 更新聊天机器人画像
-* 查询聊天机器人使用情况
-* 管理和检索多轮对话
-* 管理和检索知识库
-* 检索意图识别
-
-
-# 配置
-
-使用maven,需要配置Chatopera的Nexus OSS仓库,具体见[文档](https://github.com/chatopera/cosin/wiki/%E6%98%A5%E6%9D%BE%E5%AE%A2%E6%9C%8D%EF%BC%9A%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83#%E4%BF%AE%E6%94%B9maven2%E9%85%8D%E7%BD%AE)。
-
-```
-
- com.chatopera.chatbot
- sdk
- 1.0-SNAPSHOT
-
-```
-
-# API
-
-## Chatbot v1
-
-聊天机器人类,构造参数(tcp协议,hostname, 端口, 版本)
-
-### Chatbot#getChatbots
-获取聊天机器人列表,支持检索查询,分页
-
-### Chatbot#getChatbot
-通过聊天机器人ID获得聊天机器人详情
-
-### Chatbot#conversation
-与指定的聊天机器人进行多轮对话
-
-### Chatbot#faq
-与指定的聊天机器人进行知识库问答
-
-
-# 测试
-
-```
-mvn test
-```
-
-# 示例
-
-```
-Chatbot cb = new Chatbot("http", "lhc-dev", 8003, "v1");
-JSONObject resp = cb.conversation("co_bot_1", "sdktest", "华夏春松在哪里", false);
-```
-
-返回值参考 [智能问答引擎文档](https://docs.chatopera.com/chatbot-engine.html)。
-
-
-## 开源许可协议
-
-Copyright (2018) 北京华夏春松科技有限公司
-
-[Apache License Version 2.0](https://github.com/chatopera/cosin/blob/master/LICENSE)
-
-[![chatoper banner][co-banner-image]][co-url]
-
-[co-banner-image]: https://user-images.githubusercontent.com/3538629/42383104-da925942-8168-11e8-8195-868d5fcec170.png
-[co-url]: https://www.chatopera.com
-
diff --git a/cc-chatbot/admin/deploy.sh b/cc-chatbot/admin/deploy.sh
deleted file mode 100755
index e4ddd7a7..00000000
--- a/cc-chatbot/admin/deploy.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /bin/bash
-###########################################
-#
-###########################################
-
-# constants
-baseDir=$(cd `dirname "$0"`;pwd)
-# functions
-
-# main
-[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
-cd $baseDir/../app
-mvn clean deploy -Dmaven.test.skip=true
diff --git a/cc-chatbot/admin/gen-idea.sh b/cc-chatbot/admin/gen-idea.sh
deleted file mode 100755
index 865f884c..00000000
--- a/cc-chatbot/admin/gen-idea.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /bin/bash
-###########################################
-#
-###########################################
-
-# constants
-baseDir=$(cd `dirname "$0"`;pwd)
-# functions
-
-# main
-[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
-cd $baseDir/../app
-mvn idea:idea
diff --git a/cc-chatbot/admin/package.sh b/cc-chatbot/admin/package.sh
deleted file mode 100755
index fcd86068..00000000
--- a/cc-chatbot/admin/package.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /bin/bash
-###########################################
-#
-###########################################
-
-# constants
-baseDir=$(cd `dirname "$0"`;pwd)
-# functions
-
-# main
-[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
-cd $baseDir/../app
-mvn package
diff --git a/cc-chatbot/admin/test.sh b/cc-chatbot/admin/test.sh
deleted file mode 100755
index d122e6a0..00000000
--- a/cc-chatbot/admin/test.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /bin/bash
-###########################################
-#
-###########################################
-
-# constants
-baseDir=$(cd `dirname "$0"`;pwd)
-# functions
-
-# main
-[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
-cd $baseDir/../app
-mvn test
diff --git a/cc-chatbot/app/.classpath b/cc-chatbot/app/.classpath
deleted file mode 100644
index f0257c5a..00000000
--- a/cc-chatbot/app/.classpath
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cc-chatbot/app/.project b/cc-chatbot/app/.project
deleted file mode 100644
index 5c1f81b8..00000000
--- a/cc-chatbot/app/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- sdk
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.m2e.core.maven2Nature
-
-
diff --git a/cc-chatbot/app/.settings/org.eclipse.core.resources.prefs b/cc-chatbot/app/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index f9fe3459..00000000
--- a/cc-chatbot/app/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-encoding//src/main/java=UTF-8
-encoding//src/test/java=UTF-8
-encoding/=UTF-8
diff --git a/cc-chatbot/app/.settings/org.eclipse.jdt.apt.core.prefs b/cc-chatbot/app/.settings/org.eclipse.jdt.apt.core.prefs
deleted file mode 100644
index d4313d4b..00000000
--- a/cc-chatbot/app/.settings/org.eclipse.jdt.apt.core.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.apt.aptEnabled=false
diff --git a/cc-chatbot/app/.settings/org.eclipse.jdt.core.prefs b/cc-chatbot/app/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 5592a0a1..00000000
--- a/cc-chatbot/app/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.processAnnotations=disabled
-org.eclipse.jdt.core.compiler.release=disabled
-org.eclipse.jdt.core.compiler.source=1.8
diff --git a/cc-chatbot/app/.settings/org.eclipse.m2e.core.prefs b/cc-chatbot/app/.settings/org.eclipse.m2e.core.prefs
deleted file mode 100644
index f897a7f1..00000000
--- a/cc-chatbot/app/.settings/org.eclipse.m2e.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
diff --git a/cc-chatbot/app/pom.xml b/cc-chatbot/app/pom.xml
deleted file mode 100644
index 09879747..00000000
--- a/cc-chatbot/app/pom.xml
+++ /dev/null
@@ -1,141 +0,0 @@
-
-
-
- 4.0.0
-
- com.chatopera.chatbot
- sdk
- 1.1.0
- jar
-
- sdk
- Java SDK for Chatopera Conversational Engine.
- https://www.chatopera.com
-
-
- UTF-8
- 1.8
- 1.8
-
-
-
-
- org.apache.commons
- commons-lang3
- 3.0
-
-
- org.apache.httpcomponents
- httpclient
- 4.3.6
-
-
- org.apache.httpcomponents
- httpasyncclient
- 4.0.2
-
-
- org.apache.httpcomponents
- httpmime
- 4.3.6
-
-
- org.json
- json
- 20140107
-
-
- com.mashape.unirest
- unirest-java
- 1.4.9
-
-
- junit
- junit
- 3.8.1
-
-
- junit
- junit
- 4.12
- test
-
-
-
-
-
-
-
- maven-clean-plugin
- 3.0.0
-
-
- maven-site-plugin
- 3.7
-
-
- maven-project-info-reports-plugin
- 2.9
-
-
-
- maven-resources-plugin
- 3.0.2
-
-
- maven-compiler-plugin
- 3.7.0
-
-
- maven-surefire-plugin
- 2.20.1
-
-
- maven-jar-plugin
- 3.0.2
-
-
- maven-install-plugin
- 2.5.2
-
-
- maven-deploy-plugin
- 2.8.2
-
-
-
-
-
-
- chatopera
- http://192.168.2.217:8029/repository/maven-snapshots/
-
-
- chatopera
- http://192.168.2.217:8029/repository/maven-releases/
-
-
-
-
- hain
- Hai Liang Wang
- hailiang.hl.wang@gmail.com
- https://github.com/Samurais
- Chatopera Inc.
- http://www.chatopera.com
-
- architect
- developer
-
- Asia/Shanghai
-
-
-
-
-
- maven-project-info-reports-plugin
-
-
-
-
diff --git a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java
deleted file mode 100644
index 1a65bea7..00000000
--- a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.chatbot;
-
-import com.mashape.unirest.http.exceptions.UnirestException;
-import org.apache.commons.lang3.StringUtils;
-import org.json.JSONObject;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-
-public class ChatbotAPI {
- private String schema;
- private String hostname;
- private int port;
- private String baseUrl;
-
- private ChatbotAPI() {
- }
-
-
- public ChatbotAPI(final String baseUrl) throws ChatbotAPIRuntimeException, MalformedURLException {
- if (StringUtils.isBlank(baseUrl))
- throw new ChatbotAPIRuntimeException("智能问答引擎URL不能为空。");
-
- URL url = new URL(baseUrl);
- this.schema = url.getProtocol();
- this.hostname = url.getHost();
- this.port = url.getPort();
-
- if (port == -1) {
- this.baseUrl = this.schema + "://" + this.hostname + "/api/v1";
- } else {
- this.baseUrl = this.schema + "://" + this.hostname + ":" + this.port + "/api/v1";
- }
-
- }
-
- public ChatbotAPI(final String schema, final String hostname, final int port, final String version) {
- this.schema = schema;
- this.hostname = hostname;
- this.port = port;
- this.baseUrl = schema + "://" + hostname + ":" + Integer.toString(this.port) + "/api/" + version;
- }
-
- public ChatbotAPI(final String schema, final String hostname, final int port) {
- this(schema, hostname, port, "v1");
- }
-
- public ChatbotAPI(final String hostname, final int port) {
- this("http", hostname, port);
- }
-
- public String getSchema() {
- return schema;
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public int getPort() {
- return port;
- }
-
- public String getBaseUrl() {
- return baseUrl;
- }
-
- /**
- * 获取聊天机器人列表
- *
- * @return
- * @throws ChatbotAPIRuntimeException
- */
- public JSONObject getChatbots(final String fields, final String q, final int page, final int limit) throws ChatbotAPIRuntimeException {
- try {
- HashMap queryString = new HashMap();
- if (StringUtils.isNotBlank(fields)) {
- queryString.put("fields", fields);
- }
-
- if (StringUtils.isNotBlank(q)) {
- queryString.put("q", q);
- }
-
- queryString.put("page", page);
-
- if (limit > 0) {
- queryString.put("limit", limit);
- }
-
- return RestAPI.get(this.getBaseUrl() + "/chatbot", queryString);
- } catch (UnirestException e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
- }
-
- /**
- * 通过ChatbotID检查一个聊天机器人是否存在
- *
- * @param chatbotID
- * @return
- */
- public boolean exists(final String chatbotID) throws ChatbotAPIRuntimeException {
- try {
- JSONObject result = this.getChatbot(chatbotID);
- int rc = result.getInt("rc");
- if (rc == 0) {
- return true;
- } else if (rc == 3) {
- return false;
- } else {
- throw new ChatbotAPIRuntimeException("查询聊天机器人异常返回。");
- }
- } catch (Exception e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
- }
-
-
- /**
- * 创建聊天机器人
- *
- * @param chatbotID 聊天机器人标识,由[a-zA-Z0-9-]组成,字母开头
- * @param name 拟人化的名字
- * @param primaryLanguage 首选语言,支持 [zh_CN|en_US]
- * @param fallback 兜底回复
- * @param description 描述
- * @param welcome 欢迎语
- * @return
- */
- public JSONObject createBot(final String chatbotID,
- final String name,
- final String primaryLanguage,
- final String fallback,
- final String description,
- final String welcome) throws ChatbotAPIRuntimeException {
- HashMap body = new HashMap();
- body.put("chatbotID", chatbotID);
- body.put("name", name);
- body.put("primaryLanguage", primaryLanguage);
- body.put("description", description);
- body.put("fallback", fallback);
- body.put("welcome", welcome);
-
- try {
- return RestAPI.post(this.getBaseUrl() + "/chatbot/" + chatbotID, body);
- } catch (UnirestException e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
- }
-
- /**
- * 更新聊天机器人
- *
- * @param chatbotID
- * @param description
- * @param fallback
- * @param welcome
- * @return
- * @throws ChatbotAPIRuntimeException
- */
- public boolean updateByChatbotID(final String chatbotID,
- final String name,
- final String description,
- final String fallback,
- final String welcome) throws ChatbotAPIRuntimeException {
- if (StringUtils.isBlank(chatbotID))
- throw new ChatbotAPIRuntimeException("不合法的参数,【chatbotID】不能为空。");
-
- HashMap body = new HashMap();
- if (StringUtils.isNotBlank(description))
- body.put("description", description);
- if (StringUtils.isNotBlank(fallback))
- body.put("fallback", fallback);
- if (StringUtils.isNotBlank(welcome))
- body.put("welcome", welcome);
- if (StringUtils.isNotBlank(name))
- body.put("name", name);
-
- try {
- JSONObject result = RestAPI.put(this.baseUrl + "/chatbot/" + chatbotID, body, null);
- if (result.getInt("rc") == 0) {
- return true;
- } else {
- return false;
- }
- } catch (UnirestException e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
-
- }
-
-
- /**
- * 删除聊天机器人
- *
- * @param chatbotID
- * @return
- * @throws ChatbotAPIRuntimeException
- */
- public boolean deleteByChatbotID(final String chatbotID) throws ChatbotAPIRuntimeException {
- if (StringUtils.isBlank(chatbotID))
- throw new ChatbotAPIRuntimeException("聊天机器人ID不能为空。");
- try {
- JSONObject result = RestAPI.delete(this.getBaseUrl() + "/chatbot/" + chatbotID, null);
- if (result.getInt("rc") == 0)
- return true;
- return false;
- } catch (UnirestException e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
- }
-
- /**
- * 获取聊天机器人详情
- *
- * @param chatbotID
- * @return
- * @throws ChatbotAPIRuntimeException
- */
- public JSONObject getChatbot(final String chatbotID) throws ChatbotAPIRuntimeException {
- try {
- return RestAPI.get(this.getBaseUrl() + "/chatbot/" + chatbotID);
- } catch (UnirestException e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
- }
-
- /**
- * validate params
- *
- * @param chatbotID
- * @param fromUserId
- * @param textMessage
- */
- private void v(final String chatbotID, final String fromUserId, final String textMessage) throws ChatbotAPIRuntimeException {
- if (StringUtils.isBlank(chatbotID))
- throw new ChatbotAPIRuntimeException("[conversation] 不合法的聊天机器人标识。");
-
- if (StringUtils.isBlank(fromUserId))
- throw new ChatbotAPIRuntimeException("[conversation] 不合法的用户标识。");
-
- if (StringUtils.isBlank(textMessage))
- throw new ChatbotAPIRuntimeException("[conversation] 不合法的消息内容。");
- }
-
- /**
- * 与聊天机器人进行多轮对话
- *
- * @param fromUserId
- * @param textMessage
- * @param debug
- * @return
- */
- public JSONObject conversation(final String chatbotID, final String fromUserId, final String textMessage, boolean debug) throws ChatbotAPIRuntimeException {
- v(chatbotID, fromUserId, textMessage);
- HashMap body = new HashMap();
- body.put("fromUserId", fromUserId);
- body.put("textMessage", textMessage);
- body.put("isDebug", debug);
-
- try {
- JSONObject resp = RestAPI.post(this.getBaseUrl() + "/chatbot/" + chatbotID + "/conversation/query", body);
- return resp;
- } catch (UnirestException e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
- }
-
- /**
- * 意图识别
- * @param chatbotID
- * @param clientId
- * @param textMessage
- * @return
- * @throws UnirestException
- */
- public JSONObject intent(final String chatbotID, final String clientId, final String textMessage) throws ChatbotAPIRuntimeException {
- if(StringUtils.isBlank(chatbotID) || StringUtils.isBlank(clientId) || StringUtils.isBlank(textMessage))
- throw new ChatbotAPIRuntimeException("参数不合法,不能为空。");
-
- HashMap body = new HashMap();
- body.put("clientId", clientId);
- body.put("query", textMessage);
- try {
- JSONObject result = RestAPI.post(this.baseUrl + "/chatbot/" + chatbotID, body);
- return result;
- } catch (UnirestException e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
- }
-
- /**
- * 检索知识库
- *
- * @param chatbotID
- * @param fromUserId
- * @param textMessage
- * @param isDebug
- * @return
- */
- public JSONObject faq(final String chatbotID, final String fromUserId, final String textMessage, final boolean isDebug) throws ChatbotAPIRuntimeException {
- v(chatbotID, fromUserId, textMessage);
- HashMap body = new HashMap();
- body.put("fromUserId", fromUserId);
- body.put("query", textMessage);
- body.put("isDebug", isDebug);
- try {
- JSONObject resp = RestAPI.post(this.getBaseUrl() + "/chatbot/" + chatbotID + "/faq/query", body);
- return resp;
- } catch (UnirestException e) {
- throw new ChatbotAPIRuntimeException(e.toString());
- }
- }
-
-}
diff --git a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPIRuntimeException.java b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPIRuntimeException.java
deleted file mode 100644
index 7a7c73b9..00000000
--- a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPIRuntimeException.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.chatbot;
-
-import com.mashape.unirest.http.exceptions.UnirestException;
-
-public class ChatbotAPIRuntimeException extends Exception{
- public ChatbotAPIRuntimeException(String msg) {
- super(msg);
- }
-}
diff --git a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java
deleted file mode 100644
index ee5f7e57..00000000
--- a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.chatbot;
-
-import com.mashape.unirest.http.HttpResponse;
-import com.mashape.unirest.http.JsonNode;
-import com.mashape.unirest.http.Unirest;
-import com.mashape.unirest.http.exceptions.UnirestException;
-import com.mashape.unirest.request.GetRequest;
-import com.mashape.unirest.request.HttpRequestWithBody;
-import org.json.JSONObject;
-
-import java.util.HashMap;
-
-/**
- * RestAPI接口
- */
-public class RestAPI {
-
- /**
- * patch headers
- *
- * @param headers
- */
- private static void x(HashMap headers) {
- if (headers == null) {
- headers = new HashMap();
- headers.put("accept", "application/json");
- return;
- }
-
- if (!headers.containsKey("Content-Type"))
- headers.put("Content-Type", "application/json");
-
-
- if (!headers.containsKey("accept"))
- headers.put("accept", "application/json");
- }
-
-
- /**
- * Post
- *
- * @param url
- * @param body
- * @param query
- * @param headers
- * @return
- * @throws UnirestException
- */
- public static JSONObject post(final String url, final HashMap body, final HashMap query, HashMap headers) throws UnirestException {
- HttpRequestWithBody request = Unirest.post(url);
- x(headers);
- HttpResponse resp = request
- .headers(headers)
- .queryString(query)
- .fields(body)
- .asJson();
-
- // parse response
- JSONObject obj = resp.getBody().getObject();
- return obj;
- }
-
- public static JSONObject post(final String url, final HashMap body) throws UnirestException {
- return post(url, body, null, null);
- }
-
- /**
- * Get
- *
- * @param url
- * @param queryString
- * @param headers
- * @return
- * @throws UnirestException
- */
- public static JSONObject get(final String url, final HashMap queryString, HashMap headers) throws UnirestException {
- GetRequest request = Unirest.get(url);
- x(headers);
- HttpResponse resp = request
- .headers(headers)
- .queryString(queryString)
- .asJson();
- // parse response
- JSONObject obj = resp.getBody().getObject();
- return obj;
- }
-
- public static JSONObject get(final String url) throws UnirestException {
- return get(url, null, null);
- }
-
- public static JSONObject get(final String url, HashMap queryString) throws UnirestException {
- return get(url, queryString, null);
- }
-
- public static JSONObject delete(final String url, HashMap headers) throws UnirestException {
- x(headers);
- return Unirest.delete(url).headers(headers).asJson().getBody().getObject();
- }
-
- public static JSONObject put(final String url, HashMap body, HashMap headers) throws UnirestException {
- x(headers);
- return Unirest.put(url).headers(headers).fields(body).asJson().getBody().getObject();
- }
-}
diff --git a/cc-chatbot/app/src/site/site.xml b/cc-chatbot/app/src/site/site.xml
deleted file mode 100644
index 1be54a63..00000000
--- a/cc-chatbot/app/src/site/site.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
- sdk
- https://maven.apache.org/images/apache-maven-project.png
- https://www.apache.org/
-
-
-
- https://maven.apache.org/images/maven-logo-black-on-white.png
- https://maven.apache.org/
-
-
-
- org.apache.maven.skins
- maven-fluido-skin
- 1.7
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java b/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java
deleted file mode 100644
index 303ed688..00000000
--- a/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.chatbot;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.json.JSONObject;
-
-import java.net.MalformedURLException;
-
-/**
- * Unit test for simple App.
- */
-public class ChatbotAPITest
- extends TestCase {
- private ChatbotAPI cb;
-
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public ChatbotAPITest(String testName) {
- super(testName);
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite() {
- return new TestSuite(ChatbotAPITest.class);
- }
-
- public void setUp() {
- this.cb = new ChatbotAPI("http", "lhc-dev", 8003, "v1");
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testChatbot() {
- assertEquals(this.cb.getPort(), 8003);
- }
-
- public void testGetChatbot() {
- try {
- JSONObject resp = this.cb.getChatbot("co_bot_1");
- System.out.println("[testGetChatbot] " + resp.toString());
- } catch (ChatbotAPIRuntimeException e) {
- e.printStackTrace();
- }
- }
-
- public void testGetChatbots() {
- try {
- JSONObject resp = this.cb.getChatbots("name chatbotID", null, 0, 10);
- System.out.println("[testGetChatbots] resp " + resp.toString());
- } catch (ChatbotAPIRuntimeException e) {
- e.printStackTrace();
- }
- }
-
- public void testConversation() {
- try {
- JSONObject resp = this.cb.conversation("co_bot_1", "sdktest", "华夏春松在哪里", false);
- System.out.println("[testConversation] resp " + resp.toString());
- } catch (ChatbotAPIRuntimeException e) {
- e.printStackTrace();
- }
- }
-
- public void testFaq() {
- try {
- JSONObject resp = this.cb.faq("co_bot_1", "sdktest", "华夏春松在哪里", false);
- System.out.print("[testFaq] resp " + resp.toString());
- } catch (ChatbotAPIRuntimeException e) {
- e.printStackTrace();
- }
- }
-
- public void testParseUrl() {
- try {
- ChatbotAPI c = new ChatbotAPI("https://local:8000/");
- System.out.println("chatbot baseUrl " + c.getBaseUrl());
- assertEquals("https://local:8000/api/v1", c.getBaseUrl());
- } catch (ChatbotAPIRuntimeException e) {
- e.printStackTrace();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
-
- public void testExists() {
- JSONObject profile = null;
- try {
- assertTrue(this.cb.exists("co_bot_1"));
- } catch (ChatbotAPIRuntimeException e) {
- e.printStackTrace();
- }
- }
-
- public void testCreateBot() {
- try {
- JSONObject j = this.cb.createBot("cc_bot_2",
- "小云2",
- "zh_CN",
- "我不了解。",
- "小云机器人",
- "你好,我是小云。");
- } catch (ChatbotAPIRuntimeException e) {
- e.printStackTrace();
- }
- }
-
-
-}
-
-
diff --git a/contact-center/admin/package.sh b/contact-center/admin/package.sh
index 68d5183e..288dafad 100755
--- a/contact-center/admin/package.sh
+++ b/contact-center/admin/package.sh
@@ -7,7 +7,7 @@
baseDir=$(cd `dirname "$0"`;pwd)
# functions
-# main
+# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir/../app
mvn clean package
diff --git a/contact-center/app/.gitignore b/contact-center/app/.gitignore
index 41459fda..0fe12476 100644
--- a/contact-center/app/.gitignore
+++ b/contact-center/app/.gitignore
@@ -2,6 +2,7 @@
src/main/java/com/chatopera/cc/plugins/
# ignore views within plugins
-!src/main/resources/templates/admin/channel/callout/
!src/main/resources/templates/admin/channel/im/
src/main/resources/templates/admin/channel/*
+src/main/resources/templates/apps/callout
+src/main/resources/templates/apps/chatbot
diff --git a/contact-center/app/pom.xml b/contact-center/app/pom.xml
index 889b08d5..006b67aa 100644
--- a/contact-center/app/pom.xml
+++ b/contact-center/app/pom.xml
@@ -6,7 +6,7 @@
5.0.0
war
cskefu
- 春松客服企业版:多媒体呼叫中心,下一代呼叫中心
+ 春松客服:多渠道智能客服系统
org.springframework.boot
spring-boot-starter-parent
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/Application.java b/contact-center/app/src/main/java/com/chatopera/cc/Application.java
index 9c7c6d1e..ee1b152b 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/Application.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/Application.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,52 +65,34 @@ public class Application {
/**
* 记载模块
*/
- // 外呼模块
- private final static boolean isCalloutModule = SystemEnvHelper.parseModuleFlag("cskefu.module.callout");
-
- // CRM模块
- private final static boolean isContactsModule = SystemEnvHelper.parseModuleFlag("cskefu.module.contacts");
-
- // 聊天机器人模块
- private final static boolean isChatbotModule = SystemEnvHelper.parseModuleFlag("cskefu.module.chatbot");
-
- // 访客聊天监控模块
- private final static boolean isCcaModule = SystemEnvHelper.parseModuleFlag("cskefu.module.cca");
-
- // 企业聊天模块
- private final static boolean isEntImModule = SystemEnvHelper.parseModuleFlag("cskefu.module.entim");
-
- // 渠道:Skype渠道
- private final static boolean isSkypeModule = SystemEnvHelper.isClassExistByFullName(
- PluginRegistry.PLUGIN_ENTRY_SKYPE);
-
static {
- // 外呼模块
- if (isCalloutModule) {
- MainContext.enableModule(Constants.CSKEFU_MODULE_CALLOUT);
- }
// CRM模块
- if (isContactsModule) {
- MainContext.enableModule(Constants.CSKEFU_MODULE_CONTACTS);
- }
- // 聊天机器人模块
- if (isChatbotModule) {
- MainContext.enableModule(Constants.CSKEFU_MODULE_CHATBOT);
+ MainContext.enableModule(Constants.CSKEFU_MODULE_CONTACTS);
+
+ // 会话监控模块 Customer Chats Audit
+ MainContext.enableModule(Constants.CSKEFU_MODULE_CCA);
+
+ // 企业聊天模块
+ MainContext.enableModule(Constants.CSKEFU_MODULE_ENTIM);
+
+ /**
+ * 插件组
+ */
+ // 外呼模块
+ if (SystemEnvHelper.isClassExistByFullName(
+ PluginRegistry.PLUGIN_ENTRY_CALLOUT)) {
+ MainContext.enableModule(Constants.CSKEFU_MODULE_CALLOUT);
}
// skype模块
- if (isSkypeModule) {
+ if (SystemEnvHelper.isClassExistByFullName(
+ PluginRegistry.PLUGIN_ENTRY_SKYPE)) {
MainContext.enableModule(Constants.CSKEFU_MODULE_SKYPE);
}
- // 会话监控模块 Customer Chats Audit
- if (isCcaModule) {
- MainContext.enableModule(Constants.CSKEFU_MODULE_CCA);
-
- }
- // 企业聊天模块
- if (isEntImModule) {
- MainContext.enableModule(Constants.CSKEFU_MODULE_ENTIM);
+ // 聊天机器人模块
+ if (SystemEnvHelper.isClassExistByFullName(PluginRegistry.PLUGIN_ENTRY_CHATBOT)) {
+ MainContext.enableModule(Constants.CSKEFU_MODULE_CHATBOT);
}
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/ServletInitializer.java b/contact-center/app/src/main/java/com/chatopera/cc/ServletInitializer.java
index f11e80c0..4394300e 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/ServletInitializer.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/ServletInitializer.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/acd/AutomaticServiceDist.java b/contact-center/app/src/main/java/com/chatopera/cc/acd/AutomaticServiceDist.java
index f166566c..439d2150 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/acd/AutomaticServiceDist.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/acd/AutomaticServiceDist.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/activemq/ChatbotEventSubscription.java b/contact-center/app/src/main/java/com/chatopera/cc/activemq/ChatbotEventSubscription.java
deleted file mode 100644
index 3f798db2..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/activemq/ChatbotEventSubscription.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2019 Chatopera Inc, All rights reserved.
- *
- * This software and related documentation are provided under a license agreement containing
- * restrictions on use and disclosure and are protected by intellectual property laws.
- * Except as expressly permitted in your license agreement or allowed by law, you may not use,
- * copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform,
- * publish, or display any part, in any form, or by any means. Reverse engineering, disassembly,
- * or decompilation of this software, unless required by law for interoperability, is prohibited.
- */
-
-package com.chatopera.cc.activemq;
-
-import com.chatopera.bot.exception.ChatbotException;
-import com.chatopera.cc.basic.MainContext;
-import com.chatopera.cc.cache.Cache;
-import com.chatopera.cc.handler.api.request.RestUtils;
-import com.chatopera.cc.socketio.message.ChatMessage;
-import com.chatopera.cc.proxy.ChatbotProxy;
-import com.chatopera.cc.model.AgentUser;
-import com.chatopera.cc.model.Chatbot;
-import com.chatopera.cc.persistence.repository.AgentUserRepository;
-import com.chatopera.cc.persistence.repository.ChatbotRepository;
-import com.chatopera.cc.basic.Constants;
-import com.chatopera.cc.util.SerializeUtil;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.jms.annotation.JmsListener;
-import org.springframework.stereotype.Component;
-
-import java.net.MalformedURLException;
-
-/**
- * 发送消息给聊天机器人并处理返回结果
- */
-@Component
-public class ChatbotEventSubscription {
- private final static Logger logger = LoggerFactory.getLogger(ChatbotEventSubscription.class);
-
- @Autowired
- private Cache cache;
-
- @Autowired
- private AgentUserRepository agentUserRes;
-
- @Autowired
- private ChatbotRepository chatbotRes;
-
- @Value("${bot.baseurl}")
- private static String botBaseUrl;
-
- @Autowired
- private ChatbotProxy chatbotProxy;
-
- /**
- * 接收发送消息给聊天机器人的请求
- *
- * @param payload
- */
- @JmsListener(destination = Constants.INSTANT_MESSAGING_MQ_QUEUE_CHATBOT, containerFactory = "jmsListenerContainerQueue")
- public void onMessage(final String payload) {
- ChatMessage message = SerializeUtil.deserialize(payload);
- try {
- chat(message);
- } catch (MalformedURLException e) {
- logger.error("[onMessage] error", e);
- } catch (ChatbotException e) {
- logger.error("[onMessage] error", e);
- }
- }
-
-
- private void chat(final ChatMessage request) throws MalformedURLException, ChatbotException, JSONException {
- Chatbot c = chatbotRes
- .findOne(request.getAiid());
-
- logger.info(
- "[chat] chat request baseUrl {}, chatbot {}, fromUserId {}, textMessage {}", botBaseUrl, c.getName(),
- request.getUserid(), request.getMessage());
- // Get response from Conversational Engine.
- com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(
- c.getClientId(), c.getSecret(), botBaseUrl);
- JSONObject result = bot.conversation(request.getUserid(), request.getMessage());
-
- // parse response
- if (result != null) {
- logger.info("[chat] chat response {}", result.toString());
- if (result.getInt(RestUtils.RESP_KEY_RC) == 0) {
- // reply
- JSONObject data = result.getJSONObject("data");
- ChatMessage resp = new ChatMessage();
- resp.setCalltype(MainContext.CallType.OUT.toString());
- resp.setAppid(resp.getAppid());
- resp.setOrgi(request.getOrgi());
- resp.setAiid(request.getAiid());
- resp.setMessage(data.getString("string"));
- resp.setTouser(request.getUserid());
- resp.setAgentserviceid(request.getAgentserviceid());
- resp.setMsgtype(request.getMsgtype());
- resp.setUserid(request.getUserid());
- resp.setType(request.getType());
- resp.setChannel(request.getChannel());
- if (data.has("params")) {
- resp.setExpmsg(data.get("params").toString());
- }
- resp.setContextid(request.getContextid());
- resp.setSessionid(request.getSessionid());
- resp.setUsession(request.getUsession());
- resp.setUsername(c.getName());
- resp.setUpdatetime(System.currentTimeMillis());
-
- // 更新聊天机器人累计值
- updateAgentUserWithRespData(request.getUserid(), request.getOrgi(), data);
- // 保存并发送
- chatbotProxy.saveAndPublish(resp);
- } else {
- logger.warn("[chat] can not get expected response {}", result.toString());
- }
- }
- }
-
- /**
- * 根据聊天机器人返回数据更新agentUser
- *
- * @param userid
- * @param data
- */
- private void updateAgentUserWithRespData(final String userid, final String orgi, final JSONObject data) throws JSONException {
- cache.findOneAgentUserByUserIdAndOrgi(userid, orgi).ifPresent(p -> {
- p.setChatbotround(p.getChatbotround() + 1);
- if (data.has("logic_is_unexpected") && data.getBoolean("logic_is_unexpected")) {
- p.setChatbotlogicerror(p.getChatbotlogicerror() + 1);
- }
- agentUserRes.save(p);
- });
-
- }
-
-}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/activemq/PbxEventSubscription.java b/contact-center/app/src/main/java/com/chatopera/cc/activemq/PbxEventSubscription.java
deleted file mode 100644
index 37fe4e1c..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/activemq/PbxEventSubscription.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2019 Chatopera Inc, All rights reserved.
- *
- * This software and related documentation are provided under a license agreement containing
- * restrictions on use and disclosure and are protected by intellectual property laws.
- * Except as expressly permitted in your license agreement or allowed by law, you may not use,
- * copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform,
- * publish, or display any part, in any form, or by any means. Reverse engineering, disassembly,
- * or decompilation of this software, unless required by law for interoperability, is prohibited.
- */
-package com.chatopera.cc.activemq;
-
-import com.chatopera.cc.config.conditions.CalloutBeanCondition;
-import com.chatopera.cc.persistence.interfaces.CalloutWireEvent;
-import com.chatopera.cc.schedule.CalloutWireTask;
-import com.chatopera.cc.basic.Constants;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.jms.annotation.JmsListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-
-/**
- * FreeSWITCH
- */
-@Component
-@Conditional(CalloutBeanCondition.class)
-public class PbxEventSubscription {
-
- private final static Logger logger = LoggerFactory.getLogger(PbxEventSubscription.class);
-
- @PostConstruct
- public void setup() {
- logger.info("ActiveMQ Subscription is setup successfully.");
- }
-
- @Autowired
- private BrokerPublisher brokerPublisher;
-
- @Autowired
- private CalloutWireTask callOutWireTask;
-
- public void publish(final String dest, final String payload) {
- brokerPublisher.send(dest, payload);
- }
-
- @JmsListener(destination = Constants.INSTANT_MESSAGING_MQ_QUEUE_PBX, containerFactory = "jmsListenerContainerQueue")
- public void onMessage(final String payload) {
- logger.info("[onMessage] payload {}", payload);
- JsonParser parser = new JsonParser();
- JsonObject j = parser.parse(payload).getAsJsonObject();
- // validate message
- if (!(j.has("type")
- && j.has("to")
- && j.has("ops")
- && j.has("channel")
- && j.has("createtime"))) {
- logger.error(String.format("[callout wire] 接线数据格式不对, %s", payload));
- } else {
- try {
- CalloutWireEvent event = CalloutWireEvent.parse(j);
- switch (event.getEventType()) {
- case 1: // 自动外呼接通
- logger.info("[callout wire] 自动外呼接通 {}", j.toString());
- callOutWireTask.callOutConnect(event);
- break;
- case 2: // 自动外呼挂断
- logger.info("[callout wire] 自动外呼挂断 {}", j.toString());
- callOutWireTask.callOutDisconnect(event);
- break;
- case 3: // 自动外呼失败
- logger.info("[callout wire] 自动外呼失败 {}", j.toString());
- callOutWireTask.callOutFail(event);
- break;
- case 4: // 手动外呼接通
- logger.info("[callout wire] 手动外呼接通 {}", j.toString());
- callOutWireTask.callOutConnect(event);
- break;
- case 5: // 手动外呼挂断
- logger.info("[callout wire] 手动外呼挂断 {}", j.toString());
- callOutWireTask.callOutDisconnect(event);
- break;
- case 6: // 手动外呼失败
- logger.info("[callout wire] 手动外呼失败 {}", j.toString());
- callOutWireTask.callOutFail(event);
- break;
- case 7: // 呼入接通
- logger.info("[callin wire] 呼入接通 {}", j.toString());
- break;
- case 8: // 呼入挂断
- logger.info("[callin wire] 呼入挂断 {}", j.toString());
- break;
- case 9: // 呼入失败
- logger.info("[callin wire] 呼入失败 {}", j.toString());
- break;
- }
- } catch (Exception e) {
- logger.error("[callout wire] ", e);
- }
- }
- }
-}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/activemq/ConnectionEventSubscription.java b/contact-center/app/src/main/java/com/chatopera/cc/activemq/SocketioConnEventSubscription.java
similarity index 95%
rename from contact-center/app/src/main/java/com/chatopera/cc/activemq/ConnectionEventSubscription.java
rename to contact-center/app/src/main/java/com/chatopera/cc/activemq/SocketioConnEventSubscription.java
index 02757af4..c9ed4de5 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/activemq/ConnectionEventSubscription.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/activemq/SocketioConnEventSubscription.java
@@ -15,7 +15,6 @@ import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.persistence.repository.AgentStatusRepository;
-import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.basic.Constants;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@@ -33,16 +32,13 @@ import java.util.Date;
* 处理SocketIO的离线事件
*/
@Component
-public class ConnectionEventSubscription {
+public class SocketioConnEventSubscription {
- private final static Logger logger = LoggerFactory.getLogger(ConnectionEventSubscription.class);
+ private final static Logger logger = LoggerFactory.getLogger(SocketioConnEventSubscription.class);
@Autowired
private AgentStatusRepository agentStatusRes;
- @Autowired
- private UserRepository userRes;
-
@Autowired
private Cache cache;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/aop/OnlineUserAspect.java b/contact-center/app/src/main/java/com/chatopera/cc/aop/OnlineUserAspect.java
index 3d21deac..76ae44a0 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/aop/OnlineUserAspect.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aop/OnlineUserAspect.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.chatopera.cc.aop;
import com.chatopera.cc.basic.MainContext;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/aop/SyncDatabaseAspect.java b/contact-center/app/src/main/java/com/chatopera/cc/aop/SyncDatabaseAspect.java
index 9c924910..3d8a03dd 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/aop/SyncDatabaseAspect.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aop/SyncDatabaseAspect.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/Constants.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/Constants.java
index 1aaca73b..643af7fe 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/Constants.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/Constants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,7 +86,7 @@ public class Constants {
/**
* Modules
*/
- public final static String CSKEFU_MODULE_CALLOUT = "sales";
+ public final static String CSKEFU_MODULE_CALLOUT = "callout";
public final static String CSKEFU_MODULE_CHATBOT = "chatbot";
public final static String CSKEFU_MODULE_CONTACTS = "contacts";
public final static String CSKEFU_MODULE_SKYPE = "skype";
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/I18N.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/I18N.java
deleted file mode 100644
index 56973970..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/I18N.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.chatopera.cc.basic;
-
-/**
- * 国际化字段
- */
-public class I18N {
-
-}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java
index 175413db..51450a3f 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -786,6 +786,7 @@ public class MainContext {
MESSAGE,
END,
TRANS,
+ TRANSOUT, // 当前会话被转接出去
STATUS,
AGENTSTATUS,
SERVICE,
@@ -1031,26 +1032,6 @@ public class MainContext {
return csKeFuResourceMap.get(resource);
}
- /**
- * 是否开启机器人客服模块
- *
- * @return
- */
- public static boolean isEnableChatbotModule() {
- return modules.contains(Constants.CSKEFU_MODULE_CHATBOT);
- }
-
-
- /**
- * 是否开启外呼模块
- *
- * @return
- */
- public static boolean isEnableCalloutModule() {
- return modules.contains(Constants.CSKEFU_MODULE_CALLOUT);
- }
-
-
/**
* Redis底层接口
*/
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/MainUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/MainUtils.java
index 5621d90b..dcb3e899 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/MainUtils.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/MainUtils.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/Viewport.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/Viewport.java
index dc58e2fb..8db72d4d 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/Viewport.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/Viewport.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/IPluginDescriptor.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/IPluginDescriptor.java
index 4f8c6ab4..274b2202 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/IPluginDescriptor.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/IPluginDescriptor.java
@@ -1,5 +1,21 @@
+/*
+ * Copyright (C) 2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.chatopera.cc.basic.plugins;
public interface IPluginDescriptor {
String getPluginName();
+ String getIOEventHandler();
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/PluginRegistry.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/PluginRegistry.java
index 85e7b6c6..efa6636f 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/PluginRegistry.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/PluginRegistry.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.chatopera.cc.basic.plugins;
/**
@@ -10,5 +25,7 @@ public class PluginRegistry {
*/
public final static String PLUGIN_CHANNEL_MESSAGER_SUFFIX = "ChannelMessager";
public final static String PLUGIN_ENTRY_SKYPE = "com.chatopera.cc.plugins.skype.PluginDescriptor";
+ public final static String PLUGIN_ENTRY_CALLOUT = "com.chatopera.cc.plugins.callout.PluginDescriptor";
+ public final static String PLUGIN_ENTRY_CHATBOT = "com.chatopera.cc.plugins.chatbot.PluginDescriptor";
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/PluginsLoader.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/PluginsLoader.java
index 6fc0a1b9..77089e7a 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/PluginsLoader.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/plugins/PluginsLoader.java
@@ -1,13 +1,72 @@
+/*
+ * Copyright (C) 2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.chatopera.cc.basic.plugins;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
/**
- * 插架装载器
- * TODO Placeholder
+ * 插架装载器
+ * TODO Placeholder
*/
public class PluginsLoader {
private final static Logger logger = LoggerFactory.getLogger(PluginsLoader.class);
+
+ /**
+ * 通过插件entry获得PluginName
+ *
+ * @param pluginEntry
+ * @return
+ */
+ public static String getPluginName(final String pluginEntry) {
+ Class> clazz;
+ try {
+ clazz = Class.forName(pluginEntry);
+ IPluginDescriptor clazzInst = (IPluginDescriptor) clazz.newInstance();
+ Method method = clazz.getMethod("getPluginName");
+ return (String) method.invoke(clazzInst);
+ } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
+ logger.info("[postConstruct] error", e);
+ }
+ return null;
+ }
+
+
+
+ /**
+ * 通过插件entry获得Plugin SocketIO Event Handler
+ *
+ * @param pluginEntry
+ * @return
+ */
+ public static String getIOEventHandler(final String pluginEntry) {
+ Class> clazz;
+ try {
+ clazz = Class.forName(pluginEntry);
+ IPluginDescriptor clazzInst = (IPluginDescriptor) clazz.newInstance();
+ Method method = clazz.getMethod("getIOEventHandler");
+ return (String) method.invoke(clazzInst);
+ } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
+ logger.info("[postConstruct] error", e);
+ }
+ return null;
+ }
+
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/ActivityResource.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/ActivityResource.java
index f6553d88..53cc7ea2 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/ActivityResource.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/ActivityResource.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/BatchResource.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/BatchResource.java
index 24d30087..48a5cbda 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/BatchResource.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/BatchResource.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/OutputTextFormat.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/OutputTextFormat.java
index 4c2b7598..32454910 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/OutputTextFormat.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/OutputTextFormat.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/Resource.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/Resource.java
index cc94ecf1..85047161 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/Resource.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/Resource.java
@@ -1,12 +1,12 @@
-/**
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/*
+ * Copyright (C) 2017 优客服-多渠道客服系统
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
- * http://www.apache.org/licenses/LICENSE-2.0
- * webapps/LICENSE-Rivulet
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/ApiRequestMatchingFilter.java b/contact-center/app/src/main/java/com/chatopera/cc/config/ApiRequestMatchingFilter.java
index 0f2979f9..84703580 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/ApiRequestMatchingFilter.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/ApiRequestMatchingFilter.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/AppCtxRefreshEventListener.java b/contact-center/app/src/main/java/com/chatopera/cc/config/AppCtxRefreshEventListener.java
index bdab12a4..1f026eb7 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/AppCtxRefreshEventListener.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/AppCtxRefreshEventListener.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/ApplicationStartupListener.java b/contact-center/app/src/main/java/com/chatopera/cc/config/ApplicationStartupListener.java
index 3892e345..182873de 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/ApplicationStartupListener.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/ApplicationStartupListener.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/CSKeFuExceptionHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/config/CSKeFuExceptionHandler.java
index fa2695de..8a75aecc 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/CSKeFuExceptionHandler.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/CSKeFuExceptionHandler.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/DelegateRequestMatchingFilter.java b/contact-center/app/src/main/java/com/chatopera/cc/config/DelegateRequestMatchingFilter.java
index 5c3a89d5..c11bb27a 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/DelegateRequestMatchingFilter.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/DelegateRequestMatchingFilter.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/DruidConfiguration.java b/contact-center/app/src/main/java/com/chatopera/cc/config/DruidConfiguration.java
index c0ec35f3..be5a17d5 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/DruidConfiguration.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/DruidConfiguration.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/ExecutorConfig.java b/contact-center/app/src/main/java/com/chatopera/cc/config/ExecutorConfig.java
index 354c57c0..703870fc 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/ExecutorConfig.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/ExecutorConfig.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
*/
package com.chatopera.cc.config;
-import com.chatopera.cc.config.conditions.CalloutBeanCondition;
+import com.chatopera.cc.config.plugins.CalloutPluginPresentCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
@@ -60,7 +60,7 @@ public class ExecutorConfig {
* 外呼线程池
* @return
*/
- @Conditional(CalloutBeanCondition.class)
+ @Conditional(CalloutPluginPresentCondition.class)
@Bean(name = "callOutTaskExecutor")
public ThreadPoolTaskExecutor callout() {
ThreadPoolTaskExecutor poolTaskExecutor = new ThreadPoolTaskExecutor();
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/MessagingServerConfigure.java b/contact-center/app/src/main/java/com/chatopera/cc/config/MessagingServerConfigure.java
index 1d548473..c946d15f 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/MessagingServerConfigure.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/MessagingServerConfigure.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/RedisConfigure.java b/contact-center/app/src/main/java/com/chatopera/cc/config/RedisConfigure.java
index e488007a..ddf9039f 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/RedisConfigure.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/RedisConfigure.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/StringToDateConverter.java b/contact-center/app/src/main/java/com/chatopera/cc/config/StringToDateConverter.java
index f636f1d9..27a557f1 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/StringToDateConverter.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/StringToDateConverter.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/UKWebAppConfigurer.java b/contact-center/app/src/main/java/com/chatopera/cc/config/UKWebAppConfigurer.java
index 47c07c5b..51d8c533 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/UKWebAppConfigurer.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/UKWebAppConfigurer.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/WebConfigBeans.java b/contact-center/app/src/main/java/com/chatopera/cc/config/WebConfigBeans.java
index 9e2e3590..7b6d1e9d 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/WebConfigBeans.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/WebConfigBeans.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/WebSecurityConfig.java b/contact-center/app/src/main/java/com/chatopera/cc/config/WebSecurityConfig.java
index 2bf17289..5045cc61 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/WebSecurityConfig.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/WebSecurityConfig.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerConfiguration.java b/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerConfiguration.java
deleted file mode 100644
index 101651b5..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerConfiguration.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.cc.config;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Properties;
-
-import com.chatopera.cc.basic.MainUtils;
-import org.apache.catalina.connector.Connector;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.coyote.http11.Http11NioProtocol;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
-import org.springframework.boot.context.embedded.Ssl;
-import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
-import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class WebServerConfiguration {
- private Integer maxthread = 2000;
-
- private Integer maxconnections = 2000;
-
- @Value("${web.upload-path}")
- private String path;
-
- @Bean
- public EmbeddedServletContainerFactory createEmbeddedServletContainerFactory() throws IOException, NoSuchAlgorithmException {
- TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory();
- tomcatFactory.addConnectorCustomizers(new UKeFuTomcatConnectorCustomizer(maxthread, maxconnections));
- File sslFile = new File(path, "ssl/https.properties");
- if (sslFile.exists()) {
- Properties sslProperties = new Properties();
- FileInputStream in = new FileInputStream(sslFile);
- sslProperties.load(in);
- in.close();
- if (!StringUtils.isBlank(sslProperties.getProperty("key-store")) && !StringUtils.isBlank(
- sslProperties.getProperty("key-store-password"))) {
- Ssl ssl = new Ssl();
- ssl.setKeyStore(new File(path, "ssl/" + sslProperties.getProperty("key-store")).getAbsolutePath());
- ssl.setKeyStorePassword(MainUtils.decryption(sslProperties.getProperty("key-store-password")));
- tomcatFactory.setSsl(ssl);
- }
- }
- return tomcatFactory;
- }
-
-}
-
-class UKeFuTomcatConnectorCustomizer implements TomcatConnectorCustomizer {
- private Integer maxthread;
- private Integer maxconnection;
-
- UKeFuTomcatConnectorCustomizer(Integer maxthread, Integer maxconnection) {
- this.maxthread = maxthread;
- this.maxconnection = maxconnection;
- }
-
- public void customize(Connector connector) {
- Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
- //设置最大连接数
- protocol.setMaxConnections(maxthread != null ? maxthread : 2000);
- //设置最大线程数
- protocol.setMaxThreads(maxconnection != null ? maxconnection : 2000);
- protocol.setConnectionTimeout(30000);
- }
-}
\ No newline at end of file
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerContainerConfigure.java b/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerContainerConfigure.java
new file mode 100644
index 00000000..6dbc057b
--- /dev/null
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerContainerConfigure.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 优客服-多渠道客服系统
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.chatopera.cc.config;
+
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+
+import org.apache.catalina.connector.Connector;
+import org.apache.coyote.http11.Http11NioProtocol;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
+import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
+import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class WebServerContainerConfigure {
+
+ @Value("${server.threads.max}")
+ private Integer maxthread;
+
+ @Value("${server.connection.max}")
+ private Integer maxconnections;
+
+ @Value("${web.upload-path}")
+ private String path;
+
+ @Bean
+ public EmbeddedServletContainerFactory createEmbeddedServletContainerFactory() throws IOException, NoSuchAlgorithmException {
+ TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory();
+ tomcatFactory.addConnectorCustomizers(new CSKeFuTomcatConnectorCustomizer(maxthread, maxconnections));
+ return tomcatFactory;
+ }
+
+ class CSKeFuTomcatConnectorCustomizer implements TomcatConnectorCustomizer {
+ private Integer maxthread;
+ private Integer maxconnection;
+
+ CSKeFuTomcatConnectorCustomizer(Integer maxthread, Integer maxconnection) {
+ this.maxthread = maxthread;
+ this.maxconnection = maxconnection;
+ }
+
+ public void customize(Connector connector) {
+ Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
+ //设置最大连接数
+ protocol.setMaxConnections(maxthread != null ? maxthread : 2000);
+ //设置最大线程数
+ protocol.setMaxThreads(maxconnection != null ? maxconnection : 2000);
+ protocol.setConnectionTimeout(30000);
+ }
+ }
+}
+
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerSessionConfigure.java b/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerSessionConfigure.java
index 432334a9..b494b359 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerSessionConfigure.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/WebServerSessionConfigure.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.chatopera.cc.config;
import com.chatopera.cc.cache.RedisKey;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/conditions/CalloutBeanCondition.java b/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/CalloutPluginPresentCondition.java
similarity index 83%
rename from contact-center/app/src/main/java/com/chatopera/cc/config/conditions/CalloutBeanCondition.java
rename to contact-center/app/src/main/java/com/chatopera/cc/config/plugins/CalloutPluginPresentCondition.java
index 5ff93e5a..716b94e9 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/conditions/CalloutBeanCondition.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/CalloutPluginPresentCondition.java
@@ -8,8 +8,9 @@
* publish, or display any part, in any form, or by any means. Reverse engineering, disassembly,
* or decompilation of this software, unless required by law for interoperability, is prohibited.
*/
-package com.chatopera.cc.config.conditions;
+package com.chatopera.cc.config.plugins;
+import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
@@ -19,9 +20,9 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
* Init bean based on conditions
* https://javapapers.com/spring/spring-conditional-annotation/
*/
-public class CalloutBeanCondition implements Condition {
+public class CalloutPluginPresentCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
- return MainContext.isEnableCalloutModule();
+ return MainContext.hasModule(Constants.CSKEFU_MODULE_CALLOUT);
}
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/ChatbotPluginPresentCondition.java b/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/ChatbotPluginPresentCondition.java
new file mode 100644
index 00000000..940c1334
--- /dev/null
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/ChatbotPluginPresentCondition.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2019 Chatopera Inc, All rights reserved.
+ *
+ * This software and related documentation are provided under a license agreement containing
+ * restrictions on use and disclosure and are protected by intellectual property laws.
+ * Except as expressly permitted in your license agreement or allowed by law, you may not use,
+ * copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform,
+ * publish, or display any part, in any form, or by any means. Reverse engineering, disassembly,
+ * or decompilation of this software, unless required by law for interoperability, is prohibited.
+ */
+package com.chatopera.cc.config.plugins;
+
+import com.chatopera.cc.basic.Constants;
+import com.chatopera.cc.basic.MainContext;
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Init bean based on conditions
+ * https://javapapers.com/spring/spring-conditional-annotation/
+ */
+public class ChatbotPluginPresentCondition implements Condition {
+ @Override
+ public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
+ return MainContext.hasModule(Constants.CSKEFU_MODULE_CHATBOT);
+ }
+}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/SkypePluginPresentCondition.java b/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/SkypePluginPresentCondition.java
index 924aa065..31f938ed 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/SkypePluginPresentCondition.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/config/plugins/SkypePluginPresentCondition.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.chatopera.cc.config.plugins;
import com.chatopera.cc.basic.Constants;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuCacheException.java b/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuCacheException.java
index 0a7c9c91..0249844c 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuCacheException.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuCacheException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuException.java b/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuException.java
index 64bbb6f9..9d9bf735 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuException.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuRestException.java b/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuRestException.java
index 7590efe1..a2125616 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuRestException.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/exception/CSKefuRestException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/exception/CalloutRecordException.java b/contact-center/app/src/main/java/com/chatopera/cc/exception/CalloutRecordException.java
deleted file mode 100644
index f1ac7a93..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/exception/CalloutRecordException.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.cc.exception;
-
-public class CalloutRecordException extends Exception {
-
- public CalloutRecordException(String msg){
- super(msg);
- }
-}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/exception/CalloutRuntimeException.java b/contact-center/app/src/main/java/com/chatopera/cc/exception/CalloutRuntimeException.java
deleted file mode 100644
index a9fefb7a..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/exception/CalloutRuntimeException.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.cc.exception;
-
-public class CalloutRuntimeException extends Exception {
-
- public CalloutRuntimeException(String msg){
- super(msg);
- }
-}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/exception/FreeSwitchException.java b/contact-center/app/src/main/java/com/chatopera/cc/exception/FreeSwitchException.java
index 837d5909..f10f9314 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/exception/FreeSwitchException.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/exception/FreeSwitchException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/exception/InstantMessagingExceptionListener.java b/contact-center/app/src/main/java/com/chatopera/cc/exception/InstantMessagingExceptionListener.java
index 0fca911c..3af48eb3 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/exception/InstantMessagingExceptionListener.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/exception/InstantMessagingExceptionListener.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/ApplicationController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/ApplicationController.java
index 3030e80b..ee80b6ea 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/ApplicationController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/ApplicationController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/Handler.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/Handler.java
index 2251cf58..6c3604eb 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/Handler.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/Handler.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.basic.Viewport;
import com.chatopera.cc.cache.Cache;
-import com.chatopera.cc.handler.api.rest.QueryParams;
+import com.chatopera.cc.handler.api.QueryParams;
import com.chatopera.cc.model.StreamingFile;
import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.Tenant;
@@ -102,7 +102,7 @@ public class Handler {
user.setSessionid(user.getId());
}
} else {
- user.setSessionid(user.getId());
+ user.setSessionid(MainUtils.getContextID(request.getSession().getId()));
}
return user;
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/LoginController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/LoginController.java
index 071438ec..cd9745a5 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/LoginController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/LoginController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package com.chatopera.cc.handler;
import com.chatopera.cc.acd.AutomaticServiceDist;
import com.chatopera.cc.basic.Constants;
-import com.chatopera.cc.basic.I18N;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
@@ -177,51 +176,54 @@ public class LoginController extends Handler {
user.getUsername(), MainUtils.md5(user.getPassword()), false);
if (loginUser != null && StringUtils.isNotBlank(loginUser.getId())) {
view = this.processLogin(request, loginUser, referer);
- if (StringUtils.isNotBlank(sla) && sla.equals("1")) {
+
+ // 自动登录
+ if (StringUtils.equals("1", sla)) {
Cookie flagid = new Cookie(
Constants.CSKEFU_SYSTEM_COOKIES_FLAG, MainUtils.encryption(loginUser.getId()));
flagid.setMaxAge(7 * 24 * 60 * 60);
response.addCookie(flagid);
- // add authorization code for rest api
- final String orgi = loginUser.getOrgi();
- String auth = MainUtils.getUUID();
- cache.putLoginUserByAuthAndOrgi(auth, loginUser, orgi);
- userRepository.save(loginUser); // 更新登录状态到数据库
- response.addCookie((new Cookie("authorization", auth)));
+ }
- // 该登录用户是坐席,并且具有坐席对话的角色
- if ((loginUser.isAgent() &&
- loginUser.getRoleAuthMap().containsKey("A01") &&
- ((boolean) loginUser.getRoleAuthMap().get("A01") == true))
- || loginUser.isSuperuser()) {
- try {
- /****************************************
- * 登录成功,设置该坐席为就绪状态(默认)
- ****************************************/
- // https://gitlab.chatopera.com/chatopera/cosinee.w4l/issues/306
- final AgentStatus agentStatus = agentProxy.resolveAgentStatusByAgentnoAndOrgi(
- loginUser.getId(), orgi, loginUser.getSkills());
- agentStatus.setBusy(false);
- agentProxy.ready(loginUser, agentStatus);
+ // add authorization code for rest api
+ final String orgi = loginUser.getOrgi();
+ String auth = MainUtils.getUUID();
+ cache.putLoginUserByAuthAndOrgi(auth, loginUser, orgi);
+ userRepository.save(loginUser); // 更新登录状态到数据库
+ response.addCookie((new Cookie("authorization", auth)));
- // 更新缓存和数据库
- cache.putAgentStatusByOrgi(agentStatus, loginUser.getOrgi());
- agentStatusRes.save(agentStatus);
+ // 该登录用户是坐席,并且具有坐席对话的角色
+ if ((loginUser.isAgent() &&
+ loginUser.getRoleAuthMap().containsKey("A01") &&
+ ((boolean) loginUser.getRoleAuthMap().get("A01") == true))
+ || loginUser.isSuperuser()) {
+ try {
+ /****************************************
+ * 登录成功,设置该坐席为就绪状态(默认)
+ ****************************************/
+ // https://gitlab.chatopera.com/chatopera/cosinee.w4l/issues/306
+ final AgentStatus agentStatus = agentProxy.resolveAgentStatusByAgentnoAndOrgi(
+ loginUser.getId(), orgi, loginUser.getSkills());
+ agentStatus.setBusy(false);
+ agentProxy.ready(loginUser, agentStatus);
- // 工作状态记录
- AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(),
- agentStatus.getUsername(),
- agentStatus.getAgentno(),
- user.isSuperuser(), // 0代表admin
- agentStatus.getAgentno(),
- MainContext.AgentStatusEnum.OFFLINE.toString(),
- MainContext.AgentStatusEnum.READY.toString(),
- MainContext.AgentWorkType.MEIDIACHAT.toString(),
- orgi, null);
+ // 更新缓存和数据库
+ cache.putAgentStatusByOrgi(agentStatus, loginUser.getOrgi());
+ agentStatusRes.save(agentStatus);
- } catch (Exception e) {
- logger.error("[login] set agent status", e);
- }
+ // 工作状态记录
+ AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(),
+ agentStatus.getUsername(),
+ agentStatus.getAgentno(),
+ user.isSuperuser(), // 0代表admin
+ agentStatus.getAgentno(),
+ MainContext.AgentStatusEnum.OFFLINE.toString(),
+ MainContext.AgentStatusEnum.READY.toString(),
+ MainContext.AgentWorkType.MEIDIACHAT.toString(),
+ orgi, null);
+
+ } catch (Exception e) {
+ logger.error("[login] set agent status", e);
}
}
} else {
@@ -260,6 +262,8 @@ public class LoginController extends Handler {
// 更新redis session信息,用以支持sso
agentSessionProxy.updateUserSession(
loginUser.getId(), MainUtils.getContextID(request.getSession().getId()), loginUser.getOrgi());
+ loginUser.setSessionid(MainUtils.getContextID(request.getSession().getId()));
+
if (StringUtils.isNotBlank(referer)) {
view = new ModelAndView("redirect:" + referer);
@@ -327,7 +331,7 @@ public class LoginController extends Handler {
*
* @param request
* @param response
- * @param code 登出的代码
+ * @param code 登出的代码
* @return
*/
@RequestMapping("/logout")
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AdminController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AdminController.java
index b5e2ed32..d621b7d6 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AdminController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AdminController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/skill/AgentSkillController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AgentSkillController.java
similarity index 94%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/admin/skill/AgentSkillController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AgentSkillController.java
index 8df79f6f..ec8c1f59 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/skill/AgentSkillController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AgentSkillController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.admin.skill;
+package com.chatopera.cc.handler.admin;
import java.util.Date;
import java.util.List;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/area/AreaController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AreaController.java
similarity index 95%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/admin/area/AreaController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AreaController.java
index 38e1f3f3..ad2af5bc 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/area/AreaController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/AreaController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.admin.area;
+package com.chatopera.cc.handler.admin;
import java.io.IOException;
import java.util.Date;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/organ/OrganController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/OrganController.java
similarity index 96%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/admin/organ/OrganController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/admin/OrganController.java
index 0048dd62..5d41ebff 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/organ/OrganController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/OrganController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.admin.organ;
+package com.chatopera.cc.handler.admin;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.cache.Cache;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/role/RoleController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/RoleController.java
similarity index 96%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/admin/role/RoleController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/admin/RoleController.java
index a7450263..195b0b3e 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/role/RoleController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/RoleController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.admin.role;
+package com.chatopera.cc.handler.admin;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.handler.Handler;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/users/UsersController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/UsersController.java
similarity index 91%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/admin/users/UsersController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/admin/UsersController.java
index 5d8cb6c2..6a68e6f7 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/users/UsersController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/UsersController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,8 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.admin.users;
+package com.chatopera.cc.handler.admin;
+import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
@@ -78,8 +79,8 @@ public class UsersController extends Handler {
Sort.Direction.ASC,
"createtime"
)
- )
- );
+ )
+ );
return request(super.createAdminTempletResponse("/admin/user/index"));
}
@@ -193,8 +194,10 @@ public class UsersController extends Handler {
tempUser.setSipaccount(user.getSipaccount());
//切换成非坐席 判断是否坐席 以及 是否有对话
if (!user.isAgent()) {
- AgentStatus agentStatus = cache.findOneAgentStatusByAgentnoAndOrig((super.getUser(request)).getId(), super.getOrgi(request));
- if (!(agentStatus == null && cache.getInservAgentUsersSizeByAgentnoAndOrgi(super.getUser(request).getId(), super.getOrgi(request)) == 0)) {
+ AgentStatus agentStatus = cache.findOneAgentStatusByAgentnoAndOrig(
+ (super.getUser(request)).getId(), super.getOrgi(request));
+ if (!(agentStatus == null && cache.getInservAgentUsersSizeByAgentnoAndOrgi(
+ super.getUser(request).getId(), super.getOrgi(request)) == 0)) {
return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg=t1"));
}
}
@@ -258,7 +261,9 @@ public class UsersController extends Handler {
return msg;
}
- if (user.getUsername().equals(oldUser.getUsername()) && user.getEmail().equals(oldUser.getEmail()) && user.getMobile().equals(oldUser.getMobile()) && validUserCallcenterParams(user)) {
+ if (user.getUsername().equals(oldUser.getUsername()) && user.getEmail().equals(
+ oldUser.getEmail()) && user.getMobile().equals(oldUser.getMobile()) && validUserCallcenterParams(
+ user)) {
return "";
}
@@ -292,7 +297,7 @@ public class UsersController extends Handler {
* @return
*/
private boolean validUserCallcenterParams(final User user) {
- if (user.isCallcenter() && MainContext.isEnableCalloutModule()) {
+ if (user.isCallcenter() && MainContext.hasModule(Constants.CSKEFU_MODULE_CALLOUT)) {
List tempUserList = userRepository.findBySipaccountAndDatastatus(user.getSipaccount(), false);
return tempUserList.size() == 0 || user.getSipaccount() == "";
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterAclController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterAclController.java
index ea7df636..19ebcdd7 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterAclController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterAclController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterBlackController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterBlackController.java
index 931307d9..65d4077a 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterBlackController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterBlackController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterController.java
index 9cb6b992..a288d271 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterExtentionController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterExtentionController.java
index 148bac96..b9a4c74d 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterExtentionController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterExtentionController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.User;
-import com.chatopera.cc.proxy.CalloutQueneProxy;
+import com.chatopera.cc.proxy.CallcenterOutboundProxy;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.freeswitch.model.CallCenterAgent;
@@ -187,7 +187,7 @@ public class CallCenterExtentionController extends Handler {
ext.setUpdatetime(new Date());
extentionRes.save(ext);
- List callOutAgentList = CalloutQueneProxy.extention(ext.getExtention());
+ List callOutAgentList = CallcenterOutboundProxy.extention(ext.getExtention());
for (CallCenterAgent callOutAgent : callOutAgentList) {
callOutAgent.setSiptrunk(ext.getSiptrunk());
cache.putCallCenterAgentByIdAndOrgi(callOutAgent.getUserid(), callOutAgent.getOrgi(), callOutAgent);
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterIvrController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterIvrController.java
index a36f9f2d..c9192670 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterIvrController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterIvrController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterMediaController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterMediaController.java
index 3906d4af..581ba141 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterMediaController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterMediaController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterResourceController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterResourceController.java
index defbd1ef..b9531988 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterResourceController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterResourceController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterRouterController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterRouterController.java
index ad3149bd..7de5087c 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterRouterController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterRouterController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterSipTrunkController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterSipTrunkController.java
index 41b0f738..21e82fad 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterSipTrunkController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterSipTrunkController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterSkillController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterSkillController.java
index 639f1a6d..7568f785 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterSkillController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/callcenter/CallCenterSkillController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/CalloutChannelController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/CalloutChannelController.java
deleted file mode 100644
index 1790f1de..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/CalloutChannelController.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.cc.handler.admin.channel;
-
-import com.chatopera.cc.basic.MainContext;
-import com.chatopera.cc.basic.MainUtils;
-import com.chatopera.cc.handler.Handler;
-import com.chatopera.cc.model.CousultInvite;
-import com.chatopera.cc.model.SNSAccount;
-import com.chatopera.cc.model.Secret;
-import com.chatopera.cc.persistence.repository.ConsultInviteRepository;
-import com.chatopera.cc.persistence.repository.SNSAccountRepository;
-import com.chatopera.cc.persistence.repository.SecretRepository;
-import com.chatopera.cc.exception.CSKefuException;
-import com.chatopera.cc.util.Menu;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.validation.Valid;
-import java.security.NoSuchAlgorithmException;
-import java.util.Date;
-import java.util.List;
-
-@Controller
-@RequestMapping("/admin/callout")
-public class CalloutChannelController extends Handler {
- @Autowired
- private SNSAccountRepository snsAccountRes;
-
- @Autowired
- private ConsultInviteRepository invite;
-
- @Autowired
- private SecretRepository secRes;
-
- @RequestMapping("/index")
- @Menu(type = "callout", subtype = "channel", access = false, admin = true)
- public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute, @RequestParam(name = "status", required = false) String status) {
- map.addAttribute("snsAccountList", snsAccountRes.findBySnstypeAndOrgi(MainContext.ChannelType.PHONE.toString(), super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request))));
- map.addAttribute("status", status);
- List secretConfig = secRes.findByOrgi(super.getOrgi(request));
- if (secretConfig != null && secretConfig.size() > 0) {
- map.addAttribute("secret", secretConfig.get(0));
- }
- if (StringUtils.isNotBlank(execute) && execute.equals("false")) {
- map.addAttribute("execute", execute);
- }
- return request(super.createAdminTempletResponse("/admin/channel/callout/index"));
- }
-
- @RequestMapping("/add")
- @Menu(type = "callout", subtype = "channel", access = false, admin = true)
- public ModelAndView add(ModelMap map, HttpServletRequest request) {
- return request(super.createRequestPageTempletResponse("/admin/channel/callout/add"));
- }
-
- @RequestMapping("/save")
- @Menu(type = "callout", subtype = "channel")
- public ModelAndView save(HttpServletRequest request, @Valid SNSAccount snsAccount) throws NoSuchAlgorithmException, CSKefuException {
- String status = "new_webim_fail";
- if (StringUtils.isNotBlank(snsAccount.getBaseURL())) {
- snsAccount.setSnsid(snsAccount.getBaseURL()); // set sns ID the same SNSAccount
- int count = snsAccountRes.countBySnsidAndOrgi(snsAccount.getSnsid(), super.getOrgi(request));
- if (count == 0) {
- status = "new_webim_success";
- snsAccount.setOrgi(super.getOrgi(request));
- snsAccount.setSnstype(MainContext.ChannelType.PHONE.toString());
- snsAccount.setCreatetime(new Date());
- snsAccountRes.save(snsAccount);
-
- /**
- * 同时创建CousultInvite 记录
- */
- CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsAccount.getSnsid(), super.getOrgi(request));
- if (coultInvite == null) {
- coultInvite = new CousultInvite();
- coultInvite.setSnsaccountid(snsAccount.getSnsid());
- coultInvite.setCreate_time(new Date());
- coultInvite.setOrgi(super.getOrgi(request));
- coultInvite.setName(snsAccount.getName());
- invite.save(coultInvite);
- }
- }
- }
- return request(super.createRequestPageTempletResponse("redirect:/admin/callout/index.html?status=" + status));
- }
-
- @RequestMapping("/delete")
- @Menu(type = "callout", subtype = "delete")
- public ModelAndView delete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String confirm) {
- boolean execute = false;
- if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) {
- SNSAccount snsAccount = snsAccountRes.findByIdAndOrgi(id, super.getOrgi(request));
- if (snsAccountRes != null) {
- snsAccountRes.delete(snsAccount);
- CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsAccount.getSnsid(), super.getOrgi(request));
- if (coultInvite != null) {
- invite.delete(coultInvite);
- }
- }
- }
-
- return request(super.createRequestPageTempletResponse("redirect:/admin/callout/index.html?execute=" + execute));
- }
-
- @RequestMapping("/edit")
- @Menu(type = "callout", subtype = "channel", access = false, admin = true)
- public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
- map.addAttribute("snsAccount", snsAccountRes.findByIdAndOrgi(id, super.getOrgi(request)));
- return request(super.createRequestPageTempletResponse("/admin/channel/callout/edit"));
- }
-
- @RequestMapping("/update")
- @Menu(type = "callout", subtype = "channel", access = false, admin = true)
- public ModelAndView update(HttpServletRequest request, @Valid SNSAccount snsAccount) throws NoSuchAlgorithmException {
- SNSAccount oldSnsAccount = snsAccountRes.findByIdAndOrgi(snsAccount.getId(), super.getOrgi(request));
- if (oldSnsAccount != null) {
- oldSnsAccount.setName(snsAccount.getName());
- oldSnsAccount.setBaseURL(snsAccount.getBaseURL());
- oldSnsAccount.setUpdatetime(new Date());
- /**
- * SNSID如果有变更,需要同时变更 CoultInvite 表的 记录
- */
- if (StringUtils.isNotBlank(oldSnsAccount.getSnsid())) {
- CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(oldSnsAccount.getSnsid(), super.getOrgi(request));
- if (coultInvite == null) {
- /**
- * 同时创建CousultInvite 记录
- */
- coultInvite = new CousultInvite();
- coultInvite.setSnsaccountid(oldSnsAccount.getSnsid());
- coultInvite.setCreate_time(new Date());
- coultInvite.setOrgi(super.getOrgi(request));
- coultInvite.setName(snsAccount.getName());
- invite.save(coultInvite);
- }
- }
-
- oldSnsAccount.setSnstype(MainContext.ChannelType.PHONE.toString());
- snsAccountRes.save(oldSnsAccount);
- }
- return request(super.createRequestPageTempletResponse("redirect:/admin/callout/index.html"));
- }
-}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/SNSAccountIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/SNSAccountIMController.java
index 2e826e1a..83da70af 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/SNSAccountIMController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/SNSAccountIMController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/WebIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/WebIMController.java
index 9cf10861..d3040e5f 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/WebIMController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/channel/WebIMController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/config/SystemConfigController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/config/SystemConfigController.java
index 3c8a70a8..1ebfd420 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/config/SystemConfigController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/config/SystemConfigController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/config/SystemMessageController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/config/SystemMessageController.java
index 713bf5f3..79bb00db 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/config/SystemMessageController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/config/SystemMessageController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/MetadataController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/MetadataController.java
index ae288208..c0fb4702 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/MetadataController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/MetadataController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/SysDicController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/SysDicController.java
index 78a1b490..cee0ad97 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/SysDicController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/SysDicController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/TemplateController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/TemplateController.java
index 95335f3b..5dd8b8aa 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/TemplateController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/admin/system/TemplateController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiAgentUserController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiAgentUserController.java
new file mode 100644
index 00000000..4a966951
--- /dev/null
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiAgentUserController.java
@@ -0,0 +1,371 @@
+/*
+ * Copyright (C) 2017 优客服-多渠道客服系统
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.chatopera.cc.handler.api;
+
+import com.chatopera.cc.acd.AutomaticServiceDist;
+import com.chatopera.cc.basic.MainContext.*;
+import com.chatopera.cc.basic.MainUtils;
+import com.chatopera.cc.cache.Cache;
+import com.chatopera.cc.exception.CSKefuException;
+import com.chatopera.cc.handler.Handler;
+import com.chatopera.cc.handler.api.request.RestUtils;
+import com.chatopera.cc.model.*;
+import com.chatopera.cc.peer.PeerSyncIM;
+import com.chatopera.cc.persistence.repository.AgentServiceRepository;
+import com.chatopera.cc.persistence.repository.AgentUserRepository;
+import com.chatopera.cc.persistence.repository.UserRepository;
+import com.chatopera.cc.proxy.AgentAuditProxy;
+import com.chatopera.cc.proxy.AgentUserProxy;
+import com.chatopera.cc.socketio.message.Message;
+import com.chatopera.cc.util.Menu;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ACD服务 获取当前对话中的访客
+ */
+@RestController
+@RequestMapping("/api/agentuser")
+public class ApiAgentUserController extends Handler {
+
+ private final static Logger logger = LoggerFactory.getLogger(ApiAgentUserController.class);
+
+ @Autowired
+ private Cache cache;
+
+ @Autowired
+ private PeerSyncIM peerSyncIM;
+
+ @Autowired
+ private AgentUserRepository agentUserRes;
+
+ @Autowired
+ private UserRepository userRes;
+
+ @Autowired
+ private AgentServiceRepository agentServiceRes;
+
+ @Autowired
+ private AgentUserProxy agentUserProxy;
+
+ @Autowired
+ private AgentAuditProxy agentAuditProxy;
+
+ /**
+ * 获取当前对话中的访客
+ * 坐席相关 RestAPI
+ *
+ * @param request
+ * @return
+ */
+ @RequestMapping(method = RequestMethod.POST)
+ @Menu(type = "apps", subtype = "agentuser", access = true)
+ public ResponseEntity operations(HttpServletRequest request, @RequestBody final String body, @Valid String q) {
+ logger.info("[operations] body {}, q {}", body, q);
+ final JsonObject j = StringUtils.isBlank(body) ? (new JsonObject()) : (new JsonParser()).parse(
+ body).getAsJsonObject();
+ JsonObject json = new JsonObject();
+ HttpHeaders headers = RestUtils.header();
+
+ if (!j.has("ops")) {
+ json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
+ json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
+ } else {
+ switch (StringUtils.lowerCase(j.get("ops").getAsString())) {
+ case "inserv":
+ json = inserv(request, j);
+ break;
+ case "withdraw":
+ json = withdraw(request, j);
+ break;
+ case "end":
+ json = end(request, j);
+ break;
+ case "transout":
+ json = transout(request, j);
+ break;
+ default:
+ json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
+ json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的操作。");
+ }
+ }
+
+ return new ResponseEntity(json.toString(), headers, HttpStatus.OK);
+ }
+
+ /**
+ * 执行坐席转接
+ * 将会话转接给别人
+ *
+ * @param request
+ * @param payload
+ * @return
+ */
+ private JsonObject transout(final HttpServletRequest request, final JsonObject payload) {
+ logger.info("[transout] payload ", payload.toString());
+ final String orgi = super.getOrgi(request);
+ final User logined = super.getUser(request);
+ JsonObject resp = new JsonObject();
+
+ /**
+ * 必填参数
+ */
+ // 目标坐席
+ final String transAgentId = payload.get("agentno").getAsString();
+ // 当前会话的ID
+ final String agentUserId = payload.get("agentUserId").getAsString();
+ // 坐席服务ID
+ final String agentServiceId = payload.get("agentServiceId").getAsString();
+
+ if (StringUtils.isNotBlank(agentUserId) &&
+ StringUtils.isNotBlank(transAgentId) &&
+ StringUtils.isNotBlank(agentServiceId)) {
+ final User targetAgent = userRes.findOne(transAgentId);
+ final AgentService agentService = agentServiceRes.findByIdAndOrgi(agentServiceId, orgi);
+
+ /**
+ * 更新AgentUser
+ */
+ final AgentUser agentUser = agentUserProxy.findOne(agentUserId).orElseGet(null);
+ if (agentUser != null) {
+ final AgentUserAudit agentAudits = cache.findOneAgentUserAuditByOrgiAndId(orgi, agentUserId).orElseGet(
+ null);
+
+ // 当前服务于访客的坐席
+ final String currentAgentno = agentUser.getAgentno();
+ // 当前访客的ID
+ final String userId = agentUser.getUserid();
+
+ // 检查权限
+ if ((!logined.isSuperuser()) && (!StringUtils.equals(
+ agentUser.getAgentno(),
+ logined.getId())) && (!isTransPermissionAllowed(
+ agentAudits, logined))) {
+ // 1. 不是超级用户;2. 也是不是会话的所有者; 3. 也不是坐席监控人员
+ logger.info("[end] Permission not fulfill.");
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
+ resp.addProperty(RestUtils.RESP_KEY_ERROR, "Permission denied.");
+ return resp;
+ }
+
+ agentUser.setAgentno(transAgentId);
+ agentUser.setAgentname(targetAgent.getUname());
+ agentUserRes.save(agentUser);
+
+ /**
+ * 坐席状态
+ */
+ // 转接目标坐席
+ final AgentStatus transAgentStatus = cache.findOneAgentStatusByAgentnoAndOrig(transAgentId, orgi);
+
+ // 转接源坐席
+ final AgentStatus currentAgentStatus = cache.findOneAgentStatusByAgentnoAndOrig(currentAgentno, orgi);
+
+ if (StringUtils.equals(
+ AgentUserStatusEnum.INSERVICE.toString(),
+ agentUser.getStatus())) { //转接 , 发送消息给 目标坐席
+ // 更新当前坐席的服务访客列表
+ if (currentAgentStatus != null) {
+ cache.deleteOnlineUserIdFromAgentStatusByUseridAndAgentnoAndOrgi(userId, currentAgentno, orgi);
+ AutomaticServiceDist.updateAgentStatus(currentAgentStatus, orgi);
+ }
+
+ if (transAgentStatus != null) {
+ agentService.setAgentno(transAgentId);
+ agentService.setAgentusername(transAgentStatus.getUsername());
+ }
+
+ // 转接坐席提示消息
+ Message outMessage = new Message();
+ outMessage.setMessage(
+ AutomaticServiceDist.getSuccessMessage(agentService, agentUser.getChannel(), orgi));
+ outMessage.setMessageType(MediaType.TEXT.toString());
+ outMessage.setCalltype(CallType.IN.toString());
+ outMessage.setCreatetime(MainUtils.dateFormate.format(new Date()));
+ outMessage.setAgentUser(agentUser);
+ outMessage.setAgentService(agentService);
+
+ if (StringUtils.isNotBlank(agentUser.getUserid())) {
+ peerSyncIM.send(
+ ReceiverType.VISITOR,
+ ChannelType.toValue(agentUser.getChannel()),
+ agentUser.getAppid(),
+ MessageType.STATUS,
+ agentUser.getUserid(),
+ outMessage,
+ true);
+ }
+
+ // 通知转接消息给新坐席
+ outMessage.setChannelMessage(agentUser);
+ outMessage.setAgentUser(agentUser);
+ peerSyncIM.send(
+ ReceiverType.AGENT, ChannelType.WEBIM,
+ agentUser.getAppid(), MessageType.NEW, agentService.getAgentno(),
+ outMessage, true);
+
+ // 通知消息给前坐席
+ if (!StringUtils.equals(logined.getId(), currentAgentno)) {
+ // 如果当前坐席不是登录用户,因为登录用户会从RestAPI返回转接的结果
+ // 该登录用户可能是坐席监控或当前坐席,那么,如果是坐席监控,就有必要
+ // 通知前坐席这个事件
+ peerSyncIM.send(ReceiverType.AGENT, ChannelType.WEBIM, agentUser.getAppid(),
+ MessageType.TRANSOUT,
+ currentAgentno, outMessage, true);
+ }
+ }
+
+ if (agentService != null) {
+ agentService.setAgentno(transAgentId);
+ if (payload.has("memo") && StringUtils.isNotBlank(payload.get("memo").getAsString())) {
+ agentService.setTransmemo(payload.get("memo").getAsString());
+ }
+ agentService.setTrans(true);
+ agentService.setTranstime(new Date());
+ agentServiceRes.save(agentService);
+ }
+
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
+ resp.addProperty(RestUtils.RESP_KEY_DATA, "success");
+ } else {
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
+ resp.addProperty(RestUtils.RESP_KEY_ERROR, "Can not find agent user.");
+ }
+ } else {
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5);
+ resp.addProperty(RestUtils.RESP_KEY_ERROR, "Invalid params.");
+ }
+
+ return resp;
+ }
+
+ /**
+ * 结束坐席会话
+ *
+ * @param request
+ * @param payload
+ * @return
+ */
+ private JsonObject end(final HttpServletRequest request, final JsonObject payload) {
+ logger.info("[end] payload ", payload.toString());
+ final String orgi = super.getOrgi(request);
+ final User logined = super.getUser(request);
+ JsonObject resp = new JsonObject();
+
+ final AgentUser agentUser = agentUserRes.findByIdAndOrgi(payload.get("id").getAsString(), orgi);
+ if (agentUser != null) {
+ if ((StringUtils.equals(
+ logined.getId(), agentUser.getAgentno()) || logined.isSuperuser())) {
+ // 删除访客-坐席关联关系,包括缓存
+ try {
+ AutomaticServiceDist.deleteAgentUser(agentUser, orgi);
+ } catch (CSKefuException e) {
+ // 未能删除成功
+ logger.error("[end]", e);
+ }
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
+ resp.addProperty(RestUtils.RESP_KEY_DATA, "success");
+ } else {
+ logger.info("[end] Permission not fulfill.");
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
+ resp.addProperty(RestUtils.RESP_KEY_ERROR, "Permission denied.");
+ }
+ } else {
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
+ resp.addProperty(RestUtils.RESP_KEY_ERROR, "Agent User not found.");
+ }
+
+ return resp;
+ }
+
+ /**
+ * 撤退一个坐席
+ * 将当前坐席服务中的访客分配给其他就绪的坐席
+ *
+ * @param request
+ * @param j
+ * @return
+ */
+ private JsonObject withdraw(final HttpServletRequest request, final JsonObject j) {
+ JsonObject resp = new JsonObject();
+ AutomaticServiceDist.withdrawAgent(super.getOrgi(request), super.getUser(request).getId());
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
+ return resp;
+ }
+
+
+ /**
+ * 获得当前访客服务中的访客信息
+ * 获取当前正在对话的访客信息,包含多种渠道来源的访客
+ *
+ * @param request
+ * @param j
+ * @return
+ */
+ private JsonObject inserv(final HttpServletRequest request, final JsonObject j) {
+ JsonObject resp = new JsonObject();
+ JsonArray data = new JsonArray();
+
+ List lis = cache.findInservAgentUsersByAgentnoAndOrgi(
+ super.getUser(request).getId(), super.getOrgi(request));
+ for (final AgentUser au : lis) {
+ JsonObject obj = new JsonObject();
+ obj.addProperty("id", au.getId());
+ obj.addProperty("userid", au.getUserid());
+ obj.addProperty("status", au.getStatus());
+ obj.addProperty("agentno", au.getAgentno());
+ obj.addProperty("channel", au.getChannel());
+ obj.addProperty("nickname", au.getNickname());
+ data.add(obj);
+ }
+ resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
+ resp.add("data", data);
+
+ return resp;
+ }
+
+ /**
+ * 检查是否具备该会话的坐席监控权限
+ *
+ * @param agentUserAudit
+ * @param user
+ * @return
+ */
+ private boolean isTransPermissionAllowed(final AgentUserAudit agentUserAudit, final User user) {
+ if (agentUserAudit != null && agentUserAudit.getSubscribers().containsKey(user.getId())) {
+ return true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiAppsController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiAppsController.java
similarity index 98%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiAppsController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiAppsController.java
index 4deea505..ffd22404 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiAppsController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiAppsController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 Chatopera Inc, All rights reserved.
+ * Copyright (C) 2018-2019 Chatopera Inc, All rights reserved.
*
* This software and related documentation are provided under a license agreement containing
* restrictions on use and disclosure and are protected by intellectual property laws.
@@ -8,7 +8,7 @@
* publish, or display any part, in any form, or by any means. Reverse engineering, disassembly,
* or decompilation of this software, unless required by law for interoperability, is prohibited.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.cache.Cache;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiChatMessageController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiChatMessageController.java
similarity index 93%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiChatMessageController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiChatMessageController.java
index e666c071..10cc6905 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiChatMessageController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiChatMessageController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.persistence.repository.ChatMessageRepository;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactNotesController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactNotesController.java
similarity index 99%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactNotesController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactNotesController.java
index e749528f..4cc407fa 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactNotesController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactNotesController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactTagsController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactTagsController.java
similarity index 98%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactTagsController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactTagsController.java
index 38694553..b1d9b0a7 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactTagsController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactTagsController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.handler.Handler;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactsController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactsController.java
similarity index 96%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactsController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactsController.java
index 35563d29..7a1b3250 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiContactsController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiContactsController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.exception.CSKefuException;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiLeavemsgController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiLeavemsgController.java
similarity index 94%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiLeavemsgController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiLeavemsgController.java
index be06a71b..116f2d72 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiLeavemsgController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiLeavemsgController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.handler.Handler;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiOnlineUserController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiOnlineUserController.java
similarity index 93%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiOnlineUserController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiOnlineUserController.java
index 13b500d0..59b73026 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiOnlineUserController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiOnlineUserController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.handler.Handler;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiOrganController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiOrganController.java
similarity index 93%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiOrganController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiOrganController.java
index 20bd9d12..c010fec4 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiOrganController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiOrganController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.model.Organ;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQualityController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQualityController.java
similarity index 94%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQualityController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQualityController.java
index e22ed3cb..dde0619c 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQualityController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQualityController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.handler.Handler;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQuickReplyController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQuickReplyController.java
similarity index 94%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQuickReplyController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQuickReplyController.java
index 466ba458..7e1b46b5 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQuickReplyController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQuickReplyController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.model.QuickReply;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQuickTypeController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQuickTypeController.java
similarity index 94%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQuickTypeController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQuickTypeController.java
index 9dcf2b2e..943ad374 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiQuickTypeController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiQuickTypeController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.model.QuickType;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiServiceQueneController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiServiceQueneController.java
similarity index 96%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiServiceQueneController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiServiceQueneController.java
index f666f5e7..1a7bedbe 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiServiceQueneController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiServiceQueneController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.acd.AutomaticServiceDist;
import com.chatopera.cc.basic.MainContext;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiSysDicController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiSysDicController.java
similarity index 95%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiSysDicController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiSysDicController.java
index b2a05649..ffff48b9 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiSysDicController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiSysDicController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.handler.admin.system.SysDicController;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiTagsController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiTagsController.java
similarity index 97%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiTagsController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiTagsController.java
index 9aea20ed..fb48a091 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiTagsController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiTagsController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Chatopera Inc,
+ * Copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.handler.api.request.RestUtils;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiUserController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiUserController.java
similarity index 94%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiUserController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiUserController.java
index 8d46288e..5e4f99e5 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiUserController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiUserController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiWebIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiWebIMController.java
similarity index 93%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiWebIMController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiWebIMController.java
index 4d175419..da0326cc 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiWebIMController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiWebIMController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.model.CousultInvite;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiWlContactsController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiWlContactsController.java
similarity index 85%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiWlContactsController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiWlContactsController.java
index 3950c37d..a211f552 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiWlContactsController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiWlContactsController.java
@@ -1,17 +1,28 @@
-/**
- * Contact Controller for Wonder4Life
- * https://wiki.chatopera.com/display/W4L/Wonder4life
- * Maintain more properties
+/*
+ * Copyright (C) 2018-2019 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
+
+import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.handler.api.request.RestUtils;
import com.chatopera.cc.model.Contacts;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.es.ContactsRepository;
-import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.RestResult;
import com.chatopera.cc.util.RestResultType;
@@ -37,8 +48,9 @@ import java.text.ParseException;
import java.util.Date;
/**
- * WL联系人服务
- * Wonder4Life联系人管理功能
+ * 联系人导入API
+ * 联系人管理功能
+ * https://wiki.chatopera.com/display/W4L/Wonder4life
*/
@RestController
@RequestMapping("/api/wl/contacts")
@@ -62,9 +74,13 @@ public class ApiWlContactsController extends Handler {
Page contactsList = null;
if (StringUtils.isNotBlank(creater)) {
User user = super.getUser(request);
- contactsList = contactsRes.findByCreaterAndSharesAndOrgi(user.getId(), user.getId(), super.getOrgi(request), false, q, new PageRequest(super.getP(request), super.getPs(request)));
+ contactsList = contactsRes.findByCreaterAndSharesAndOrgi(
+ user.getId(), user.getId(), super.getOrgi(request), false, q, new PageRequest(super.getP(request),
+ super.getPs(
+ request)));
} else {
- contactsList = contactsRes.findByOrgi(super.getOrgi(request), false, q, new PageRequest(super.getP(request), super.getPs(request)));
+ contactsList = contactsRes.findByOrgi(
+ super.getOrgi(request), false, q, new PageRequest(super.getP(request), super.getPs(request)));
}
return new ResponseEntity<>(new RestResult(RestResultType.OK, contactsList), HttpStatus.OK);
}
@@ -110,9 +126,10 @@ public class ApiWlContactsController extends Handler {
* @param j
* @return
*/
- private JsonObject createContact(final String creator,
- final String orgi,
- final JsonObject j) {
+ private JsonObject createContact(
+ final String creator,
+ final String orgi,
+ final JsonObject j) {
JsonObject result = new JsonObject();
if (j.has("uid") && j.has("sid")) {
@@ -217,8 +234,9 @@ public class ApiWlContactsController extends Handler {
}
- if (j.has("gender"))
+ if (j.has("gender")) {
record.setGender(j.get("gender").getAsString());
+ }
if (isNew) {
record.setId(MainUtils.getUUID());
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/QueryParams.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/QueryParams.java
similarity index 87%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/QueryParams.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/QueryParams.java
index 895e0740..1265c16e 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/QueryParams.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/QueryParams.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
public class QueryParams {
private String begin ;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/RequestValues.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/RequestValues.java
similarity index 86%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/RequestValues.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/RequestValues.java
index 340b5b26..0e13ee07 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/RequestValues.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/RequestValues.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import java.io.Serializable;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/UkefuApiTagsController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/UkefuApiTagsController.java
similarity index 92%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/UkefuApiTagsController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/UkefuApiTagsController.java
index 87405673..40c854c7 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/UkefuApiTagsController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/UkefuApiTagsController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api.rest;
+package com.chatopera.cc.handler.api;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.handler.Handler;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiLoginController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/auth/ApiLoginController.java
similarity index 91%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiLoginController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/auth/ApiLoginController.java
index 1956447a..ff40821a 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiLoginController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/auth/ApiLoginController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api;
+package com.chatopera.cc.handler.api.auth;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
@@ -26,6 +26,8 @@ import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.persistence.repository.UserRoleRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -47,6 +49,8 @@ import java.util.List;
@RestController
@RequestMapping("/tokens")
public class ApiLoginController extends Handler {
+ private final static Logger logger = LoggerFactory.getLogger(ApiLoginController.class);
+
@Autowired
private UserRepository userRepository;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiTokensErrorController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/auth/ApiTokensErrorController.java
similarity index 90%
rename from contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiTokensErrorController.java
rename to contact-center/app/src/main/java/com/chatopera/cc/handler/api/auth/ApiTokensErrorController.java
index 4524fa94..335ab965 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/ApiTokensErrorController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/auth/ApiTokensErrorController.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.handler.api;
+package com.chatopera.cc.handler.api.auth;
import com.chatopera.cc.handler.Handler;
import com.chatopera.cc.util.Menu;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/QueryParams.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/QueryParams.java
index 08dd4c84..76766666 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/QueryParams.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/QueryParams.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/RequestValues.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/RequestValues.java
index f029e6c4..ef8f6b37 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/RequestValues.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/RequestValues.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/RestUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/RestUtils.java
index e7331a2b..7a2b4249 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/RestUtils.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/request/RestUtils.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
+ * Modifications copyright (C) 2018-2019 Chatopera Inc,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiAgentUserController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiAgentUserController.java
deleted file mode 100644
index 3f1c6959..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiAgentUserController.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.cc.handler.api.rest;
-
-import com.chatopera.cc.acd.AutomaticServiceDist;
-import com.chatopera.cc.cache.Cache;
-import com.chatopera.cc.handler.Handler;
-import com.chatopera.cc.handler.api.request.RestUtils;
-import com.chatopera.cc.model.AgentUser;
-import com.chatopera.cc.util.Menu;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.validation.Valid;
-import java.util.List;
-
-/**
- * ACD服务 获取当前对话中的访客
- */
-@RestController
-@RequestMapping("/api/agentuser")
-public class ApiAgentUserController extends Handler {
-
- private final static Logger logger = LoggerFactory.getLogger(ApiAgentUserController.class);
-
- @Autowired
- private Cache cache;
-
- /**
- * 获取当前对话中的访客
- * 坐席相关 RestAPI
- *
- * @param request
- * @return
- */
- @RequestMapping(method = RequestMethod.POST)
- @Menu(type = "apps", subtype = "agentuser", access = true)
- public ResponseEntity operations(HttpServletRequest request, @RequestBody final String body, @Valid String q) {
- logger.info("[operations] body {}, q {}", body, q);
- final JsonObject j = StringUtils.isBlank(body) ? (new JsonObject()) : (new JsonParser()).parse(body).getAsJsonObject();
- JsonObject json = new JsonObject();
- HttpHeaders headers = RestUtils.header();
-
- if (!j.has("ops")) {
- json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
- json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
- } else {
- switch (StringUtils.lowerCase(j.get("ops").getAsString())) {
- case "inserv":
- json = inserv(request, j);
- break;
- case "withdraw":
- json = withdraw(request, j);
- break;
- default:
- json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
- json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的操作。");
- }
- }
-
- return new ResponseEntity(json.toString(), headers, HttpStatus.OK);
- }
-
- /**
- * 撤退一个坐席
- * 将当前坐席服务中的访客分配给其他就绪的坐席
- *
- * @param request
- * @param j
- * @return
- */
- private JsonObject withdraw(final HttpServletRequest request, final JsonObject j) {
- JsonObject resp = new JsonObject();
- AutomaticServiceDist.withdrawAgent(super.getOrgi(request), super.getUser(request).getId());
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
- return resp;
- }
-
-
- /**
- * 获得当前访客服务中的访客信息
- * 获取当前正在对话的访客信息,包含多种渠道来源的访客
- *
- * @param request
- * @param j
- * @return
- */
- private JsonObject inserv(final HttpServletRequest request, final JsonObject j) {
- JsonObject resp = new JsonObject();
- JsonArray data = new JsonArray();
-
- List lis = cache.findInservAgentUsersByAgentnoAndOrgi(super.getUser(request).getId(), super.getOrgi(request));
- for (final AgentUser au : lis) {
- JsonObject obj = new JsonObject();
- obj.addProperty("id", au.getId());
- obj.addProperty("userid", au.getUserid());
- obj.addProperty("status", au.getStatus());
- obj.addProperty("agentno", au.getAgentno());
- obj.addProperty("channel", au.getChannel());
- obj.addProperty("nickname", au.getNickname());
- data.add(obj);
- }
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
- resp.add("data", data);
-
- return resp;
- }
-}
\ No newline at end of file
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiCallMonitorController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiCallMonitorController.java
deleted file mode 100644
index 4b818125..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiCallMonitorController.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * Copyright (C) 2017 优客服-多渠道客服系统
- * Modifications copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.cc.handler.api.rest;
-
-import com.chatopera.cc.basic.MainContext;
-import com.chatopera.cc.basic.Constants;
-import com.chatopera.cc.util.Menu;
-import com.chatopera.cc.util.MathHelper;
-import com.chatopera.cc.exception.CalloutRecordException;
-import com.chatopera.cc.model.*;
-import com.chatopera.cc.persistence.repository.*;
-import com.chatopera.cc.handler.Handler;
-import com.chatopera.cc.handler.api.request.RestUtils;
-import com.chatopera.cc.proxy.UserProxy;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.HashOperations;
-import org.springframework.data.redis.core.StringRedisTemplate;
-import org.springframework.data.redis.listener.ChannelTopic;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.PostConstruct;
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 通话记录
- * 语音渠道坐席监控
- * 监控语音渠道使用情况,支持监听等操作。
- */
-@RestController
-@RequestMapping("/api/callout/monitor")
-public class ApiCallMonitorController extends Handler {
- private static final Logger logger = LoggerFactory.getLogger(ApiCallMonitorController.class);
- private HashOperations redisHashOps;
-
- /**
- * 使用StringRedisTemplate而不是RedisTemplate解决序列化问题
- * https://stackoverflow.com/questions/13215024/weird-redis-key-with-spring-data-jedis
- */
- @Autowired
- private StringRedisTemplate redis;
-
- @Autowired
- private SNSAccountRepository snsAccountRes;
-
- @Autowired
- private OrganRepository organRes;
-
- @Autowired
- private UserRepository userRes;
-
- @Autowired
- private AgentStatusRepository agentStatusRes;
-
- @Autowired
- private StatusEventRepository statusEventRes;
-
- @PostConstruct
- private void init() {
- redisHashOps = redis.opsForHash();
- }
-
-
- private AgentStatus getAgentStatus(final String agentId, final String orgi) {
- List x = agentStatusRes.findByAgentnoAndOrgi(agentId, orgi);
- if (x.size() > 0)
- return x.get(0);
- return null;
- }
-
- /**
- * 获取正在通话的数据
- *
- * @param agentId
- * @param sip
- * @param status
- * @return
- */
- private JsonObject getStatusEvent(final String agentId, final String sip, final String status) {
- JsonObject j = new JsonObject();
- StatusEvent s = statusEventRes.findByAgentAndSiptrunkAndStatus(agentId, sip, status);
- if (s != null) {
- j.addProperty("callid", s.getCallid());
- j.addProperty("called", s.getCalled());
- j.addProperty("direction", s.getDirection());
- // 格式化开始时间
- j.addProperty("createtime", Constants.DISPLAY_DATE_FORMATTER.format(s.getCreatetime()));
- // 增加持续时间
- j.addProperty("duration", MathHelper.formatSecondsBetweenTwoDates(s.getCreatetime(), null));
- }
- return j;
- }
-
- /**
- * @param organ
- * @return
- */
- private String getOrganName(final String organ) {
- if (StringUtils.isBlank(organ))
- return "未设置";
-
- Organ o = organRes.findOne(organ);
- if (o == null) {
- return "";
- } else {
- return o.getName();
- }
- }
-
- /**
- * 查询通话记录
- *
- * @return
- */
- private JsonObject status(final JsonObject j) {
- JsonObject resp = new JsonObject();
- try {
- if (j.has("channel")) {
- final String channel = j.get("channel").getAsString();
- SNSAccount snsAccount = snsAccountRes.findBySnsid(channel);
- if (snsAccount == null) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "不存在该语音渠道。");
- return resp;
- }
-
- // 检查organ
- String organ = null;
- if (j.has("organ")) {
- organ = j.get("organ").getAsString();
- if (StringUtils.isBlank(organ)) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_6);
- resp.addProperty(RestUtils.RESP_KEY_MSG, "部门参数是空字符串,不合法。");
- return resp;
- }
- if (organRes.findOne(organ) == null) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_6);
- resp.addProperty(RestUtils.RESP_KEY_MSG, "不存在该部门。");
- return resp;
- }
- }
-
- // 从Redis中取数据
- Map pbxSipStatusMap = redisHashOps.entries(String.format(Constants.FS_SIP_STATUS, channel));
- if (pbxSipStatusMap.keySet().size() == 0) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_6);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "软交换系统不存在该语音渠道的数据。");
- return resp;
- }
-
- // 获取到数据,返回
- JsonArray ja = new JsonArray();
-
- // 客服列表
- List agents = UserProxy.findAllByCallcenterIsTrueAndDatastatusIsFalseAndOrgan(organ);
-
- for (User g : agents) {
- JsonObject x = new JsonObject();
- x.addProperty("name", g.getUname());
-
- AgentStatus as = getAgentStatus(g.getId(), MainContext.SYSTEM_ORGI);
- if (as == null) {
- // 离线客服
- x.addProperty("web", MainContext.AgentStatusEnum.OFFLINE.zh());
- } else {
- x.addProperty("web", as.isBusy() ? MainContext.AgentStatusEnum.BUSY.zh() : MainContext.AgentStatusEnum.IDLE.zh());
- }
-
- String sipaccount = g.getSipaccount();
- if (StringUtils.isNotBlank(sipaccount)) {
- String sipstatus = pbxSipStatusMap.get(sipaccount);
- if (StringUtils.isNotBlank(sipstatus)) {
- x.addProperty("sip", sipaccount);
- x.addProperty("status", sipstatus);
- if (Constants.FS_LEG_INCALL_ZH.equals(sipstatus))
- x.add("current", getStatusEvent(g.getId(), sipaccount, MainContext.CallServiceStatus.INCALL.toString()));
- } else {
- x.addProperty("sip", sipaccount);
- x.addProperty("status", MainContext.CallServiceStatus.OFFLINE.toString());
- }
- } else {
- x.addProperty("sip", "未设置");
- x.addProperty("status", "无");
- }
- ja.add(x);
- }
-
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
- resp.add(RestUtils.RESP_KEY_DATA, ja);
- } else {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "缺少请求参数 [语音渠道标识]。");
- }
- } catch (Exception e) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "检索数据返回异常。");
- logger.error("[callout monitor] 检索数据返回异常 {}", j.toString(), e);
- }
- return resp;
- }
-
- /**
- * 获取SIP账号状态
- *
- * @param channel
- * @param sipaccount
- * @return
- */
- private String getSipStatus(String channel, String sipaccount) {
- logger.info("[callout monitor] getSipStatus hash {}, key {}", String.format(Constants.FS_SIP_STATUS, channel), sipaccount);
- String s = redisHashOps.get(String.format(Constants.FS_SIP_STATUS, channel), sipaccount);
- if (s == null)
- return "SIP账号未注册到语音网关或离线中。";
- if (s.equals("空闲"))
- return null;
- return String.format("SIP账号的状态为【%s】,该状态不能完成监听。", s);
- }
-
- /**
- * 监听
- *
- * @param request
- * @param j
- * @return
- */
- private JsonObject dropin(HttpServletRequest request, final JsonObject j) {
- logger.info("[callout] dropin data {}", j.toString());
- JsonObject resp = new JsonObject();
- String callid = null;
- String channel = null;
- // 分析参数
- if (!j.has("callid")) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "通话ID参数不存在。");
- return resp;
- } else {
- callid = j.get("callid").getAsString();
- }
-
- if (!j.has("channel")) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "语音渠道参数不存在。");
- return resp;
- } else {
- channel = j.get("channel").getAsString();
- if (snsAccountRes.findBySnsid(channel) == null) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_6);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "语音渠道不存在。");
- return resp;
- }
- }
-
- User current = super.getUser(request);
- if (current == null) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "无法解析登录账号。");
- return resp;
- }
-
- logger.info("[callout monitor] current isCallcenter {} , getSipaccount {}", current.isCallcenter(), current.getSipaccount());
- if (current.isCallcenter() && StringUtils.isNotBlank(current.getSipaccount())) {
- String status = getSipStatus(channel, current.getSipaccount());
- if (status != null) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_7);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, status);
- return resp;
- }
-
- ChannelTopic ct = new ChannelTopic(String.format(Constants.FS_CHANNEL_CC_TO_FS, channel));
- JsonObject payload = new JsonObject();
- payload.addProperty("ops", "monitor");
- payload.addProperty("uuid", callid);
- payload.addProperty("sip", current.getSipaccount());
- payload.addProperty("channel", channel);
- redis.convertAndSend(ct.getTopic(), payload.toString());
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
- resp.addProperty(RestUtils.RESP_KEY_DATA, "监听任务已经下发,如果该线路还没有被监听,将您接入。");
- } else {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "未绑定SIP账号,无法监听。");
- return resp;
- }
-
- return resp;
- }
-
-
- /**
- * 通话记录
- * 通话记录查询
- * @param request
- * @return
- */
- @RequestMapping(method = RequestMethod.POST)
- @Menu(type = "apps", subtype = "callout", access = true)
- public ResponseEntity execute(HttpServletRequest request, @RequestBody final String body) throws CalloutRecordException {
- logger.info("[callout monitor] raw payload {}", body);
- final JsonObject j = (new JsonParser()).parse(body).getAsJsonObject();
- JsonObject json = new JsonObject();
- HttpHeaders headers = RestUtils.header();
-
- if (!j.has("ops")) {
- json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
- json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
- } else {
- switch (StringUtils.lowerCase(j.get("ops").getAsString())) {
- case "status": // 根据语音渠道获取状态
- json = status(j);
- break;
- case "dropin":
- json = dropin(request, j);
- break;
- default:
- json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
- json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的操作。");
- }
- }
- return new ResponseEntity(json.toString(), headers, HttpStatus.OK);
- }
-
-
-}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiCallRecordsController.java b/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiCallRecordsController.java
deleted file mode 100644
index 0ba67a68..00000000
--- a/contact-center/app/src/main/java/com/chatopera/cc/handler/api/rest/ApiCallRecordsController.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * Copyright (C) 2018 Chatopera Inc,
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.chatopera.cc.handler.api.rest;
-
-import com.chatopera.cc.basic.MainContext;
-import com.chatopera.cc.handler.Handler;
-import com.chatopera.cc.handler.api.request.RestUtils;
-import com.chatopera.cc.model.SNSAccount;
-import com.chatopera.cc.model.StatusEvent;
-import com.chatopera.cc.model.User;
-import com.chatopera.cc.persistence.repository.OrganRepository;
-import com.chatopera.cc.persistence.repository.SNSAccountRepository;
-import com.chatopera.cc.persistence.repository.StatusEventRepository;
-import com.chatopera.cc.persistence.repository.UserRepository;
-import com.chatopera.cc.persistence.storage.MinioService;
-import com.chatopera.cc.exception.CalloutRecordException;
-import com.chatopera.cc.basic.Constants;
-import com.chatopera.cc.util.MathHelper;
-import com.chatopera.cc.util.Menu;
-import com.chatopera.cc.proxy.UserProxy;
-import com.chatopera.cc.util.callout.CalloutHangupAggsResult;
-import com.chatopera.cc.util.callout.CalloutHangupAuditResult;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import io.minio.errors.*;
-import org.apache.commons.collections4.SetUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DateUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Sort;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-import org.xmlpull.v1.XmlPullParserException;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.text.ParseException;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * 通话记录
- * 按条件查询通话记录
- */
-@RestController
-@RequestMapping("/api/callout/records")
-public class ApiCallRecordsController extends Handler {
- private static final Logger logger = LoggerFactory.getLogger(ApiCallRecordsController.class);
-
- @Autowired
- StatusEventRepository statusEventRes;
-
- @Autowired
- MinioService minioService;
-
- @Autowired
- SNSAccountRepository snsAccountRes;
-
- @Autowired
- OrganRepository organRes;
-
- @Autowired
- UserRepository userRes;
-
- /**
- * 处理日期格式
- *
- * @return
- */
- private Date enddate(final JsonObject j) throws ParseException {
- if (j.has("enddate")) {
- Date end = Constants.QUERY_DATE_FORMATTER.parse(j.get("enddate").getAsString());
- return end;
- }
- return null;
- }
-
- /**
- * 处理日期格式
- *
- * @return
- */
- private Date fromdate(final JsonObject j) throws ParseException {
- if (j.has("fromdate")) {
- Date from = Constants.QUERY_DATE_FORMATTER.parse(j.get("fromdate").getAsString());
- return from;
- }
- return null;
- }
-
- /**
- * 查询通话记录
- *
- * @return
- */
- private JsonObject query(final HttpServletRequest request, final JsonObject j) {
- JsonObject resp = new JsonObject();
- Date fromdate, enddate;
-
- try {
- // 分析查询起止日期
- try {
- fromdate = fromdate(j);
- } catch (ParseException e) {
- fromdate = null;
- }
-
- try {
- enddate = enddate(j);
- } catch (ParseException e) {
- enddate = null;
- }
-
- if ((fromdate != null) && (enddate != null)) {
- if (fromdate.after(enddate)) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "开始日期不得晚于结束日期。");
- return resp;
- }
- }
-
-
- // 其他查询参数
- String organ = j.has("organ") ? j.get("organ").getAsString() : null;
- String agent = j.has("agent") ? j.get("agent").getAsString() : null;
- String called = j.has("called") ? j.get("called").getAsString() : null;
-
- Page records = statusEventRes.queryCalloutDialplanSuccRecords(fromdate,
- DateUtils.addDays(enddate, 1),
- organ,
- agent,
- called,
- MainContext.CallType.OUT.toString(),// 呼出
- MainContext.CallServiceStatus.HANGUP.toString(),// 挂机
- null, // Dialplan,null代表所有外呼
- new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
-
- JsonArray ja = new JsonArray();
- for (StatusEvent record : records) {
- JsonObject jo = new JsonObject();
- jo.addProperty("id", record.getId());
- jo.addProperty("name", record.getName()); // 访客名字
- jo.addProperty("duration", record.getDuration()); // 通话时间,秒
- jo.addProperty("called", record.getCalled()); // 被叫号码
- jo.addProperty("calledcity", record.getCity());
- jo.addProperty("calledprovince", record.getProvince());
- jo.addProperty("agent", record.getAgent()); // 坐席ID
- jo.addProperty("agentname", record.getAgentname()); // 坐席名字
- jo.addProperty("calltype", record.getCalltype()); // 呼叫类型
- jo.addProperty("direction", record.getDirection()); // 呼叫方向
- jo.addProperty("starttime", Constants.DISPLAY_DATE_FORMATTER.format(record.getStarttime())); // 开始时间
- jo.addProperty("endtime", Constants.DISPLAY_DATE_FORMATTER.format(record.getEndtime())); // 结束时间
- jo.addProperty("organ", record.getOrgan()); // 部门名字
- jo.addProperty("organid", record.getOrganid()); // 部门ID
- jo.addProperty("recordingfile", record.getRecordingfile()); // 录音文件标识
- jo.addProperty("status", record.getStatus()); // 状态代码
- ja.add(jo);
- }
-
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
- resp.add("data", ja);
- resp.addProperty("size", records.getSize()); // 每页条数
- resp.addProperty("number", records.getNumber()); // 当前页
- resp.addProperty("totalPage", records.getTotalPages()); // 所有页
- resp.addProperty("totalElements", records.getTotalElements()); // 所有检索结果数量
- } catch (Exception e) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "检索数据返回异常。");
- logger.error("[callout records] 检索数据返回异常 {}", j.toString(), e);
- }
- return resp;
- }
-
- /**
- * 获取录音文件的路径
- *
- * @param j
- * @return
- */
- private JsonObject wav(JsonObject j) {
- JsonObject resp = new JsonObject();
- if (j.has("file")) {
- final String file = j.get("file").getAsString();
- try {
- String url = minioService.presignedGetObject(Constants.MINIO_BUCKET, file);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
- JsonObject data = new JsonObject();
- data.addProperty("url", url);
- resp.add(RestUtils.RESP_KEY_DATA, data);
- } catch (InvalidBucketNameException e) {
- logger.error("[callout records] 无效的bucket {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "无效的存储桶");
- } catch (NoSuchAlgorithmException e) {
- logger.error("[callout records] NoSuchAlgorithmException {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "获取文件地址失败,请联系管理员。");
- } catch (InsufficientDataException e) {
- logger.error("[callout records] 数据损坏 {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "该数据已损坏。");
- } catch (IOException e) {
- logger.error("[callout records] 读写异常 {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "文件读写异常。");
- } catch (InvalidKeyException e) {
- logger.error("[callout records] 密钥无效。 {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "获取文件密钥无效,请联系管理员。");
- } catch (NoResponseException e) {
- logger.error("[callout records] 存储服务无返回。 {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "存储服务无返回。");
- } catch (XmlPullParserException e) {
- logger.error("[callout records] XML解析错误 {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "XML解析错误。");
- } catch (ErrorResponseException e) {
- logger.error("[callout records] 存储服务错误返回 {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "存储服务错误返回。");
- } catch (InternalException e) {
- logger.error("[callout records] 内部异常 {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "内部异常。");
- } catch (InvalidExpiresRangeException e) {
- logger.error("[callout records] 过期时间设置错误 {}", j.toString(), e);
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "过期时间设置错误。");
- }
- } else {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, "请求参数错误,没有文件标识。");
- }
-
- return resp;
- }
-
- /**
- * 验证聚合请求的参数
- *
- * @param j
- * @return
- */
- private String validateAggBody(JsonObject j) {
- // 检索语音渠道
- if (!j.has("channel")) {
- return "语音渠道标识参数不存在。";
- } else {
- SNSAccount snsAccount = snsAccountRes.findBySnsid(j.get("channel").getAsString());
- if (snsAccount == null) // 不存在该渠道
- return "该语音渠道不存在。";
- }
-
- // 检索日期
- if (!j.has("datestr")) {
- return "日期参数不存在。";
- } else {
- try {
- Constants.QUERY_DATE_FORMATTER.parse(j.get("datestr").getAsString());
- } catch (ParseException e) {
- return "日期参数不合法。";
- }
- }
-
- // 呼叫类型
- if (!j.has("direction")) {
- return "呼叫类型参数不存在。";
- } else if (Constants.CALL_DIRECTION_TYPES.contains(j.get("direction").getAsString())) {
- return null;
- } else {
- return "呼叫类型不合法。";
- }
- }
-
- /**
- * 外呼日报:返回聚合数据
- *
- * @param j
- * @return
- */
- private JsonObject agg(final JsonObject j) {
- JsonObject resp = new JsonObject();
- String valid = validateAggBody(j);
-
- // 参数有误
- if (valid != null) {
- resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
- resp.addProperty(RestUtils.RESP_KEY_ERROR, valid);
- return resp;
- }
-
- // 解析参数
- final String channel = j.get("channel").getAsString();
- final String datestr = j.get("datestr").getAsString();
- final String direction = j.get("direction").getAsString();
-
- List