From 7ac4b59029e70fd05859078810c47f3a3863cf32 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sun, 29 May 2022 10:26:51 +0800 Subject: [PATCH] https://github.com/chatopera/cskefu/issues/704 shift chatbot code as a plugin, set it as base codes directly --- contact-center/app/.gitignore | 4 +- .../src/main/java/com/chatopera/cc/.gitignore | 3 + .../java/com/chatopera/cc/plugins/.gitignore | 2 - .../java/com/chatopera/cc/plugins/README.md | 0 .../chatbot}/ApiChatbotController.java | 0 .../cc/plugins/chatbot}/ChatbotComposer.java | 0 .../cc/plugins/chatbot}/ChatbotConstants.java | 0 .../cc/plugins/chatbot}/ChatbotContext.java | 0 .../plugins/chatbot}/ChatbotController.java | 0 .../plugins/chatbot}/ChatbotEventHandler.java | 0 .../chatbot}/ChatbotEventSubscription.java | 0 .../chatbot}/ChatbotPluginConfigurer.java | 0 .../cc/plugins/chatbot}/ChatbotProxy.java | 0 .../chatbot}/ChatbotSocketIOConfigurer.java | 0 .../templates/admin}/system/chatbot/edit.pug | 0 .../admin}/system/chatbot/include/left.pug | 0 .../templates/admin}/system/chatbot/index.pug | 0 public/plugins/README.md | 6 +- public/plugins/chatbot/README.md | 28 ------ public/plugins/chatbot/scripts/install.sh | 91 ------------------- public/plugins/chatbot/scripts/uninstall.sh | 59 ------------ public/plugins/scripts/install-all.sh | 4 +- public/plugins/scripts/uninstall-all.sh | 2 +- 23 files changed, 8 insertions(+), 191 deletions(-) create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/.gitignore delete mode 100644 contact-center/app/src/main/java/com/chatopera/cc/plugins/.gitignore create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/plugins/README.md rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ApiChatbotController.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotComposer.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotConstants.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotContext.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotController.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotEventHandler.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotEventSubscription.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotPluginConfigurer.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotProxy.java (100%) rename {public/plugins/chatbot/classes => contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot}/ChatbotSocketIOConfigurer.java (100%) rename {public/plugins/chatbot/views => contact-center/app/src/main/resources/templates/admin}/system/chatbot/edit.pug (100%) rename {public/plugins/chatbot/views => contact-center/app/src/main/resources/templates/admin}/system/chatbot/include/left.pug (100%) rename {public/plugins/chatbot/views => contact-center/app/src/main/resources/templates/admin}/system/chatbot/index.pug (100%) delete mode 100644 public/plugins/chatbot/README.md delete mode 100755 public/plugins/chatbot/scripts/install.sh delete mode 100755 public/plugins/chatbot/scripts/uninstall.sh diff --git a/contact-center/app/.gitignore b/contact-center/app/.gitignore index 2d941f0e..e1dd3832 100644 --- a/contact-center/app/.gitignore +++ b/contact-center/app/.gitignore @@ -7,9 +7,7 @@ src/main/resources/templates/admin/channel/* # ignore app views within plugins src/main/resources/templates/apps/callout -src/main/resources/templates/apps/chatbot src/main/resources/templates/apps/callcenter -# ignore system views for chatbot -src/main/resources/templates/admin/system/chatbot +# ignore logs logs/ diff --git a/contact-center/app/src/main/java/com/chatopera/cc/.gitignore b/contact-center/app/src/main/java/com/chatopera/cc/.gitignore new file mode 100644 index 00000000..6acddf6c --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/.gitignore @@ -0,0 +1,3 @@ +plugins/* +!plugins/chatbot +!plugins/README.md \ No newline at end of file diff --git a/contact-center/app/src/main/java/com/chatopera/cc/plugins/.gitignore b/contact-center/app/src/main/java/com/chatopera/cc/plugins/.gitignore deleted file mode 100644 index d6b7ef32..00000000 --- a/contact-center/app/src/main/java/com/chatopera/cc/plugins/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/contact-center/app/src/main/java/com/chatopera/cc/plugins/README.md b/contact-center/app/src/main/java/com/chatopera/cc/plugins/README.md new file mode 100644 index 00000000..e69de29b diff --git a/public/plugins/chatbot/classes/ApiChatbotController.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ApiChatbotController.java similarity index 100% rename from public/plugins/chatbot/classes/ApiChatbotController.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ApiChatbotController.java diff --git a/public/plugins/chatbot/classes/ChatbotComposer.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotComposer.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotComposer.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotComposer.java diff --git a/public/plugins/chatbot/classes/ChatbotConstants.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotConstants.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotConstants.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotConstants.java diff --git a/public/plugins/chatbot/classes/ChatbotContext.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotContext.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotContext.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotContext.java diff --git a/public/plugins/chatbot/classes/ChatbotController.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotController.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotController.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotController.java diff --git a/public/plugins/chatbot/classes/ChatbotEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotEventHandler.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotEventHandler.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotEventHandler.java diff --git a/public/plugins/chatbot/classes/ChatbotEventSubscription.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotEventSubscription.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotEventSubscription.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotEventSubscription.java diff --git a/public/plugins/chatbot/classes/ChatbotPluginConfigurer.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotPluginConfigurer.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotPluginConfigurer.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotPluginConfigurer.java diff --git a/public/plugins/chatbot/classes/ChatbotProxy.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotProxy.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotProxy.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotProxy.java diff --git a/public/plugins/chatbot/classes/ChatbotSocketIOConfigurer.java b/contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotSocketIOConfigurer.java similarity index 100% rename from public/plugins/chatbot/classes/ChatbotSocketIOConfigurer.java rename to contact-center/app/src/main/java/com/chatopera/cc/plugins/chatbot/ChatbotSocketIOConfigurer.java diff --git a/public/plugins/chatbot/views/system/chatbot/edit.pug b/contact-center/app/src/main/resources/templates/admin/system/chatbot/edit.pug similarity index 100% rename from public/plugins/chatbot/views/system/chatbot/edit.pug rename to contact-center/app/src/main/resources/templates/admin/system/chatbot/edit.pug diff --git a/public/plugins/chatbot/views/system/chatbot/include/left.pug b/contact-center/app/src/main/resources/templates/admin/system/chatbot/include/left.pug similarity index 100% rename from public/plugins/chatbot/views/system/chatbot/include/left.pug rename to contact-center/app/src/main/resources/templates/admin/system/chatbot/include/left.pug diff --git a/public/plugins/chatbot/views/system/chatbot/index.pug b/contact-center/app/src/main/resources/templates/admin/system/chatbot/index.pug similarity index 100% rename from public/plugins/chatbot/views/system/chatbot/index.pug rename to contact-center/app/src/main/resources/templates/admin/system/chatbot/index.pug diff --git a/public/plugins/README.md b/public/plugins/README.md index f5f0bf12..60ca5b92 100644 --- a/public/plugins/README.md +++ b/public/plugins/README.md @@ -31,6 +31,7 @@ cd plugins/PLUGIN ``` ## 应用打包 + 安装插件后,插件开发过程同[春松客服开发环境搭建](https://docs.chatopera.com/products/cskefu/osc/engineering.html)。 如果需要部署到系统测试、生产环境等,首先打包为 WAR 应用,方式如下: @@ -41,8 +42,3 @@ cd contact-center ``` 春松客服的发布形式为 Docker 镜像,如果在更改源码后,也可以使用春松客服的 Docker 镜像构建脚本发布,参考[构建脚本](https://github.com/chatopera/cskefu/blob/osc/contact-center/admin/build.sh)。 - -## 机器人客服 - -- [源码和安装说明](./chatbot) -- [使用介绍](https://docs.chatopera.com/products/cskefu/work-chatbot/index.html) diff --git a/public/plugins/chatbot/README.md b/public/plugins/chatbot/README.md deleted file mode 100644 index e9c15a50..00000000 --- a/public/plugins/chatbot/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# 春松客服智能机器人插件 - -## 使用介绍 - -[春松客服机器人客服文档](https://docs.chatopera.com/products/cskefu/work-chatbot.html) - -## 安装插件 - -``` -./scripts/install.sh -``` - -## 卸载插件 - -``` -./scripts/uninstall.sh -``` - -## 开源许可协议 - -Copyright (2018-2019) 北京华夏春松科技有限公司 - -[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/public/plugins/chatbot/scripts/install.sh b/public/plugins/chatbot/scripts/install.sh deleted file mode 100755 index a68728b4..00000000 --- a/public/plugins/chatbot/scripts/install.sh +++ /dev/null @@ -1,91 +0,0 @@ -#! /bin/bash -########################################### -# Install Plugin -# Copyright (2019-2020) 北京华夏春松科技有限公司 -########################################### - -# constants -## for windows platform -export MSYS=winsymlinks:nativestrict - -baseDir=$(cd `dirname "$0"`;pwd) -rootDir=$(cd -P $baseDir/..;pwd) -upperDir=$(cd -P $rootDir/..;pwd) -CSKEFU_ROOT=$(cd -P $upperDir/../..;pwd) -pluginName=$(basename $rootDir) - -# functions - -# main -[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return -cd $rootDir/.. -echo "[plugins] path" `pwd` - -if [ -d $CSKEFU_ROOT ]; then - PLUGINS_DIR=$CSKEFU_ROOT/contact-center/app/src/main/java/com/chatopera/cc/plugins - echo "[plugin] link" $rootDir "as" $pluginName "..." - if [ ! -d $PLUGINS_DIR ]; then - mkdir -p $PLUGINS_DIR - fi - - cd $PLUGINS_DIR - pwd - if [ -e $pluginName ]; then - rm -rf $pluginName - fi - - echo "[plugin] link source codes" - ln -s $rootDir/classes $pluginName - - # Install channel views - if [ -d $rootDir/views/channel/$pluginName ]; then - echo "[plugin] unlink views for channel" - VIEW_ADMIN_CHANNEL=$CSKEFU_ROOT/contact-center/app/src/main/resources/templates/admin/channel - - if [ -d $VIEW_ADMIN_CHANNEL/$pluginName ]; then - rm -rf $VIEW_ADMIN_CHANNEL/$pluginName - fi - - cd $VIEW_ADMIN_CHANNEL - ln -s $rootDir/views/channel/$pluginName . - else - echo "[plugin] channel views not present" - fi - - # Install apps view - if [ -d $rootDir/views/apps/$pluginName ]; then - echo "[plugin] unlink views for apps" - VIEW_ADMIN_APPS=$CSKEFU_ROOT/contact-center/app/src/main/resources/templates/apps - - if [ -d $VIEW_ADMIN_APPS/$pluginName ]; then - rm -rf $VIEW_ADMIN_APPS/$pluginName - fi - - cd $VIEW_ADMIN_APPS - ln -s $rootDir/views/apps/$pluginName . - else - echo "[plugin] apps views not present" - fi - - # Install admin/system view - if [ -d $rootDir/views/system/$pluginName ]; then - echo "[plugin] unlink views for system" - VIEW_ADMIN_SYSTEM=$CSKEFU_ROOT/contact-center/app/src/main/resources/templates/admin/system - - if [ -d $VIEW_ADMIN_SYSTEM/$pluginName ]; then - rm -rf $VIEW_ADMIN_SYSTEM/$pluginName - fi - - cd $VIEW_ADMIN_SYSTEM - ln -s $rootDir/views/system/$pluginName . - echo "[note] remember to ignore src/main/resources/templates/admin/system/chatbot in contact-center/app/.gitignore" - else - echo "[plugin] system views not present" - fi - - - echo "[plugin] install done." -else - echo "[error] not found cosinee dir." - exit 2 -fi \ No newline at end of file diff --git a/public/plugins/chatbot/scripts/uninstall.sh b/public/plugins/chatbot/scripts/uninstall.sh deleted file mode 100755 index ea4ea227..00000000 --- a/public/plugins/chatbot/scripts/uninstall.sh +++ /dev/null @@ -1,59 +0,0 @@ -#! /bin/bash -########################################### -# Uninstall Plugin -# Copyright (2019) 北京华夏春松科技有限公司 -########################################### - -# constants -## for windows platform -export MSYS=winsymlinks:nativestrict - -baseDir=$(cd `dirname "$0"`;pwd) -rootDir=$(cd -P $baseDir/..;pwd) -upperDir=$(cd -P $rootDir/..;pwd) -COSINEE_BASEDIR=$(cd -P $upperDir/../..;pwd) -pluginName=$(basename $rootDir) - -# functions - -# main -[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return -cd $rootDir/.. -echo "[plugins] path" `pwd` - -if [ -d $COSINEE_BASEDIR ]; then - PLUGINS_DIR=$COSINEE_BASEDIR/contact-center/app/src/main/java/com/chatopera/cc/plugins - echo "[plugin] unlink" $pluginName "..." - if [ ! -d $PLUGINS_DIR ]; then - mkdir -p $PLUGINS_DIR - fi - - cd $PLUGINS_DIR - if [ -L $pluginName ]; then - rm -rf $pluginName - fi - - if [ -d $rootDir/views/channel/$pluginName ]; then - echo "[plugin] unlink views for channel" - VIEW_ADMIN_CHANNEL=$COSINEE_BASEDIR/contact-center/app/src/main/resources/templates/admin/channel - - if [ -L $VIEW_ADMIN_CHANNEL/$pluginName ]; then - rm -rf $VIEW_ADMIN_CHANNEL/$pluginName - fi - fi - - # Install apps view - if [ -d $rootDir/views/apps/$pluginName ]; then - echo "[plugin] unlink views for apps" - VIEW_ADMIN_APPS=$COSINEE_BASEDIR/contact-center/app/src/main/resources/templates/apps - - if [ -L $VIEW_ADMIN_APPS/$pluginName ]; then - rm -rf $VIEW_ADMIN_APPS/$pluginName - fi - fi - - echo "[plugin] uninstall done." -else - echo "[error] not found cosinee dir." - exit 2 -fi \ No newline at end of file diff --git a/public/plugins/scripts/install-all.sh b/public/plugins/scripts/install-all.sh index 2b0749d8..172cf959 100755 --- a/public/plugins/scripts/install-all.sh +++ b/public/plugins/scripts/install-all.sh @@ -1,7 +1,7 @@ #! /bin/bash ########################################### # Install All public plugins -# Copyright (2019) 北京华夏春松科技有限公司 +# Copyright (2019-2022) 北京华夏春松科技有限公司 ########################################### # constants @@ -24,7 +24,7 @@ function install_plugin(){ cd $baseDir/.. echo "Inspect plugins -->" `pwd` for x in `ls .`; do - if [ $x != "scripts" ] && [ -d ./$x ]; then + if [ $x != "scripts" ] && [ $x != "tmp" ] && [ -d ./$x ]; then install_plugin $x echo -e "\n" fi diff --git a/public/plugins/scripts/uninstall-all.sh b/public/plugins/scripts/uninstall-all.sh index 1b61a4b0..51168c40 100755 --- a/public/plugins/scripts/uninstall-all.sh +++ b/public/plugins/scripts/uninstall-all.sh @@ -1,7 +1,7 @@ #! /bin/bash ########################################### # Uninstall all public plugins -# Copyright (2019) 北京华夏春松科技有限公司 +# Copyright (2019-2022) 北京华夏春松科技有限公司 ########################################### # constants