diff --git a/cc-chatbot/app/pom.xml b/cc-chatbot/app/pom.xml
index 64cc275d..09879747 100644
--- a/cc-chatbot/app/pom.xml
+++ b/cc-chatbot/app/pom.xml
@@ -6,7 +6,7 @@
com.chatopera.chatbot
sdk
- 1.0.3
+ 1.1.0
jar
sdk
@@ -20,16 +20,6 @@
-
- org.slf4j
- slf4j-api
- 1.7.25
-
-
- org.slf4j
- slf4j-simple
- 1.7.25
-
org.apache.commons
commons-lang3
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
index 2c1d5494..1a65bea7 100644
--- a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java
+++ b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java
@@ -18,15 +18,12 @@ package com.chatopera.chatbot;
import com.mashape.unirest.http.exceptions.UnirestException;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
public class ChatbotAPI {
- private static final Logger logger = LoggerFactory.getLogger(ChatbotAPI.class);
private String schema;
private String hostname;
private int port;
@@ -179,6 +176,7 @@ public class ChatbotAPI {
* @throws ChatbotAPIRuntimeException
*/
public boolean updateByChatbotID(final String chatbotID,
+ final String name,
final String description,
final String fallback,
final String welcome) throws ChatbotAPIRuntimeException {
@@ -192,6 +190,8 @@ public class ChatbotAPI {
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);
@@ -275,8 +275,6 @@ public class ChatbotAPI {
body.put("textMessage", textMessage);
body.put("isDebug", debug);
- logger.info("conversation body {}", body);
-
try {
JSONObject resp = RestAPI.post(this.getBaseUrl() + "/chatbot/" + chatbotID + "/conversation/query", body);
return resp;
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
index d85a693c..ee5f7e57 100644
--- a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java
+++ b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java
@@ -22,8 +22,6 @@ import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import com.mashape.unirest.request.HttpRequestWithBody;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.HashMap;
@@ -31,7 +29,6 @@ import java.util.HashMap;
* RestAPI接口
*/
public class RestAPI {
- private static final Logger logger = LoggerFactory.getLogger(RestAPI.class);
/**
* patch headers
@@ -66,7 +63,6 @@ public class RestAPI {
*/
public static JSONObject post(final String url, final HashMap body, final HashMap query, HashMap headers) throws UnirestException {
HttpRequestWithBody request = Unirest.post(url);
- logger.info("post body {}", body.toString());
x(headers);
HttpResponse resp = request
.headers(headers)
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
index 7dfb4ec6..303ed688 100644
--- a/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java
+++ b/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java
@@ -19,8 +19,6 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.net.MalformedURLException;
@@ -29,7 +27,6 @@ import java.net.MalformedURLException;
*/
public class ChatbotAPITest
extends TestCase {
- private static final Logger logger = LoggerFactory.getLogger(ChatbotAPITest.class);
private ChatbotAPI cb;
/**
@@ -62,7 +59,7 @@ public class ChatbotAPITest
public void testGetChatbot() {
try {
JSONObject resp = this.cb.getChatbot("co_bot_1");
- logger.info("[testGetChatbot] {}", resp.toString());
+ System.out.println("[testGetChatbot] " + resp.toString());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
@@ -71,7 +68,7 @@ public class ChatbotAPITest
public void testGetChatbots() {
try {
JSONObject resp = this.cb.getChatbots("name chatbotID", null, 0, 10);
- logger.info("[testGetChatbots] resp {}", resp.toString());
+ System.out.println("[testGetChatbots] resp " + resp.toString());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
@@ -80,7 +77,7 @@ public class ChatbotAPITest
public void testConversation() {
try {
JSONObject resp = this.cb.conversation("co_bot_1", "sdktest", "华夏春松在哪里", false);
- logger.info("[testConversation] resp {}", resp.toString());
+ System.out.println("[testConversation] resp " + resp.toString());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
@@ -89,7 +86,7 @@ public class ChatbotAPITest
public void testFaq() {
try {
JSONObject resp = this.cb.faq("co_bot_1", "sdktest", "华夏春松在哪里", false);
- logger.info("[testFaq] resp {}", resp.toString());
+ System.out.print("[testFaq] resp " + resp.toString());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
@@ -98,7 +95,7 @@ public class ChatbotAPITest
public void testParseUrl() {
try {
ChatbotAPI c = new ChatbotAPI("https://local:8000/");
- logger.info("chatbot baseUrl {}", c.getBaseUrl());
+ System.out.println("chatbot baseUrl " + c.getBaseUrl());
assertEquals("https://local:8000/api/v1", c.getBaseUrl());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
@@ -124,7 +121,6 @@ public class ChatbotAPITest
"我不了解。",
"小云机器人",
"你好,我是小云。");
- logger.info("[testCreateBot] {}", j);
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
diff --git a/contact-center/app/pom.xml b/contact-center/app/pom.xml
index 8c5efd09..e21195a8 100644
--- a/contact-center/app/pom.xml
+++ b/contact-center/app/pom.xml
@@ -312,7 +312,7 @@
com.chatopera.chatbot
sdk
- 1.0.3
+ 1.1.0
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/util/chatbot/ChatbotUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/webim/util/chatbot/ChatbotUtils.java
index 29d54a16..955823a2 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/util/chatbot/ChatbotUtils.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/webim/util/chatbot/ChatbotUtils.java
@@ -32,7 +32,7 @@ public class ChatbotUtils {
* @return
*/
public static String resolveChatbotIDWithSnsid(String snsid, String clientId) {
- return clientId + "_" + snsid;
+ return (clientId + "_" + snsid).toLowerCase();
}
/**
@@ -42,6 +42,6 @@ public class ChatbotUtils {
* @return
*/
public static String resolveSnsidWithChatbotID(String chatbotID, String clientId) {
- return StringUtils.remove(chatbotID, clientId + "_");
+ return StringUtils.remove(chatbotID, clientId.toLowerCase() + "_");
}
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/admin/channel/SNSAccountIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/admin/channel/SNSAccountIMController.java
index 57e7defb..61ab1da0 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/admin/channel/SNSAccountIMController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/admin/channel/SNSAccountIMController.java
@@ -50,7 +50,7 @@ import com.chatopera.cc.webim.web.model.Secret;
@Controller
@RequestMapping("/admin/im")
public class SNSAccountIMController extends Handler{
-
+
@Autowired
private SNSAccountRepository snsAccountRes;
@@ -84,7 +84,7 @@ public class SNSAccountIMController extends Handler{
@Menu(type = "admin" , subtype = "weixin")
public ModelAndView save(HttpServletRequest request ,@Valid SNSAccount snsAccount) throws NoSuchAlgorithmException {
if(!StringUtils.isBlank(snsAccount.getBaseURL())){
- snsAccount.setSnsid(Base62.encode(snsAccount.getBaseURL()));
+ snsAccount.setSnsid(Base62.encode(snsAccount.getBaseURL()).toLowerCase());
int count = snsAccountRes.countBySnsidAndOrgi(snsAccount.getSnsid() , super.getOrgi(request)) ;
if(count == 0){
snsAccount.setOrgi(super.getOrgi(request));
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/api/rest/ApiChatbotController.java b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/api/rest/ApiChatbotController.java
index 12c8d2c3..9bf0947c 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/api/rest/ApiChatbotController.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/api/rest/ApiChatbotController.java
@@ -148,12 +148,13 @@ public class ApiChatbotController extends Handler {
String description = j.has("description") ? j.get("description").getAsString() : null;
String fallback = j.has("fallback") ? j.get("fallback").getAsString() : null;
String welcome = j.has("welcome") ? j.get("welcome").getAsString() : null;
+ String name = j.has("name") ? j.get("name").getAsString() : null;
if (StringUtils.isNotBlank(description) ||
StringUtils.isNotBlank(fallback) ||
StringUtils.isNotBlank(welcome)) {
try {
- if (c.getApi().updateByChatbotID(c.getChatbotID(), description, fallback, welcome)) {
+ if (c.getApi().updateByChatbotID(c.getChatbotID(), name, description, fallback, welcome)) {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty(RestUtils.RESP_KEY_DATA, "更新成功。");
} else {
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/model/SNSAccount.java b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/model/SNSAccount.java
index eb6cfb43..4a2ef9ba 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/model/SNSAccount.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/model/SNSAccount.java
@@ -33,6 +33,8 @@ import org.hibernate.annotations.GenericGenerator;
@org.hibernate.annotations.Proxy(lazy = false)
public class SNSAccount{
private String id ;
+
+ @Column(unique=true)
private String snsid ; //表示 SNSAccount
private String name ;
private String code ;
diff --git a/contact-center/config/postman/Chatopera_cc_v1.postman_collection.json b/contact-center/config/postman/Chatopera_cc_v1.postman_collection.json
index 546f257e..e97b8f47 100644
--- a/contact-center/config/postman/Chatopera_cc_v1.postman_collection.json
+++ b/contact-center/config/postman/Chatopera_cc_v1.postman_collection.json
@@ -533,7 +533,7 @@
"header": [
{
"key": "authorization",
- "value": "00bf99785103475c896435ef7216ebd1"
+ "value": "b641622ea4c54f1e9e45520e7fed266b"
},
{
"key": "Content-Type",
@@ -542,7 +542,7 @@
],
"body": {
"mode": "raw",
- "raw": "{\n \"ops\": \"create\",\n \"primaryLanguage\": \"zh_CN\",\n \"snsid\": \"104EAc\",\n \"name\": \"小C\",\n \"baseUrl\": \"http://lhc-dev:8003\",\n \"description\": \"描述\",\n \"fallback\": \"我不理解。\",\n \"welcome\": \"你好\",\n \"workmode\": \"客服机器人优先\"\n}"
+ "raw": "{\n \"ops\": \"create\",\n \"primaryLanguage\": \"zh_CN\",\n \"snsid\": \"104eac\",\n \"name\": \"小C\",\n \"baseUrl\": \"http://lhc-dev:8003\",\n \"description\": \"描述\",\n \"fallback\": \"我不理解。\",\n \"welcome\": \"你好\",\n \"workmode\": \"客服机器人优先\"\n}"
},
"url": {
"raw": "http://{{IP}}:{{PORT}}/api/chatbot",
@@ -566,7 +566,7 @@
"header": [
{
"key": "authorization",
- "value": "8b9567161da54400b994f141d119100b"
+ "value": "869c0e6dfd44421cabea7934d6fde218"
},
{
"key": "Content-Type",
@@ -591,6 +591,39 @@
}
},
"response": []
+ },
+ {
+ "name": "机器人客服:更新",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "authorization",
+ "value": "b641622ea4c54f1e9e45520e7fed266b"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"ops\": \"update\",\n \"id\": \"54509c828fcd4d0e9709a975a04bf190\",\n \"workmode\": \"\",\n \"enabled\": false,\n \"description\": \"描述\",\n \"fallback\": \"我不知道。\",\n \"welcome\": \"你好!\",\n \"name\": \"cc\"\n}"
+ },
+ "url": {
+ "raw": "http://{{IP}}:{{PORT}}/api/chatbot",
+ "protocol": "http",
+ "host": [
+ "{{IP}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "chatbot"
+ ]
+ }
+ },
+ "response": []
}
],
"event": [