提交 6974275b 编写于 作者: Chatopera 研发团队's avatar Chatopera 研发团队

https://github.com/chatopera/cosin/issues/373 release 春松客服 v6, 支持多组织,多管理员

上级 b2fde6a8
......@@ -19,4 +19,5 @@ backups/
.env
build.gradle
.vscode/
nohup.out
private
Copyright 2018-2020 Chatopera Inc. <https://www.chatopera.com>. All rights reserved.
Copyright (2018-2020) Chatopera Inc. <https://www.chatopera.com>. 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.
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
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,
......
......@@ -122,9 +122,9 @@ The collaboration is efficient, very professional. The software is steady with h
寻找开发者合作智能客服项目,社区共建,携手共赢!
* 组织或个人,在春松客服主页展示为认证开发者
* 春松客服官方推荐项目机会
* 专访并通过官方渠道曝光
- 组织或个人,在春松客服主页展示为认证开发者
- 春松客服官方推荐项目机会
- 专访并通过官方渠道曝光
填写申请:[https://www.wjx.top/jq/93397428.aspx](https://www.wjx.top/jq/93397428.aspx)
......@@ -135,8 +135,6 @@ The collaboration is efficient, very professional. The software is steady with h
<img src="https://static-public.chatopera.com/assets/images/44915395-6bff5d80-ad65-11e8-817a-8abb812fb5ee.png" width="900">
</p>
<details>
<summary>展开查看更多产品截图</summary>
<p>
......@@ -185,7 +183,6 @@ The collaboration is efficient, very professional. The software is steady with h
参考部署[开源社区版本文档](https://docs.chatopera.com/products/cskefu/deploy.html)
## 鸣谢
[FreeSWITCH 中国社区](http://www.freeswitch.org.cn/)
......@@ -201,8 +198,6 @@ Copyright (2018-2020) <a href="https://www.chatopera.com/" target="_blank">北
[co-banner-image]: https://static-public.chatopera.com/assets/images/42383104-da925942-8168-11e8-8195-868d5fcec170.png
[co-url]: https://www.chatopera.com
## Chatopera 云服务
[https://bot.chatopera.com/](https://bot.chatopera.com/)
......@@ -263,7 +258,6 @@ Chatopera 机器人平台包括知识库、多轮对话、意图识别和语音
</p>
</details>
<p align="center">
<b>立即使用</b><br>
<a href="https://bot.chatopera.com" target="_blank">
......
app/target
!app/target/*.war.original
!app/target/*.war
!app/target/*.jar.original
!app/target/*.jar
logs/
tmp/
data/
......@@ -38,7 +38,7 @@ RUN /bin/bash -c "mkdir -p /{data,logs}"
# build WAR
RUN mkdir -p /opt/chatopera
COPY ./app/target/contact-center-*.war /opt/chatopera/contact-center.war
COPY ./app/target/contact-center.war /opt/chatopera/contact-center.war
COPY ./assets/mysql.setup.db.sh /opt/chatopera
COPY ./assets/mysql.upgrade.db.sh /opt/chatopera
COPY ./assets/utils.sh /opt/chatopera
......
......@@ -29,4 +29,11 @@ docker build --build-arg VCS_REF=$PACKAGE_VERSION \
--build-arg APPLICATION_BUILD_DATESTR=$TIMESTAMP \
--build-arg APPLICATION_CUSTOMER_ENTITY=$APPLICATION_CUSTOMER_ENTITY \
--no-cache \
--force-rm=true --tag $registryName/$imagename:$PACKAGE_VERSION .
\ No newline at end of file
--force-rm=true --tag $registryName/$imagename:$PACKAGE_VERSION .
if [ $? -eq 0 ]; then
docker tag $registryName/$imagename:$PACKAGE_VERSION $registryName/$imagename:develop
else
echo "Build contact-center failure."
exit 1
fi
\ No newline at end of file
#! /bin/bash
###########################################
#
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
REPO_ID_SNP=chatopera-snapshots
REPO_URL_SNP=https://nexus.chatopera.com/repository/maven-snapshots/
REPO_ID_REL=chatopera-releases
REPO_URL_REL=https://nexus.chatopera.com/repository/maven-releases/
# functions
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir/../app
mvn clean jar:jar
PACKAGE_VERSION=$(grep --max-count=1 '<version>' pom.xml | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }')
if [[ $PACKAGE_VERSION == *SNAPSHOT ]]; then
echo "Deploy as snapshot package ..."
mvn deploy:deploy-file \
-Dmaven.test.skip=true \
-Dfile=./target/contact-center.jar \
-DgroupId=com.chatopera.cc \
-DartifactId=cc-core \
-Dversion=$PACKAGE_VERSION \
-Dpackaging=jar \
-DgeneratePom=true \
-DrepositoryId=$REPO_ID_SNP \
-Durl=$REPO_URL_SNP
if [ ! $? -eq 0 ]; then
exit 1
fi
else
echo "Deploy as release package ..."
mvn deploy:deploy-file \
-Dmaven.test.skip=true \
-Dfile=./target/contact-center.jar \
-DgroupId=com.chatopera.cc \
-DartifactId=cc-core \
-Dversion=$PACKAGE_VERSION \
-Dpackaging=jar \
-DgeneratePom=true \
-DrepositoryId=$REPO_ID_REL \
-Durl=$REPO_URL_REL
if [ ! $? -eq 0 ]; then
exit 1
fi
fi
#! /bin/bash
###########################################
#
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
SCRIPT_PATH=$0
ts=`date +"%Y-%m-%d_%H-%M-%S"`
buildDir=/tmp/cc-build-$ts
# functions
function print_usage(){
echo "Install contact-center plugin: $SCRIPT_PATH contact-center_jar_path plugin_path output_path"
}
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
if [ "$#" -ne 4 ]; then
CONTACT_CENTER=$1
CC_PLUGIN=$2
OUTPUT_PATH=$3
if [ ! -f $1 ]; then
echo "contact center jar file not exist."
print_usage
exit 1
fi
if [ ! -f $2 ]; then
echo "cc plugin jar file not exist."
print_usage
exit 2
fi
# create jar
rm -rf $buildDir
mkdir $buildDir
unzip $CONTACT_CENTER -d $buildDir
cp $CC_PLUGIN $buildDir/BOOT-INF/lib
cd $buildDir
jar -cvfM0 $3 .
echo "Created new jar file as" $OUTPUT_PATH "successfully."
echo "Build done, delete buildDir" $buildDir "in 3 seconds ..."
sleep 3
rm -rf $buildDir
else
print_usage
fi
export SERVER_PORT=8035
export SERVER_LOG_PATH=$baseDir/../logs
# Log Level: INFO, DEBUG, ERROR, STDOUT
export SERVER_LOG_LEVEL=INFO
export WEB_UPLOAD_PATH=$baseDir/../data
export SPRING_FREEMARKER_CACHE=false
export SPRING_DATA_ELASTICSEARCH_PROPERTIES_PATH_DATA=$baseDir/../data
export UK_IM_SERVER_PORT=8036
export UK_IM_SERVER_HOST=localhost
export UK_IM_SERVER_THREADS=10
export SPRING_DATASOURCE_TYPE=com.alibaba.druid.pool.DruidDataSource
export SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.jdbc.Driver
export SPRING_DATASOURCE_URL=jdbc:mysql://localhost:8889/ukefu-test?useUnicode=true&characterEncoding=UTF-8
export SPRING_DATASOURCE_USERNAME=root
export SPRING_DATASOURCE_PASSWORD=root
export MANAGEMENT_SECURITY_ENABLED=false
export SPRING_REDIS_DATABASE=2
export SPRING_REDIS_HOST=redis
export SPRING_REDIS_PORT=6379
......@@ -10,7 +10,9 @@ baseDir=$(cd `dirname "$0"`;pwd)
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir/../app
mvn clean package
mvn -DskipTests clean package
# take too long time with dev002 for uploading artifact, skip this operation
# $baseDir/deploy.app.sh
if [ ! $? -eq 0 ]; then
exit 1
......
......@@ -5,12 +5,17 @@
# constants
baseDir=$(cd `dirname "$0"`;pwd)
appHome=$baseDir/..
registryName=dockerhub.qingcloud.com
imagename=chatopera/contact-center
PACKAGE_VERSION=w4l
# functions
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
docker push $registryName/$imagename:$PACKAGE_VERSION
\ No newline at end of file
# build
cd $appHome
PACKAGE_VERSION=`git rev-parse --short HEAD`
docker push $registryName/$imagename:$PACKAGE_VERSION
docker push $registryName/$imagename:develop
\ No newline at end of file
......@@ -9,5 +9,5 @@ baseDir=$(cd `dirname "$0"`;pwd)
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir/../app
mvn eclipse:eclipse
cd $baseDir/../root
mvn deploy
......@@ -5,26 +5,8 @@
# constants
baseDir=$(cd `dirname "$0"`;pwd)
if [ -f $baseDir/localrc ]; then
echo "Load localrc for environment variables ..."
set -x
source $baseDir/localrc
else
echo $baseDir/localrc "not exist."
echo "First, copy and modify the rc template."
echo "cp " $baseDir/localrc.sample $baseDir/localrc
exit 1
fi
# functions
function start(){
cd $baseDir/../app
mvn spring-boot:run
}
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
start
rm -rf ~/.m2/repository/com/chatopera/cc
# dev profile
src/main/resources/application-dev.properties
# ignore plugins source code
src/main/java/com/chatopera/cc/plugins/
# ignore channel views within plugins
src/main/resources/templates/admin/channel/*
!src/main/resources/templates/admin/channel/im
......@@ -11,3 +8,5 @@ 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
logs/
......@@ -3,382 +3,31 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.chatopera.cc</groupId>
<artifactId>contact-center</artifactId>
<version>5.1.0</version>
<packaging>war</packaging>
<name>cskefu</name>
<name>cc-core</name>
<description>春松客服:多渠道智能客服系统</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<groupId>com.chatopera.cc</groupId>
<artifactId>cc-root</artifactId>
<version>6.0.0-SNAPSHOT</version>
<relativePath/>
<!-- for local reference if file is available with latest version -->
<!-- <relativePath>../cc-root/pom.xml</relativePath> -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.14.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.29</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>1.5.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>jaudiotagger</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>lt.jave</groupId>
<artifactId>jave</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Hypermedia for actuator MVC endpoints -->
<!-- https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/html/production-ready-endpoints.html#production-ready-endpoint-hypermedia -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<!-- Micrometer Prometheus registry -->
<!-- https://www.callicoder.com/spring-boot-actuator-metrics-monitoring-dashboard-prometheus-grafana/ -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-spring-legacy</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<!-- AOP dependencies -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.27</version>
</dependency>
<dependency>
<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
<version>2.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-dbutils/commons-dbutils -->
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/de.odysseus.juel/juel-impl -->
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
<version>2.2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>12.1.0.1-atlassian-hosted</version>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.olap4j</groupId>
<artifactId>olap4j</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>mondrian</groupId>
<artifactId>mondrian</artifactId>
<version>3.7.0</version>
</dependency>
<!-- Distribute Storage Service https://github.com/minio/minio-java -->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>5.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.aviator/aviator -->
<dependency>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
<version>3.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-core -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
<dependency>
<groupId>com.chatopera.compose4j</groupId>
<artifactId>compose4j</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.chatopera.bot</groupId>
<artifactId>sdk</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>contact-center</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
......@@ -436,7 +85,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
......@@ -463,7 +111,6 @@
</configuration>
<version>2.1.1</version>
</plugin>
</plugins>
<defaultGoal>compile</defaultGoal>
</build>
......@@ -471,7 +118,7 @@
<repository>
<id>chatopera</id>
<name>Chatopera Inc.</name>
<url>https://nexus.chatopera.com/repository/maven-public</url>
<url>https://nexus.chatopera.com/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
......
......@@ -22,6 +22,8 @@ import com.chatopera.cc.basic.plugins.PluginRegistry;
import com.chatopera.cc.config.AppCtxRefreshEventListener;
import com.chatopera.cc.util.SystemEnvHelper;
import com.chatopera.cc.util.mobile.MobileNumberUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
......@@ -36,8 +38,6 @@ import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.servlet.MultipartConfigElement;
......@@ -65,41 +65,46 @@ public class Application {
*/
static {
// CRM模块
MainContext.enableModule(Constants.CSKEFU_MODULE_CONTACTS);
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.contacts"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_CONTACTS);
}
// 会话监控模块 Customer Chats Audit
MainContext.enableModule(Constants.CSKEFU_MODULE_CCA);
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.cca"), "true")) {
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);
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.entim"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_ENTIM);
}
// skype模块
if (SystemEnvHelper.isClassExistByFullName(
PluginRegistry.PLUGIN_ENTRY_SKYPE)) {
MainContext.enableModule(Constants.CSKEFU_MODULE_SKYPE);
// 数据报表
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.report"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_REPORT);
}
// 聊天机器人模块
if (SystemEnvHelper.isClassExistByFullName(PluginRegistry.PLUGIN_ENTRY_CHATBOT)) {
MainContext.enableModule(Constants.CSKEFU_MODULE_CHATBOT);
}
}
/**
* Init local resources
*/
protected static void init() {
protected static void serve(final String[] args) {
try {
MobileNumberUtils.init();
/************************
* 该APP中加载多个配置文件
* http://roufid.com/load-multiple-configuration-files-different-directories-spring-boot/
************************/
SpringApplication app = new SpringApplicationBuilder(Application.class)
.properties("spring.config.name:application,git")
.build();
app.setBannerMode(Banner.Mode.CONSOLE);
app.setAddCommandLineProperties(false);
app.addListeners(new AppCtxRefreshEventListener());
MainContext.setApplicationContext(app.run(args));
} catch (IOException e) {
logger.error("Application Startup Error", e);
System.exit(1);
......@@ -127,19 +132,6 @@ public class Application {
}
public static void main(String[] args) {
Application.init();
/************************
* 该APP中加载多个配置文件
* http://roufid.com/load-multiple-configuration-files-different-directories-spring-boot/
************************/
SpringApplication app = new SpringApplicationBuilder(Application.class)
.properties("spring.config.name:application,git")
.build();
app.setBannerMode(Banner.Mode.CONSOLE);
app.setAddCommandLineProperties(false);
app.addListeners(new AppCtxRefreshEventListener());
MainContext.setApplicationContext(app.run(args));
Application.serve(args);
}
}
......@@ -40,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Component
......@@ -183,9 +184,9 @@ public class ACDAgentService {
// 获得所有待服务访客的列表
final Map<String, AgentUser> pendingAgentUsers = cache.getAgentUsersInQueByOrgi(orgi);
final SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
// 本次批量分配访客数目
int assigned = 0;
Map<String, Integer> assigned = new HashMap<>();
int currentAssigned = cache.getInservAgentUsersSizeByAgentnoAndOrgi(
agentStatus.getAgentno(), agentStatus.getOrgi());
......@@ -226,14 +227,15 @@ public class ACDAgentService {
}
// 坐席未达到最大咨询访客数量,并且单次批量分配小于坐席就绪时分配最大访客数量(initMaxuser)
if (((currentAssigned + assigned) < sessionConfig.getMaxuser()) && (assigned < sessionConfig.getInitmaxuser())) {
assigned++;
final SessionConfig sessionConfig = acdPolicyService.initSessionConfig(agentUser.getSkill(), orgi);
if ((ACDServiceRouter.getAcdPolicyService().getAgentUsersBySkill(agentStatus, agentUser.getSkill()) < sessionConfig.getMaxuser()) && (assigned.getOrDefault(agentUser.getSkill(), 0) < sessionConfig.getInitmaxuser())) {
assigned.merge(agentUser.getSkill(), 1, Integer::sum);
pickupAgentUserInQueue(agentUser, agentStatus);
} else {
logger.info(
"[assignVisitors] agentno {} reach the max users limit {}/{} or batch assign limit {}/{}",
agentno,
(currentAssigned + assigned),
(currentAssigned + assigned.getOrDefault(agentUser.getSkill(), 0)),
sessionConfig.getMaxuser(), assigned, sessionConfig.getInitmaxuser());
break;
}
......@@ -282,6 +284,9 @@ public class ACDAgentService {
peerSyncIM.send(MainContext.ReceiverType.AGENT, MainContext.ChannelType.WEBIM,
agentUser.getAppid(),
MainContext.MessageType.NEW, agentUser.getAgentno(), outMessage, true);
// 通知更新在线数据
agentStatusProxy.broadcastAgentsStatus(agentUser.getOrgi(), "agent", "pickup", agentStatus.getAgentno());
}
} catch (Exception ex) {
logger.warn("[assignVisitors] fail to process service", ex);
......@@ -317,7 +322,7 @@ public class ACDAgentService {
// 从缓存中删除agentUser缓存
agentUserRes.save(agentUser);
final SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
final SessionConfig sessionConfig = acdPolicyService.initSessionConfig(agentUser.getSkill(), orgi);
/**
* 坐席服务
......@@ -384,7 +389,7 @@ public class ACDAgentService {
// 向访客发送消息
Message outMessage = new Message();
outMessage.setAgentStatus(agentStatus);
outMessage.setMessage(acdMessageHelper.getServiceFinishMessage(agentUser.getChannel(), orgi));
outMessage.setMessage(acdMessageHelper.getServiceFinishMessage(agentUser.getChannel(), agentUser.getSkill(), orgi));
outMessage.setMessageType(MainContext.AgentUserStatusEnum.END.toString());
outMessage.setCalltype(MainContext.CallType.IN.toString());
outMessage.setCreatetime(MainUtils.dateFormate.format(new Date()));
......@@ -432,7 +437,7 @@ public class ACDAgentService {
// 当前访客服务已经结束,为坐席寻找新访客
if (agentStatus != null) {
if ((agentStatus.getUsers() - 1) < sessionConfig.getMaxuser()) {
if ((ACDServiceRouter.getAcdPolicyService().getAgentUsersBySkill(agentStatus, agentUser.getSkill()) - 1) < sessionConfig.getMaxuser()) {
assignVisitors(agentStatus.getAgentno(), orgi);
}
}
......
......@@ -16,12 +16,14 @@
package com.chatopera.cc.acd;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.model.AgentUser;
import com.chatopera.cc.model.SessionConfig;
import com.chatopera.cc.persistence.repository.AgentUserRepository;
import com.chatopera.cc.persistence.repository.OnlineUserRepository;
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
import com.chatopera.cc.util.HashMapUtils;
......@@ -33,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
......@@ -52,6 +55,9 @@ public class ACDPolicyService {
@Autowired
private OnlineUserRepository onlineUserRes;
@Autowired
private AgentUserRepository agentUserRes;
/**
* 载入坐席 ACD策略配置
*
......@@ -60,10 +66,10 @@ public class ACDPolicyService {
@SuppressWarnings("unchecked")
public List<SessionConfig> initSessionConfigList() {
List<SessionConfig> sessionConfigList;
if ((sessionConfigList = cache.findOneSessionConfigListByOrgi(MainContext.SYSTEM_ORGI)) == null) {
if ((sessionConfigList = cache.findOneSessionConfigListByOrgi(Constants.SYSTEM_ORGI)) == null) {
sessionConfigList = sessionConfigRes.findAll();
if (sessionConfigList != null && sessionConfigList.size() > 0) {
cache.putSessionConfigListByOrgi(sessionConfigList, MainContext.SYSTEM_ORGI);
cache.putSessionConfigListByOrgi(sessionConfigList, Constants.SYSTEM_ORGI);
}
}
return sessionConfigList;
......@@ -75,14 +81,14 @@ public class ACDPolicyService {
* @param orgi
* @return
*/
public SessionConfig initSessionConfig(final String orgi) {
public SessionConfig initSessionConfig(String organid, final String orgi) {
SessionConfig sessionConfig;
if ((sessionConfig = cache.findOneSessionConfigByOrgi(orgi)) == null) {
sessionConfig = sessionConfigRes.findByOrgi(orgi);
if ((sessionConfig = cache.findOneSessionConfigByOrgi(organid, orgi)) == null) {
sessionConfig = sessionConfigRes.findByOrgiAndSkill(orgi, organid);
if (sessionConfig == null) {
sessionConfig = new SessionConfig();
} else {
cache.putSessionConfigByOrgi(sessionConfig, orgi);
cache.putSessionConfigByOrgi(sessionConfig, organid, orgi);
}
}
......@@ -113,14 +119,7 @@ public class ACDPolicyService {
*/
public AgentStatus decideAgentStatusInAverage(final List<AgentStatus> agentStatuses) {
// 查找最少人数的AgentStatus
AgentStatus x = null;
int min = 0;
for (final AgentStatus o : agentStatuses) {
if ((x == null) || (o.getUsers() < min)) {
x = o;
min = o.getUsers();
}
}
AgentStatus x = agentStatuses.stream().min(Comparator.comparingInt(AgentStatus::getUsers)).get();
if (x != null) {
logger.info("[decideAgentStatusWithIdleAgent] choose agentno {} in average.", x.getAgentno());
......@@ -144,7 +143,7 @@ public class ACDPolicyService {
logger.info(
"[filterOutAvailableAgentStatus] pre-conditions: agentUser.agentno {}, orgi {}, skill {}, onlineUser {}",
agentUser.getAgentno(), orgi, agentUser.getSkill(), agentUser.getUserid()
);
);
List<AgentStatus> agentStatuses = new ArrayList<>();
Map<String, AgentStatus> map = cache.findAllReadyAgentStatusByOrgi(orgi);
......@@ -155,10 +154,10 @@ public class ACDPolicyService {
for (final Map.Entry<String, AgentStatus> f : map.entrySet()) {
sb.append(
String.format(" name %s, agentno %s, service %d/%d, status %s, busy %s, skills %s \n",
f.getValue().getUsername(),
f.getValue().getAgentno(), f.getValue().getUsers(), f.getValue().getMaxusers(),
f.getValue().getStatus(), f.getValue().isBusy(),
HashMapUtils.concatKeys(f.getValue().getSkills(), "|")));
f.getValue().getUsername(),
f.getValue().getAgentno(), f.getValue().getUsers(), f.getValue().getMaxusers(),
f.getValue().getStatus(), f.getValue().isBusy(),
HashMapUtils.concatKeys(f.getValue().getSkills(), "|")));
}
logger.info(sb.toString());
} else {
......@@ -198,7 +197,7 @@ public class ACDPolicyService {
// 指定技能组
for (final Map.Entry<String, AgentStatus> entry : map.entrySet()) {
if ((!entry.getValue().isBusy()) &&
(entry.getValue().getUsers() < sessionConfig.getMaxuser()) &&
(getAgentUsersBySkill(entry.getValue(), agentUser.getSkill()) < sessionConfig.getMaxuser()) &&
(entry.getValue().getSkills() != null &&
entry.getValue().getSkills().containsKey(agentUser.getSkill()))) {
logger.info(
......@@ -227,26 +226,28 @@ public class ACDPolicyService {
/**
* 在指定的坐席和技能组中未查到坐席
* 接下来进行无差别查询
*
* TODO 指定技能组无用户,停止分配
*/
// 对于该租户的所有客服
for (final Map.Entry<String, AgentStatus> entry : map.entrySet()) {
if ((!entry.getValue().isBusy()) && (entry.getValue().getUsers() < sessionConfig.getMaxuser())) {
agentStatuses.add(entry.getValue());
logger.info(
"[filterOutAvailableAgentStatus] <Redundance> find ready agent {}, agentname {}, status {}, service {}/{}, skills {}",
entry.getValue().getAgentno(), entry.getValue().getUsername(), entry.getValue().getStatus(),
entry.getValue().getUsers(),
entry.getValue().getMaxusers(),
HashMapUtils.concatKeys(entry.getValue().getSkills(), "|"));
} else {
logger.info(
"[filterOutAvailableAgentStatus] <Redundance> skip ready agent {}, name {}, status {}, service {}/{}, skills {}",
entry.getValue().getAgentno(), entry.getValue().getUsername(), entry.getValue().getStatus(),
entry.getValue().getUsers(),
entry.getValue().getMaxusers(),
HashMapUtils.concatKeys(entry.getValue().getSkills(), "|"));
}
}
// for (final Map.Entry<String, AgentStatus> entry : map.entrySet()) {
// if ((!entry.getValue().isBusy()) && (entry.getValue().getUsers() < sessionConfig.getMaxuser())) {
// agentStatuses.add(entry.getValue());
// logger.info(
// "[filterOutAvailableAgentStatus] <Redundance> find ready agent {}, agentname {}, status {}, service {}/{}, skills {}",
// entry.getValue().getAgentno(), entry.getValue().getUsername(), entry.getValue().getStatus(),
// entry.getValue().getUsers(),
// entry.getValue().getMaxusers(),
// HashMapUtils.concatKeys(entry.getValue().getSkills(), "|"));
// } else {
// logger.info(
// "[filterOutAvailableAgentStatus] <Redundance> skip ready agent {}, name {}, status {}, service {}/{}, skills {}",
// entry.getValue().getAgentno(), entry.getValue().getUsername(), entry.getValue().getStatus(),
// entry.getValue().getUsers(),
// entry.getValue().getMaxusers(),
// HashMapUtils.concatKeys(entry.getValue().getSkills(), "|"));
// }
// }
}
logger.info("[filterOutAvailableAgentStatus] agent status list size: {}", agentStatuses.size());
......@@ -292,11 +293,11 @@ public class ACDPolicyService {
logger.info("[filterOutAgentStatusWithPolicies] check agent against chat history.");
// 启用了历史坐席优先 , 查找 历史服务坐席
List<com.chatopera.cc.util.WebIMReport> webIMaggs = MainUtils.getWebIMDataAgg(
onlineUserRes.findByOrgiForDistinctAgent(orgi, onlineUserId));
onlineUserRes.findBySkillAndOrgiForDistinctAgent(sessionConfig.getSkill(), orgi, onlineUserId));
for (WebIMReport report : webIMaggs) {
for (final AgentStatus o : agentStatuses) {
if (StringUtils.equals(
o.getAgentno(), report.getData()) && o.getUsers() < sessionConfig.getMaxuser()) {
o.getAgentno(), report.getData()) && getAgentUsersBySkill(o, sessionConfig.getSkill()) < sessionConfig.getMaxuser()) {
agentStatus = o;
logger.info(
"[filterOutAgentStatusWithPolicies] choose agentno {} by chat history.",
......@@ -349,4 +350,8 @@ public class ACDPolicyService {
return agentStatus;
}
public int getAgentUsersBySkill(AgentStatus agentStatus, String skill) {
return agentUserRes.countByAgentnoAndStatusAndOrgiAndSkill(agentStatus.getAgentno(), MainContext.AgentUserStatusEnum.INSERVICE.toString(), agentStatus.getOrgi(), skill);
}
}
......@@ -20,8 +20,12 @@ import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.AgentReport;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.WorkMonitor;
import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.persistence.repository.AgentUserRepository;
import com.chatopera.cc.persistence.repository.WorkMonitorRepository;
import com.chatopera.cc.proxy.OrganProxy;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -42,6 +46,15 @@ public class ACDWorkMonitor {
@Autowired
private Cache cache;
@Autowired
private OrganProxy organProxy;
@Autowired
private AgentServiceRepository agentServiceRes;
@Autowired
private AgentUserRepository agentUserRes;
/**
* 获得 当前服务状态
*
......@@ -96,16 +109,26 @@ public class ACDWorkMonitor {
/**
* 统计当前服务中的用户数量
*/
// 服务中
report.setUsers(cache.getInservAgentUsersSizeByOrgi(orgi));
// 等待中
report.setInquene(cache.getInqueAgentUsersSizeByOrgi(orgi));
if (organ != null) {
Organ currentOrgan = new Organ();
currentOrgan.setId(organ);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, orgi);
report.setUsers(agentServiceRes.countByOrgiAndStatusAndAgentskillIn(orgi, MainContext.AgentUserStatusEnum.INSERVICE.toString(), organs.keySet()));
report.setInquene(agentUserRes.countByOrgiAndStatusAndSkillIn(orgi, MainContext.AgentUserStatusEnum.INQUENE.toString(), organs.keySet()));
} else {
// 服务中
report.setUsers(cache.getInservAgentUsersSizeByOrgi(orgi));
// 等待中
report.setInquene(cache.getInqueAgentUsersSizeByOrgi(orgi));
}
// DEBUG
logger.info(
"[getAgentReport] orgi {}, organ {}, agents {}, busy {}, users {}, inqueue {}", orgi, organ,
report.getAgents(), report.getBusy(), report.getUsers(), report.getInquene()
);
);
return report;
}
......@@ -129,7 +152,7 @@ public class ACDWorkMonitor {
String worktype,
String orgi,
Date lasttime
) {
) {
WorkMonitor workMonitor = new WorkMonitor();
if (StringUtils.isNotBlank(agent) && StringUtils.isNotBlank(status)) {
workMonitor.setAgent(agent);
......@@ -149,7 +172,7 @@ public class ACDWorkMonitor {
int count = workMonitorRes.countByAgentAndDatestrAndStatusAndOrgi(
agent, MainUtils.simpleDateFormat.format(new Date()),
MainContext.AgentStatusEnum.READY.toString(), orgi
);
);
if (count == 0) {
workMonitor.setFirsttime(true);
}
......
......@@ -86,7 +86,7 @@ public class ACDMessageHelper {
if (!MainContext.ChannelType.WEBIM.toString().equals(channel)) {
queneTip = agentService.getAgentusername();
}
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(agentService.getSkill(), orgi);
String successMsg = "坐席分配成功," + queneTip + "为您服务。";
if (StringUtils.isNotBlank(sessionConfig.getSuccessmsg())) {
successMsg = sessionConfig.getSuccessmsg().replaceAll("\\{agent\\}", queneTip);
......@@ -101,8 +101,8 @@ public class ACDMessageHelper {
* @param orgi
* @return
*/
public String getServiceFinishMessage(String channel, String orgi) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
public String getServiceFinishMessage(String channel, String organid, String orgi) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(organid, orgi);
String queneTip = "坐席已断开和您的对话";
if (StringUtils.isNotBlank(sessionConfig.getFinessmsg())) {
queneTip = sessionConfig.getFinessmsg();
......@@ -118,8 +118,8 @@ public class ACDMessageHelper {
* @param orgi
* @return
*/
public String getServiceOffMessage(String channel, String orgi) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
public String getServiceOffMessage(String channel, String organid, String orgi) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(organid, orgi);
String queneTip = "坐席已断开和您的对话,刷新页面为您分配新的坐席";
if (StringUtils.isNotBlank(sessionConfig.getFinessmsg())) {
queneTip = sessionConfig.getFinessmsg();
......@@ -127,7 +127,7 @@ public class ACDMessageHelper {
return queneTip;
}
public String getNoAgentMessage(int queneIndex, String channel, String orgi) {
public String getNoAgentMessage(int queneIndex, String channel, String organid, String orgi) {
if (queneIndex < 0) {
queneIndex = 0;
}
......@@ -135,7 +135,7 @@ public class ACDMessageHelper {
if (!MainContext.ChannelType.WEBIM.toString().equals(channel)) {
queneTip = String.valueOf(queneIndex);
}
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(organid, orgi);
String noAgentTipMsg = "坐席全忙,已进入等待队列,您也可以在其他时间再来咨询。";
if (StringUtils.isNotBlank(sessionConfig.getNoagentmsg())) {
noAgentTipMsg = sessionConfig.getNoagentmsg().replaceAll("\\{num\\}", queneTip);
......@@ -143,13 +143,13 @@ public class ACDMessageHelper {
return noAgentTipMsg;
}
public String getQueneMessage(int queneIndex, String channel, String orgi) {
public String getQueneMessage(int queneIndex, String channel, String organid, String orgi) {
String queneTip = "<span id='queneindex'>" + queneIndex + "</span>";
if (!MainContext.ChannelType.WEBIM.toString().equals(channel)) {
queneTip = String.valueOf(queneIndex);
}
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(organid, orgi);
String agentBusyTipMsg = "正在排队,请稍候,在您之前,还有 " + queneTip + " 位等待用户。";
if (StringUtils.isNotBlank(sessionConfig.getAgentbusymsg())) {
agentBusyTipMsg = sessionConfig.getAgentbusymsg().replaceAll("\\{num\\}", queneTip);
......
......@@ -182,6 +182,7 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
ctx.setMessage(acdMessageHelper.getQueneMessage(
ctx.getAgentService().getQueneindex(),
ctx.getAgentUser().getChannel(),
ctx.getOrganid(),
ctx.getOrgi()));
} else {
// TODO 什么是否返回 noAgentMessage, 是否在是 INQUENE 时 getQueneindex == 0
......@@ -190,6 +191,7 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
ctx.setMessage(acdMessageHelper.getNoAgentMessage(
ctx.getAgentService().getQueneindex(),
ctx.getChannel(),
ctx.getOrganid(),
ctx.getOrgi()));
}
......
......@@ -59,6 +59,7 @@ public class ACDVisServiceMw implements Middleware<ACDComposeContext> {
acdMessageHelper.getQueneMessage(
queueIndex,
ctx.getChannel(),
ctx.getOrganid(),
ctx.getOrgi()));
break;
case INSERVICE:
......
......@@ -45,7 +45,7 @@ public class ACDVisSessionCfgMw implements Middleware<ACDComposeContext> {
@Override
public void apply(final ACDComposeContext ctx, final Functional next) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(ctx.getOrganid(),
ctx.getOrgi());
ctx.setSessionConfig(sessionConfig);
......
......@@ -29,7 +29,9 @@ public class Constants {
/**
* 系统配置
*/
public static final String SYSTEM_ORGI = "cskefu";
public static final String USER_SESSION_NAME = "user";
public static final String ORGAN_SESSION_NAME = "organ";
public static final String GUEST_USER = "guest";
public static final String IM_USER_SESSION_NAME = "im_user";
public static final String CSKEFU_SYSTEM_DIC = "com.dic.system.template";
......@@ -45,7 +47,6 @@ public class Constants {
public static final String CSKEFU_SYSTEM_DIS_TIME = "distime";
public static final String CSKEFU_SYSTEM_COOKIES_FLAG = "uk_flagid";
public static final String CSKEFU_SYSTEM_NO_DAT = "NOTEXIST";
public static final String SYSTEM_INDEX = "cskefu";
public static final String CSKEFU_SYSTEM_SECFIELD = "cskefu_sec_field";
public static final String CSKEFU_SYSTEM_CALLCENTER = "callcenter";
......@@ -92,6 +93,7 @@ public class Constants {
public final static String CSKEFU_MODULE_ENTIM = "entim";
public final static String CSKEFU_MODULE_WORKORDERS = "workorders";
public final static String CSKEFU_MODULE_CALLCENTER = "callcenter";
public final static String CSKEFU_MODULE_REPORT = "report";
/**
* Formatter
......@@ -136,6 +138,10 @@ public class Constants {
/**
* FreeSwitch Communication
*/
// callcenter
public final static String ACTIVEMQ_QUEUE_SWITCH_SYNC = "cskefu.callcenter.switch.sync";
// callout
public final static String FS_SIP_STATUS = "pbx:%s:sips"; // 查询SIP状态
public final static String FS_CHANNEL_CC_TO_FS = "pbx/%s/execute"; // 发送外呼执行信号
public final static String FS_DIALPLAN_STATUS = "pbx:%s:status"; // 外呼执行状态存储
......
......@@ -43,8 +43,6 @@ public class MainContext {
private static boolean imServerRunning = false; // IM服务状态
public static String SYSTEM_ORGI = "cskefu";
private static Set<String> modules = new HashSet<String>();
public static Map<String, Class<?>> csKeFuResourceMap = new HashMap<String, Class<?>>();
......@@ -61,13 +59,10 @@ public class MainContext {
static {
ConvertUtils.register(new DateConverter(), java.util.Date.class);
enableModule("report");
csKeFuResourceMap.put(TaskType.ACTIVE.toString(), ActivityResource.class);
csKeFuResourceMap.put(TaskType.BATCH.toString(), BatchResource.class);
}
public enum AskSectionType {
DEFAULT;
......@@ -435,7 +430,10 @@ public class MainContext {
}
}
public enum ExtentionType {
/**
* 分机类型
*/
public enum ExtensionType {
LINE,
IVR,
BUSINESS,
......@@ -446,6 +444,15 @@ public class MainContext {
public String toString() {
return super.toString().toLowerCase();
}
public static ExtensionType toValue(final String str) {
for (final ExtensionType item : values()) {
if (StringUtils.equalsIgnoreCase(item.toString(), str)) {
return item;
}
}
throw new IllegalArgumentException();
}
}
public enum DTMFType {
......
......@@ -763,7 +763,7 @@ public class MainUtils {
public static String processEmoti(String message) {
Pattern pattern = Pattern.compile("\\[([\\d]*?)\\]");
SystemConfig systemConfig = MainContext.getCache().findOneSystemByIdAndOrgi(
"systemConfig", MainContext.SYSTEM_ORGI);
"systemConfig", Constants.SYSTEM_ORGI);
Matcher matcher = pattern.matcher(message);
StringBuffer strb = new StringBuffer();
......@@ -839,10 +839,10 @@ public class MainUtils {
*/
public static SystemConfig getSystemConfig() {
SystemConfig systemConfig = MainContext.getCache().findOneSystemByIdAndOrgi(
"systemConfig", MainContext.SYSTEM_ORGI);
"systemConfig", Constants.SYSTEM_ORGI);
if (systemConfig == null) {
SystemConfigRepository systemConfigRes = MainContext.getContext().getBean(SystemConfigRepository.class);
systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI);
systemConfig = systemConfigRes.findByOrgi(Constants.SYSTEM_ORGI);
}
return systemConfig;
}
......@@ -856,7 +856,7 @@ public class MainUtils {
if (tpRes != null) {
List<TableProperties> tpList = tpRes.findBySecfield(true);
MainContext.getCache().putSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_SECFIELD, MainContext.SYSTEM_ORGI, tpList);
Constants.CSKEFU_SYSTEM_SECFIELD, Constants.SYSTEM_ORGI, tpList);
}
}
......@@ -866,10 +866,10 @@ public class MainUtils {
* @return
*/
public static void initSystemArea() {
MainContext.getCache().deleteSystembyIdAndOrgi(Constants.CSKEFU_SYSTEM_AREA, MainContext.SYSTEM_ORGI);
MainContext.getCache().deleteSystembyIdAndOrgi(Constants.CSKEFU_SYSTEM_AREA, Constants.SYSTEM_ORGI);
AreaTypeRepository areaTypeRes = MainContext.getContext().getBean(AreaTypeRepository.class);
MainContext.getCache().putSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_AREA, MainContext.SYSTEM_ORGI, areaTypeRes.findAll());
Constants.CSKEFU_SYSTEM_AREA, Constants.SYSTEM_ORGI, areaTypeRes.findAll());
}
/**
......@@ -877,19 +877,19 @@ public class MainUtils {
*
* @return
*/
public static void initAdv(String orgi) {
MainContext.getCache().deleteSystembyIdAndOrgi(Constants.CSKEFU_SYSTEM_ADV + "_" + orgi, orgi);
public static void initAdv(String orgi, String skill) {
MainContext.getCache().deleteSystembyIdAndOrgi(Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi);
AdTypeRepository adRes = MainContext.getContext().getBean(AdTypeRepository.class);
MainContext.getCache().putSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_ADV + "_" + orgi, orgi, adRes.findByOrgi(orgi));
Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi, adRes.findByOrgiAndSkill(orgi, skill));
}
public static Template getTemplate(String id) {
Template templet = null;
if ((templet = MainContext.getCache().findOneSystemByIdAndOrgi(id, MainContext.SYSTEM_ORGI)) == null) {
if ((templet = MainContext.getCache().findOneSystemByIdAndOrgi(id, Constants.SYSTEM_ORGI)) == null) {
TemplateRepository templateRes = MainContext.getContext().getBean(TemplateRepository.class);
templet = templateRes.findByIdAndOrgi(id, MainContext.SYSTEM_ORGI);
MainContext.getCache().putSystemByIdAndOrgi(id, MainContext.SYSTEM_ORGI, templet);
templet = templateRes.findByIdAndOrgi(id, Constants.SYSTEM_ORGI);
MainContext.getCache().putSystemByIdAndOrgi(id, Constants.SYSTEM_ORGI, templet);
}
return templet;
}
......@@ -901,15 +901,15 @@ public class MainUtils {
* @return
*/
@SuppressWarnings("unchecked")
public static AdType getPointAdv(String adpos, String orgi) {
public static AdType getPointAdv(String adpos, String skill, String orgi) {
List<AdType> adTypeList = new ArrayList<AdType>();
List<AdType> cacheAdTypeList = MainContext.getCache().findOneSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_ADV + "_" + orgi, orgi);
Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi);
if (cacheAdTypeList == null) {
AdTypeRepository adRes = MainContext.getContext().getBean(AdTypeRepository.class);
cacheAdTypeList = adRes.findByOrgi(orgi);
cacheAdTypeList = adRes.findByOrgiAndSkill(orgi, skill);
MainContext.getCache().putSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_ADV + "_" + orgi, orgi, cacheAdTypeList);
Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi, cacheAdTypeList);
}
List<SysDic> sysDicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_ADPOS_DIC);
SysDic sysDic = null;
......
package com.chatopera.cc.basic.plugins;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractPluginConfigurer implements IPluginConfigurer {
public abstract String getPluginId();
public abstract String getPluginName();
public abstract String getIOEventHandler();
public Map<String, String> getEnvironmentVariables() {
Map<String, String> env = new HashMap<>();
return env;
}
public boolean isModule() {
return false;
}
public abstract void setup();
}
......@@ -17,9 +17,22 @@ package com.chatopera.cc.basic.plugins;
import java.util.Map;
public interface IPluginDescriptor {
public interface IPluginConfigurer {
// 插件的ID:插件的标识,用于区别其它插件,由[a-z]组成,最大32位长度
String getPluginId();
// 插件的名字:最少的概述插件
String getPluginName();
// 即时通信接口
String getIOEventHandler();
// 获得环境变量及默认值
Map<String, String> getEnvironmentVariables();
// 是否是Module(在一级菜单有入口的插件)
boolean isModule();
// 安装插件
public void setup();
}
......@@ -15,17 +15,85 @@
*/
package com.chatopera.cc.basic.plugins;
import com.chatopera.cc.basic.MainContext;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* 插件注册表
*/
@Component
public class PluginRegistry {
/**
* Plugins Entry
*/
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";
// 插件列表
private final List<IPluginConfigurer> plugins = new ArrayList<>();
/**
* 添加插件
*
* @param plugin
* @return
*/
public boolean addPlugin(final IPluginConfigurer plugin) {
for (final IPluginConfigurer x : plugins) {
if (StringUtils.equalsIgnoreCase(x.getPluginId(), plugin.getPluginId())) {
return false;
}
}
if (StringUtils.isNotBlank(plugin.getPluginId())) {
MainContext.enableModule(plugin.getPluginId());
}
plugins.add(plugin);
return true;
}
/**
* 获得插件列表
*
* @return
*/
public List<IPluginConfigurer> getPlugins() {
return plugins;
}
/**
* 获得一个插件
*
* @param pluginId
* @return
*/
public Optional<IPluginConfigurer> getPlugin(final String pluginId) {
IPluginConfigurer p = null;
for (final IPluginConfigurer plugin : plugins) {
if (StringUtils.equalsIgnoreCase(plugin.getPluginId(), pluginId)) {
p = plugin;
break;
}
}
return Optional.ofNullable(p);
}
/**
* 删除插件
*
* @param pluginId
*/
public void removePlugin(final String pluginId) {
for (final IPluginConfigurer plugin : plugins) {
if (StringUtils.equalsIgnoreCase(plugin.getPluginId(), pluginId)) {
plugins.remove(plugin);
break;
}
}
}
}
/*
* Copyright (C) 2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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
*/
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;
}
}
......@@ -754,24 +754,24 @@ public class Cache {
* Session Config 相关
**************************/
public void putSessionConfigByOrgi(final SessionConfig sessionConfig, final String orgi) {
redisCommand.put(RedisKey.getSessionConfig(orgi), SerializeUtil.serialize(sessionConfig));
public void putSessionConfigByOrgi(final SessionConfig sessionConfig, String organid, final String orgi) {
redisCommand.put(RedisKey.getSessionConfig(organid, orgi), SerializeUtil.serialize(sessionConfig));
}
public SessionConfig findOneSessionConfigByOrgi(final String orgi) {
String serialized = redisCommand.get(RedisKey.getSessionConfig(orgi));
public SessionConfig findOneSessionConfigByOrgi(String organid, final String orgi) {
String serialized = redisCommand.get(RedisKey.getSessionConfig(organid, orgi));
if (StringUtils.isNotBlank(serialized)) {
return (SessionConfig) SerializeUtil.deserialize(serialized);
}
return null;
}
public void deleteSessionConfigByOrgi(final String orgi) {
redisCommand.delete(RedisKey.getSessionConfig(orgi));
public void deleteSessionConfigByOrgi(String organid, final String orgi) {
redisCommand.delete(RedisKey.getSessionConfig(organid, orgi));
}
public boolean existSessionConfigByOrgi(final String orgi) {
return redisCommand.exists(RedisKey.getSessionConfig(orgi));
public boolean existSessionConfigByOrgi(String organid, final String orgi) {
return redisCommand.exists(RedisKey.getSessionConfig(organid, orgi));
}
public void putSessionConfigListByOrgi(final List<SessionConfig> lis, final String orgi) {
......
......@@ -238,9 +238,11 @@ public class RedisKey {
return sb.toString();
}
public static String getSessionConfig(final String orgi) {
public static String getSessionConfig(String organid, final String orgi) {
StringBuffer sb = new StringBuffer();
sb.append(orgi);
sb.append(":");
sb.append(organid);
sb.append(":session:config");
return sb.toString();
}
......
......@@ -19,6 +19,8 @@ package com.chatopera.cc.config;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.basic.plugins.IPluginConfigurer;
import com.chatopera.cc.basic.plugins.PluginRegistry;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.BlackEntity;
import com.chatopera.cc.model.SysDic;
......@@ -49,7 +51,6 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
Cache cache = event.getApplicationContext().getBean(Cache.class);
String cacheSetupStrategy = event.getApplicationContext().getEnvironment().getProperty("cache.setup.strategy");
if (!StringUtils.equalsIgnoreCase(cacheSetupStrategy, Constants.cache_setup_strategy_skip)) {
/**************************
......@@ -58,7 +59,7 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
**************************/
// 首先将之前缓存清空,此处使用系统的默认租户信息
cache.eraseSysDicByOrgi(MainContext.SYSTEM_ORGI);
cache.eraseSysDicByOrgi(Constants.SYSTEM_ORGI);
List<SysDic> sysDicList = sysDicRes.findAll();
Map<String, List<SysDic>> rootDictItems = new HashMap<>(); // 关联根词典及其子项
......@@ -91,19 +92,19 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
// 所以,当前代码不支持集群,需要解决启动上的这个问题!
// 存储根词典 TODO 此处只考虑了系统默认租户
cache.putSysDicByOrgi(new ArrayList<>(rootDics.values()), MainContext.SYSTEM_ORGI);
cache.putSysDicByOrgi(new ArrayList<>(rootDics.values()), Constants.SYSTEM_ORGI);
for (final Map.Entry<String, List<SysDic>> entry : rootDictItems.entrySet()) {
SysDic rootDic = rootDics.get(entry.getKey());
// 打印根词典信息
logger.debug("[onApplicationEvent] root dict: {}, code {}, name {}, item size {}", entry.getKey(), rootDics.get(entry.getKey()).getCode(), rootDics.get(entry.getKey()).getName(), entry.getValue().size());
// 存储子项列表
cache.putSysDicByOrgi(rootDic.getCode(), MainContext.SYSTEM_ORGI, entry.getValue());
cache.putSysDicByOrgi(rootDic.getCode(), Constants.SYSTEM_ORGI, entry.getValue());
// 存储子项成员
cache.putSysDicByOrgi(entry.getValue(), MainContext.SYSTEM_ORGI);
cache.putSysDicByOrgi(entry.getValue(), Constants.SYSTEM_ORGI);
}
List<BlackEntity> blackList = blackListRes.findByOrgi(MainContext.SYSTEM_ORGI);
List<BlackEntity> blackList = blackListRes.findByOrgi(Constants.SYSTEM_ORGI);
for (final BlackEntity black : blackList) {
if (StringUtils.isNotBlank(black.getUserid())) {
if (black.getEndtime() == null || black.getEndtime().after(new Date())) {
......@@ -116,9 +117,9 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
* 加载系统全局配置
*/
SystemConfigRepository systemConfigRes = event.getApplicationContext().getBean(SystemConfigRepository.class);
SystemConfig config = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI);
SystemConfig config = systemConfigRes.findByOrgi(Constants.SYSTEM_ORGI);
if (config != null) {
cache.putSystemByIdAndOrgi("systemConfig", MainContext.SYSTEM_ORGI, config);
cache.putSystemByIdAndOrgi("systemConfig", Constants.SYSTEM_ORGI, config);
}
logger.info("[StartedEventListener] setup Sysdicts in Redis done, strategy {}", cacheSetupStrategy);
} else {
......@@ -129,6 +130,13 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
MainUtils.initSystemSecField(event.getApplicationContext().getBean(TablePropertiesRepository.class));
// MainUtils.initAdv();//初始化广告位
// 初始化插件
PluginRegistry pluginRegistry = MainContext.getContext().getBean(PluginRegistry.class);
for (final IPluginConfigurer p : pluginRegistry.getPlugins()) {
logger.info("[Plugins] registered plugin id {}, class {}", p.getPluginId(), p.getClass().getName());
}
} else {
logger.info("[onApplicationEvent] bypass, initialization has been done already.");
}
......
......@@ -16,9 +16,7 @@
*/
package com.chatopera.cc.config;
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;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
......@@ -55,29 +53,6 @@ public class ExecutorConfig {
return poolTaskExecutor;
}
/**
* 外呼线程池
* @return
*/
@Conditional(CalloutPluginPresentCondition.class)
@Bean(name = "callOutTaskExecutor")
public ThreadPoolTaskExecutor callout() {
ThreadPoolTaskExecutor poolTaskExecutor = new ThreadPoolTaskExecutor();
// 线程池维护线程的最少数量
poolTaskExecutor.setCorePoolSize(CORE_POOL_SIZE);
// 线程池维护线程的最大数量
poolTaskExecutor.setMaxPoolSize(MAX_POOL_SIZE);
// 线程池所使用的缓冲队列
poolTaskExecutor.setQueueCapacity(200);
// 线程池维护线程所允许的空闲时间
poolTaskExecutor.setKeepAliveSeconds(30000);
poolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
poolTaskExecutor.setThreadNamePrefix("cs-callout-");
return poolTaskExecutor;
}
@Bean(name = "scheduleTaskExecutor")
public ThreadPoolTaskScheduler schedule(){
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
......
/*
* Copyright (C) 2019 Chatopera Inc, All rights reserved.
* <https://www.chatopera.com>
* 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 CalloutPluginPresentCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
return MainContext.hasModule(Constants.CSKEFU_MODULE_CALLOUT);
}
}
/*
* Copyright (C) 2019 Chatopera Inc, All rights reserved.
* <https://www.chatopera.com>
* 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);
}
}
/*
* Copyright (C) 2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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;
import com.chatopera.cc.basic.MainContext;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Skype渠道检测
*/
public class SkypePluginPresentCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
return MainContext.hasModule(Constants.CSKEFU_MODULE_SKYPE);
}
}
......@@ -17,9 +17,16 @@
package com.chatopera.cc.controller;
import com.chatopera.cc.acd.ACDWorkMonitor;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.ExtensionRepository;
import com.chatopera.cc.persistence.repository.OrganRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.proxy.OrganProxy;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -27,10 +34,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.stream.Collectors;
@Controller
public class ApplicationController extends Handler {
......@@ -57,19 +71,39 @@ public class ApplicationController extends Handler {
@Value("${tongji.baidu.sitekey}")
private String tongjiBaiduSiteKey;
@Autowired
private OrganProxy organProxy;
@Autowired
private OrganRepository organRepository;
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private ExtensionRepository extensionRes;
@RequestMapping("/")
public ModelAndView admin(HttpServletRequest request) {
// logger.info("[admin] path {} queryString {}", request.getPathInfo(),request.getQueryString());
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/index"));
User logined = super.getUser(request);
Organ currentOrgan = super.getOrgan(request);
TimeZone timezone = TimeZone.getDefault();
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(logined.getOrgi()));
view.addObject("tenant", super.getTenant(request));
view.addObject("istenantshare", super.isEnabletneant());
view.addObject("timeDifference", timezone.getRawOffset());
List<Organ> organs = organProxy.findOrganInIds(logined.getAffiliates());
view.addObject(
"skills",
organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request)).keySet().stream().collect(Collectors.joining(","))
);
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(currentOrgan != null ? currentOrgan.getId() : null, logined.getOrgi()));
view.addObject("istenantshare", false);
view.addObject("timeDifference", timezone.getRawOffset());
view.addObject("organList", organs);
view.addObject("currentOrgan", super.getOrgan(request));
// 增加版本信息
view.addObject("appBuildDate", appBuildDate);
......@@ -77,19 +111,28 @@ public class ApplicationController extends Handler {
view.addObject("appVersionNumber", appVersionNumber);
view.addObject("appCustomerEntity", appCustomerEntity);
if (super.isEnabletneant()) {
// 多租户启用 非管理员 一定要选择租户才能进入界面
if (!logined.isAdmin() && StringUtils.isNotBlank(
logined.getOrgid()) && super.isTenantconsole() && MainContext.SYSTEM_ORGI.equals(
logined.getOrgi())) {
view = request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
}
if (StringUtils.isBlank(logined.getOrgid())) {
view = request(super.createRequestPageTempletResponse("redirect:/apps/organization/add.html"));
}
}
// 在线坐席状态信息
view.addObject("agentStatus", cache.findOneAgentStatusByAgentnoAndOrig(logined.getId(), logined.getOrgi()));
// 呼叫中心信息
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER) && logined.isCallcenter()) {
extensionRes.findByAgentnoAndOrgi(logined.getId(), logined.getOrgi()).ifPresent(ext -> {
pbxHostRes.findById(ext.getHostid()).ifPresent(pbx -> {
Map<String, Object> webrtcData = new HashMap<>();
webrtcData.put("callCenterWebrtcIP", pbx.getWebrtcaddress());
webrtcData.put("callCenterWebRtcPort", pbx.getWebrtcport());
webrtcData.put("callCenterExtensionNum", ext.getExtension());
try {
webrtcData.put("callCenterExtensionPassword", MainUtils.decryption(ext.getPassword()));
} catch (NoSuchAlgorithmException e) {
logger.error("[admin]", e);
webrtcData.put("callCenterError", "Invalid data for callcenter agent.");
}
view.addObject("webrtc", webrtcData);
});
});
}
if (StringUtils.isNotBlank(tongjiBaiduSiteKey) && !StringUtils.equalsIgnoreCase(tongjiBaiduSiteKey, "placeholder")) {
logger.info("tongjiBaiduSiteKey: {}", tongjiBaiduSiteKey);
view.addObject("tongjiBaiduSiteKey", tongjiBaiduSiteKey);
......@@ -98,9 +141,25 @@ public class ApplicationController extends Handler {
return view;
}
@RequestMapping("/setorgan")
@ResponseBody
public String setOrgan(HttpServletRequest request, @Valid String organ) {
if (StringUtils.isNotBlank(organ)) {
Organ currentOrgan = organRepository.findByIdAndOrgi(organ, super.getOrgi(request));
if (currentOrgan != null) {
request.getSession(true).setAttribute(Constants.ORGAN_SESSION_NAME, currentOrgan);
}
}
return "ok";
}
@RequestMapping("/lazyAgentStatus")
public ModelAndView lazyAgentStatus(HttpServletRequest request) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/index"));
ModelAndView view = request(super.createRequestPageTempletResponse("/public/agentstatustext"));
Organ currentOrgan = super.getOrgan(request);
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(currentOrgan != null ? currentOrgan.getId() : null, super.getOrgi(request)));
return view;
}
......
......@@ -17,20 +17,18 @@
package com.chatopera.cc.controller;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.basic.Viewport;
import com.chatopera.cc.basic.auth.AuthToken;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.api.QueryParams;
import com.chatopera.cc.exception.CSKefuException;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.StreamingFile;
import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.Tenant;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
import com.chatopera.cc.persistence.repository.StreamingFileRepository;
import com.chatopera.cc.persistence.repository.TenantRepository;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -50,6 +48,7 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Map;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
......@@ -60,9 +59,6 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery;
public class Handler {
private static final Logger logger = LoggerFactory.getLogger(Handler.class);
@Autowired
private TenantRepository tenantRes;
@Autowired
private JpaBlobHelper jpaBlobHelper;
......@@ -101,7 +97,7 @@ public class Handler {
user = new User();
user.setId(MainUtils.getContextID(request.getSession().getId()));
user.setUsername(Constants.GUEST_USER + "_" + MainUtils.genIDByKey(user.getId()));
user.setOrgi(MainContext.SYSTEM_ORGI);
user.setOrgi(Constants.SYSTEM_ORGI);
user.setSessionid(user.getId());
}
} else {
......@@ -110,6 +106,33 @@ public class Handler {
return user;
}
/**
* 获得登录账号的当前导航的组织机构
* @param request
* @return
*/
public Organ getOrgan(HttpServletRequest request) {
User user = getUser(request);
if (user.getOrgans() != null) {
ArrayList<Organ> organs = new ArrayList<>(user.getOrgans().values());
if (organs.size() == 0) {
return null;
}
Organ organ = (Organ) request.getSession(true).getAttribute(Constants.ORGAN_SESSION_NAME);
if (organ == null) {
if (organs.size() > 0) {
organ = organs.get(0);
request.getSession(true).setAttribute(Constants.ORGAN_SESSION_NAME, organ);
}
}
return organ;
} else {
return null;
}
}
/**
* 构建ElasticSearch基于部门查询的Filter
*
......@@ -310,7 +333,7 @@ public class Handler {
user.setUsername(nickname);
} else {
Map<String, String> sessionMessage = cache.findOneSystemMapByIdAndOrgi(
request.getSession().getId(), MainContext.SYSTEM_ORGI);
request.getSession().getId(), Constants.SYSTEM_ORGI);
if (sessionMessage != null) {
String struname = sessionMessage.get("username");
String strcname = sessionMessage.get("company_name");
......@@ -340,7 +363,7 @@ public class Handler {
user.setUsername(nickname);
} else {
Map<String, String> sessionMessage = cache.findOneSystemMapByIdAndOrgi(
sessionid, MainContext.SYSTEM_ORGI);
sessionid, Constants.SYSTEM_ORGI);
if (sessionMessage != null) {
String struname = sessionMessage.get("username");
String strcname = sessionMessage.get("company_name");
......@@ -455,68 +478,13 @@ public class Handler {
return pagesize;
}
public String getOrgi(HttpServletRequest request) {
return getUser(request).getOrgi();
}
/**
* 机构id
*
* @param request
* @return
*/
public String getOrgid(HttpServletRequest request) {
User u = getUser(request);
return u.getOrgid();
}
public Tenant getTenant(HttpServletRequest request) {
return tenantRes.findById(getOrgi(request));
public String getOrgi() {
return Constants.SYSTEM_ORGI;
}
/**
* 根据是否租户共享获取orgi
*
* @param request
* @return
*/
public String getOrgiByTenantshare(HttpServletRequest request) {
SystemConfig systemConfig = MainUtils.getSystemConfig();
if (systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantshare()) {
User user = this.getUser(request);
return user.getOrgid();
}
return getOrgi(request);
}
/**
* 判断是否租户共享
*
* @return
*/
public boolean isTenantshare() {
SystemConfig systemConfig = MainUtils.getSystemConfig();
return systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantshare();
}
/**
* 判断是否多租户
*
* @return
*/
public boolean isEnabletneant() {
SystemConfig systemConfig = MainUtils.getSystemConfig();
return systemConfig != null && systemConfig.isEnabletneant();
}
/**
* 判断是否多租户
*
* @return
*/
public boolean isTenantconsole() {
SystemConfig systemConfig = MainUtils.getSystemConfig();
return systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantconsole();
// FIXME: 保存此处是为了兼容之前到代码,宜去掉
public String getOrgi(HttpServletRequest request) {
return getOrgi();
}
public long getStarttime() {
......
......@@ -21,17 +21,14 @@ import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.basic.auth.AuthToken;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.UserRole;
import com.chatopera.cc.persistence.repository.AgentStatusRepository;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.persistence.repository.UserRoleRepository;
import com.chatopera.cc.proxy.AgentProxy;
import com.chatopera.cc.proxy.AgentSessionProxy;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
......@@ -73,12 +70,6 @@ public class LoginController extends Handler {
@Autowired
private AuthToken authToken;
@Autowired
private AgentStatusRepository agentStatusRes;
@Autowired
private Cache cache;
@Autowired
private AgentProxy agentProxy;
......@@ -161,7 +152,7 @@ public class LoginController extends Handler {
view.addObject("tongjiBaiduSiteKey", tongjiBaiduSiteKey);
}
if(StringUtils.isNotBlank(adsLoginBanner) && StringUtils.equalsIgnoreCase(adsLoginBanner, "on")){
if (StringUtils.isNotBlank(adsLoginBanner) && StringUtils.equalsIgnoreCase(adsLoginBanner, "on")) {
view.addObject("adsLoginBanner", "on");
}
......@@ -309,10 +300,6 @@ public class LoginController extends Handler {
}
super.setUser(request, loginUser);
// 当前用户 企业id为空 调到创建企业页面
if (StringUtils.isBlank(loginUser.getOrgid())) {
view = new ModelAndView("redirect:/apps/organization/add.html");
}
}
return view;
}
......@@ -378,21 +365,10 @@ public class LoginController extends Handler {
if (StringUtils.isNotBlank(user.getPassword())) {
user.setPassword(MainUtils.md5(user.getPassword()));
}
user.setOrgi(super.getOrgiByTenantshare(request));
/*if(StringUtils.isNotBlank(super.getUser(request).getOrgid())) {
user.setOrgid(super.getUser(request).getOrgid());
}else {
user.setOrgid(MainContext.SYSTEM_ORGI);
}*/
user.setOrgi(super.getOrgi());
userRepository.save(user);
OnlineUserProxy.clean(super.getOrgi(request));
}
ModelAndView view = this.processLogin(request, user, "");
//当前用户 企业id为空 调到创建企业页面
if (StringUtils.isBlank(user.getOrgid())) {
view = request(super.createRequestPageTempletResponse("redirect:/apps/organization/add.html"));
}
return view;
}
......
......@@ -79,7 +79,7 @@ public class AdminController extends Handler {
map.put("onlineUserCache", cache.getOnlineUserSizeByOrgi(orgi));
map.put("onlineUserClients", OnlineUserProxy.webIMClients.size());
map.put("chatClients", NettyClients.getInstance().size());
map.put("systemCaches", cache.getSystemSizeByOrgi(MainContext.SYSTEM_ORGI));
map.put("systemCaches", cache.getSystemSizeByOrgi(Constants.SYSTEM_ORGI));
map.put("agentReport", acdWorkMonitor.getAgentReport(orgi));
map.put("webIMReport", MainUtils.getWebIMReport(userEventRes.findByOrgiAndCreatetimeRange(super.getOrgi(request), MainUtils.getStartTime(), MainUtils.getEndTime())));
......@@ -107,12 +107,7 @@ public class AdminController extends Handler {
private List<User> getAgent(HttpServletRequest request) {
//获取当前产品or租户坐席数
List<User> userList = new ArrayList<>();
if (super.isEnabletneant()) {
userList = userRes.findByOrgidAndAgentAndDatastatus(super.getOrgid(request), true, false);
} else {
userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
}
List<User> userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
return userList.isEmpty() ? new ArrayList<User>() : userList;
}
......
......@@ -86,8 +86,7 @@ public class OrganController extends Handler {
@RequestMapping("/index")
@Menu(type = "admin", subtype = "organ")
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String organ, @Valid String msg) {
List<Organ> organList = organRepository.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request), super.getOrgid(request));
List<Organ> organList = organRepository.findByOrgi(super.getOrgi());
map.addAttribute("organList", organList);
if (organList.size() > 0) {
Organ organData = null;
......@@ -105,15 +104,12 @@ public class OrganController extends Handler {
map.addAttribute(
"userList", userProxy.findByOrganAndOrgiAndDatastatus(
organData.getId(),
super.getOrgiByTenantshare(request),
super.getOrgi(),
false));
}
}
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
map.addAttribute(
"roleList", roleRepository.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request),
super.getOrgid(request)));
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi()));
map.addAttribute("roleList", roleRepository.findByOrgi(super.getOrgi()));
map.put("msg", msg);
return request(super.createAdminTempletResponse("/admin/organ/index"));
}
......@@ -121,18 +117,15 @@ public class OrganController extends Handler {
@RequestMapping("/add")
@Menu(type = "admin", subtype = "organ")
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String parent, @Valid String area) {
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi()));
if (!StringUtils.isBlank(parent)) {
map.addAttribute("organ", organRepository.findByIdAndOrgi(parent, super.getOrgiByTenantshare(request)));
map.addAttribute("organ", organRepository.findByIdAndOrgi(parent, super.getOrgi()));
}
if (!StringUtils.isBlank(area)) {
map.addAttribute("area", areaRepository.findByIdAndOrgi(area, super.getOrgiByTenantshare(request)));
map.addAttribute("area", areaRepository.findByIdAndOrgi(area, super.getOrgi()));
}
map.addAttribute(
"organList", organRepository.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request),
super.getOrgid(request)));
map.addAttribute("organList", organRepository.findByOrgi(super.getOrgi()));
return request(super.createRequestPageTempletResponse("/admin/organ/add"));
}
......@@ -140,25 +133,16 @@ public class OrganController extends Handler {
@RequestMapping("/save")
@Menu(type = "admin", subtype = "organ")
public ModelAndView save(HttpServletRequest request, @Valid Organ organ) {
Organ tempOrgan = organRepository.findByNameAndOrgiAndOrgid(
organ.getName(), super.getOrgiByTenantshare(request), super.getOrgid(request));
Organ tempOrgan = organRepository.findByNameAndOrgi(organ.getName(), super.getOrgi(request));
String msg = "admin_organ_new_success";
String firstId = null;
if (tempOrgan != null) {
msg = "admin_organ_update_name_not"; //分类名字重复
} else {
organ.setOrgi(super.getOrgiByTenantshare(request));
if (!StringUtils.isBlank(super.getUser(request).getOrgid())) {
organ.setOrgid(super.getUser(request).getOrgid());
} else {
organ.setOrgid(MainContext.SYSTEM_ORGI);
}
organ.setOrgi(super.getOrgi());
firstId = organ.getId();
organRepository.save(organ);
OnlineUserProxy.clean(super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse(
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + firstId));
......@@ -176,11 +160,10 @@ public class OrganController extends Handler {
@Menu(type = "admin", subtype = "seluser", admin = true)
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String organ) {
map.addAttribute(
"userList", userRepository.findByOrgiAndDatastatusAndOrgid(super.getOrgiByTenantshare(request), false,
super.getOrgid(request)));
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgiByTenantshare(request));
"userList", userRepository.findByOrgiAndDatastatus(super.getOrgi(), false));
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgi());
map.addAttribute("userOrganList", userProxy
.findByOrganAndOrgiAndDatastatus(organ, super.getOrgiByTenantshare(request), false));
.findByOrganAndOrgiAndDatastatus(organ, super.getOrgi(), false));
map.addAttribute("organ", organData);
return request(super.createRequestPageTempletResponse("/admin/organ/seluser"));
}
......@@ -200,13 +183,13 @@ public class OrganController extends Handler {
HttpServletRequest request,
final @Valid String[] users,
final @Valid String organ
) {
) {
logger.info("[saveuser] save users {} into organ {}", StringUtils.join(users, ","), organ);
final User loginUser = super.getUser(request);
if (users != null && users.length > 0) {
List<String> chosen = new ArrayList<String>(Arrays.asList(users));
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgiByTenantshare(request));
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgi());
List<User> organUserList = userRepository.findAll(chosen);
for (final User user : organUserList) {
OrganUser ou = organUserRes.findByUseridAndOrgan(user.getId(), organ);
......@@ -240,19 +223,18 @@ public class OrganController extends Handler {
* 以下更新技能组状态
*/
AgentStatus agentStatus = cache.findOneAgentStatusByAgentnoAndOrig(
user.getId(), super.getOrgiByTenantshare(request));
user.getId(), super.getOrgi());
// TODO 因为一个用户可以包含在多个技能组中,所以,skill应该对应
// 一个List列表,此处需要重构Skill为列表
if (agentStatus != null) {
userProxy.attachOrgansPropertiesForUser(user);
agentStatus.setSkills(user.getSkills());
cache.putAgentStatusByOrgi(agentStatus, super.getOrgiByTenantshare(request));
cache.putAgentStatusByOrgi(agentStatus, super.getOrgi());
}
}
}
userRepository.save(organUserList);
OnlineUserProxy.clean(super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
......@@ -264,11 +246,10 @@ public class OrganController extends Handler {
final HttpServletRequest request,
final @Valid String id,
final @Valid String organ
) {
) {
logger.info("[userroledelete] user id {}, organ {}", id, organ);
if (id != null) {
organUserRes.deleteOrganUserByUseridAndOrgan(id, organ);
OnlineUserProxy.clean(super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
}
......@@ -277,13 +258,10 @@ public class OrganController extends Handler {
@Menu(type = "admin", subtype = "organ")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/organ/edit"));
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
view.addObject("organData", organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi()));
view.addObject("organData", organRepository.findByIdAndOrgi(id, super.getOrgi()));
map.addAttribute(
"organList", organRepository.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request),
super.getOrgid(request)));
map.addAttribute("organList", organRepository.findByOrgi(super.getOrgi()));
return view;
}
......@@ -306,7 +284,7 @@ public class OrganController extends Handler {
}
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC));
map.addAttribute("organData", organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
map.addAttribute("organData", organRepository.findByIdAndOrgi(id, super.getOrgi()));
return request(super.createRequestPageTempletResponse("/admin/organ/area"));
}
......@@ -314,12 +292,11 @@ public class OrganController extends Handler {
@RequestMapping("/area/update")
@Menu(type = "admin", subtype = "organ")
public ModelAndView areaupdate(HttpServletRequest request, @Valid Organ organ) {
Organ tempOrgan = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgiByTenantshare(request));
Organ tempOrgan = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgi());
String msg = "admin_organ_update_success";
if (tempOrgan != null) {
tempOrgan.setArea(organ.getArea());
organRepository.save(tempOrgan);
OnlineUserProxy.clean(super.getOrgi(request));
} else {
msg = "admin_organ_update_not_exist";
}
......@@ -332,7 +309,7 @@ public class OrganController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid Organ organ) {
String msg = "admin_organ_delete";
Organ organSelf = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgiByTenantshare(request));
Organ organSelf = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgi());
List<Organ> organParentAre = organRepository.findByOrgiAndParent(organSelf.getOrgi(), organSelf.getId());
if (organ != null && organParentAre != null && organParentAre.size() > 0) {
msg = "admin_oran_not_delete";
......@@ -340,7 +317,6 @@ public class OrganController extends Handler {
List<OrganUser> organUsers = organUserRes.findByOrgan(organ.getId());
organUserRes.deleteInBatch(organUsers);
organRepository.delete(organ);
OnlineUserProxy.clean(super.getOrgi(request));
} else {
msg = "admin_organ_not_exist";
}
......@@ -350,8 +326,8 @@ public class OrganController extends Handler {
@RequestMapping("/auth/save")
@Menu(type = "admin", subtype = "role")
public ModelAndView authsave(HttpServletRequest request, @Valid String id, @Valid String menus) {
Organ organData = organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request));
List<OrganRole> organRoleList = organRoleRes.findByOrgiAndOrgan(super.getOrgiByTenantshare(request), organData);
Organ organData = organRepository.findByIdAndOrgi(id, super.getOrgi());
List<OrganRole> organRoleList = organRoleRes.findByOrgiAndOrgan(super.getOrgi(), organData);
organRoleRes.delete(organRoleList);
if (!StringUtils.isBlank(menus)) {
String[] menusarray = menus.split(",");
......@@ -364,7 +340,7 @@ public class OrganController extends Handler {
organRole.setOrgan(organData);
organRole.setCreater(super.getUser(request).getId());
organRole.setOrgi(super.getOrgiByTenantshare(request));
organRole.setOrgi(super.getOrgi(request));
organRole.setCreatetime(new Date());
organRoleRes.save(organRole);
}
......
......@@ -61,7 +61,7 @@ public class RoleController extends Handler {
@RequestMapping("/index")
@Menu(type = "admin", subtype = "role")
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String role, @Valid String msg) {
List<Role> roleList = roleRepository.findByOrgiAndOrgid(super.getOrgiByTenantshare(request), super.getOrgid(request));
List<Role> roleList = roleRepository.findByOrgi(super.getOrgi());
map.addAttribute("roleList", roleList);
map.addAttribute("msg", msg);
if (roleList.size() > 0) {
......@@ -77,7 +77,7 @@ public class RoleController extends Handler {
map.addAttribute("roleData", roleData = roleList.get(0));
}
if (roleData != null) {
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), roleData, new PageRequest(super.getP(request), super.getPs(request))));
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData, new PageRequest(super.getP(request), super.getPs(request))));
}
}
return request(super.createAdminTempletResponse("/admin/role/index"));
......@@ -92,22 +92,15 @@ public class RoleController extends Handler {
@RequestMapping("/save")
@Menu(type = "admin", subtype = "role")
public ModelAndView save(HttpServletRequest request, @Valid Role role) {
Role tempRole = roleRepository.findByNameAndOrgiAndOrgid(role.getName(), super.getOrgiByTenantshare(request), super.getOrgid(request));
Role tempRole = roleRepository.findByNameAndOrgi(role.getName(), super.getOrgi());
String msg = "admin_role_save_success";
if (tempRole != null) {
msg = "admin_role_save_exist";
} else {
role.setOrgi(super.getOrgiByTenantshare(request));
role.setOrgi(super.getOrgi());
role.setCreater(super.getUser(request).getId());
role.setCreatetime(new Date());
role.setUpdatetime(new Date());
if (StringUtils.isNotBlank(super.getUser(request).getOrgid())) {
role.setOrgid(super.getUser(request).getOrgid());
} else {
role.setOrgid(MainContext.SYSTEM_ORGI);
}
roleRepository.save(role);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?msg=" + msg));
......@@ -116,9 +109,9 @@ public class RoleController extends Handler {
@RequestMapping("/seluser")
@Menu(type = "admin", subtype = "seluser", admin = true)
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String role) {
map.addAttribute("userList", userRepository.findByOrgiAndDatastatusAndOrgid(super.getOrgiByTenantshare(request), false, super.getOrgid(request)));
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgiByTenantshare(request));
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), roleData));
map.addAttribute("userList", userRepository.findByOrgiAndDatastatus(super.getOrgi(), false));
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgi());
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData));
map.addAttribute("role", roleData);
return request(super.createRequestPageTempletResponse("/admin/role/seluser"));
}
......@@ -127,8 +120,8 @@ public class RoleController extends Handler {
@RequestMapping("/saveuser")
@Menu(type = "admin", subtype = "saveuser", admin = true)
public ModelAndView saveuser(HttpServletRequest request, @Valid String[] users, @Valid String role) {
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgiByTenantshare(request));
List<UserRole> userRoleList = userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), roleData);
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgi());
List<UserRole> userRoleList = userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData);
if (users != null && users.length > 0) {
for (String user : users) {
boolean exist = false;
......@@ -142,7 +135,7 @@ public class RoleController extends Handler {
UserRole userRole = new UserRole();
userRole.setUser(new User(user));
userRole.setRole(new Role(role));
userRole.setOrgi(super.getOrgiByTenantshare(request));
userRole.setOrgi(super.getOrgi());
userRole.setCreater(super.getUser(request).getId());
userRoleRes.save(userRole);
}
......@@ -164,27 +157,20 @@ public class RoleController extends Handler {
@Menu(type = "admin", subtype = "role")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/role/edit"));
view.addObject("roleData", roleRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
view.addObject("roleData", roleRepository.findByIdAndOrgi(id, super.getOrgi()));
return view;
}
@RequestMapping("/update")
@Menu(type = "admin", subtype = "role")
public ModelAndView update(HttpServletRequest request, @Valid Role role) {
Role tempRoleExist = roleRepository.findByNameAndOrgi(role.getName(), super.getOrgiByTenantshare(request));
Role tempRoleExist = roleRepository.findByNameAndOrgi(role.getName(), super.getOrgi());
String msg = "";
if (tempRoleExist == null) {
msg = "admin_role_update_success";
Role tempRole = roleRepository.findByIdAndOrgi(role.getId(), super.getOrgiByTenantshare(request));
Role tempRole = roleRepository.findByIdAndOrgi(role.getId(), super.getOrgi());
tempRole.setName(role.getName());
tempRole.setUpdatetime(new Date());
if (StringUtils.isNotBlank(super.getUser(request).getOrgid())) {
tempRole.setOrgid(super.getUser(request).getOrgid());
} else {
tempRole.setOrgid(MainContext.SYSTEM_ORGI);
}
roleRepository.save(tempRole);
} else if (!role.getId().equals(tempRoleExist.getId())) {
msg = "admin_role_update_not_exist";
......@@ -197,7 +183,7 @@ public class RoleController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid Role role) {
String msg = "admin_role_delete";
if (role != null) {
userRoleRes.delete(userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), role));
userRoleRes.delete(userRoleRes.findByOrgiAndRole(super.getOrgi(), role));
roleRepository.delete(role);
} else {
msg = "admin_role_not_exist";
......@@ -214,18 +200,18 @@ public class RoleController extends Handler {
map.addAttribute("resourceList", sysDicRes.findByDicid(sysDic.getId()));
}
map.addAttribute("sysDic", sysDic);
Role role = roleRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request));
Role role = roleRepository.findByIdAndOrgi(id, super.getOrgi());
map.addAttribute("role", role);
map.addAttribute("roleAuthList", roleAuthRes.findByRoleidAndOrgi(role.getId(), super.getOrgiByTenantshare(request)));
map.addAttribute("roleAuthList", roleAuthRes.findByRoleidAndOrgi(role.getId(), super.getOrgi()));
return request(super.createRequestPageTempletResponse("/admin/role/auth"));
}
@RequestMapping("/auth/save")
@Menu(type = "admin", subtype = "role")
public ModelAndView authsave(HttpServletRequest request, @Valid String id, @Valid String menus) {
logger.info("[authsave] id {}, menus {}", id, menus);
// logger.info("[authsave] id {}, menus {}", id, menus);
List<RoleAuth> roleAuthList = roleAuthRes.findByRoleidAndOrgi(id, super.getOrgiByTenantshare(request));
List<RoleAuth> roleAuthList = roleAuthRes.findByRoleidAndOrgi(id, super.getOrgi());
roleAuthRes.delete(roleAuthList);
if (StringUtils.isNotBlank(menus)) {
String[] menuarray = menus.split(",");
......@@ -242,7 +228,7 @@ public class RoleController extends Handler {
if (sysDic != null && (!StringUtils.equals(sysDic.getParentid(), "0"))) {
logger.debug("[authsave] get sysdict {}, code {}, name {}, parent {}", sysDic.getId(), sysDic.getCode(), sysDic.getName(), sysDic.getParentid());
roleAuth.setCreater(super.getUser(request).getId());
roleAuth.setOrgi(super.getOrgiByTenantshare(request));
roleAuth.setOrgi(super.getOrgi());
roleAuth.setCreatetime(new Date());
roleAuth.setName(sysDic.getName());
roleAuth.setDicvalue(sysDic.getCode());
......@@ -253,4 +239,4 @@ public class RoleController extends Handler {
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?role=" + id));
}
}
\ No newline at end of file
}
......@@ -16,12 +16,17 @@
*/
package com.chatopera.cc.controller.admin;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.OrganUser;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.UserRole;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.persistence.repository.UserRoleRepository;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -37,6 +42,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author 程序猿DD
......@@ -54,24 +60,49 @@ public class UsersController extends Handler {
@Autowired
private UserRoleRepository userRoleRes;
@Autowired
OrganProxy organProxy;
@Autowired
UserProxy userProxy;
@Autowired
private OrganUserRepository organUserRes;
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private ExtensionRepository extensionRes;
@RequestMapping("/index")
@Menu(type = "admin", subtype = "user")
public ModelAndView index(ModelMap map, HttpServletRequest request) throws IOException {
map.addAttribute(
"userList",
userRepository.findByDatastatusAndOrgiAndOrgidAndSuperadminNot(
false,
super.getOrgiByTenantshare(request),
super.getOrgid(request),
true,
new PageRequest(
super.getP(request),
super.getPs(request),
Sort.Direction.ASC,
"createtime"
)
)
);
User logined = super.getUser(request);
if (!logined.isSuperadmin()) {
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(super.getOrgan(request), super.getOrgi(request));
map.addAttribute("userList", userProxy.findUserInOrgans(organs.keySet(), new PageRequest(
super.getP(request),
super.getPs(request),
Sort.Direction.ASC,
"createtime"
)));
} else {
map.addAttribute(
"userList",
userRepository.findByDatastatusAndOrgiAndSuperadminNot(
false,
super.getOrgi(),
true,
new PageRequest(
super.getP(request),
super.getPs(request),
Sort.Direction.ASC,
"createtime"
)
)
);
}
return request(super.createAdminTempletResponse("/admin/user/index"));
}
......@@ -85,7 +116,20 @@ public class UsersController extends Handler {
@Menu(type = "admin", subtype = "user")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/user/edit"));
view.addObject("userData", userRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
User user = userRepository.findById(id);
if (user != null && MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
// 加载呼叫中心信息
extensionRes.findByAgentnoAndOrgi(user.getId(), user.getOrgi()).ifPresent(p -> {
user.setExtensionId(p.getId());
user.setExtension(p);
pbxHostRes.findById(p.getHostid()).ifPresent(b -> {
user.setPbxhostId(b.getId());
user.setPbxHost(b);
});
});
}
view.addObject("userData", user);
return view;
}
......@@ -94,12 +138,19 @@ public class UsersController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid User user) {
String msg = "admin_user_delete";
if (user != null) {
List<UserRole> userRole = userRoleRes.findByOrgiAndUser(super.getOrgiByTenantshare(request), user);
userRoleRes.delete(userRole); //删除用户的时候,同时删除用户对应的
user = userRepository.getOne(user.getId());
user.setDatastatus(true);
userRepository.save(user);
OnlineUserProxy.clean(super.getOrgi(request));
User dbUser = userRepository.getOne(user.getId());
if (dbUser.isSuperadmin()) {
msg = "admin_user_abandoned";
} else {
// 删除用户的时候,同时删除用户对应的权限数据
List<UserRole> userRole = userRoleRes.findByOrgiAndUser(super.getOrgi(), user);
userRoleRes.delete(userRole);
// 删除用户对应的组织机构关系
List<OrganUser> organUsers = organUserRes.findByUserid(user.getId());
organUserRes.delete(organUsers);
userRepository.delete(dbUser);
}
} else {
msg = "admin_user_not_exist";
}
......
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Acl;
import com.chatopera.cc.persistence.repository.AclRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterAclController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private AclRepository aclRes ;
@RequestMapping(value = "/acl")
@Menu(type = "callcenter" , subtype = "callcenteracl" , access = false , admin = true)
public ModelAndView acl(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("aclList" , aclRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/index"));
}
@RequestMapping(value = "/acl/add")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acladd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/add"));
}
@RequestMapping(value = "/acl/save")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView aclsave(ModelMap map , HttpServletRequest request , @Valid Acl acl) {
if(!StringUtils.isBlank(acl.getName())){
int count = aclRes.countByNameAndOrgi(acl.getName(), super.getOrgi(request)) ;
if(count == 0){
acl.setOrgi(super.getOrgi(request));
acl.setCreater(super.getUser(request).getId());
aclRes.save(acl) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+acl.getHostid()));
}
@RequestMapping(value = "/acl/edit")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acledit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("acl" , aclRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/edit"));
}
@RequestMapping(value = "/acl/update")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid Acl acl) {
if(!StringUtils.isBlank(acl.getId())){
Acl oldAcl = aclRes.findByIdAndOrgi(acl.getId(), super.getOrgi(request)) ;
if(oldAcl!=null){
oldAcl.setName(acl.getName());
oldAcl.setDefaultvalue(acl.getDefaultvalue());
oldAcl.setStrategy(acl.getStrategy());
aclRes.save(oldAcl);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+acl.getHostid()));
}
@RequestMapping(value = "/acl/delete")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acldelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
aclRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+hostid));
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.BlackEntity;
import com.chatopera.cc.persistence.repository.BlackListRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterBlackController extends Handler{
@Autowired
private BlackListRepository blackRes ;
@RequestMapping(value = "/black")
@Menu(type = "callcenter" , subtype = "callcenterblack" , access = false , admin = true)
public ModelAndView black(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.addAttribute("blackList" , blackRes.findByOrgi(super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/index"));
}
@RequestMapping(value = "/black/add")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView blackadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/add"));
}
@RequestMapping(value = "/black/save")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView blacksave(ModelMap map , HttpServletRequest request , @Valid String phones) {
if(!StringUtils.isBlank(phones)){
String[] ps = phones.split("[ ,,\t\n]") ;
for(String ph : ps){
if(ph.length() >= 3){
int count = blackRes.countByPhoneAndOrgi(ph.trim(), super.getOrgi(request)) ;
if(count == 0){
BlackEntity be = new BlackEntity();
be.setPhone(ph.trim());
be.setChannel(MainContext.ChannelType.PHONE.toString());
be.setOrgi(super.getOrgi(request));
be.setCreater(super.getUser(request).getId());
blackRes.save(be) ;
}
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
}
@RequestMapping(value = "/black/edit")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView blackedit(ModelMap map , HttpServletRequest request , @Valid String id) {
map.addAttribute("black" , blackRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/edit"));
}
@RequestMapping(value = "/black/update")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid BlackEntity black) {
if(!StringUtils.isBlank(black.getId())){
BlackEntity oldBlack = blackRes.findByIdAndOrgi(black.getId(), super.getOrgi(request)) ;
if(oldBlack!=null){
oldBlack.setPhone(black.getPhone());
oldBlack.setChannel(MainContext.ChannelType.PHONE.toString());
oldBlack.setOrgi(super.getOrgi(request));
blackRes.save(oldBlack);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
}
@RequestMapping(value = "/black/delete")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView blackdelete(ModelMap map , HttpServletRequest request , @Valid String id) {
if(!StringUtils.isBlank(id)){
blackRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.persistence.interfaces.CallCenterInterface;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes;
@RequestMapping(value = "/index")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String msg) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter");
for (PbxHost pbxHost : pbxHostList) {
if (callCenterImpl != null) {
pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
}
}
}
map.addAttribute("pbxHostList", pbxHostList);
return request(super.createAdminTempletResponse("/admin/callcenter/index"));
}
@RequestMapping(value = "/pbxhost")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhost(ModelMap map, HttpServletRequest request) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter");
for (PbxHost pbxHost : pbxHostList) {
if (callCenterImpl != null) {
pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
}
}
}
map.addAttribute("pbxHostList", pbxHostList);
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/index"));
}
@RequestMapping(value = "/pbxhost/add")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhostadd(ModelMap map, HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/add"));
}
@RequestMapping(value = "/pbxhost/save")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhostsave(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
String msg = null;
if (!StringUtils.isBlank(pbxHost.getName())) {
int count = pbxHostRes.countByHostnameAndOrgi(pbxHost.getHostname(), super.getOrgi(request));
if (count == 0) {
pbxHost.setOrgi(super.getOrgi(request));
pbxHost.setCreater(super.getUser(request).getId());
pbxHostRes.save(pbxHost);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter");
if (callCenterImpl != null) {
try {
callCenterImpl.init(pbxHost);
} catch (Exception ex) {
msg = ex.getMessage();
ex.printStackTrace();
}
}
}
}
}
if (!StringUtils.isBlank(msg)) {
view = request(
super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html?msg=" + msg));
}
return view;
}
@RequestMapping(value = "/pbxhost/edit")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhostedit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/edit"));
}
@RequestMapping(value = "/pbxhost/update")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
String msg = null;
if (!StringUtils.isBlank(pbxHost.getId())) {
PbxHost destHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request));
destHost.setHostname(pbxHost.getHostname());
destHost.setIpaddr(pbxHost.getIpaddr());
destHost.setName(pbxHost.getName());
destHost.setPort(pbxHost.getPort());
if (!StringUtils.isBlank(pbxHost.getPassword())) {
destHost.setPassword(pbxHost.getPassword());
}
pbxHostRes.save(destHost);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter");
if (callCenterImpl != null) {
try {
callCenterImpl.init(destHost);
} catch (Exception ex) {
msg = ex.getMessage();
ex.printStackTrace();
}
}
}
}
if (!StringUtils.isBlank(msg)) {
view = request(
super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html?msg=" + msg));
}
return view;
}
@RequestMapping(value = "/pbxhost/delete")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView mediadelete(ModelMap map, HttpServletRequest request, @Valid String id) {
if (!StringUtils.isBlank(id)) {
pbxHostRes.delete(id);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter");
if (callCenterImpl != null) {
callCenterImpl.remove(id);
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.CallcenterOutboundProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.freeswitch.model.CallCenterAgent;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterExtentionController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private ExtentionRepository extentionRes;
@Autowired
private SipTrunkRepository sipTrunkRes;
@Autowired
private MediaRepository mediaRes;
@Autowired
private ServiceAiRepository serviceAiRes;
@Autowired
private ProductRepository productRes;
@Autowired
private QueSurveyProcessRepository queSurveyProcessRes;
@Autowired
private Cache cache;
@RequestMapping(value = "/extention")
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
public ModelAndView extention(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null;
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList", extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/index"));
}
private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) {
PbxHost pbxHost = pbxHostList.get(0);
if (StringUtils.isNotBlank(hostid)) {
for (PbxHost pbx : pbxHostList) {
if (pbx.getId().equals(hostid)) {
pbxHost = pbx;
break;
}
}
}
return pbxHost;
}
@RequestMapping(value = "/extention/add")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/add"));
}
@RequestMapping(value = "/extention/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map, HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getExtention()) && StringUtils.isNotBlank(extention.getPassword())) {
String[] extstr = extention.getExtention().split("[,, ]");
int extnum = 0;
for (String ext : extstr) {
if (ext.matches("[\\d]{3,8}")) { //分机号码最少3位数字
createNewExtention(ext, super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention);
} else {
String[] ph = ext.split("[~-]");
if (ph.length == 2 && ph[0].matches("[\\d]{3,8}") && ph[1].matches("[\\d]{3,8}") && ph[0].length() == ph[1].length()) {
int start = Integer.parseInt(ph[0]);
int end = Integer.parseInt(ph[1]);
for (int i = start; i <= end && extnum < 100; i++) { //最大一次批量生产的 分机号不超过100个
createNewExtention(String.valueOf(i), super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention);
}
}
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
}
private Extention createNewExtention(String num, User user, String hostid, String password, String orgi, Extention src) {
Extention extno = new Extention();
extno.setExtention(num);
extno.setOrgi(orgi);
extno.setCreater(user.getId());
extno.setHostid(hostid);
extno.setPassword(password);
extno.setPlaynum(src.isPlaynum());
extno.setCallout(src.isCallout());
extno.setRecord(src.isRecord());
extno.setExtype(src.getExtype());
extno.setMediapath(src.getMediapath());
extno.setSiptrunk(src.getSiptrunk());
extno.setEnablewebrtc(src.isEnablewebrtc());
int count = extentionRes.countByExtentionAndHostidAndOrgi(extno.getExtention(), hostid, orgi);
if (count == 0) {
extentionRes.save(extno);
}
return extno;
}
@RequestMapping(value = "/extention/edit")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/edit"));
}
@RequestMapping(value = "/extention/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionupdate(ModelMap map, HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getId())) {
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
if (ext != null) {
// ext.setExtention(extention.getExtention());//分机号不能修改
if (StringUtils.isNotBlank(extention.getPassword())) {
ext.setPassword(extention.getPassword());
}
ext.setPlaynum(extention.isPlaynum());
ext.setCallout(extention.isCallout());
ext.setRecord(extention.isRecord());
ext.setExtype(extention.getExtype());
ext.setSubtype(extention.getSubtype());
ext.setDescription(extention.getDescription());
ext.setMediapath(extention.getMediapath());
ext.setSiptrunk(extention.getSiptrunk());
ext.setEnablewebrtc(extention.isEnablewebrtc());
ext.setUpdatetime(new Date());
extentionRes.save(ext);
List<CallCenterAgent> callOutAgentList = CallcenterOutboundProxy.extention(ext.getExtention());
for (CallCenterAgent callOutAgent : callOutAgentList) {
callOutAgent.setSiptrunk(ext.getSiptrunk());
cache.putCallCenterAgentByIdAndOrgi(callOutAgent.getUserid(), callOutAgent.getOrgi(), callOutAgent);
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
}
@RequestMapping(value = "/extention/ivr")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView ivr(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request)));
map.put("queList", queSurveyProcessRes.findByOrgi(super.getOrgi(request)));
map.put("productList", productRes.findByOrgi(super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/ivr"));
}
@RequestMapping(value = "/extention/ivr/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView ivrupdate(ModelMap map, HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getId())) {
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
if (ext != null) {
ext.setEnableai(extention.getEnableai());
ext.setAiid(extention.getAiid());
ext.setSceneid(extention.getSceneid());
ext.setWelcomemsg(extention.getWelcomemsg());
ext.setWaitmsg(extention.getWaitmsg());
ext.setTipmessage(extention.getTipmessage());
ext.setAitype(extention.getAitype());
ext.setBustype(extention.getBustype());
ext.setProid(extention.getProid());
ext.setQueid(extention.getQueid());
extentionRes.save(ext);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
}
@RequestMapping(value = "/extention/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentiondelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
if (StringUtils.isNotBlank(id)) {
extentionRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + hostid));
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Extention;
import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.IvrMenuRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterIvrController extends Handler{
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private ExtentionRepository extentionRes ;
@Autowired
private IvrMenuRepository ivrMenuRes;
@RequestMapping(value = "/ivr")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView ivr(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("ivrList" , extentionRes.findByExtypeAndOrgi("ivr", super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/index"));
}
@RequestMapping(value = "/ivr/edit")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/edit"));
}
@RequestMapping(value = "/ivr/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionupdate(ModelMap map , HttpServletRequest request , @Valid Extention extention) {
if(!StringUtils.isBlank(extention.getId())){
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)) ;
ext.setExtention(extention.getExtention());
ext.setDescription(extention.getDescription());
extentionRes.save(ext) ;
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid="+extention.getHostid()));
}
@RequestMapping(value = "/ivr/delete")
@Menu(type = "callcenter" , subtype = "ivr" , access = false , admin = true)
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
extentionRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid="+hostid));
}
@RequestMapping(value = "/ivr/design")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView design(ModelMap map , HttpServletRequest request , @Valid String hostid , @Valid String id) {
if(!StringUtils.isBlank(hostid)){
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.addAttribute("ivrMenuList" , ivrMenuRes.findByExtentionidAndHostidAndOrgi(id, hostid, super.getOrgi(request)));
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/design"));
}
@RequestMapping(value = "/ivr/menu/add")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView ivrmenuadd(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid , @Valid String parentid) {
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/menuadd"));
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Media;
import com.chatopera.cc.persistence.repository.MediaRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.File;
import java.io.IOException;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterMediaController extends Handler{
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private MediaRepository mediaRes ;
@Value("${web.upload-path}")
private String path;
@RequestMapping(value = "/media")
@Menu(type = "callcenter" , subtype = "callcentermedia" , access = false , admin = true)
public ModelAndView media(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("mediaList" , mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/index"));
}
@RequestMapping(value = "/media/add")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView mediaadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/add"));
}
@RequestMapping(value = "/media/save")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView mediasave(ModelMap map , HttpServletRequest request , @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
Media media = new Media();
media.setName(request.getParameter("name"));
media.setHostid(request.getParameter("hostid"));
if(!StringUtils.isBlank(media.getName())){
int count = mediaRes.countByNameAndOrgi(media.getName(), super.getOrgi(request)) ;
if(count == 0){
String fileName = "media/"+ MainUtils.getUUID()+mediafile.getOriginalFilename().substring(mediafile.getOriginalFilename().lastIndexOf(".")) ;
media.setOrgi(super.getOrgi(request));
media.setCreater(super.getUser(request).getId());
media.setFilelength((int) mediafile.getSize());
media.setContent(mediafile.getContentType());
media.setFilename(fileName);
if(mediafile!=null && mediafile.getOriginalFilename().lastIndexOf(".") > 0){
File logoDir = new File(path , "media");
if(!logoDir.exists()){
logoDir.mkdirs() ;
}
FileCopyUtils.copy(mediafile.getBytes(), new File(path , fileName));
}
mediaRes.save(media) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+media.getHostid()));
}
@RequestMapping(value = "/media/edit")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView mediaedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("media" , mediaRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/edit"));
}
@RequestMapping(value = "/media/update")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
Media media = new Media();
media.setName(request.getParameter("name"));
media.setHostid(request.getParameter("hostid"));
media.setId(request.getParameter("id"));
if(!StringUtils.isBlank(media.getId())){
Media oldMedia = mediaRes.findByIdAndOrgi(media.getId(), super.getOrgi(request)) ;
if(oldMedia!=null){
if(mediafile!=null && mediafile.getSize() > 0){
File wavFile = new File(path , oldMedia.getFilename());
if(!wavFile.exists()){
wavFile.deleteOnExit();
}
String fileName = "media/"+ MainUtils.getUUID()+mediafile.getOriginalFilename().substring(mediafile.getOriginalFilename().lastIndexOf(".")) ;
oldMedia.setFilename(fileName);
if(mediafile!=null && mediafile.getOriginalFilename().lastIndexOf(".") > 0){
File mediaDir = new File(path , "media");
if(!mediaDir.exists()){
mediaDir.mkdirs() ;
}
FileCopyUtils.copy(mediafile.getBytes(), new File(path , fileName));
}
}
oldMedia.setName(media.getName());
mediaRes.save(oldMedia);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+media.getHostid()));
}
@RequestMapping(value = "/media/delete")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView mediadelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
mediaRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+hostid));
}
@RequestMapping(value = "/play")
@Menu(type = "callcenter" , subtype = "play" , access = false)
public ModelAndView play(ModelMap map , HttpServletRequest request ,@Valid final String id ,@Valid final String hostid) {
map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/play"));
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.persistence.interfaces.CallCenterInterface;
import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.ServiceAiRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterResourceController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private ExtentionRepository extentionRes;
@Autowired
private ServiceAiRepository serviceAiRes;
@RequestMapping(value = "/resource")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList);
map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request)));
PbxHost pbxHost = null;
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList",
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
}
return request(super.createAdminTempletResponse("/admin/callcenter/resource/index"));
}
@RequestMapping(value = "/resource/config")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView config(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null;
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList",
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/resource/config"));
}
@RequestMapping(value = "/resource/save")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) throws Exception {
PbxHost tempPbxHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request));
if (tempPbxHost != null) {
pbxHost.setCreater(tempPbxHost.getCreater());
pbxHost.setCreatetime(tempPbxHost.getCreatetime());
if (StringUtils.isBlank(pbxHost.getPassword())) {
pbxHost.setPassword(tempPbxHost.getPassword());
}
pbxHost.setOrgi(super.getOrgi(request));
pbxHostRes.save(pbxHost);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter");
callCenterImpl.init(pbxHost);
}
}
return request(super.createRequestPageTempletResponse(
"redirect:/admin/callcenter/resource.html?hostid=" + pbxHost.getId()));
}
@RequestMapping(value = "/resource/pbxhost")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView resourcepbx(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null;
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList",
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
}
return request(super.createAdminTempletResponse("/admin/callcenter/resource/pbxhost"));
}
private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) {
PbxHost pbxHost = pbxHostList.get(0);
if (!StringUtils.isBlank(hostid)) {
for (PbxHost pbx : pbxHostList) {
if (pbx.getId().equals(hostid)) {
pbxHost = pbx;
break;
}
}
}
return pbxHost;
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.RouterRules;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.RouterRulesRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterRouterController extends Handler{
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private RouterRulesRepository routerRulesRes ;
@RequestMapping(value = "/router")
@Menu(type = "callcenter" , subtype = "callcenterresource" , access = false , admin = true)
public ModelAndView skill(ModelMap map , HttpServletRequest request , @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)) ;
map.addAttribute("pbxHostList" , pbxHostList);
if(pbxHostList.size() > 0){
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("routerRulesList" , routerRulesRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/index"));
}
@RequestMapping(value = "/router/add")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/add"));
}
@RequestMapping(value = "/router/save")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionsave(ModelMap map , HttpServletRequest request , @Valid RouterRules router) {
if(!StringUtils.isBlank(router.getName())){
int count = routerRulesRes.countByNameAndOrgi(router.getName(), super.getOrgi(request)) ;
if(count == 0){
router.setOrgi(super.getOrgi(request));
router.setCreater(super.getUser(request).getId());
routerRulesRes.save(router) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid()));
}
@RequestMapping(value = "/router/edit")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView routeredit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("routerRules" , routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/edit"));
}
@RequestMapping(value = "/router/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid RouterRules router) {
if(!StringUtils.isBlank(router.getId())){
RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)) ;
if(oldRouter!=null){
oldRouter.setName(router.getName());
oldRouter.setField(router.getField());
oldRouter.setRegex(router.getRegex());
oldRouter.setRouterinx(router.getRouterinx());
oldRouter.setFalsebreak(router.isFalsebreak());
routerRulesRes.save(oldRouter);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid()));
}
@RequestMapping(value = "/router/code")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView routercode(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("routerRules" , routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/code"));
}
@RequestMapping(value = "/router/code/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView routercodeupdate(ModelMap map , HttpServletRequest request , @Valid RouterRules router) {
if(!StringUtils.isBlank(router.getId())){
RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)) ;
if(!StringUtils.isBlank(router.getRoutercontent())){
oldRouter.setRoutercontent(router.getRoutercontent());
routerRulesRes.save(oldRouter);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid()));
}
@RequestMapping(value = "/router/delete")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
routerRulesRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+hostid));
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.SipTrunk;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.SipTrunkRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterSipTrunkController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private SipTrunkRepository sipTrunkRes;
@Autowired
private Cache cache;
@RequestMapping(value = "/siptrunk")
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) {
if (!StringUtils.isBlank(hostid)) {
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/index"));
}
@RequestMapping(value = "/siptrunk/add")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/add"));
}
@RequestMapping(value = "/siptrunk/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getName())) {
int count = sipTrunkRes.countByNameAndOrgi(siptrunk.getName(), super.getOrgi(request));
if (count == 0) {
siptrunk.setOrgi(super.getOrgi(request));
siptrunk.setCreater(super.getUser(request).getId());
sipTrunkRes.save(siptrunk);
cache.putSystemByIdAndOrgi(siptrunk.getId(), siptrunk.getOrgi(), siptrunk);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
}
@RequestMapping(value = "/siptrunk/edit")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/edit"));
}
@RequestMapping(value = "/siptrunk/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getId())) {
SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request));
if (oldSipTrunk != null) {
oldSipTrunk.setName(siptrunk.getName());
oldSipTrunk.setSipserver(siptrunk.getSipserver());
oldSipTrunk.setPort(siptrunk.getPort());
oldSipTrunk.setProtocol(siptrunk.getProtocol());
oldSipTrunk.setRegister(siptrunk.isRegister());
oldSipTrunk.setDefaultsip(siptrunk.isDefaultsip());
oldSipTrunk.setTitle(siptrunk.getTitle());
oldSipTrunk.setEnablecallagent(siptrunk.isEnablecallagent());
oldSipTrunk.setOutnumber(siptrunk.getOutnumber());
oldSipTrunk.setBusyext(siptrunk.getBusyext());
oldSipTrunk.setNotready(siptrunk.getNotready());
oldSipTrunk.setNoname(siptrunk.getNoname());
oldSipTrunk.setProvince(siptrunk.getProvince());
oldSipTrunk.setCity(siptrunk.getCity());
oldSipTrunk.setPrefix(siptrunk.getPrefix());
sipTrunkRes.save(oldSipTrunk);
cache.putSystemByIdAndOrgi(oldSipTrunk.getId(), oldSipTrunk.getOrgi(), oldSipTrunk);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
}
@RequestMapping(value = "/siptrunk/code")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkcode(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/code"));
}
@RequestMapping(value = "/siptrunk/code/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkcodeupdate(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getId())) {
SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request));
if (!StringUtils.isBlank(siptrunk.getSipcontent())) {
oldSipTrunk.setSipcontent(siptrunk.getSipcontent());
sipTrunkRes.save(oldSipTrunk);
cache.putSystemByIdAndOrgi(oldSipTrunk.getId(), oldSipTrunk.getOrgi(), oldSipTrunk);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
}
@RequestMapping(value = "/siptrunk/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentiondelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
if (!StringUtils.isBlank(id)) {
sipTrunkRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + hostid));
}
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* 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.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CallCenterSkill;
import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.SkillExtention;
import com.chatopera.cc.persistence.repository.CallCenterSkillRepository;
import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.SkillExtentionRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterSkillController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private ExtentionRepository extentionRes;
@Autowired
private CallCenterSkillRepository skillRes ;
@Autowired
private SkillExtentionRepository skillExtentionRes;
@RequestMapping(value = "/skill")
@Menu(type = "callcenter" , subtype = "callcenterresource" , access = false , admin = true)
public ModelAndView skill(ModelMap map , HttpServletRequest request , @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)) ;
map.addAttribute("pbxHostList" , pbxHostList);
PbxHost pbxHost = null ;
if(pbxHostList.size() > 0){
map.addAttribute("pbxHost" , pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
map.addAttribute("skillExtentionList" , skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/index"));
}
private PbxHost getPbxHost(List<PbxHost> pbxHostList ,String hostid){
PbxHost pbxHost = pbxHostList.get(0) ;
if(!StringUtils.isBlank(hostid)){
for(PbxHost pbx : pbxHostList){
if(pbx.getId().equals(hostid)){
pbxHost = pbx; break ;
}
}
}
return pbxHost ;
}
@RequestMapping(value = "/skill/add")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/add"));
}
@RequestMapping(value = "/skill/save")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionsave(ModelMap map , HttpServletRequest request , @Valid CallCenterSkill skill) {
if(!StringUtils.isBlank(skill.getSkill())){
int count = skillRes.countBySkillAndOrgi(skill.getSkill(), super.getOrgi(request)) ;
if(count == 0){
skill.setOrgi(super.getOrgi(request));
skill.setCreater(super.getUser(request).getId());
skillRes.save(skill) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+skill.getHostid()));
}
@RequestMapping(value = "/skill/edit")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/edit"));
}
@RequestMapping(value = "/skill/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid Extention extention) {
if(!StringUtils.isBlank(extention.getId())){
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)) ;
if(ext!=null && !StringUtils.isBlank(ext.getExtention()) && ext.getExtention().matches("[\\d]{3,8}")){
ext.setExtention(extention.getExtention());
if(!StringUtils.isBlank(extention.getPassword())){
ext.setPassword(extention.getPassword());
}
ext.setUpdatetime(new Date());
extentionRes.save(ext) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+extention.getHostid()));
}
@RequestMapping(value = "/skill/delete")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
extentionRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid));
}
@RequestMapping(value = "/skill/imp")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillimp(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
map.put("extentionList", extentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request))) ;
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(hostid , super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/imp"));
}
@RequestMapping(value = "/skill/extention/delete")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillextentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
skillExtentionRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid));
}
@RequestMapping(value = "/skill/extention/save")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillextentionsave(ModelMap map , HttpServletRequest request , @Valid SkillExtention skillExtention, @Valid String hostid , @Valid String[] exts) {
if(exts!=null && exts.length > 0){
List<SkillExtention> skillExtentionList = skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)) ;
for(String ext :exts){
SkillExtention skillExt = new SkillExtention() ;
skillExt.setOrgi(super.getOrgi(request));
skillExt.setCreater(super.getUser(request).getId());
skillExt.setCreatetime(new Date());
skillExt.setExtention(ext);
skillExt.setHostid(hostid);
skillExt.setSkillid(skillExtention.getSkillid());
skillExt.setUpdatetime(new Date());
boolean ingroup = false;
for(SkillExtention temp : skillExtentionList){
if(temp.getSkillid().equals(skillExt.getSkillid()) && temp.getExtention().equals(skillExt.getExtention())){
ingroup = true ;
}
}
if(ingroup == false){
skillExtentionRes.save(skillExt) ;
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid));
}
}
......@@ -19,13 +19,11 @@ package com.chatopera.cc.controller.admin.channel;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CousultInvite;
import com.chatopera.cc.model.SNSAccount;
import com.chatopera.cc.model.Secret;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.*;
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.proxy.OrganProxy;
import com.chatopera.cc.util.Base62;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
......@@ -42,9 +40,9 @@ import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
*
*
*/
@Controller
......@@ -60,11 +58,20 @@ public class SNSAccountIMController extends Handler {
@Autowired
private SecretRepository secRes;
@Autowired
private OrganProxy organProxy;
@RequestMapping("/index")
@Menu(type = "admin", subtype = "im", 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.WEBIM.toString(), super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request))));
map.addAttribute("status",status);
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute, @RequestParam(name = "status", required = false) String status) {
User logined = super.getUser(request);
if (logined.isSuperadmin()) {
map.addAttribute("snsAccountList", snsAccountRes.findBySnstypeAndOrgi(MainContext.ChannelType.WEBIM.toString(), super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request))));
} else {
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(super.getOrgan(request), super.getOrgi(request));
map.addAttribute("snsAccountList", snsAccountRes.findBySnstypeAndOrgiAndOrgan(MainContext.ChannelType.WEBIM.toString(), super.getOrgi(request), organs.keySet(), new PageRequest(super.getP(request), super.getPs(request))));
}
map.addAttribute("status", status);
List<Secret> secretConfig = secRes.findByOrgi(super.getOrgi(request));
if (secretConfig != null && secretConfig.size() > 0) {
map.addAttribute("secret", secretConfig.get(0));
......
......@@ -291,21 +291,10 @@ public class WebIMController extends Handler {
*/
private List<Organ> getSkillGroups(HttpServletRequest request) {
List<Organ> skillgroups = new ArrayList<>();
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
}
}
skillgroups = organRes.findAll(organIdList);
} else {
List<Organ> allgroups = organRes.findByOrgiAndOrgid(super.getOrgi(request), super.getOrgid(request));
for (Organ o : allgroups) {
if (o.isSkill()) {
skillgroups.add(o);
}
List<Organ> allgroups = organRes.findByOrgi(super.getOrgi(request));
for (Organ o : allgroups) {
if (o.isSkill()) {
skillgroups.add(o);
}
}
return skillgroups;
......@@ -318,19 +307,7 @@ public class WebIMController extends Handler {
* @return
*/
private List<User> getUsers(HttpServletRequest request) {
List<User> userList;
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
}
}
userList = userProxy.findByOrganInAndAgentAndDatastatus(organIdList, true, false);
} else {
userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
}
List<User> userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
return userList;
}
}
\ No newline at end of file
......@@ -194,8 +194,8 @@ public class SystemConfigController extends Handler {
@Valid Secret secret) throws SQLException, IOException, NoSuchAlgorithmException {
/*SystemConfig systemConfig = systemConfigRes.findByOrgi(super.getOrgi(request)) ;
config.setOrgi(super.getOrgi(request));*/
SystemConfig systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI);
config.setOrgi(MainContext.SYSTEM_ORGI);
SystemConfig systemConfig = systemConfigRes.findByOrgi(Constants.SYSTEM_ORGI);
config.setOrgi(Constants.SYSTEM_ORGI);
String msg = "0";
if (StringUtils.isBlank(config.getJkspassword())) {
config.setJkspassword(null);
......
......@@ -20,11 +20,14 @@ import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Dict;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.SystemMessage;
import com.chatopera.cc.persistence.repository.OrganRepository;
import com.chatopera.cc.persistence.repository.SystemMessageRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
......@@ -35,135 +38,148 @@ import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
@Controller
@RequestMapping("/admin")
public class SystemMessageController extends Handler {
@Autowired
private SystemMessageRepository systemMessageRepository;
@Autowired
private SystemMessageRepository systemMessageRepository;
@Autowired
private OrganRepository organRes;
@RequestMapping("/email/index")
@Menu(type = "setting" , subtype = "email")
public ModelAndView index(ModelMap map , HttpServletRequest request) throws IOException {
map.addAttribute("emailList", systemMessageRepository.findByMsgtypeAndOrgi("email" , super.getOrgi(request) , new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAdminTempletResponse("/admin/email/index"));
@Menu(type = "setting", subtype = "email")
public ModelAndView index(ModelMap map, HttpServletRequest request) throws IOException {
Page<SystemMessage> emails = systemMessageRepository.findByMsgtypeAndOrgi("email", super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)));
List<Organ> organs = organRes.findByOrgi(super.getOrgi(request));
emails.getContent().stream().forEach(p -> {
organs.stream().filter(o -> StringUtils.equals(p.getOrgan(), o.getId())).findAny().ifPresent(o -> p.setOrgan(o.getName()));
});
map.addAttribute("emailList", emails);
return request(super.createAdminTempletResponse("/admin/email/index"));
}
@RequestMapping("/email/add")
@Menu(type = "admin" , subtype = "email")
public ModelAndView add(ModelMap map , HttpServletRequest request) {
@Menu(type = "admin", subtype = "email")
public ModelAndView add(ModelMap map, HttpServletRequest request) {
map.put("organList", organRes.findByOrgi(super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/email/add"));
}
@RequestMapping("/email/save")
@Menu(type = "admin" , subtype = "user")
public ModelAndView save(HttpServletRequest request ,@Valid SystemMessage email) throws NoSuchAlgorithmException {
email.setOrgi(super.getOrgi(request));
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
if(!StringUtils.isBlank(email.getSmtppassword())) {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
}
systemMessageRepository.save(email) ;
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
@Menu(type = "admin", subtype = "user")
public ModelAndView save(HttpServletRequest request, @Valid SystemMessage email) throws NoSuchAlgorithmException {
email.setOrgi(super.getOrgi(request));
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
if (!StringUtils.isBlank(email.getSmtppassword())) {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
}
systemMessageRepository.save(email);
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
}
@RequestMapping("/email/edit")
@Menu(type = "admin" , subtype = "email")
public ModelAndView edit(ModelMap map , HttpServletRequest request , @Valid String id) {
map.addAttribute("email", systemMessageRepository.findByIdAndOrgi(id, super.getOrgi(request))) ;
@Menu(type = "admin", subtype = "email")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.put("organList", organRes.findByOrgi(super.getOrgi(request)));
map.addAttribute("email", systemMessageRepository.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/email/edit"));
}
@RequestMapping("/email/update")
@Menu(type = "admin" , subtype = "user" , admin = true)
public ModelAndView update(HttpServletRequest request ,@Valid SystemMessage email) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(email.getId(), super.getOrgi(request)) ;
if(email!=null) {
email.setCreatetime(temp.getCreatetime());
email.setOrgi(temp.getOrgi());
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
if(!StringUtils.isBlank(email.getSmtppassword())) {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
}else {
email.setSmtppassword(temp.getSmtppassword());
}
systemMessageRepository.save(email) ;
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
@Menu(type = "admin", subtype = "user", admin = true)
public ModelAndView update(HttpServletRequest request, @Valid SystemMessage email) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(email.getId(), super.getOrgi(request));
if (email != null) {
email.setCreatetime(temp.getCreatetime());
email.setOrgi(temp.getOrgi());
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
if (!StringUtils.isBlank(email.getSmtppassword())) {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
} else {
email.setSmtppassword(temp.getSmtppassword());
}
systemMessageRepository.save(email);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
}
@RequestMapping("/email/delete")
@Menu(type = "admin" , subtype = "user")
public ModelAndView delete(HttpServletRequest request ,@Valid SystemMessage email) {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(email.getId(), super.getOrgi(request)) ;
if(email!=null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
@Menu(type = "admin", subtype = "user")
public ModelAndView delete(HttpServletRequest request, @Valid SystemMessage email) {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(email.getId(), super.getOrgi(request));
if (email != null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
}
@RequestMapping("/sms/index")
@Menu(type = "setting" , subtype = "sms")
public ModelAndView smsindex(ModelMap map , HttpServletRequest request) throws IOException {
map.addAttribute("smsList", systemMessageRepository.findByMsgtypeAndOrgi("sms" , super.getOrgi(request) , new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAdminTempletResponse("/admin/sms/index"));
@Menu(type = "setting", subtype = "sms")
public ModelAndView smsindex(ModelMap map, HttpServletRequest request) throws IOException {
map.addAttribute("smsList", systemMessageRepository.findByMsgtypeAndOrgi("sms", super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAdminTempletResponse("/admin/sms/index"));
}
@RequestMapping("/sms/add")
@Menu(type = "admin" , subtype = "sms")
public ModelAndView smsadd(ModelMap map , HttpServletRequest request) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type")) ;
@Menu(type = "admin", subtype = "sms")
public ModelAndView smsadd(ModelMap map, HttpServletRequest request) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type"));
return request(super.createRequestPageTempletResponse("/admin/sms/add"));
}
@RequestMapping("/sms/save")
@Menu(type = "admin" , subtype = "sms")
public ModelAndView smssave(HttpServletRequest request ,@Valid SystemMessage sms) throws NoSuchAlgorithmException {
sms.setOrgi(super.getOrgi(request));
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
if(!StringUtils.isBlank(sms.getSmtppassword())) {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
}
systemMessageRepository.save(sms) ;
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
@Menu(type = "admin", subtype = "sms")
public ModelAndView smssave(HttpServletRequest request, @Valid SystemMessage sms) throws NoSuchAlgorithmException {
sms.setOrgi(super.getOrgi(request));
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
if (!StringUtils.isBlank(sms.getSmtppassword())) {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
}
systemMessageRepository.save(sms);
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
}
@RequestMapping("/sms/edit")
@Menu(type = "admin" , subtype = "sms")
public ModelAndView smsedit(ModelMap map , HttpServletRequest request , @Valid String id) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type")) ;
map.addAttribute("sms", systemMessageRepository.findByIdAndOrgi(id, super.getOrgi(request))) ;
@Menu(type = "admin", subtype = "sms")
public ModelAndView smsedit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type"));
map.addAttribute("sms", systemMessageRepository.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/sms/edit"));
}
@RequestMapping("/sms/update")
@Menu(type = "admin" , subtype = "sms" , admin = true)
public ModelAndView smsupdate(HttpServletRequest request ,@Valid SystemMessage sms) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(sms.getId(), super.getOrgi(request)) ;
if(sms!=null) {
sms.setCreatetime(temp.getCreatetime());
sms.setOrgi(temp.getOrgi());
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
if(!StringUtils.isBlank(sms.getSmtppassword())) {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
}else {
sms.setSmtppassword(temp.getSmtppassword());
}
systemMessageRepository.save(sms) ;
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
@Menu(type = "admin", subtype = "sms", admin = true)
public ModelAndView smsupdate(HttpServletRequest request, @Valid SystemMessage sms) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(sms.getId(), super.getOrgi(request));
if (sms != null) {
sms.setCreatetime(temp.getCreatetime());
sms.setOrgi(temp.getOrgi());
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
if (!StringUtils.isBlank(sms.getSmtppassword())) {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
} else {
sms.setSmtppassword(temp.getSmtppassword());
}
systemMessageRepository.save(sms);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
}
@RequestMapping("/sms/delete")
@Menu(type = "admin" , subtype = "sms")
public ModelAndView smsdelete(HttpServletRequest request ,@Valid SystemMessage sms) {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(sms.getId(), super.getOrgi(request)) ;
if(sms!=null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
@Menu(type = "admin", subtype = "sms")
public ModelAndView smsdelete(HttpServletRequest request, @Valid SystemMessage sms) {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(sms.getId(), super.getOrgi(request));
if (sms != null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
}
}
\ No newline at end of file
......@@ -67,7 +67,7 @@ public class TemplateController extends Handler{
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response) throws Exception {
List<Template> templateList = templateRes.findByOrgi(super.getOrgi(request)) ;
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Template-Export-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".data");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Template-Export-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".data");
response.getOutputStream().write(MainUtils.toBytes(templateList));
return ;
}
......
......@@ -313,7 +313,7 @@ public class ApiContactNotesController extends Handler {
JsonObject json = new JsonObject();
HttpHeaders headers = RestUtils.header();
j.addProperty("creater", super.getUser(request).getId());
j.addProperty("orgi", MainContext.SYSTEM_ORGI);
j.addProperty("orgi", Constants.SYSTEM_ORGI);
if (!j.has("ops")) {
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
......
......@@ -16,6 +16,7 @@
package com.chatopera.cc.controller.api;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.controller.api.request.RestUtils;
......@@ -197,7 +198,7 @@ public class ApiContactTagsController extends Handler {
JsonObject json = new JsonObject();
HttpHeaders headers = RestUtils.header();
j.addProperty("creater", super.getUser(request).getId());
j.addProperty("orgi", MainContext.SYSTEM_ORGI);
j.addProperty("orgi", super.getOrgi(request));
if (!j.has("ops")) {
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
......
......@@ -104,10 +104,10 @@ public class ApiServiceQueneController extends Handler {
p.setAgentno(logined.getId());
p.setLogindate(new Date());
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(logined.getOrgi());
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(logined.getOrgi());
p.setUpdatetime(new Date());
p.setOrgi(super.getOrgi(request));
p.setMaxusers(sessionConfig.getMaxuser());
// p.setMaxusers(sessionConfig.getMaxuser());
return p;
});
......
......@@ -16,16 +16,16 @@
*/
package com.chatopera.cc.controller.api;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.controller.api.request.RestUtils;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.model.OrganUser;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.repository.OrganUserRepository;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.persistence.repository.UserRoleRepository;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
......@@ -61,16 +61,19 @@ public class ApiUserController extends Handler {
private final static Logger logger = LoggerFactory.getLogger(ApiUserController.class);
@Autowired
private UserRepository userRes;
private Cache cache;
@Autowired
private OrganUserRepository organUserRepository;
private UserProxy userProxy;
@Autowired
private UserProxy userProxy;
private UserRepository userRes;
@Autowired
private Cache cache;
private OrganUserRepository organUserRes;
@Autowired
private UserRoleRepository userRoleRes;
/**
* 返回用户列表,支持分页,分页参数为 p=1&ps=50,默认分页尺寸为 20条每页
......@@ -83,11 +86,11 @@ public class ApiUserController extends Handler {
@Menu(type = "apps", subtype = "user", access = true)
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String id, @Valid String username) {
Page<User> userList = null;
if (!StringUtils.isBlank(id)) {
if (StringUtils.isNotBlank(id)) {
userList = userRes.findByIdAndOrgi(
id, super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)));
} else {
if (!StringUtils.isBlank(username)) {
if (StringUtils.isNotBlank(username)) {
userList = userRes.findByDatastatusAndOrgiAndUsernameLike(
false, super.getOrgi(request), username, new PageRequest(
super.getP(request),
......@@ -100,52 +103,6 @@ public class ApiUserController extends Handler {
return new ResponseEntity<>(new RestResult(RestResultType.OK, userList), HttpStatus.OK);
}
/**
* 新增或修改用户用户 ,在修改用户信息的时候,如果用户 密码未改变,请设置为 NULL
*
* @param request
* @param user
* @return
*/
@RequestMapping(method = RequestMethod.PUT)
@Menu(type = "apps", subtype = "user", access = true)
public ResponseEntity<RestResult> put(HttpServletRequest request, @Valid User user) {
if (user != null && !StringUtils.isBlank(user.getUsername())) {
if (!StringUtils.isBlank(user.getPassword())) {
user.setPassword(MainUtils.md5(user.getPassword()));
userRes.save(user);
} else if (!StringUtils.isBlank(user.getId())) {
User old = userRes.findByIdAndOrgi(user.getId(), super.getOrgi(request));
user.setPassword(old.getPassword());
userRes.save(user);
}
}
return new ResponseEntity<>(new RestResult(RestResultType.OK), HttpStatus.OK);
}
/**
* 删除用户,只提供 按照用户ID删除 , 并且,不能删除系统管理员
*
* @param request
* @param id
* @return
*/
@RequestMapping(method = RequestMethod.DELETE)
@Menu(type = "apps", subtype = "user", access = true)
public ResponseEntity<RestResult> delete(HttpServletRequest request, @Valid String id) {
RestResult result = new RestResult(RestResultType.OK);
User user = null;
if (!StringUtils.isBlank(id)) {
user = userRes.findByIdAndOrgi(id, super.getOrgi(request));
if (!user.isSuperadmin()) { //系统管理员, 不允许 使用 接口删除
userRes.delete(user);
} else {
result.setStatus(RestResultType.USER_DELETE);
}
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
/**
* 用户管理
*
......@@ -177,6 +134,9 @@ public class ApiUserController extends Handler {
case "findbyorgan":
json = findByOrgan(j);
break;
case "delete":
json = delete(request, j);
break;
default:
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的操作。");
......@@ -184,37 +144,24 @@ public class ApiUserController extends Handler {
}
return new ResponseEntity<String>(json.toString(), headers, HttpStatus.OK);
}
/**
* 根据组织查找用户
* 创建新用户
*
* @param request
* @param payload
* @return
*/
private JsonObject findByOrgan(final JsonObject payload) {
final JsonObject resp = new JsonObject();
if (payload.has("organ")) {
List<OrganUser> organUsers = organUserRepository.findByOrgan(payload.get("organ").getAsString());
List<String> userids = organUsers.stream().map(p -> p.getUserid()).collect(Collectors.toList());
List<User> users = userRes.findAll(userids);
JsonArray data = new JsonArray();
users.stream().forEach(u -> {
JsonObject obj = new JsonObject();
obj.addProperty("id", u.getId());
obj.addProperty("uname", u.getUname());
data.add(obj);
});
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.add(RestUtils.RESP_KEY_DATA, data);
} else {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Invalid params.");
}
private JsonObject create(final HttpServletRequest request, final JsonObject payload) {
logger.info("[create] payload {}", payload.toString());
// 创建新用户时,阻止传入ID
payload.remove("id");
// 从payload中创建User
User user = userProxy.parseUserFromJson(payload);
JsonObject resp = userProxy.createNewUser(user);
logger.info("[create] response {}", resp.toString());
return resp;
}
......@@ -235,7 +182,7 @@ public class ApiUserController extends Handler {
return resp;
}
final User previous = userRes.getOne(updated.getId());
final User previous = userRes.findById(updated.getId());
if (previous != null) {
String msg = userProxy.validUserUpdate(updated, previous);
if (StringUtils.equals(msg, "edit_user_success")) {
......@@ -260,17 +207,16 @@ public class ApiUserController extends Handler {
previous.setUsername(updated.getUsername());
previous.setEmail(updated.getEmail());
previous.setMobile(updated.getMobile());
previous.setSipaccount(updated.getSipaccount());
previous.setAgent(updated.isAgent());
previous.setOrgi(super.getOrgiByTenantshare(request));
if (StringUtils.isNotBlank(previous.getOrgid())) {
previous.setOrgid(previous.getOrgid());
} else {
previous.setOrgid(MainContext.SYSTEM_ORGI);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
previous.setCallcenter(updated.isCallcenter());
if (updated.isCallcenter()) {
previous.setExtensionId(updated.getExtensionId());
previous.setPbxhostId(updated.getPbxhostId());
}
}
previous.setCallcenter(updated.isCallcenter());
if (StringUtils.isNotBlank(updated.getPassword())) {
previous.setPassword(MainUtils.md5(updated.getPassword()));
}
......@@ -283,7 +229,6 @@ public class ApiUserController extends Handler {
previous.setAdmin(updated.isAdmin());
previous.setSuperadmin(false);
userRes.save(previous);
OnlineUserProxy.clean(previous.getOrgi());
}
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
......@@ -298,34 +243,80 @@ public class ApiUserController extends Handler {
}
/**
* 创建新用户
* 根据组织查找用户
*
* @param request
* @param payload
* @return
*/
private JsonObject create(final HttpServletRequest request, final JsonObject payload) {
logger.info("[create] payload {}", payload.toString());
final User logined = super.getUser(request);
JsonObject resp = new JsonObject();
private JsonObject findByOrgan(final JsonObject payload) {
final JsonObject resp = new JsonObject();
if (payload.has("organ")) {
List<OrganUser> organUsers = organUserRes.findByOrgan(payload.get("organ").getAsString());
List<String> userids = organUsers.stream().map(p -> p.getUserid()).collect(Collectors.toList());
List<User> users = userRes.findAll(userids);
// 从payload中创建User
User newUser = null;
// 创建新用户时,阻止传入ID
payload.remove("id");
newUser = userProxy.parseUserFromJson(payload);
final String msg = userProxy.createNewUser(
newUser, logined.getOrgi(), logined.getOrgid(), super.getOrgiByTenantshare(request));
JsonArray data = new JsonArray();
users.stream().forEach(u -> {
JsonObject obj = new JsonObject();
obj.addProperty("id", u.getId());
obj.addProperty("uname", u.getUname());
data.add(obj);
});
if (StringUtils.isNotBlank(msg)) {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty(RestUtils.RESP_KEY_DATA, msg);
resp.add(RestUtils.RESP_KEY_DATA, data);
} else {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Unexpected response.");
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Invalid params.");
}
return resp;
}
/**
* 删除账号
*
* @param request
* @param payload
* @return
*/
private JsonObject delete(final HttpServletRequest request, final JsonObject payload) {
logger.info("[create] payload {}", payload.toString());
JsonObject resp = new JsonObject();
if (payload.has("id")) {
String id = payload.get("id").getAsString();
if (StringUtils.isNotBlank(id)) {
User user = userRes.findById(id);
if (user == null) {
// 用户不存在
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty(RestUtils.RESP_KEY_MSG, "done");
return resp;
}
// 系统管理员, 不允许 使用 接口删除
if (!user.isSuperadmin()) {
// 删除用户的时候,同时删除用户对应的权限
List<UserRole> userRoles = userRoleRes.findByOrgiAndUser(user.getOrgi(), user);
userRoleRes.delete(userRoles);
// 删除用户对应的组织机构关系
List<OrganUser> organUsers = organUserRes.findByUserid(id);
organUserRes.delete(organUsers);
// 删除用户
userRes.delete(user);
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty(RestUtils.RESP_KEY_MSG, "done");
} else {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "USER_DELETE");
}
}
} else {
// 参数不合法
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "INVALID_PARAMS");
}
return resp;
}
}
......@@ -31,6 +31,19 @@ public class RestUtils {
public final static int RESP_RC_FAIL_5 = 5;
public final static int RESP_RC_FAIL_6 = 6;
public final static int RESP_RC_FAIL_7 = 7;
public final static int RESP_RC_FAIL_8 = 8;
public final static int RESP_RC_FAIL_9 = 9;
public final static int RESP_RC_FAIL_10 = 10;
public final static int RESP_RC_FAIL_11 = 11;
public final static int RESP_RC_FAIL_12 = 12;
public final static int RESP_RC_FAIL_13 = 13;
public final static int RESP_RC_FAIL_14 = 14;
public final static int RESP_RC_FAIL_15 = 15;
public final static int RESP_RC_FAIL_16 = 16;
public final static int RESP_RC_FAIL_17 = 17;
public final static int RESP_RC_FAIL_18 = 18;
public final static int RESP_RC_FAIL_19 = 19;
public final static int RESP_RC_FAIL_20 = 20;
// /**
// * 复制请求处理结果
......@@ -48,7 +61,7 @@ public class RestUtils {
// return target;
// }
public static HttpHeaders header(){
public static HttpHeaders header() {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
return headers;
......
......@@ -62,7 +62,8 @@ public class AgentQualityController extends Handler {
@RequestMapping(value = "/index")
@Menu(type = "agent", subtype = "quality", access = false)
public ModelAndView index(ModelMap map, HttpServletRequest request) {
map.addAttribute("sessionConfig", acdPolicyService.initSessionConfig(super.getOrgi(request)));
// TODO: mdx-organ clean
// map.addAttribute("sessionConfig", acdPolicyService.initSessionConfig(super.getOrgi(request)));
map.addAttribute("qualityList", qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request)));
map.addAttribute("tagList", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString()));
return request(super.createAppsTempletResponse("/apps/quality/index"));
......@@ -72,7 +73,7 @@ public class AgentQualityController extends Handler {
@RequestMapping(value = "/save")
@Menu(type = "agent", subtype = "quality", access = false)
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid QualityRequest qualityArray) {
String orgi = super.getOrgi(request);
String orgi = super.getOrgi(request);
if (qualityArray != null && qualityArray.getTitle() != null) {
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
......@@ -94,18 +95,20 @@ public class AgentQualityController extends Handler {
if (tempList.size() > 0) {
qualityRes.save(tempList);
}
SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
if (config != null) {
if ("points".equals(request.getParameter("qualityscore"))) {
config.setQualityscore("points");
} else {
config.setQualityscore("score");
}
sessionConfigRes.save(config);
cache.putSessionConfigByOrgi(config, orgi);
cache.deleteSessionConfigListByOrgi(orgi);
}
// TODO: mdx-organ clean
// SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
// if (config != null) {
// if ("points".equals(request.getParameter("qualityscore"))) {
// config.setQualityscore("points");
// } else {
// config.setQualityscore("score");
// }
//
// sessionConfigRes.save(config);
// cache.putSessionConfigByOrgi(config, orgi);
// cache.deleteSessionConfigListByOrgi(orgi);
// }
if (qualityArray != null && qualityArray.getTag() != null && qualityArray.getTag().length > 0) {
List<Tag> tagList = tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString());
if (tagList.size() > 0) {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册