1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-07-24 08:31:45 +08:00

#406 Refactor the front end with pug

This commit is contained in:
mukaiu 2021-02-10 17:14:00 +08:00
parent 19b75e1d3c
commit 62d06de6c3
635 changed files with 25525 additions and 50589 deletions

View File

@ -0,0 +1,13 @@
#! /bin/bash
###########################################
#
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
# functions
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir/../app
SPRING_PROFILES_ACTIVE=dev mvn spring-boot:run

View File

@ -9,4 +9,7 @@ src/main/resources/templates/admin/channel/*
src/main/resources/templates/apps/callout
src/main/resources/templates/apps/chatbot
src/main/resources/templates/apps/callcenter
# ignore system views for chatbot
src/main/resources/templates/admin/system/chatbot
logs/

View File

@ -9,7 +9,7 @@
<parent>
<groupId>com.chatopera.cc</groupId>
<artifactId>cc-root</artifactId>
<version>6.0.0-SNAPSHOT</version>
<version>6.1.0-SNAPSHOT</version>
<!-- for Chatopera Nexus reference if file is available with latest version -->
<!-- <relativePath/> -->
<!-- for local reference if file is available with latest version -->
@ -130,10 +130,10 @@
</repositories>
<developers>
<developer>
<id>hain</id>
<name>Hai Liang Wang</name>
<email>hain@chatopera.com</email>
<url>https://github.com/Samurais</url>
<id>chatopera</id>
<name>Chatopera</name>
<email>info@chatopera.com</email>
<url>https://www.chatopera.com</url>
<organization>Chatopera Inc.</organization>
<organizationUrl>https://www.chatopera.com</organizationUrl>
<roles>

View File

@ -117,6 +117,7 @@ public class ACDAgentService {
* 发送消息给访客
*/
Message outMessage = new Message();
outMessage.setAgentUser(ctx.getAgentUser());
outMessage.setMessage(ctx.getMessage());
outMessage.setMessageType(MainContext.MessageType.MESSAGE.toString());
outMessage.setCalltype(MainContext.CallType.IN.toString());
@ -127,7 +128,8 @@ public class ACDAgentService {
}
MainContext.getPeerSyncIM().send(MainContext.ReceiverType.VISITOR,
MainContext.ChannelType.WEBIM, ctx.getAppid(),
MainContext.ChannelType.toValue(ctx.getChannel()),
ctx.getAppid(),
MainContext.MessageType.NEW, ctx.getOnlineUserId(), outMessage, true);
@ -380,6 +382,8 @@ public class ACDAgentService {
agentStatusRes.save(agentStatus);
}
Message outMessage = new Message();
/**
* 发送到访客端的通知
*/
@ -387,7 +391,6 @@ public class ACDAgentService {
case WEBIM:
// WebIM 发送对话结束事件
// 向访客发送消息
Message outMessage = new Message();
outMessage.setAgentStatus(agentStatus);
outMessage.setMessage(acdMessageHelper.getServiceFinishMessage(agentUser.getChannel(), agentUser.getSkill(), orgi));
outMessage.setMessageType(MainContext.AgentUserStatusEnum.END.toString());
@ -418,6 +421,30 @@ public class ACDAgentService {
NettyClients.getInstance().sendCalloutEventMessage(
agentUser.getAgentno(), MainContext.MessageType.END.toString(), agentUser);
break;
case MESSENGER:
outMessage.setAgentStatus(agentStatus);
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()));
outMessage.setAgentUser(agentUser);
// 向访客发送消息
peerSyncIM.send(
MainContext.ReceiverType.VISITOR,
MainContext.ChannelType.toValue(agentUser.getChannel()), agentUser.getAppid(),
MainContext.MessageType.STATUS, agentUser.getUserid(), outMessage, true
);
if (agentStatus != null) {
// 坐席在线通知结束会话
outMessage.setChannelMessage(agentUser);
outMessage.setAgentUser(agentUser);
peerSyncIM.send(MainContext.ReceiverType.AGENT, MainContext.ChannelType.MESSENGER,
agentUser.getAppid(),
MainContext.MessageType.END, agentUser.getAgentno(), outMessage, true);
}
break;
default:
logger.info(
"[finishAgentService] ignore notify agent service end for channel {}, agent user id {}",

View File

@ -205,6 +205,13 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
default:
}
ctx.setChannelMessage(ctx.getAgentUser());
} else {
ctx.setNoagent(true);
ctx.setMessage(acdMessageHelper.getNoAgentMessage(
0,
ctx.getChannel(),
ctx.getOrganid(),
ctx.getOrgi()));
}
logger.info(

View File

@ -78,6 +78,7 @@ public class Constants {
* Channels
*/
public static final String CHANNEL_TYPE_WEBIM = "webim";
public static final String CHANNEL_TYPE_MESSENGER = "messenger";
public final static String IM_MESSAGE_TYPE_MESSAGE = "message";
public final static String IM_MESSAGE_TYPE_WRITING = "writing";
public final static String CHATBOT_EVENT_TYPE_CHAT = "chat";
@ -89,6 +90,7 @@ public class Constants {
public final static String CSKEFU_MODULE_CHATBOT = "chatbot";
public final static String CSKEFU_MODULE_CONTACTS = "contacts";
public final static String CSKEFU_MODULE_SKYPE = "skype";
public final static String CSKEFU_MODULE_MESSENGER = "messenger";
public final static String CSKEFU_MODULE_CCA = "cca";
public final static String CSKEFU_MODULE_ENTIM = "entim";
public final static String CSKEFU_MODULE_WORKORDERS = "workorders";
@ -121,7 +123,11 @@ public class Constants {
// 发送给聊天机器人并处理返回结果
public final static String INSTANT_MESSAGING_MQ_QUEUE_CHATBOT = "cskefu.outbound.chatbot";
public static final String AUDIT_AGENT_MESSAGE = "cskefu.agent.audit";
// 机器人返回的结果数据来源为faq
public final static String PROVIDER_FAQ = "faq";
// Facebook OTN 发送
public final static String INSTANT_MESSAGING_MQ_QUEUE_FACEBOOK_OTN = "cskefu.outbound.faceboot.otn";
/**
* 登录用户的唯一登录会话管理

View File

@ -635,6 +635,7 @@ public class MainContext {
WEBIM,
PHONE,
SKYPE,
MESSENGER,
EMAIL,
AI;
@ -904,6 +905,7 @@ public class MainContext {
APP,
TELECOM,
SKYPE,
MESSENGER,
OTHER,
WEIBO;
@ -1017,6 +1019,15 @@ public class MainContext {
}
}
public enum FbMessengerStatus {
ENABLED,
DISABLED;
public String toString() {
return super.toString().toLowerCase();
}
}
/**
* 呼出电话的主叫类型
*/

View File

@ -34,8 +34,13 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.googlecode.aviator.AviatorEvaluator;
import freemarker.template.Configuration;
import freemarker.template.TemplateException;
import de.neuland.pug4j.Pug4J;
import de.neuland.pug4j.PugConfiguration;
import de.neuland.pug4j.expression.JexlExpressionHandler;
import de.neuland.pug4j.parser.Parser;
import de.neuland.pug4j.parser.node.Node;
import de.neuland.pug4j.template.PugTemplate;
import de.neuland.pug4j.template.ReaderTemplateLoader;
import io.netty.handler.codec.http.HttpHeaders;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.beanutils.BeanUtilsBean;
@ -59,6 +64,7 @@ import org.springframework.util.ClassUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
@ -748,7 +754,7 @@ public class MainUtils {
public static File processImage(final File destFile, final File imageFile) throws IOException {
if (imageFile != null && imageFile.exists()) {
Thumbnails.of(imageFile).width(460).keepAspectRatio(true).toFile(destFile);
Thumbnails.of(imageFile).imageType(BufferedImage.TYPE_INT_ARGB).width(460).keepAspectRatio(true).toFile(destFile);
}
return destFile;
}
@ -973,25 +979,32 @@ public class MainUtils {
return hexString.toString();
}
private static PugTemplate getPugTemplate(String name, String templet) throws IOException {
Reader reader = new StringReader(templet);
ReaderTemplateLoader loader = new ReaderTemplateLoader(reader, name);
JexlExpressionHandler expressionHandler = new JexlExpressionHandler();
Parser parser = new Parser(name, loader, expressionHandler);
Node root = parser.parse();
PugTemplate template = new PugTemplate();
template.setExpressionHandler(expressionHandler);
template.setTemplateLoader(loader);
template.setRootNode(root);
return template;
}
/**
* @throws IOException
* @throws TemplateException
*/
@SuppressWarnings("deprecation")
public static String getTemplet(String templet, Map<String, Object> values) throws IOException, TemplateException {
StringWriter writer = new StringWriter();
Configuration cfg = null;
freemarker.template.Template template = null;
String retValue = templet;
if (templet != null && templet.length() > 0 && templet.indexOf("$") >= 0) {
cfg = new Configuration();
TempletLoader loader = new TempletLoader(templet);
cfg.setTemplateLoader(loader);
cfg.setDefaultEncoding("UTF-8");
template = cfg.getTemplate("");
template.process(values, writer);
retValue = writer.toString();
}
public static String getTemplet(String templet, Map<String, Object> values) throws IOException {
PugTemplate template = getPugTemplate("templet.pug", templet);
PugConfiguration config = new PugConfiguration();
config.setCaching(false);
config.setMode(Pug4J.Mode.XML);
config.setPrettyPrint(true);
String retValue = config.renderTemplate(template,values);
return retValue;
}

View File

@ -18,10 +18,10 @@ package com.chatopera.cc.basic;
public class Viewport {
private String page;
private String templet;
private String template;
public Viewport(String templet, String page) {
this.templet = templet;
public Viewport(String template, String page) {
this.template = template;
this.page = page;
}
@ -37,11 +37,11 @@ public class Viewport {
this.page = page;
}
public String getTemplet() {
return templet;
public String getTemplate() {
return template;
}
public void setTemplet(String templet) {
this.templet = templet;
public void setTemplate(String template) {
this.template = template;
}
}

View File

@ -33,6 +33,8 @@ public class PluginRegistry {
*/
public final static String PLUGIN_CHANNEL_MESSAGER_SUFFIX = "ChannelMessager";
public final static String PLUGIN_CHATBOT_MESSAGER_SUFFIX = "ChatbotMessager";
// 插件列表
private final List<IPluginConfigurer> plugins = new ArrayList<>();

View File

@ -32,7 +32,7 @@ public class CSKeFuWebAppConfigurer
// 多个拦截器组成一个拦截器链
// addPathPatterns 用于添加拦截规则
// excludePathPatterns 用户排除拦截
registry.addInterceptor(new UserInterceptorHandler()).addPathPatterns("/**").excludePathPatterns("/login.html","/im/**","/res/image*","/res/file*","/cs/**");
registry.addInterceptor(new UserInterceptorHandler()).addPathPatterns("/**").excludePathPatterns("/login.html","/im/**","/res/image*","/res/file*","/cs/**","/messenger/webhook/*");
registry.addInterceptor(new CrossInterceptorHandler()).addPathPatterns("/**");
registry.addInterceptor(new LogIntercreptorHandler()).addPathPatterns("/**");
super.addInterceptors(registry);

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2020 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;
import org.springframework.beans.factory.annotation.Value;
import de.neuland.pug4j.PugConfiguration;
import de.neuland.pug4j.spring.template.SpringTemplateLoader;
import de.neuland.pug4j.spring.view.PugViewResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
@Configuration
public class PugConfig {
@Value("${spring.pug4j.cache}")
private Boolean pug4jCache;
@Value("${spring.pug4j.template-loader-path}")
private String templatePath;
@Bean
public SpringTemplateLoader templateLoader() {
SpringTemplateLoader templateLoader = new SpringTemplateLoader();
templateLoader.setTemplateLoaderPath(templatePath);
templateLoader.setEncoding("UTF-8");
templateLoader.setSuffix(".pug");
return templateLoader;
}
@Bean
public PugConfiguration pugConfiguration() {
PugConfiguration configuration = new PugConfiguration();
configuration.setCaching(pug4jCache);
configuration.setTemplateLoader(templateLoader());
return configuration;
}
@Bean
public ViewResolver viewResolver() {
PugViewResolver viewResolver = new PugCskefuViewResolver();
viewResolver.setConfiguration(pugConfiguration());
viewResolver.setOrder(0);
viewResolver.setSuffix(".pug");
return viewResolver;
}
}

View File

@ -0,0 +1,17 @@
package com.chatopera.cc.config;
import de.neuland.pug4j.spring.view.PugView;
import de.neuland.pug4j.spring.view.PugViewResolver;
import org.springframework.web.servlet.view.AbstractUrlBasedView;
public class PugCskefuViewResolver extends PugViewResolver {
@Override
protected AbstractUrlBasedView buildView(String viewName) throws Exception {
AbstractUrlBasedView view = super.buildView(viewName);
if (viewName.startsWith("/resource/css")) {
PugView pugView = (PugView) view;
pugView.setContentType("text/css ; charset=UTF-8");
}
return view;
}
}

View File

@ -86,7 +86,7 @@ public class ApplicationController extends Handler {
@RequestMapping("/")
public ModelAndView admin(HttpServletRequest request) {
// logger.info("[admin] path {} queryString {}", request.getPathInfo(),request.getQueryString());
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/index"));
ModelAndView view = request(super.createView("/apps/index"));
User logined = super.getUser(request);
Organ currentOrgan = super.getOrgan(request);
@ -156,7 +156,7 @@ public class ApplicationController extends Handler {
@RequestMapping("/lazyAgentStatus")
public ModelAndView lazyAgentStatus(HttpServletRequest request) {
ModelAndView view = request(super.createRequestPageTempletResponse("/public/agentstatustext"));
ModelAndView view = request(super.createView("/public/agentstatustext"));
Organ currentOrgan = super.getOrgan(request);
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(currentOrgan != null ? currentOrgan.getId() : null, super.getOrgi(request)));

View File

@ -25,7 +25,6 @@ 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.User;
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
import com.chatopera.cc.persistence.repository.StreamingFileRepository;
@ -392,7 +391,7 @@ public class Handler {
* @param page
* @return
*/
public Viewport createAdminTempletResponse(String page) {
public Viewport createViewIncludedByFreemarkerTplForAdmin(String page) {
return new Viewport("/admin/include/tpl", page);
}
@ -402,7 +401,7 @@ public class Handler {
* @param page
* @return
*/
public Viewport createAppsTempletResponse(String page) {
public Viewport createViewIncludedByFreemarkerTpl(String page) {
return new Viewport("/apps/include/tpl", page);
}
@ -412,11 +411,11 @@ public class Handler {
* @param page
* @return
*/
public Viewport createEntIMTempletResponse(final String page) {
public Viewport createViewIncludedByFreemarkerTplForEntIM(final String page) {
return new Viewport("/apps/entim/include/tpl", page);
}
public Viewport createRequestPageTempletResponse(final String page) {
public Viewport createView(final String page) {
return new Viewport(page);
}
@ -425,7 +424,7 @@ public class Handler {
* @return
*/
public ModelAndView request(Viewport data) {
return new ModelAndView(data.getTemplet() != null ? data.getTemplet() : data.getPage(), "data", data);
return new ModelAndView(data.getTemplate() != null ? data.getTemplate() : data.getPage(), "data", data);
}
public int getP(HttpServletRequest request) {

View File

@ -127,7 +127,7 @@ public class LoginController extends Handler {
}
} catch (EncryptionOperationNotPossibleException e) {
logger.error("[login] error:", e);
view = request(super.createRequestPageTempletResponse("/public/clearcookie"));
view = request(super.createView("/public/clearcookie"));
return view;
} catch (NoSuchAlgorithmException e) {
logger.error("[login] error:", e);
@ -232,7 +232,7 @@ public class LoginController extends Handler {
}
}
} else {
view = request(super.createRequestPageTempletResponse("/login"));
view = request(super.createView("/login"));
if (StringUtils.isNotBlank(referer)) {
view.addObject("referer", referer);
}
@ -342,9 +342,9 @@ public class LoginController extends Handler {
@RequestMapping(value = "/register")
@Menu(type = "apps", subtype = "user", access = true)
public ModelAndView register(HttpServletRequest request, HttpServletResponse response, @Valid String msg) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
ModelAndView view = request(super.createView("redirect:/"));
if (request.getSession(true).getAttribute(Constants.USER_SESSION_NAME) == null) {
view = request(super.createRequestPageTempletResponse("/register"));
view = request(super.createView("/register"));
}
if (StringUtils.isNotBlank(msg)) {
view.addObject("msg", msg);
@ -358,7 +358,7 @@ public class LoginController extends Handler {
String msg = "";
msg = validUser(user);
if (StringUtils.isNotBlank(msg)) {
return request(super.createRequestPageTempletResponse("redirect:/register.html?msg=" + msg));
return request(super.createView("redirect:/register.html?msg=" + msg));
} else {
user.setUname(user.getUsername());
user.setAdmin(true);

View File

@ -67,7 +67,7 @@ public class AdminController extends Handler {
@RequestMapping("/admin")
public ModelAndView index(ModelMap map, HttpServletRequest request) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
ModelAndView view = request(super.createView("redirect:/"));
User user = super.getUser(request);
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(user.getOrgi()));
view.addObject("agentStatus", cache.findOneAgentStatusByAgentnoAndOrig(user.getId(), user.getOrgi()));
@ -115,7 +115,7 @@ public class AdminController extends Handler {
@Menu(type = "admin", subtype = "content")
public ModelAndView content(ModelMap map, HttpServletRequest request) {
aggValues(map, request);
return request(super.createAdminTempletResponse("/admin/content"));
return request(super.createView("/admin/content"));
/*if(super.getUser(request).isSuperuser()) {
aggValues(map, request);
return request(super.createAdminTempletResponse("/admin/content"));
@ -133,49 +133,6 @@ public class AdminController extends Handler {
} else {
request.getSession().setAttribute(Constants.CSKEFU_SYSTEM_INFOACQ, "true");
}
return request(super.createRequestPageTempletResponse("redirect:/"));
return request(super.createView("redirect:/"));
}
@RequestMapping("/admin/auth/event")
@Menu(type = "admin", subtype = "authevent")
public ModelAndView authevent(ModelMap map, HttpServletRequest request, @Valid String title, @Valid String url, @Valid String iconstr, @Valid String icontext) {
map.addAttribute("title", title);
map.addAttribute("url", url);
if (StringUtils.isNotBlank(iconstr) && StringUtils.isNotBlank(icontext)) {
map.addAttribute("iconstr", iconstr.replaceAll(icontext, "&#x" + MainUtils.string2HexString(icontext) + ";"));
}
return request(super.createRequestPageTempletResponse("/admin/system/auth/exchange"));
}
@RequestMapping("/admin/auth/save")
@Menu(type = "admin", subtype = "authsave")
public ModelAndView authsave(ModelMap map, HttpServletRequest request, @Valid String title, @Valid SysDic dic) {
SysDic sysDic = sysDicRes.findByCode(Constants.CSKEFU_SYSTEM_AUTH_DIC);
boolean newdic = false;
if (sysDic != null && StringUtils.isNotBlank(dic.getName())) {
if (StringUtils.isNotBlank(dic.getParentid())) {
if (dic.getParentid().equals("0")) {
dic.setParentid(sysDic.getId());
newdic = true;
} else {
List<SysDic> dicList = sysDicRes.findByDicid(sysDic.getId());
for (SysDic temp : dicList) {
if (temp.getCode().equals(dic.getParentid()) || temp.getName().equals(dic.getParentid())) {
dic.setParentid(temp.getId());
newdic = true;
}
}
}
}
if (newdic) {
dic.setCreater(super.getUser(request).getId());
dic.setCreatetime(new Date());
dic.setCtype("auth");
dic.setDicid(sysDic.getId());
sysDicRes.save(dic);
}
}
return request(super.createRequestPageTempletResponse("/public/success"));
}
}

View File

@ -1,123 +0,0 @@
/*
* 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;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Skill;
import com.chatopera.cc.persistence.repository.SkillRepository;
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;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@Controller
@RequestMapping("/admin/skill")
public class AgentSkillController extends Handler{
@Autowired
private SkillRepository skillRepository;
@RequestMapping("/index")
@Menu(type = "admin" , subtype = "skill")
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String skill) {
List<Skill> skillGroups = skillRepository.findAll() ;
map.addAttribute("skillGroups", skillGroups);
if(skillGroups.size() > 0){
if(!StringUtils.isBlank(skill)){
for(Skill data : skillGroups){
if(data.getId().equals(skill)){
map.addAttribute("skillData", data);
}
}
}else{
map.addAttribute("skillData", skillGroups.get(0));
}
// map.addAttribute("userList", userRepository.findBySkill(skill));
}
return request(super.createAdminTempletResponse("/admin/skill/index"));
}
@RequestMapping("/add")
@Menu(type = "admin" , subtype = "skill")
public ModelAndView add(ModelMap map , HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/admin/skill/add"));
}
@RequestMapping("/save")
@Menu(type = "admin" , subtype = "skill")
public ModelAndView save(HttpServletRequest request ,@Valid Skill skill) {
Skill tempSkill = skillRepository.findByNameAndOrgi(skill.getName() , super.getOrgi(request)) ;
String msg = "admin_skill_save_success" ;
if(tempSkill != null){
msg = "admin_skill_save_exist";
}else{
skillRepository.save(skill) ;
}
return request(super.createRequestPageTempletResponse("redirect:/admin/skill/index.html?msg="+msg));
}
@RequestMapping("/edit")
@Menu(type = "admin" , subtype = "skill")
public ModelAndView edit(ModelMap map ,HttpServletRequest request , @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/skill/edit")) ;
view.addObject("skillData", skillRepository.findByIdAndOrgi(id , super.getOrgi(request))) ;
return view;
}
@RequestMapping("/update")
@Menu(type = "admin" , subtype = "skill")
public ModelAndView update(HttpServletRequest request ,@Valid Skill skill) {
Skill tempSkill = skillRepository.findByIdAndOrgi(skill.getId() , super.getOrgi(request)) ;
String msg = "admin_skill_update_success" ;
if(tempSkill != null){
tempSkill.setName(skill.getName());
tempSkill.setUpdatetime(new Date());
skillRepository.save(tempSkill) ;
}else{
msg = "admin_skill_update_not_exist";
}
return request(super.createRequestPageTempletResponse("redirect:/admin/skill/index.html?msg="+msg));
}
@RequestMapping("/delete")
@Menu(type = "admin" , subtype = "skill")
public ModelAndView delete(HttpServletRequest request ,@Valid Skill skill) {
String msg = "admin_skill_delete" ;
if(skill!=null){
skillRepository.delete(skill);
}else{
msg = "admin_skill_not_exist" ;
}
return request(super.createRequestPageTempletResponse("redirect:/admin/skill/index.html?msg="+msg));
}
}

View File

@ -1,127 +0,0 @@
/*
* 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;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.AreaType;
import com.chatopera.cc.model.Dict;
import com.chatopera.cc.model.SysDic;
import com.chatopera.cc.persistence.repository.AreaTypeRepository;
import com.chatopera.cc.persistence.repository.SysDicRepository;
import com.chatopera.cc.util.Menu;
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.io.IOException;
import java.util.Date;
/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@Controller
@RequestMapping("/admin/area")
public class AreaController extends Handler{
@Autowired
private AreaTypeRepository areaRepository;
@Autowired
private SysDicRepository sysDicRepository;
@RequestMapping("/index")
@Menu(type = "admin" , subtype = "area")
public ModelAndView index(ModelMap map , HttpServletRequest request) throws IOException {
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi(request)));
return request(super.createAdminTempletResponse("/admin/area/index"));
}
@RequestMapping("/add")
@Menu(type = "admin" , subtype = "area")
public ModelAndView add(ModelMap map , HttpServletRequest request) {
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC) ;
if(sysDic!=null){
map.addAttribute("sysarea", sysDic) ;
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId())) ;
}
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC)) ;
return request(super.createRequestPageTempletResponse("/admin/area/add"));
}
@RequestMapping("/save")
@Menu(type = "admin" , subtype = "area")
public ModelAndView save(HttpServletRequest request ,@Valid AreaType area) {
int areas = areaRepository.countByNameAndOrgi(area.getName(), super.getOrgi(request)) ;
if(areas == 0){
area.setOrgi(super.getOrgi(request));
area.setCreatetime(new Date());
area.setCreater(super.getUser(request).getId());
areaRepository.save(area) ;
MainUtils.initSystemArea();
}
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
}
@RequestMapping("/edit")
@Menu(type = "admin" , subtype = "area")
public ModelAndView edit(ModelMap map ,HttpServletRequest request , @Valid String id) {
map.addAttribute("area", areaRepository.findByIdAndOrgi(id, super.getOrgi(request))) ;
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC) ;
if(sysDic!=null){
map.addAttribute("sysarea", sysDic) ;
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId())) ;
}
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC)) ;
return request(super.createRequestPageTempletResponse("/admin/area/edit"));
}
@RequestMapping("/update")
@Menu(type = "admin" , subtype = "area" , admin = true)
public ModelAndView update(HttpServletRequest request ,@Valid AreaType area) {
AreaType areaType = areaRepository.findByIdAndOrgi(area.getId(), super.getOrgi(request)) ;
if(areaType != null){
area.setCreatetime(areaType.getCreatetime());
area.setOrgi(super.getOrgi(request));
area.setCreater(areaType.getCreater());
areaRepository.save(area) ;
MainUtils.initSystemArea();
}
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
}
@RequestMapping("/delete")
@Menu(type = "admin" , subtype = "area")
public ModelAndView delete(HttpServletRequest request ,@Valid AreaType area) {
AreaType areaType = areaRepository.findByIdAndOrgi(area.getId(), super.getOrgi(request)) ;
if(areaType!=null){
areaRepository.delete(areaType);
MainUtils.initSystemArea();
}
return request(super.createRequestPageTempletResponse("redirect:/admin/area/index.html"));
}
}

View File

@ -17,12 +17,10 @@
package com.chatopera.cc.controller.admin;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.*;
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;
@ -113,7 +111,7 @@ public class OrganController extends Handler {
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"));
return request(super.createView("/admin/organ/index"));
}
@RequestMapping("/add")
@ -129,7 +127,7 @@ public class OrganController extends Handler {
map.addAttribute("organList", getOwnOragans(request));
return request(super.createRequestPageTempletResponse("/admin/organ/add"));
return request(super.createView("/admin/organ/add"));
}
@RequestMapping("/save")
@ -146,7 +144,7 @@ public class OrganController extends Handler {
organRepository.save(organ);
}
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + firstId));
}
@ -167,7 +165,7 @@ public class OrganController extends Handler {
map.addAttribute("userOrganList", userProxy
.findByOrganAndOrgiAndDatastatus(organ, super.getOrgi(), false));
map.addAttribute("organ", organData);
return request(super.createRequestPageTempletResponse("/admin/organ/seluser"));
return request(super.createView("/admin/organ/seluser"));
}
@ -239,7 +237,7 @@ public class OrganController extends Handler {
userRepository.save(organUserList);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
return request(super.createView("redirect:/admin/organ/index.html?organ=" + organ));
}
@RequestMapping("/user/delete")
@ -255,16 +253,16 @@ public class OrganController extends Handler {
if (organUsers.size() > 1) {
organUserRes.deleteOrganUserByUseridAndOrgan(id, organ);
} else {
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ + "&msg=not_allow_remove_user"));
return request(super.createView("redirect:/admin/organ/index.html?organ=" + organ + "&msg=not_allow_remove_user"));
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
return request(super.createView("redirect:/admin/organ/index.html?organ=" + organ));
}
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "organ")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/organ/edit"));
ModelAndView view = request(super.createView("/admin/organ/edit"));
Organ currentOrgan = super.getOrgan(request);
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi()));
view.addObject("organData", organRepository.findByIdAndOrgi(id, super.getOrgi()));
@ -277,7 +275,7 @@ public class OrganController extends Handler {
@Menu(type = "admin", subtype = "organ")
public ModelAndView update(HttpServletRequest request, @Valid Organ organ) {
String msg = organProxy.updateOrgan(organ, super.getOrgi(request), super.getUser(request));
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + organ.getId()));
}
@ -293,7 +291,7 @@ public class OrganController extends Handler {
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC));
map.addAttribute("organData", organRepository.findByIdAndOrgi(id, super.getOrgi()));
return request(super.createRequestPageTempletResponse("/admin/organ/area"));
return request(super.createView("/admin/organ/area"));
}
@ -308,7 +306,7 @@ public class OrganController extends Handler {
} else {
msg = "admin_organ_update_not_exist";
}
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + organ.getId()));
}
@ -328,7 +326,7 @@ public class OrganController extends Handler {
} else {
msg = "admin_organ_not_exist";
}
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?msg=" + msg));
return request(super.createView("redirect:/admin/organ/index.html?msg=" + msg));
}
@RequestMapping("/auth/save")
@ -356,6 +354,6 @@ public class OrganController extends Handler {
}
}
return request(
super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organData.getId()));
super.createView("redirect:/admin/organ/index.html?organ=" + organData.getId()));
}
}

View File

@ -17,7 +17,6 @@
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.*;
import com.chatopera.cc.persistence.repository.*;
@ -91,13 +90,13 @@ public class RoleController extends Handler {
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData, new PageRequest(super.getP(request), super.getPs(request))));
}
}
return request(super.createAdminTempletResponse("/admin/role/index"));
return request(super.createView("/admin/role/index"));
}
@RequestMapping("/add")
@Menu(type = "admin", subtype = "role")
public ModelAndView add(ModelMap map, HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/admin/role/add"));
return request(super.createView("/admin/role/add"));
}
@RequestMapping("/save")
@ -116,7 +115,7 @@ public class RoleController extends Handler {
role.setOrgan(currentOrgan.getId());
roleRepository.save(role);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?msg=" + msg));
return request(super.createView("redirect:/admin/role/index.html?msg=" + msg));
}
@RequestMapping("/seluser")
@ -127,7 +126,7 @@ public class RoleController extends Handler {
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"));
return request(super.createView("/admin/role/seluser"));
}
@RequestMapping("/saveuser")
@ -154,7 +153,7 @@ public class RoleController extends Handler {
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?role=" + role));
return request(super.createView("redirect:/admin/role/index.html?role=" + role));
}
@RequestMapping("/user/delete")
@ -163,13 +162,13 @@ public class RoleController extends Handler {
if (role != null) {
userRoleRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?role=" + role));
return request(super.createView("redirect:/admin/role/index.html?role=" + role));
}
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "role")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/role/edit"));
ModelAndView view = request(super.createView("/admin/role/edit"));
view.addObject("roleData", roleRepository.findByIdAndOrgi(id, super.getOrgi()));
return view;
}
@ -188,7 +187,7 @@ public class RoleController extends Handler {
} else if (!role.getId().equals(tempRoleExist.getId())) {
msg = "admin_role_update_not_exist";
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?msg=" + msg));
return request(super.createView("redirect:/admin/role/index.html?msg=" + msg));
}
@RequestMapping("/delete")
@ -201,7 +200,7 @@ public class RoleController extends Handler {
} else {
msg = "admin_role_not_exist";
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?msg=" + msg));
return request(super.createView("redirect:/admin/role/index.html?msg=" + msg));
}
@RequestMapping("/auth")
@ -216,7 +215,7 @@ public class RoleController extends Handler {
Role role = roleRepository.findByIdAndOrgi(id, super.getOrgi());
map.addAttribute("role", role);
map.addAttribute("roleAuthList", roleAuthRes.findByRoleidAndOrgi(role.getId(), super.getOrgi()));
return request(super.createRequestPageTempletResponse("/admin/role/auth"));
return request(super.createView("/admin/role/auth"));
}
@RequestMapping("/auth/save")
@ -250,6 +249,6 @@ public class RoleController extends Handler {
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?role=" + id));
return request(super.createView("redirect:/admin/role/index.html?role=" + id));
}
}

View File

@ -24,7 +24,6 @@ import com.chatopera.cc.model.OrganUser;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.UserRole;
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;
@ -89,13 +88,13 @@ public class UsersController extends Handler {
)));
return request(super.createAdminTempletResponse("/admin/user/index"));
return request(super.createView("/admin/user/index"));
}
@RequestMapping("/add")
@Menu(type = "admin", subtype = "user")
public ModelAndView add(ModelMap map, HttpServletRequest request) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/user/add"));
ModelAndView view = request(super.createView("/admin/user/add"));
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
map.addAttribute("currentOrgan", currentOrgan);
@ -107,7 +106,7 @@ public class UsersController extends Handler {
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "user")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/user/edit"));
ModelAndView view = request(super.createView("/admin/user/edit"));
User user = userRepository.findById(id);
if (user != null && MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
// 加载呼叫中心信息
@ -146,7 +145,7 @@ public class UsersController extends Handler {
} else {
msg = "admin_user_not_exist";
}
return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg=" + msg));
return request(super.createView("redirect:/admin/user/index.html?msg=" + msg));
}
}

View File

@ -75,13 +75,13 @@ public class SNSAccountIMController extends Handler {
if (StringUtils.isNotBlank(execute) && execute.equals("false")) {
map.addAttribute("execute", execute);
}
return request(super.createAdminTempletResponse("/admin/channel/im/index"));
return request(super.createView("/admin/channel/im/index"));
}
@RequestMapping("/add")
@Menu(type = "admin", subtype = "send", access = false, admin = true)
public ModelAndView add(ModelMap map, HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/admin/channel/im/add"));
return request(super.createView("/admin/channel/im/add"));
}
@RequestMapping("/save")
@ -123,7 +123,7 @@ public class SNSAccountIMController extends Handler {
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/im/index.html?status=" + status));
return request(super.createView("redirect:/admin/im/index.html?status=" + status));
}
@RequestMapping("/delete")
@ -141,14 +141,14 @@ public class SNSAccountIMController extends Handler {
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/im/index.html?execute=" + execute));
return request(super.createView("redirect:/admin/im/index.html?execute=" + execute));
}
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "send", access = false, admin = true)
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("snsAccount", snsAccountRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/channel/im/edit"));
return request(super.createView("/admin/channel/im/edit"));
}
@RequestMapping("/update")
@ -180,6 +180,6 @@ public class SNSAccountIMController extends Handler {
oldSnsAccount.setSnstype(MainContext.ChannelType.WEBIM.toString());
snsAccountRes.save(oldSnsAccount);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/im/index.html"));
return request(super.createView("redirect:/admin/im/index.html"));
}
}

View File

@ -20,7 +20,6 @@ import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CousultInvite;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.OrgiSkillRel;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OnlineUserProxy;
@ -86,10 +85,10 @@ public class WebIMController extends Handler {
map.addAttribute("inviteData", coultInvite);
map.addAttribute("skillGroups", getSkillGroups(request));
map.addAttribute("agentList", getUsers(request));
map.addAttribute("import", request.getServerPort());
map.addAttribute("port", request.getServerPort());
map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request)));
}
return request(super.createAdminTempletResponse("/admin/webim/index"));
return request(super.createView("/admin/webim/index"));
}
/**
@ -134,7 +133,7 @@ public class WebIMController extends Handler {
}
inviteRes.save(inviteData);
cache.putConsultInviteByOrgi(inviteData.getOrgi(), inviteData);
return request(super.createRequestPageTempletResponse("redirect:/admin/webim/index.html?snsid=" + inviteData.getSnsaccountid()));
return request(super.createView("redirect:/admin/webim/index.html?snsid=" + inviteData.getSnsaccountid()));
}
@RequestMapping("/profile")
@ -151,7 +150,7 @@ public class WebIMController extends Handler {
map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request)));
map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request)));
return request(super.createAdminTempletResponse("/admin/webim/profile"));
return request(super.createView("/admin/webim/profile"));
}
@RequestMapping("/profile/save")
@ -236,7 +235,7 @@ public class WebIMController extends Handler {
}
cache.putConsultInviteByOrgi(orgi, inviteData);
return request(super.createRequestPageTempletResponse("redirect:/admin/webim/profile.html?snsid=" + inviteData.getSnsaccountid()));
return request(super.createView("redirect:/admin/webim/profile.html?snsid=" + inviteData.getSnsaccountid()));
}
@RequestMapping("/invote")
@ -250,7 +249,7 @@ public class WebIMController extends Handler {
}
map.addAttribute("import", request.getServerPort());
map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request)));
return request(super.createAdminTempletResponse("/admin/webim/invote"));
return request(super.createView("/admin/webim/invote"));
}
@RequestMapping("/invote/save")
@ -280,7 +279,7 @@ public class WebIMController extends Handler {
inviteRes.save(inviteData);
}
cache.putConsultInviteByOrgi(inviteData.getOrgi(), inviteData);
return request(super.createRequestPageTempletResponse("redirect:/admin/webim/invote.html?snsid=" + inviteData.getSnsaccountid()));
return request(super.createView("redirect:/admin/webim/invote.html?snsid=" + inviteData.getSnsaccountid()));
}
/**

View File

@ -93,9 +93,11 @@ public class SystemConfigController extends Handler {
map.addAttribute("server", server);
map.addAttribute("imServerStatus", MainContext.getIMServerStatus());
List<Secret> secretConfig = secRes.findByOrgi(super.getOrgi(request));
// check out secretConfig
if (secretConfig != null && secretConfig.size() > 0) {
map.addAttribute("secret", secretConfig.get(0));
}
List<SysDic> dicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC);
SysDic callCenterDic = null, workOrderDic = null, smsDic = null;
for (SysDic dic : dicList) {
@ -133,7 +135,7 @@ public class SystemConfigController extends Handler {
if (StringUtils.isNotBlank(request.getParameter("msg"))) {
map.addAttribute("msg", request.getParameter("msg"));
}
return request(super.createAdminTempletResponse("/admin/config/index"));
return request(super.createView("/admin/config/index"));
}
@RequestMapping("/stopimserver")
@ -144,21 +146,21 @@ public class SystemConfigController extends Handler {
server.stop();
MainContext.setIMServerStatus(false);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute));
return request(super.createView("redirect:/admin/config/index.html?execute=" + execute));
}
@RequestMapping("/startentim")
@Menu(type = "admin", subtype = "startentim", access = false, admin = true)
public ModelAndView startentim(ModelMap map, HttpServletRequest request) throws SQLException {
MainContext.enableModule(Constants.CSKEFU_MODULE_ENTIM);
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html"));
return request(super.createView("redirect:/admin/config/index.html"));
}
@RequestMapping("/stopentim")
@Menu(type = "admin", subtype = "stopentim", access = false, admin = true)
public ModelAndView stopentim(ModelMap map, HttpServletRequest request) throws SQLException {
MainContext.removeModule(Constants.CSKEFU_MODULE_ENTIM);
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html"));
return request(super.createView("redirect:/admin/config/index.html"));
}
/**
@ -178,7 +180,7 @@ public class SystemConfigController extends Handler {
MainContext.setIMServerStatus(false);
System.exit(0);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute));
return request(super.createView("redirect:/admin/config/index.html?execute=" + execute));
}
@ -277,6 +279,6 @@ public class SystemConfigController extends Handler {
MainContext.getCache().putSystemByIdAndOrgi("systemConfig", super.getOrgi(request), systemConfig);
map.addAttribute("imServerStatus", MainContext.getIMServerStatus());
return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?msg=" + msg));
return request(super.createView("redirect:/admin/config/index.html?msg=" + msg));
}
}

View File

@ -61,14 +61,14 @@ public class SystemMessageController extends Handler {
});
map.addAttribute("emailList", emails);
return request(super.createAdminTempletResponse("/admin/email/index"));
return request(super.createView("/admin/email/index"));
}
@RequestMapping("/email/add")
@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"));
return request(super.createView("/admin/email/add"));
}
@RequestMapping("/email/save")
@ -80,7 +80,7 @@ public class SystemMessageController extends Handler {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
}
systemMessageRepository.save(email);
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
return request(super.createView("redirect:/admin/email/index.html"));
}
@RequestMapping("/email/edit")
@ -88,7 +88,7 @@ public class SystemMessageController extends Handler {
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"));
return request(super.createView("/admin/email/edit"));
}
@RequestMapping("/email/update")
@ -106,7 +106,7 @@ public class SystemMessageController extends Handler {
}
systemMessageRepository.save(email);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
return request(super.createView("redirect:/admin/email/index.html"));
}
@RequestMapping("/email/delete")
@ -116,7 +116,7 @@ public class SystemMessageController extends Handler {
if (email != null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
return request(super.createView("redirect:/admin/email/index.html"));
}
@ -124,15 +124,14 @@ public class SystemMessageController extends Handler {
@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"));
return request(super.createView("/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"));
return request(super.createRequestPageTempletResponse("/admin/sms/add"));
return request(super.createView("/admin/sms/add"));
}
@RequestMapping("/sms/save")
@ -144,7 +143,7 @@ public class SystemMessageController extends Handler {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
}
systemMessageRepository.save(sms);
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
return request(super.createView("redirect:/admin/sms/index.html"));
}
@RequestMapping("/sms/edit")
@ -152,7 +151,7 @@ public class SystemMessageController extends Handler {
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"));
return request(super.createView("/admin/sms/edit"));
}
@RequestMapping("/sms/update")
@ -170,7 +169,7 @@ public class SystemMessageController extends Handler {
}
systemMessageRepository.save(sms);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
return request(super.createView("redirect:/admin/sms/index.html"));
}
@RequestMapping("/sms/delete")
@ -180,6 +179,6 @@ public class SystemMessageController extends Handler {
if (sms != null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
return request(super.createView("redirect:/admin/sms/index.html"));
}
}

View File

@ -80,14 +80,14 @@ public class MetadataController extends Handler {
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request) throws SQLException {
map.addAttribute("metadataList", metadataRes.findAll(new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAdminTempletResponse("/admin/system/metadata/index"));
return request(super.createView("/admin/system/metadata/index"));
}
@RequestMapping("/edit")
@Menu(type = "admin", subtype = "metadata", admin = true)
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("metadata", metadataRes.findById(id));
return request(super.createRequestPageTempletResponse("/admin/system/metadata/edit"));
return request(super.createView("/admin/system/metadata/edit"));
}
@RequestMapping("/update")
@ -99,7 +99,7 @@ public class MetadataController extends Handler {
table.setListblocktemplet(metadata.getListblocktemplet());
table.setPreviewtemplet(metadata.getPreviewtemplet());
metadataRes.save(table);
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
return request(super.createView("redirect:/admin/metadata/index.html"));
}
@RequestMapping("/properties/edit")
@ -109,7 +109,7 @@ public class MetadataController extends Handler {
map.addAttribute("sysdicList", sysDicRes.findByParentid("0"));
map.addAttribute("dataImplList", Dict.getInstance().getDic("com.dic.data.impl"));
return request(super.createRequestPageTempletResponse("/admin/system/metadata/tpedit"));
return request(super.createView("/admin/system/metadata/tpedit"));
}
@RequestMapping("/properties/update")
@ -134,7 +134,7 @@ public class MetadataController extends Handler {
tableProperties.setImpfield(tp.isImpfield());
tablePropertiesRes.save(tableProperties);
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/table.html?id=" + tableProperties.getDbtableid()));
return request(super.createView("redirect:/admin/metadata/table.html?id=" + tableProperties.getDbtableid()));
}
@RequestMapping("/delete")
@ -142,7 +142,7 @@ public class MetadataController extends Handler {
public ModelAndView delete(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException {
MetadataTable table = metadataRes.findById(id);
metadataRes.delete(table);
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
return request(super.createView("redirect:/admin/metadata/index.html"));
}
@RequestMapping("/batdelete")
@ -151,7 +151,7 @@ public class MetadataController extends Handler {
if (ids != null && ids.length > 0) {
metadataRes.delete(metadataRes.findAll(Arrays.asList(ids)));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
return request(super.createView("redirect:/admin/metadata/index.html"));
}
@RequestMapping("/properties/delete")
@ -159,7 +159,7 @@ public class MetadataController extends Handler {
public ModelAndView propertiesdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tbid) throws SQLException {
TableProperties prop = tablePropertiesRes.findById(id);
tablePropertiesRes.delete(prop);
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/table.html?id=" + (!StringUtils.isBlank(tbid) ? tbid : prop.getDbtableid())));
return request(super.createView("redirect:/admin/metadata/table.html?id=" + (!StringUtils.isBlank(tbid) ? tbid : prop.getDbtableid())));
}
@RequestMapping("/properties/batdelete")
@ -168,7 +168,7 @@ public class MetadataController extends Handler {
if (ids != null && ids.length > 0) {
tablePropertiesRes.delete(tablePropertiesRes.findAll(Arrays.asList(ids)));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/table.html?id=" + tbid));
return request(super.createView("redirect:/admin/metadata/table.html?id=" + tbid));
}
@RequestMapping("/table")
@ -177,7 +177,7 @@ public class MetadataController extends Handler {
map.addAttribute("propertiesList", tablePropertiesRes.findByDbtableid(id));
map.addAttribute("tbid", id);
map.addAttribute("table", metadataRes.findById(id));
return request(super.createAdminTempletResponse("/admin/system/metadata/table"));
return request(super.createView("/admin/system/metadata/table"));
}
@RequestMapping("/imptb")
@ -197,7 +197,7 @@ public class MetadataController extends Handler {
});
return request(super
.createRequestPageTempletResponse("/admin/system/metadata/imptb"));
.createView("/admin/system/metadata/imptb"));
}
@RequestMapping("/imptbsave")
@ -236,7 +236,7 @@ public class MetadataController extends Handler {
}
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
return request(super.createView("redirect:/admin/metadata/index.html"));
}
private MetadataTable processMetadataTable(UKTableMetaData metaData, MetadataTable table) {
@ -293,7 +293,7 @@ public class MetadataController extends Handler {
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
return request(super.createView("redirect:/admin/metadata/index.html"));
}
@SuppressWarnings({"rawtypes", "unchecked"})
@ -324,7 +324,7 @@ public class MetadataController extends Handler {
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
return request(super.createView("redirect:/admin/metadata/index.html"));
}
@SuppressWarnings({"rawtypes"})
@ -351,7 +351,7 @@ public class MetadataController extends Handler {
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
return request(super.createView("redirect:/admin/metadata/index.html"));
}
}

View File

@ -50,13 +50,13 @@ public class SysDicController extends Handler {
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView index(ModelMap map, HttpServletRequest request) {
map.addAttribute("sysDicList", sysDicRes.findByParentid("0", new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")));
return request(super.createAdminTempletResponse("/admin/system/sysdic/index"));
return request(super.createView("/admin/system/sysdic/index"));
}
@RequestMapping("/add")
@Menu(type = "admin", subtype = "sysdic")
public ModelAndView add(ModelMap map, HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/add"));
return request(super.createView("/admin/system/sysdic/add"));
}
@RequestMapping("/save")
@ -75,7 +75,7 @@ public class SysDicController extends Handler {
} else {
msg = "exist";
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sysdic/index.html" + (msg != null ? "?msg=" + msg : "")));
return request(super.createView("redirect:/admin/sysdic/index.html" + (msg != null ? "?msg=" + msg : "")));
}
@RequestMapping("/edit")
@ -83,7 +83,7 @@ public class SysDicController extends Handler {
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("p", p);
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/edit"));
return request(super.createView("/admin/system/sysdic/edit"));
}
@RequestMapping("/update")
@ -102,7 +102,7 @@ public class SysDicController extends Handler {
String orgi = super.getOrgi(request);
reloadSysDicItem(sysDic, orgi);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sysdic/index.html?p=" + p));
return request(super.createView("redirect:/admin/sysdic/index.html?p=" + p));
}
@RequestMapping("/delete")
@ -114,7 +114,7 @@ public class SysDicController extends Handler {
reloadSysDicItem(sysDic, super.getOrgi(request));
return request(super.createRequestPageTempletResponse("redirect:/admin/sysdic/index.html?p=" + p));
return request(super.createView("redirect:/admin/sysdic/index.html?p=" + p));
}
@RequestMapping("/dicitem")
@ -122,7 +122,7 @@ public class SysDicController extends Handler {
public ModelAndView dicitem(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("sysDicList", sysDicRes.findByParentid(id, new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")));
return request(super.createAdminTempletResponse("/admin/system/sysdic/dicitem"));
return request(super.createView("/admin/system/sysdic/dicitem"));
}
@RequestMapping("/dicitem/add")
@ -130,7 +130,7 @@ public class SysDicController extends Handler {
public ModelAndView dicitemadd(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("p", p);
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/dicitemadd"));
return request(super.createView("/admin/system/sysdic/dicitemadd"));
}
@RequestMapping("/dicitem/save")
@ -149,7 +149,7 @@ public class SysDicController extends Handler {
} else {
msg = "exist";
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sysdic/dicitem.html?id=" + dic.getParentid() + (msg != null ? "&p=" + p + "&msg=" + msg : "")));
return request(super.createView("redirect:/admin/sysdic/dicitem.html?id=" + dic.getParentid() + (msg != null ? "&p=" + p + "&msg=" + msg : "")));
}
/**
@ -179,7 +179,7 @@ public class SysDicController extends Handler {
public ModelAndView dicitembatadd(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("p", p);
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/batadd"));
return request(super.createView("/admin/system/sysdic/batadd"));
}
@RequestMapping("/dicitem/batsave")
@ -210,7 +210,7 @@ public class SysDicController extends Handler {
}
reloadSysDicItem(sysDicRes.getOne(sysDic.getParentid()), orig);
return request(super.createRequestPageTempletResponse("redirect:/admin/sysdic/dicitem.html?id=" + sysDic.getParentid() + "&p=" + p));
return request(super.createView("redirect:/admin/sysdic/dicitem.html?id=" + sysDic.getParentid() + "&p=" + p));
}
@RequestMapping("/dicitem/edit")
@ -218,7 +218,7 @@ public class SysDicController extends Handler {
public ModelAndView dicitemedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String p) {
map.addAttribute("sysDic", sysDicRes.findById(id));
map.addAttribute("p", p);
return request(super.createRequestPageTempletResponse("/admin/system/sysdic/dicitemedit"));
return request(super.createView("/admin/system/sysdic/dicitemedit"));
}
@RequestMapping("/dicitem/update")
@ -240,7 +240,7 @@ public class SysDicController extends Handler {
reloadSysDicItem(sysDic, orgi);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sysdic/dicitem.html?id=" + dic.getParentid() + "&p=" + p));
return request(super.createView("redirect:/admin/sysdic/dicitem.html?id=" + dic.getParentid() + "&p=" + p));
}
@RequestMapping("/dicitem/delete")
@ -250,7 +250,7 @@ public class SysDicController extends Handler {
SysDic dic = sysDicRes.getOne(id);
sysDicRes.delete(dic);
reloadSysDicItem(dic, super.getOrgi(request));
return request(super.createRequestPageTempletResponse("redirect:/admin/sysdic/dicitem.html?id=" + dic.getParentid() + "&p=" + p));
return request(super.createView("redirect:/admin/sysdic/dicitem.html?id=" + dic.getParentid() + "&p=" + p));
}
}

View File

@ -60,7 +60,7 @@ public class TemplateController extends Handler{
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
public ModelAndView index(ModelMap map , HttpServletRequest request) {
map.addAttribute("sysDicList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC));
return request(super.createAdminTempletResponse("/admin/system/template/index"));
return request(super.createView("/admin/system/template/index"));
}
@RequestMapping("/expall")
@ -75,7 +75,7 @@ public class TemplateController extends Handler{
@RequestMapping("/imp")
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
public ModelAndView imp(ModelMap map , HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/admin/system/template/imp"));
return request(super.createView("/admin/system/template/imp"));
}
@SuppressWarnings("unchecked")
@ -91,7 +91,7 @@ public class TemplateController extends Handler{
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/template/index.html"));
return request(super.createView("redirect:/admin/template/index.html"));
}
@RequestMapping("/list")
@ -99,14 +99,14 @@ public class TemplateController extends Handler{
public ModelAndView list(ModelMap map , HttpServletRequest request ,@Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(type, super.getOrgi(request)));
return request(super.createAdminTempletResponse("/admin/system/template/list"));
return request(super.createView("/admin/system/template/list"));
}
@RequestMapping("/add")
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
public ModelAndView add(ModelMap map , HttpServletRequest request ,@Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type));
return request(super.createRequestPageTempletResponse("/admin/system/template/add"));
return request(super.createView("/admin/system/template/add"));
}
@RequestMapping( "/save")
@ -121,7 +121,7 @@ public class TemplateController extends Handler{
}
templateRes.save(template) ;
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type="+template.getTemplettype()));
return request(super.createView("redirect:/admin/template/list.html?type="+template.getTemplettype()));
}
@RequestMapping("/edit")
@ -129,7 +129,7 @@ public class TemplateController extends Handler{
public ModelAndView edit(ModelMap map , HttpServletRequest request , @Valid String id, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/system/template/edit"));
return request(super.createView("/admin/system/template/edit"));
}
@RequestMapping( "/update")
@ -153,7 +153,7 @@ public class TemplateController extends Handler{
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type="+template.getTemplettype()));
return request(super.createView("redirect:/admin/template/list.html?type="+template.getTemplettype()));
}
@RequestMapping("/code")
@ -161,7 +161,7 @@ public class TemplateController extends Handler{
public ModelAndView code(ModelMap map , HttpServletRequest request , @Valid String id, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/system/template/code"));
return request(super.createView("/admin/system/template/code"));
}
@RequestMapping( "/codesave")
@ -175,7 +175,7 @@ public class TemplateController extends Handler{
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type="+template.getTemplettype()));
return request(super.createView("redirect:/admin/template/list.html?type="+template.getTemplettype()));
}
@RequestMapping("/delete")
@ -186,7 +186,7 @@ public class TemplateController extends Handler{
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/template/list.html?type="+template.getTemplettype()));
return request(super.createView("redirect:/admin/template/list.html?type="+template.getTemplettype()));
}
}

View File

@ -1,104 +0,0 @@
/*
* 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.api;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.QuickReply;
import com.chatopera.cc.persistence.es.QuickReplyRepository;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.RestResult;
import com.chatopera.cc.util.RestResultType;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
/**
* 快捷回复服务
* 快捷回复管理功能
*/
@RestController
@RequestMapping("/api/quickreply")
public class ApiQuickReplyController extends Handler {
@Autowired
private QuickReplyRepository quickReplyRepository;
/**
* 返回快捷回复列表cate为分类id通过/api/quicktype 获取分类id支持分页分页参数为 p=1&ps=50默认分页尺寸为 20条每页
* @param request
* @param cate 搜索分类id精确搜索通过/api/quicktype 获取分类id
* @return
*/
@RequestMapping(method = RequestMethod.GET)
@Menu(type = "apps", subtype = "quickreply", access = true)
public ResponseEntity<RestResult> list(HttpServletRequest request, String id, @Valid String cate, @Valid String q, Integer p, Integer ps) {
if (StringUtils.isNotBlank(id)) {
return new ResponseEntity<>(new RestResult(RestResultType.OK, quickReplyRepository.findOne(id)), HttpStatus.OK);
}
Page<QuickReply> replyList = quickReplyRepository.getByOrgiAndCate(getOrgi(request), cate, q,
new PageRequest(p == null ? 1 : p, ps == null ? 20 : ps));
return new ResponseEntity<>(new RestResult(RestResultType.OK, replyList), HttpStatus.OK);
}
/**
* 新增或修改快捷回复
* @param request
* @param user
* @return
*/
@RequestMapping(method = RequestMethod.PUT)
@Menu(type = "apps", subtype = "quickreply", access = true)
public ResponseEntity<RestResult> put(HttpServletRequest request, @Valid QuickReply quickReply) {
if (quickReply != null && !StringUtils.isBlank(quickReply.getTitle())) {
quickReply.setOrgi(getOrgi(request));
quickReply.setCreater(getUser(request).getId());
quickReplyRepository.save(quickReply);
}
return new ResponseEntity<>(new RestResult(RestResultType.OK), HttpStatus.OK);
}
/**
* 删除用户只提供 按照用户ID删除
* @param request
* @param id
* @return
*/
@RequestMapping(method = RequestMethod.DELETE)
@Menu(type = "apps", subtype = "quickreply", access = true)
public ResponseEntity<RestResult> delete(HttpServletRequest request, @Valid String id) {
RestResult result = new RestResult(RestResultType.OK);
if (!StringUtils.isBlank(id)) {
QuickReply reply = quickReplyRepository.findOne(id);
if (reply != null) {
quickReplyRepository.delete(reply);
} else {
return new ResponseEntity<>(new RestResult(RestResultType.ORGAN_DELETE), HttpStatus.OK);
}
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
}

View File

@ -1,111 +0,0 @@
/*
* 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.api;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.QuickType;
import com.chatopera.cc.persistence.es.QuickReplyRepository;
import com.chatopera.cc.persistence.repository.QuickTypeRepository;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.RestResult;
import com.chatopera.cc.util.RestResultType;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
/**
* 快捷回复分类服务
* 快捷回复分类管理功能
*/
@RestController
@RequestMapping("/api/quicktype")
public class ApiQuickTypeController extends Handler {
@Autowired
private QuickTypeRepository quickTypeRepository;
@Autowired
private QuickReplyRepository quickReplyRepository;
/**
* 返回快捷回复分类列表
* @param request
* @param quicktype 搜索pub,pri
* @return
*/
@RequestMapping(method = RequestMethod.GET)
@Menu(type = "apps", subtype = "quicktype", access = true)
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String id, @Valid String quicktype) {
if (StringUtils.isNotBlank(id)) {
return new ResponseEntity<>(new RestResult(RestResultType.OK, quickTypeRepository.findOne(id)), HttpStatus.OK);
}
List<QuickType> quickTypeList = quickTypeRepository.findByOrgiAndQuicktype(getOrgi(request), quicktype);
return new ResponseEntity<>(new RestResult(RestResultType.OK, quickTypeList), HttpStatus.OK);
}
/**
* 新增或修改快捷回复分类
* @param request
* @param user
* @return
*/
@RequestMapping(method = RequestMethod.PUT)
@Menu(type = "apps", subtype = "quicktype", access = true)
public ResponseEntity<RestResult> put(HttpServletRequest request, @Valid QuickType quickType) {
if (quickType != null && !StringUtils.isBlank(quickType.getName())) {
quickType.setOrgi(getOrgi(request));
quickType.setCreater(getUser(request).getId());
quickType.setCreatetime(new Date());
if (StringUtils.isNotBlank(quickType.getId())) {
quickType.setUpdatetime(new Date());
}
quickType = quickTypeRepository.save(quickType);
}
return new ResponseEntity<>(new RestResult(RestResultType.OK, quickType), HttpStatus.OK);
}
/**
* 删除分类并且删除分类下的快捷回复
* @param request
* @param id
* @return
*/
@RequestMapping(method = RequestMethod.DELETE)
@Menu(type = "apps", subtype = "reply", access = true)
public ResponseEntity<RestResult> delete(HttpServletRequest request, @Valid String id) {
RestResult result = new RestResult(RestResultType.OK);
if (!StringUtils.isBlank(id)) {
QuickType quickType = quickTypeRepository.findOne(id);
if (quickType != null) {
quickReplyRepository.deleteByCate(quickType.getId(), quickType.getOrgi());
quickTypeRepository.delete(quickType);
} else {
return new ResponseEntity<>(new RestResult(RestResultType.ORGAN_DELETE), HttpStatus.OK);
}
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
}

View File

@ -32,7 +32,7 @@ import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.*;
import com.chatopera.cc.socketio.message.Message;
import com.chatopera.cc.util.Menu;
import freemarker.template.TemplateException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -121,6 +121,9 @@ public class AgentAuditController extends Handler {
@Autowired
private OrganProxy organProxy;
@Autowired
private ChatbotRepository chatbotRes;
@RequestMapping(value = "/index")
@Menu(type = "cca", subtype = "cca", access = true)
public ModelAndView index(
@ -136,7 +139,7 @@ public class AgentAuditController extends Handler {
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(super.getOrgan(request), super.getOrgi(request));
ModelAndView view = request(super.createAppsTempletResponse("/apps/cca/index"));
ModelAndView view = request(super.createView("/apps/cca/index"));
Sort defaultSort = null;
if (StringUtils.isNotBlank(sort)) {
@ -207,7 +210,7 @@ public class AgentAuditController extends Handler {
@RequestMapping("/query")
@Menu(type = "apps", subtype = "cca")
public ModelAndView query(HttpServletRequest request, String skill, String agentno) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/cca/chatusers"));
ModelAndView view = request(super.createView("/apps/cca/chatusers"));
final String orgi = super.getOrgi(request);
final User logined = super.getUser(request);
@ -240,7 +243,7 @@ public class AgentAuditController extends Handler {
@RequestMapping("/agentusers")
@Menu(type = "apps", subtype = "cca")
public ModelAndView agentusers(HttpServletRequest request, String userid) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/cca/agentusers"));
ModelAndView view = request(super.createView("/apps/cca/agentusers"));
User logined = super.getUser(request);
final String orgi = super.getOrgi(request);
Sort defaultSort = new Sort(Sort.Direction.DESC, "status");
@ -261,12 +264,12 @@ public class AgentAuditController extends Handler {
HttpServletRequest request,
String id,
String channel
) throws IOException, TemplateException {
) throws IOException {
String mainagentuser = "/apps/cca/mainagentuser";
if (channel.equals("phone")) {
mainagentuser = "/apps/cca/mainagentuser_callout";
}
ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuser));
ModelAndView view = request(super.createView(mainagentuser));
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
AgentUser agentUser = agentUserRepository.findByIdAndOrgi(id, orgi);
@ -274,10 +277,11 @@ public class AgentAuditController extends Handler {
if (agentUser != null) {
view.addObject("curagentuser", agentUser);
CousultInvite invite = OnlineUserProxy.consult(agentUser.getAppid(), agentUser.getOrgi());
if (invite != null) {
view.addObject("ccaAisuggest", invite.isAisuggest());
Chatbot c = chatbotRes.findBySnsAccountIdentifierAndOrgi(agentUser.getAppid(), agentUser.getOrgi());
if (c != null) {
view.addObject("ccaAisuggest", c.isAisuggest());
}
view.addObject("inviteData", OnlineUserProxy.consult(agentUser.getAppid(), agentUser.getOrgi()));
List<AgentUserTask> agentUserTaskList = agentUserTaskRes.findByIdAndOrgi(id, orgi);
if (agentUserTaskList.size() > 0) {
@ -420,7 +424,7 @@ public class AgentAuditController extends Handler {
map.addAttribute("currentorgan", currentOrgan);
}
return request(super.createRequestPageTempletResponse("/apps/cca/transfer"));
return request(super.createView("/apps/cca/transfer"));
}
@ -462,7 +466,7 @@ public class AgentAuditController extends Handler {
map.addAttribute("userList", userList);
map.addAttribute("currentorgan", organ);
}
return request(super.createRequestPageTempletResponse("/apps/cca/transferagentlist"));
return request(super.createView("/apps/cca/transferagentlist"));
}
/**
@ -575,7 +579,7 @@ public class AgentAuditController extends Handler {
agentServiceRes.save(agentService);
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/cca/index.html"));
return request(super.createView("redirect:/apps/cca/index.html"));
}
@ -612,7 +616,7 @@ public class AgentAuditController extends Handler {
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/cca/index.html"));
return request(super.createView("redirect:/apps/cca/index.html"));
}
@RequestMapping({"/blacklist/add"})
@ -623,7 +627,7 @@ public class AgentAuditController extends Handler {
map.addAttribute("agentserviceid", agentserviceid);
map.addAttribute("userid", userid);
map.addAttribute("agentUser", agentUserRes.findByIdAndOrgi(userid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/apps/cca/blacklistadd"));
return request(super.createView("/apps/cca/blacklistadd"));
}
@RequestMapping({"/blacklist/save"})

View File

@ -25,13 +25,13 @@
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.exception.CSKefuException;
import com.chatopera.cc.model.*;
import com.chatopera.cc.peer.PeerSyncIM;
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
import com.chatopera.cc.persistence.es.ChatMessageEsRepository;
import com.chatopera.cc.persistence.es.ContactsRepository;
import com.chatopera.cc.persistence.es.QuickReplyRepository;
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.*;
@ -40,7 +40,7 @@
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.PinYinTools;
import com.chatopera.cc.util.PropertiesEventUtil;
import freemarker.template.TemplateException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -50,6 +50,9 @@
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils;
@ -122,12 +125,6 @@
@Autowired
private TagRelationRepository tagRelationRes;
@Autowired
private QuickReplyRepository quickReplyRes;
@Autowired
private QuickTypeRepository quickTypeRes;
@Autowired
private AgentUserTaskRepository agentUserTaskRes;
@ -182,6 +179,9 @@
@Autowired
private OrganRepository organRes;
@Autowired
private ChatbotRepository chatbotRes;
/**
* 坐席从联系人列表进入坐席工作台和该联系人聊天
*
@ -203,11 +203,11 @@
HttpServletResponse response,
@Valid String sort,
@Valid String channels,
@RequestParam(name = "contactid", required = false) String contactid) throws IOException, TemplateException, CSKefuException {
@RequestParam(name = "contactid", required = false) String contactid) throws IOException, CSKefuException {
if (StringUtils.isBlank(contactid)) {
logger.info("[chat] empty contactid, fast return error page.");
return request(super.createRequestPageTempletResponse("/public/error"));
return request(super.createView("/public/error"));
}
logger.info(
@ -230,7 +230,7 @@
// TODO 在agentUser没有得到的情况下传回的前端信息增加提示提示放在modelview中
// 处理原聊天数据
ModelAndView view = request(super.createAppsTempletResponse("/apps/agent/index"));
ModelAndView view = request(super.createView("/apps/agent/index"));
agentUserProxy.buildIndexViewWithModels(view, map, request, response, sort, logined, orgi, agentUser);
return view;
}
@ -253,10 +253,10 @@
ModelMap map,
HttpServletRequest request,
HttpServletResponse response,
@Valid String sort) throws IOException, TemplateException {
@Valid String sort) throws IOException {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
ModelAndView view = request(super.createAppsTempletResponse("/apps/agent/index"));
ModelAndView view = request(super.createView("/apps/agent/index"));
agentUserProxy.buildIndexViewWithModels(view, map, request, response, sort, logined, orgi, null);
return view;
}
@ -264,7 +264,7 @@
@RequestMapping("/agentusers")
@Menu(type = "apps", subtype = "agent")
public ModelAndView agentusers(HttpServletRequest request, String userid) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/agentusers"));
ModelAndView view = request(super.createView("/apps/agent/agentusers"));
User logined = super.getUser(request);
view.addObject(
"agentUserList", agentUserRes.findByAgentnoAndOrgi(logined.getId(), logined.getOrgi(),
@ -283,9 +283,9 @@
HttpServletRequest request,
String id,
Integer page,
Integer current) throws IOException, TemplateException {
Integer current) throws IOException {
String mainagentuserconter = "/apps/agent/mainagentuserconter";
ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuserconter));
ModelAndView view = request(super.createView(mainagentuserconter));
AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, super.getOrgi(request));
if (agentUser != null) {
view.addObject("curagentuser", agentUser);
@ -300,9 +300,9 @@
public ModelAndView agentuserLabel(
ModelMap map,
HttpServletRequest request,
String iconid) throws IOException, TemplateException {
String iconid) throws IOException {
String mainagentuserconter = "/apps/agent/mainagentuserconter";
ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuserconter));
ModelAndView view = request(super.createView(mainagentuserconter));
ChatMessage labelid = this.chatMessageRes.findById(iconid);
if (labelid != null) {
if (labelid.isIslabel() == false) {
@ -323,9 +323,9 @@
String id,
String search,
String condition
) throws IOException, TemplateException {
) throws IOException {
String mainagentuserconter = "/apps/agent/mainagentusersearch";
ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuserconter));
ModelAndView view = request(super.createView(mainagentuserconter));
AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, super.getOrgi(request));
if (agentUser != null) {
@ -350,9 +350,9 @@
HttpServletRequest request,
String id,
String createtime,
String thisid) throws IOException, TemplateException, ParseException {
String thisid) throws IOException, ParseException {
String mainagentuserconter = "/apps/agent/mainagentuserconter";
ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuserconter));
ModelAndView view = request(super.createView(mainagentuserconter));
AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, super.getOrgi(request));
if (agentUser != null) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -373,10 +373,13 @@
ModelMap map,
HttpServletRequest request,
String id,
String channel) throws IOException, TemplateException {
String channel) throws IOException {
// set default Value as WEBIM
String mainagentuser = "/apps/agent/mainagentuser";
switch (MainContext.ChannelType.toValue(channel)) {
case MESSENGER:
mainagentuser = "/apps/agent/mainagentuser_messenger";
break;
case PHONE:
mainagentuser = "/apps/agent/mainagentuser_callout";
break;
@ -385,7 +388,7 @@
break;
}
ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuser));
ModelAndView view = request(super.createView(mainagentuser));
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, orgi);
@ -393,10 +396,11 @@
if (agentUser != null) {
view.addObject("curagentuser", agentUser);
CousultInvite invite = OnlineUserProxy.consult(agentUser.getAppid(), agentUser.getOrgi());
if (invite != null) {
view.addObject("aisuggest", invite.isAisuggest());
Chatbot c = chatbotRes.findBySnsAccountIdentifierAndOrgi(agentUser.getAppid(), agentUser.getOrgi());
if (c != null) {
view.addObject("aisuggest", c.isAisuggest());
}
view.addObject("inviteData", OnlineUserProxy.consult(agentUser.getAppid(), agentUser.getOrgi()));
List<AgentUserTask> agentUserTaskList = agentUserTaskRes.findByIdAndOrgi(id, orgi);
if (agentUserTaskList.size() > 0) {
@ -472,57 +476,13 @@
view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid()));
}
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
//
// view.addObject("sessionConfig", sessionConfig);
// if (sessionConfig.isOtherquickplay()) {
// view.addObject("topicList", OnlineUserProxy.search(null, orgi, super.getUser(request)));
// }
AgentService service = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), orgi);
if (service != null) {
view.addObject("tags", tagRes.findByOrgiAndTagtypeAndSkill(orgi, MainContext.ModelType.USER.toString(), service.getSkill()));
}
view.addObject(
"quickReplyList", quickReplyRes.findByOrgiAndCreater(orgi, super.getUser(request).getId(), null));
List<QuickType> quickTypeList = quickTypeRes.findByOrgiAndQuicktype(
orgi, MainContext.QuickType.PUB.toString());
List<QuickType> priQuickTypeList = quickTypeRes.findByOrgiAndQuicktypeAndCreater(
orgi, MainContext.QuickType.PRI.toString(), super.getUser(request).getId());
quickTypeList.addAll(priQuickTypeList);
view.addObject("pubQuickTypeList", quickTypeList);
return view;
}
// TODO: mdx-organ clean
// @RequestMapping("/other/topic")
// @Menu(type = "apps", subtype = "othertopic")
// public ModelAndView othertopic(ModelMap map, HttpServletRequest request, String q) throws IOException, TemplateException {
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
//
// map.put("sessionConfig", sessionConfig);
// if (sessionConfig.isOtherquickplay()) {
// map.put("topicList", OnlineUserProxy.search(q, super.getOrgi(request), super.getUser(request)));
// }
//
// return request(super.createRequestPageTempletResponse("/apps/agent/othertopic"));
// }
//
// @RequestMapping("/other/topic/detail")
// @Menu(type = "apps", subtype = "othertopicdetail")
// public ModelAndView othertopicdetail(ModelMap map, HttpServletRequest request, String id) throws IOException, TemplateException {
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
//
// map.put("sessionConfig", sessionConfig);
// if (sessionConfig.isOtherquickplay()) {
// map.put("topic", OnlineUserProxy.detail(id, super.getOrgi(request), super.getUser(request)));
// }
//
// return request(super.createRequestPageTempletResponse("/apps/agent/topicdetail"));
// }
@RequestMapping("/workorders/list")
@Menu(type = "apps", subtype = "workorderslist")
public ModelAndView workorderslist(HttpServletRequest request, String contactsid, ModelMap map) {
@ -537,7 +497,7 @@
}
map.addAttribute("contactsid", contactsid);
}
return request(super.createRequestPageTempletResponse("/apps/agent/workorders"));
return request(super.createView("/apps/agent/workorders"));
}
/**
@ -569,7 +529,7 @@
MainContext.AgentWorkType.MEIDIACHAT.toString(),
orgi, null);
return request(super.createRequestPageTempletResponse("/public/success"));
return request(super.createView("/public/success"));
}
/**
@ -607,7 +567,7 @@
MainContext.AgentWorkType.MEIDIACHAT.toString(),
orgi, null);
return request(super.createRequestPageTempletResponse("/public/success"));
return request(super.createView("/public/success"));
}
/**
@ -642,7 +602,7 @@
agentStatusProxy.broadcastAgentsStatus(super.getOrgi(request), "agent", "busy", logined.getId());
return request(super.createRequestPageTempletResponse("/public/success"));
return request(super.createView("/public/success"));
}
/**
@ -686,7 +646,7 @@
// 重新分配访客给坐席
acdAgentService.assignVisitors(agentStatus.getAgentno(), super.getOrgi(request));
return request(super.createRequestPageTempletResponse("/public/success"));
return request(super.createView("/public/success"));
}
@RequestMapping(value = "/clean")
@ -709,7 +669,7 @@
}
agentServiceRes.save(agentServiceList);
return request(super
.createRequestPageTempletResponse("redirect:/agent/index.html"));
.createView("redirect:/agent/index.html"));
}
@ -747,7 +707,7 @@
}
return request(super
.createRequestPageTempletResponse("redirect:/agent/index.html"));
.createView("redirect:/agent/index.html"));
}
@RequestMapping({"/readmsg"})
@ -759,7 +719,7 @@
agentUserTask.setTokenum(0);
agentUserTaskRes.save(agentUserTask);
}
return request(super.createRequestPageTempletResponse("/public/success"));
return request(super.createView("/public/success"));
}
@RequestMapping({"/blacklist/add"})
@ -770,7 +730,7 @@
map.addAttribute("agentserviceid", agentserviceid);
map.addAttribute("userid", userid);
map.addAttribute("agentUser", agentUserRes.findByIdAndOrgi(userid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/apps/agent/blacklistadd"));
return request(super.createView("/apps/agent/blacklistadd"));
}
@RequestMapping({"/blacklist/save"})
@ -823,7 +783,7 @@
} else {
tagRelationRes.delete(tagRelation);
}
return request(super.createRequestPageTempletResponse("/public/success"));
return request(super.createView("/public/success"));
}
/**
@ -839,7 +799,7 @@
*/
@RequestMapping("/image/upload")
@Menu(type = "im", subtype = "image", access = false)
public ModelAndView upload(
public ResponseEntity<String> upload(
ModelMap map,
HttpServletRequest request,
@RequestParam(value = "imgFile", required = false) MultipartFile multipart,
@ -848,8 +808,9 @@
logger.info("[upload] image file, agentUser id {}, paste {}", id, paste);
final User logined = super.getUser(request);
final String orgi = super.getOrgi(request);
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/upload"));
UploadStatus notify;
JSONObject result = new JSONObject();
HttpHeaders headers = RestUtils.header();
final AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, orgi);
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) {
@ -859,15 +820,17 @@
if (!paste) {
agentProxy.sendFileMessageByAgent(logined, agentUser, multipart, sf);
}
notify = new UploadStatus("0", sf.getFileUrl());
result.put("error", 0);
result.put("url", sf.getFileUrl());
} catch (CSKefuException e) {
notify = new UploadStatus("请选择文件");
result.put("error", 1);
result.put("message", "请选择文件");
}
} else {
notify = new UploadStatus("请选择图片文件");
result.put("error", 1);
result.put("message", "请选择图片文件");
}
map.addAttribute("upload", notify);
return view;
return new ResponseEntity<>(result.toString(), headers, HttpStatus.OK);
}
@RequestMapping("/message/image")
@ -880,7 +843,7 @@
map.addAttribute("t", t) ;
}*/
map.addAttribute("t", true);
return request(super.createRequestPageTempletResponse("/apps/agent/media/messageimage"));
return request(super.createView("/apps/agent/media/messageimage"));
}
@RequestMapping("/message/image/upload")
@ -945,7 +908,7 @@
}
}
}
return request(super.createRequestPageTempletResponse("/public/success"));
return request(super.createView("/public/success"));
}
@ -1031,7 +994,7 @@
agentUserContactsRes.save(agentUserContacts);
}
}
return request(super.createRequestPageTempletResponse("/apps/agent/contacts"));
return request(super.createView("/apps/agent/contacts"));
}
@ -1047,7 +1010,7 @@
}
}
return request(super.createRequestPageTempletResponse("/apps/agent/contacts"));
return request(super.createView("/apps/agent/contacts"));
}
@ResponseBody
@ -1103,7 +1066,7 @@
map.addAttribute("agentuserid", agentuserid);
map.addAttribute("channel", channel);
}
return request(super.createRequestPageTempletResponse("/apps/agent/summary"));
return request(super.createView("/apps/agent/summary"));
}
@RequestMapping(value = "/summary/save")
@ -1137,7 +1100,7 @@
serviceSummaryRes.save(summary);
}
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/agent/agentuser.html?id=" + agentuserid + "&channel=" + channel));
}
@ -1210,7 +1173,7 @@
map.addAttribute("currentorgan", currentOrgan);
}
return request(super.createRequestPageTempletResponse("/apps/agent/transfer"));
return request(super.createView("/apps/agent/transfer"));
}
/**
@ -1250,188 +1213,15 @@
map.addAttribute("userList", userList);
map.addAttribute("currentorgan", organ);
}
return request(super.createRequestPageTempletResponse("/apps/agent/transferagentlist"));
return request(super.createView("/apps/agent/transferagentlist"));
}
@RequestMapping("/quicklist")
@Menu(type = "setting", subtype = "quickreply", admin = true)
public ModelAndView quicklist(ModelMap map, HttpServletRequest request, @Valid String typeid) {
map.addAttribute(
"quickReplyList",
quickReplyRes.findByOrgiAndCreater(super.getOrgi(request), super.getUser(request).getId(), null));
List<QuickType> quickTypeList = quickTypeRes.findByOrgiAndQuicktype(
super.getOrgi(request), MainContext.QuickType.PUB.toString());
List<QuickType> priQuickTypeList = quickTypeRes.findByOrgiAndQuicktypeAndCreater(
super.getOrgi(request), MainContext.QuickType.PRI.toString(), super.getUser(request).getId());
quickTypeList.addAll(priQuickTypeList);
map.addAttribute("pubQuickTypeList", quickTypeList);
if (StringUtils.isNotBlank(typeid)) {
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/apps/agent/quicklist"));
}
@RequestMapping("/quickreply/add")
@Menu(type = "setting", subtype = "quickreplyadd", admin = true)
public ModelAndView quickreplyadd(ModelMap map, HttpServletRequest request, @Valid String parentid) {
if (StringUtils.isNotBlank(parentid)) {
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(parentid, super.getOrgi(request)));
}
map.addAttribute(
"quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(
super.getOrgi(request),
MainContext.QuickType.PRI.toString(),
super.getUser(request).getId()));
return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/add"));
}
@RequestMapping("/quickreply/save")
@Menu(type = "setting", subtype = "quickreply", admin = true)
public ModelAndView quickreplysave(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) {
if (StringUtils.isNotBlank(quickReply.getTitle()) && StringUtils.isNotBlank(quickReply.getContent())) {
quickReply.setOrgi(super.getOrgi(request));
quickReply.setCreater(super.getUser(request).getId());
quickReply.setType(MainContext.QuickType.PRI.toString());
quickReplyRes.save(quickReply);
}
return request(super.createRequestPageTempletResponse(
"redirect:/agent/quicklist.html?typeid=" + quickReply.getCate()));
}
@RequestMapping("/quickreply/delete")
@Menu(type = "setting", subtype = "quickreply", admin = true)
public ModelAndView quickreplydelete(ModelMap map, HttpServletRequest request, @Valid String id) {
QuickReply quickReply = quickReplyRes.findOne(id);
if (quickReply != null) {
quickReplyRes.delete(quickReply);
}
return request(super.createRequestPageTempletResponse(
"redirect:/agent/quicklist.html?typeid=" + quickReply.getCate()));
}
@RequestMapping("/quickreply/edit")
@Menu(type = "setting", subtype = "quickreply", admin = true)
public ModelAndView quickreplyedit(ModelMap map, HttpServletRequest request, @Valid String id) {
QuickReply quickReply = quickReplyRes.findOne(id);
map.put("quickReply", quickReply);
if (quickReply != null) {
map.put("quickType", quickTypeRes.findByIdAndOrgi(quickReply.getCate(), super.getOrgi(request)));
}
map.addAttribute(
"quickTypeList", quickTypeRes.findByOrgiAndQuicktype(
super.getOrgi(request),
MainContext.QuickType.PUB.toString()));
return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/edit"));
}
@RequestMapping("/quickreply/update")
@Menu(type = "setting", subtype = "quickreply", admin = true)
public ModelAndView quickreplyupdate(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) {
if (StringUtils.isNotBlank(quickReply.getId())) {
QuickReply temp = quickReplyRes.findOne(quickReply.getId());
quickReply.setOrgi(super.getOrgi(request));
quickReply.setCreater(super.getUser(request).getId());
if (temp != null) {
quickReply.setCreatetime(temp.getCreatetime());
}
quickReply.setType(MainContext.QuickType.PUB.toString());
quickReplyRes.save(quickReply);
}
return request(super.createRequestPageTempletResponse(
"redirect:/agent/quicklist.html?typeid=" + quickReply.getCate()));
}
@RequestMapping({"/quickreply/addtype"})
@Menu(type = "apps", subtype = "kbs")
public ModelAndView addtype(ModelMap map, HttpServletRequest request, @Valid String typeid) {
map.addAttribute(
"quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(
super.getOrgi(request),
MainContext.QuickType.PRI.toString(),
super.getUser(request).getId()));
if (StringUtils.isNotBlank(typeid)) {
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/addtype"));
}
@RequestMapping("/quickreply/type/save")
@Menu(type = "apps", subtype = "kbs")
public ModelAndView typesave(HttpServletRequest request, @Valid QuickType quickType) {
int count = quickTypeRes.countByOrgiAndNameAndParentid(
super.getOrgi(request), quickType.getName(), quickType.getParentid());
if (count == 0) {
quickType.setOrgi(super.getOrgi(request));
quickType.setCreater(super.getUser(request).getId());
quickType.setCreatetime(new Date());
quickType.setQuicktype(MainContext.QuickType.PRI.toString());
quickTypeRes.save(quickType);
}
return request(super.createRequestPageTempletResponse(
"redirect:/agent/quicklist.html?typeid=" + quickType.getParentid()));
}
@RequestMapping({"/quickreply/edittype"})
@Menu(type = "apps", subtype = "kbs")
public ModelAndView edittype(ModelMap map, HttpServletRequest request, String id) {
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.addAttribute(
"quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(
super.getOrgi(request),
MainContext.QuickType.PRI.toString(),
super.getUser(request).getId()));
return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/edittype"));
}
@RequestMapping("/quickreply/type/update")
@Menu(type = "apps", subtype = "kbs")
public ModelAndView typeupdate(HttpServletRequest request, @Valid QuickType quickType) {
QuickType tempQuickType = quickTypeRes.findByIdAndOrgi(quickType.getId(), super.getOrgi(request));
if (tempQuickType != null) {
tempQuickType.setName(quickType.getName());
tempQuickType.setDescription(quickType.getDescription());
tempQuickType.setInx(quickType.getInx());
tempQuickType.setParentid(quickType.getParentid());
quickTypeRes.save(tempQuickType);
}
return request(
super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid=" + quickType.getId()));
}
@RequestMapping({"/quickreply/deletetype"})
@Menu(type = "apps", subtype = "kbs")
public ModelAndView deletetype(ModelMap map, HttpServletRequest request, @Valid String id) {
QuickType tempQuickType = quickTypeRes.findByIdAndOrgi(id, super.getOrgi(request));
if (tempQuickType != null) {
quickTypeRes.delete(tempQuickType);
Page<QuickReply> quickReplyList = quickReplyRes.getByOrgiAndCate(
super.getOrgi(request), id, null, new PageRequest(0, 10000));
quickReplyRes.delete(quickReplyList.getContent());
}
return request(super.createRequestPageTempletResponse(
"redirect:/agent/quicklist.html" + (tempQuickType != null ? "?typeid=" + tempQuickType.getParentid() : "")));
}
@RequestMapping({"/quickreply/content"})
@Menu(type = "apps", subtype = "quickreply")
public ModelAndView quickreplycontent(ModelMap map, HttpServletRequest request, @Valid String id) {
QuickReply quickReply = quickReplyRes.findOne(id);
if (quickReply != null) {
map.addAttribute("quickReply", quickReply);
}
return request(super.createRequestPageTempletResponse("/apps/agent/quickreplycontent"));
}
@RequestMapping("/calloutcontact/add")
@Menu(type = "apps", subtype = "calloutcontact", admin = true)
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String ckind) {
map.addAttribute("ckind", ckind);
return request(super.createRequestPageTempletResponse("/apps/agent/calloutcontact/add"));
return request(super.createView("/apps/agent/calloutcontact/add"));
}
@RequestMapping(value = "/calloutcontact/save")
@ -1468,7 +1258,7 @@
auc.setAppid(au.getAppid());
auc.setCreater(logined.getId());
agentUserContactsRes.save(auc);
return request(super.createRequestPageTempletResponse("redirect:/agent/index.html"));
return request(super.createView("redirect:/agent/index.html"));
}
@RequestMapping("/calloutcontact/update")
@ -1503,6 +1293,6 @@
contactsRes.save(contacts);
}
return request(super.createRequestPageTempletResponse("redirect:/agent/index.html"));
return request(super.createView("redirect:/agent/index.html"));
}
}

View File

@ -1,134 +0,0 @@
/*
* 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.apps;
import com.chatopera.cc.acd.ACDPolicyService;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Quality;
import com.chatopera.cc.model.QualityRequest;
import com.chatopera.cc.model.SessionConfig;
import com.chatopera.cc.model.Tag;
import com.chatopera.cc.persistence.repository.QualityRepository;
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
import com.chatopera.cc.persistence.repository.TagRepository;
import com.chatopera.cc.util.Menu;
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.ArrayList;
import java.util.List;
@Controller
@RequestMapping("/apps/quality")
public class AgentQualityController extends Handler {
@Autowired
private ACDPolicyService acdPolicyService;
@Autowired
private QualityRepository qualityRes;
@Autowired
private SessionConfigRepository sessionConfigRes;
@Autowired
private TagRepository tagRes;
@Autowired
private Cache cache;
@RequestMapping(value = "/index")
@Menu(type = "agent", subtype = "quality", access = false)
public ModelAndView index(ModelMap map, HttpServletRequest 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"));
}
@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);
if (qualityArray != null && qualityArray.getTitle() != null) {
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
qualityRes.delete(qualityList);
List<Quality> tempList = new ArrayList<Quality>();
for (int i = 0; i < qualityArray.getTitle().length; i++) {
Quality temp = new Quality();
temp.setName(qualityArray.getTitle()[i]);
if (qualityArray.getDescription().length == qualityArray.getTitle().length) {
temp.setDescription(qualityArray.getDescription()[i]);
}
if (qualityArray.getScore().length == qualityArray.getTitle().length) {
temp.setScore(qualityArray.getScore()[i]);
}
temp.setOrgi(super.getOrgi(request));
temp.setQualitytype(MainContext.QualityType.CHAT.toString());
tempList.add(temp);
}
if (tempList.size() > 0) {
qualityRes.save(tempList);
}
// 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) {
tagRes.delete(tagList);
}
List<Tag> tagTempList = new ArrayList<Tag>();
for (String tag : qualityArray.getTag()) {
Tag temp = new Tag();
temp.setOrgi(super.getOrgi(request));
temp.setCreater(super.getUser(request).getId());
temp.setTag(tag);
temp.setCreater(super.getOrgi(request));
temp.setTagtype(MainContext.TagType.QUALITY.toString());
tagTempList.add(temp);
}
if (tagTempList.size() > 0) {
tagRes.save(tagTempList);
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/quality/index.html"));
}
}

View File

@ -18,7 +18,6 @@ package com.chatopera.cc.controller.apps;
import com.chatopera.cc.acd.ACDPolicyService;
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;
@ -27,6 +26,8 @@ import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
@ -49,6 +50,7 @@ import java.util.Map;
@Controller
@RequestMapping("/setting")
public class AgentSettingsController extends Handler {
private final static Logger logger = LoggerFactory.getLogger(AgentSettingsController.class);
@Autowired
private ACDPolicyService acdPolicyService;
@ -90,8 +92,8 @@ public class AgentSettingsController extends Handler {
if (sessionConfig == null) {
sessionConfig = new SessionConfig();
}
map.put("sessionConfig", sessionConfig);
map.put("sessionConfig", sessionConfig);
List<SysDic> dicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC);
SysDic inputDic = null, outputDic = null;
@ -110,7 +112,7 @@ public class AgentSettingsController extends Handler {
map.addAttribute("outputtemlet", templateRes.findByTemplettypeAndOrgi(outputDic.getId(), super.getOrgi(request)));
}
return request(super.createAppsTempletResponse("/apps/setting/agent/index"));
return request(super.createView("/apps/setting/agent/index"));
}
@RequestMapping("/agent/sessionconfig/save")
@ -119,7 +121,7 @@ public class AgentSettingsController extends Handler {
Organ currentOrgan = super.getOrgan(request);
String orgi = super.getOrgi(request);
SessionConfig tempSessionConfig = sessionConfigRes.findByOrgiAndSkill(orgi, currentOrgan.getId());
if (tempSessionConfig == null) {
tempSessionConfig = sessionConfig;
tempSessionConfig.setCreater(super.getUser(request).getId());
@ -141,7 +143,7 @@ public class AgentSettingsController extends Handler {
acdPolicyService.initSessionConfigList();
map.put("sessionConfig", tempSessionConfig);
return request(super.createRequestPageTempletResponse("redirect:/setting/agent/index.html"));
return request(super.createView("redirect:/setting/agent/index.html"));
}
@RequestMapping("/blacklist")
@ -152,9 +154,10 @@ public class AgentSettingsController extends Handler {
Page<BlackEntity> blackList = blackListRes.findByOrgiAndSkillIn(super.getOrgi(request), organs.keySet(), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime"));
map.put("blackList", blackList);
map.put("tagTypeList", Dict.getInstance().getDic("com.dic.tag.type"));
return request(super.createAppsTempletResponse("/apps/setting/agent/blacklist"));
return request(super.createView("/apps/setting/agent/blacklist"));
}
@RequestMapping("/blacklist/delete")
@ -167,7 +170,7 @@ public class AgentSettingsController extends Handler {
cache.deleteSystembyIdAndOrgi(tempBlackEntity.getUserid(), Constants.SYSTEM_ORGI);
}
}
return request(super.createRequestPageTempletResponse("redirect:/setting/blacklist.html"));
return request(super.createView("redirect:/setting/blacklist.html"));
}
@RequestMapping("/tag")
@ -194,14 +197,14 @@ public class AgentSettingsController extends Handler {
map.put("tagList", tagRes.findByOrgiAndTagtypeAndSkill(super.getOrgi(request), tagType.getCode(), currentOrgan.getId(), new PageRequest(super.getP(request), super.getPs(request))));
}
map.put("tagTypeList", tagList);
return request(super.createAppsTempletResponse("/apps/setting/agent/tag"));
return request(super.createView("/apps/setting/agent/tag"));
}
@RequestMapping("/tag/add")
@Menu(type = "setting", subtype = "tag", admin = false)
public ModelAndView tagadd(ModelMap map, HttpServletRequest request, @Valid String tagtype) {
map.addAttribute("tagtype", tagtype);
return request(super.createRequestPageTempletResponse("/apps/setting/agent/tagadd"));
return request(super.createView("/apps/setting/agent/tagadd"));
}
@RequestMapping("/tag/edit")
@ -209,7 +212,7 @@ public class AgentSettingsController extends Handler {
public ModelAndView tagedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) {
map.put("tag", tagRes.findOne(id));
map.addAttribute("tagtype", tagtype);
return request(super.createRequestPageTempletResponse("/apps/setting/agent/tagedit"));
return request(super.createView("/apps/setting/agent/tagedit"));
}
@RequestMapping("/tag/update")
@ -228,7 +231,7 @@ public class AgentSettingsController extends Handler {
tag.setSkill(currentOrgan.getId());
tagRes.save(tag);
}
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
return request(super.createView("redirect:/setting/tag.html?code=" + tagtype));
}
@RequestMapping("/tag/save")
@ -242,14 +245,14 @@ public class AgentSettingsController extends Handler {
tag.setSkill(currentOrgan.getId());
tagRes.save(tag);
}
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
return request(super.createView("redirect:/setting/tag.html?code=" + tagtype));
}
@RequestMapping("/tag/delete")
@Menu(type = "setting", subtype = "tag", admin = false)
public ModelAndView tagdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) {
tagRes.delete(id);
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
return request(super.createView("redirect:/setting/tag.html?code=" + tagtype));
}
@ -257,7 +260,7 @@ public class AgentSettingsController extends Handler {
@Menu(type = "setting", subtype = "acd", admin = false)
public ModelAndView acd(ModelMap map, HttpServletRequest request) {
map.put("tagTypeList", Dict.getInstance().getDic("com.dic.tag.type"));
return request(super.createAppsTempletResponse("/apps/setting/agent/acd"));
return request(super.createView("/apps/setting/agent/acd"));
}
@ -288,14 +291,14 @@ public class AgentSettingsController extends Handler {
map.put("advTypeList", Dict.getInstance().getDic("com.dic.adv.type"));
return request(super.createAppsTempletResponse("/apps/setting/agent/adv"));
return request(super.createView("/apps/setting/agent/adv"));
}
@RequestMapping("/adv/add")
@Menu(type = "setting", subtype = "adv", admin = false)
public ModelAndView advadd(ModelMap map, HttpServletRequest request, @Valid String adpos) {
map.addAttribute("adpos", adpos);
return request(super.createRequestPageTempletResponse("/apps/setting/agent/adadd"));
return request(super.createView("/apps/setting/agent/adadd"));
}
@RequestMapping("/adv/save")
@ -319,7 +322,7 @@ public class AgentSettingsController extends Handler {
MainUtils.initAdv(super.getOrgi(request), adv.getSkill());
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adv.getAdpos()));
return request(super.createView("redirect:/setting/adv.html?adpos=" + adv.getAdpos()));
}
@RequestMapping("/adv/edit")
@ -327,7 +330,7 @@ public class AgentSettingsController extends Handler {
public ModelAndView advedit(ModelMap map, HttpServletRequest request, @Valid String adpos, @Valid String id) {
map.addAttribute("adpos", adpos);
map.put("ad", adTypeRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/apps/setting/agent/adedit"));
return request(super.createView("/apps/setting/agent/adedit"));
}
@RequestMapping("/adv/update")
@ -356,7 +359,7 @@ public class AgentSettingsController extends Handler {
adTypeRes.save(ad);
MainUtils.initAdv(orgi, tempad.getSkill());
}
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos));
return request(super.createView("redirect:/setting/adv.html?adpos=" + adpos));
}
@RequestMapping("/adv/delete")
@ -368,6 +371,6 @@ public class AgentSettingsController extends Handler {
adTypeRes.delete(id);
MainUtils.initAdv(orgi, adType.getSkill());
}
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos));
return request(super.createView("redirect:/setting/adv.html?adpos=" + adpos));
}
}

View File

@ -143,12 +143,13 @@ public class AppsController extends Handler {
map.put("onlineUserList", onlineUserList);
map.put("msg", msg);
map.put("now", new Date());
aggValues(map, request);
// 获取agentStatus
map.put("agentStatus", cache.findOneAgentStatusByAgentnoAndOrig(user.getId(), orgi));
return request(super.createAppsTempletResponse("/apps/desktop/index"));
return request(super.createView("/apps/desktop/index"));
}
private void aggValues(ModelMap map, HttpServletRequest request) {
@ -242,7 +243,7 @@ public class AppsController extends Handler {
map.put("onlineUserList", onlineUserList);
aggValues(map, request);
return request(super.createAppsTempletResponse("/apps/desktop/onlineuser"));
return request(super.createView("/apps/desktop/onlineuser"));
}
@RequestMapping({"/apps/profile"})
@ -250,7 +251,7 @@ public class AppsController extends Handler {
public ModelAndView profile(ModelMap map, HttpServletRequest request, @Valid String index) {
map.addAttribute("userData", super.getUser(request));
map.addAttribute("index", index);
return request(super.createRequestPageTempletResponse("/apps/desktop/profile"));
return request(super.createView("/apps/desktop/profile"));
}
@RequestMapping({"/apps/profile/save"})
@ -266,9 +267,9 @@ public class AppsController extends Handler {
if (StringUtils.isNotBlank(msg) && (!StringUtils.equals(msg, "edit_user_success"))) {
// 处理异常返回
if (StringUtils.isBlank(index)) {
return request(super.createRequestPageTempletResponse("redirect:/apps/content.html?msg=" + msg));
return request(super.createView("redirect:/apps/content.html?msg=" + msg));
}
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index.html?msg=" + msg));
return request(super.createView("redirect:/apps/tenant/index.html?msg=" + msg));
}
// 执行更新
@ -306,17 +307,17 @@ public class AppsController extends Handler {
if (!(agentStatus == null && cache.getInservAgentUsersSizeByAgentnoAndOrgi(
super.getUser(request).getId(), super.getOrgi(request)) == 0)) {
if (StringUtils.isBlank(index)) {
return request(super.createRequestPageTempletResponse("redirect:/apps/content.html?msg=t1"));
return request(super.createView("redirect:/apps/content.html?msg=t1"));
}
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index.html?msg=t1"));
return request(super.createView("redirect:/apps/tenant/index.html?msg=t1"));
}
}
}
if (StringUtils.isBlank(index)) {
return request(super.createRequestPageTempletResponse("redirect:/apps/content.html"));
return request(super.createView("redirect:/apps/content.html"));
}
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index.html"));
return request(super.createView("redirect:/apps/tenant/index.html"));
}
/**

View File

@ -110,7 +110,7 @@ public class ContactsController extends Handler {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
return request(super.createViewIncludedByFreemarkerTpl("/apps/contacts/index"));
}
if (StringUtils.isNotBlank(q)) {
@ -143,7 +143,7 @@ public class ContactsController extends Handler {
contactsProxy.bindContactsApproachableData(contacts, map, logined);
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
return request(super.createView("/apps/contacts/index"));
}
@RequestMapping("/today")
@ -158,7 +158,7 @@ public class ContactsController extends Handler {
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
return request(super.createView("/apps/contacts/index"));
}
if (StringUtils.isNotBlank(q)) {
@ -183,7 +183,7 @@ public class ContactsController extends Handler {
contactsProxy.bindContactsApproachableData(contacts, map, logined);
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
return request(super.createView("/apps/contacts/index"));
}
@RequestMapping("/week")
@ -198,7 +198,7 @@ public class ContactsController extends Handler {
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
return request(super.createView("/apps/contacts/index"));
}
if (StringUtils.isNotBlank(q)) {
@ -222,7 +222,7 @@ public class ContactsController extends Handler {
contactsProxy.bindContactsApproachableData(contacts, map, logined);
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
return request(super.createView("/apps/contacts/index"));
}
@RequestMapping("/creater")
@ -237,7 +237,7 @@ public class ContactsController extends Handler {
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
return request(super.createView("/apps/contacts/index"));
}
boolQueryBuilder.must(termQuery("creater", logined.getId()));
@ -262,7 +262,7 @@ public class ContactsController extends Handler {
map.addAttribute(
"contactsList", contacts);
contactsProxy.bindContactsApproachableData(contacts, map, logined);
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
return request(super.createView("/apps/contacts/index"));
}
@RequestMapping("/delete")
@ -273,7 +273,7 @@ public class ContactsController extends Handler {
contacts.setDatastatus(true); //客户和联系人都是 逻辑删除
contactsRes.save(contacts);
}
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/apps/contacts/index.html?p=" + p + "&ckind=" + ckind));
}
@ -281,7 +281,7 @@ public class ContactsController extends Handler {
@Menu(type = "contacts", subtype = "add")
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String ckind) {
map.addAttribute("ckind", ckind);
return request(super.createRequestPageTempletResponse("/apps/business/contacts/add"));
return request(super.createView("/apps/contacts/add"));
}
@ -317,11 +317,11 @@ public class ContactsController extends Handler {
contactsRes.save(contacts);
msg = "new_contacts_success";
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/apps/contacts/index.html?ckind=" + contacts.getCkind() + "&msg=" + msg));
}
msg = "new_contacts_fail";
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/apps/contacts/index.html?ckind=" + contacts.getCkind() + "&msg=" + msg));
}
@ -330,7 +330,7 @@ public class ContactsController extends Handler {
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String ckind) {
map.addAttribute("contacts", contactsRes.findOne(id));
map.addAttribute("ckindId", ckind);
return request(super.createRequestPageTempletResponse("/apps/business/contacts/edit"));
return request(super.createView("/apps/contacts/edit"));
}
@RequestMapping("/detail")
@ -340,7 +340,8 @@ public class ContactsController extends Handler {
return null; // id is required. Block strange requst anyway with g2.min, https://github.com/alibaba/BizCharts/issues/143
}
map.addAttribute("contacts", contactsRes.findOne(id));
return request(super.createAppsTempletResponse("/apps/business/contacts/detail"));
return request(super.createView("/apps/contacts/detail"));
}
@ -403,13 +404,13 @@ public class ContactsController extends Handler {
msg = "edit_contacts_success";
} else {
//无修改直接点击确定
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/apps/contacts/index.html?ckind=" + ckindId));
}
} else {
logger.info("[contacts edit] errer :The same skypeid exists");
msg = "edit_contacts_fail";
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/apps/contacts/index.html?ckind=" + ckindId + "&msg=" + msg));
}
@ -443,7 +444,7 @@ public class ContactsController extends Handler {
if (msg.equals("edit_contacts_success")) {
contactsRes.save(contacts);
}
return request(super.createRequestPageTempletResponse(
return request(super.createView(
"redirect:/apps/contacts/index.html?ckind=" + ckindId + "&msg=" + msg));
}
@ -452,7 +453,7 @@ public class ContactsController extends Handler {
@Menu(type = "contacts", subtype = "contacts")
public ModelAndView imp(ModelMap map, HttpServletRequest request, @Valid String ckind) {
map.addAttribute("ckind", ckind);
return request(super.createRequestPageTempletResponse("/apps/business/contacts/imp"));
return request(super.createView("/apps/contacts/imp"));
}
@RequestMapping("/impsave")
@ -483,16 +484,7 @@ public class ContactsController extends Handler {
reporterRes.save(event.getDSData().getReport());
new ExcelImportProecess(event).process(); //启动导入任务
}
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/index.html"));
}
@RequestMapping("/startmass")
@Menu(type = "contacts", subtype = "contacts")
public ModelAndView mass(ModelMap map, HttpServletRequest request, @Valid String ids) {
map.addAttribute("organList", organRes.findByOrgiAndSkill(super.getOrgi(request), true));
map.addAttribute("ids", ids);
return request(super.createRequestPageTempletResponse("/apps/business/contacts/mass"));
return request(super.createView("redirect:/apps/contacts/index.html"));
}
@RequestMapping("/expids")
@ -607,7 +599,7 @@ public class ContactsController extends Handler {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
map.put("msg", msg);
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/contacts/embed/index"));
return request(super.createViewIncludedByFreemarkerTpl("/apps/contacts/embed/index"));
}
if (StringUtils.isNotBlank(q)) {
map.put("q", q);
@ -636,7 +628,7 @@ public class ContactsController extends Handler {
});
}
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/index"));
return request(super.createView("/apps/contacts/embed/index"));
}
@RequestMapping("/embed/add")
@ -645,7 +637,7 @@ public class ContactsController extends Handler {
if (StringUtils.isNotBlank(agentserviceid)) {
map.put("agentserviceid", agentserviceid);
}
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/add"));
return request(super.createView("/apps/contacts/embed/add"));
}
@RequestMapping("/embed/save")
@ -675,10 +667,10 @@ public class ContactsController extends Handler {
contactsRes.save(contacts);
msg = "new_contacts_success";
return request(
super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
super.createView("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
}
msg = "new_contacts_fail";
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
return request(super.createView("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
}
@RequestMapping("/embed/edit")
@ -688,7 +680,7 @@ public class ContactsController extends Handler {
if (StringUtils.isNotBlank(agentserviceid)) {
map.addAttribute("agentserviceid", agentserviceid);
}
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/edit"));
return request(super.createView("/apps/contacts/embed/edit"));
}
@RequestMapping("/embed/update")
@ -714,13 +706,13 @@ public class ContactsController extends Handler {
msg = "edit_contacts_success";
} else {
//无修改直接点击确定
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?agentserviceid=" + agentserviceid));
return request(super.createView("redirect:/apps/contacts/embed/index.html?agentserviceid=" + agentserviceid));
}
} else {
logger.info("[contacts edit] errer :The same skypeid exists");
msg = "edit_contacts_fail";
return request(
super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
super.createView("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
}
List<PropertiesEvent> events = PropertiesEventUtil.processPropertiesModify(
@ -753,6 +745,6 @@ public class ContactsController extends Handler {
if (msg.equals("edit_contacts_success")) {
contactsRes.save(contacts);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
return request(super.createView("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
}
}

View File

@ -106,7 +106,7 @@ public class CustomerController extends Handler {
map.put("msg", msg);
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
if (StringUtils.isNotBlank(q)) {
@ -129,7 +129,7 @@ public class CustomerController extends Handler {
q,
new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
@RequestMapping("/today")
@ -142,7 +142,7 @@ public class CustomerController extends Handler {
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
if (StringUtils.isNotBlank(q)) {
@ -155,7 +155,7 @@ public class CustomerController extends Handler {
}
map.addAttribute("entCustomerList", entCustomerRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), MainUtils.getStartTime(), null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
@RequestMapping("/week")
@ -168,7 +168,7 @@ public class CustomerController extends Handler {
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
if (StringUtils.isNotBlank(q)) {
@ -180,7 +180,7 @@ public class CustomerController extends Handler {
}
map.addAttribute("entCustomerList", entCustomerRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), MainUtils.getWeekStartTime(), null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
@RequestMapping("/enterprise")
@ -193,7 +193,7 @@ public class CustomerController extends Handler {
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
boolQueryBuilder.must(termQuery("etype", MainContext.CustomerTypeEnum.ENTERPRISE.toString()));
@ -205,7 +205,7 @@ public class CustomerController extends Handler {
map.put("q", q);
}
map.addAttribute("entCustomerList", entCustomerRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
@RequestMapping("/personal")
@ -218,7 +218,7 @@ public class CustomerController extends Handler {
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
boolQueryBuilder.must(termQuery("etype", MainContext.CustomerTypeEnum.PERSONAL.toString()));
@ -232,7 +232,7 @@ public class CustomerController extends Handler {
map.put("q", q);
}
map.addAttribute("entCustomerList", entCustomerRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
@RequestMapping("/creater")
@ -245,7 +245,7 @@ public class CustomerController extends Handler {
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
boolQueryBuilder.must(termQuery("creater", super.getUser(request).getId()));
@ -259,14 +259,14 @@ public class CustomerController extends Handler {
}
map.addAttribute("entCustomerList", entCustomerRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, q, new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
return request(super.createView("/apps/customer/index"));
}
@RequestMapping("/add")
@Menu(type = "customer", subtype = "customer")
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String ekind) {
map.addAttribute("ekind", ekind);
return request(super.createRequestPageTempletResponse("/apps/business/customer/add"));
return request(super.createView("/apps/customer/add"));
}
@RequestMapping("/save")
@ -300,7 +300,7 @@ public class CustomerController extends Handler {
contactsRes.save(customerGroupForm.getContacts());
}
return request(super.createRequestPageTempletResponse("redirect:/apps/customer/index.html?ekind=" + customerGroupForm.getEntcustomer().getEkind() + "&msg=" + msg));
return request(super.createView("redirect:/apps/customer/index.html?ekind=" + customerGroupForm.getEntcustomer().getEkind() + "&msg=" + msg));
}
@RequestMapping("/delete")
@ -311,7 +311,7 @@ public class CustomerController extends Handler {
entCustomer.setDatastatus(true); //客户和联系人都是 逻辑删除
entCustomerRes.save(entCustomer);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/customer/index.html?p=" + p + "&ekind=" + ekind));
return request(super.createView("redirect:/apps/customer/index.html?p=" + p + "&ekind=" + ekind));
}
@RequestMapping("/edit")
@ -319,7 +319,7 @@ public class CustomerController extends Handler {
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String ekind) {
map.addAttribute("entCustomer", entCustomerRes.findOne(id));
map.addAttribute("ekindId", ekind);
return request(super.createRequestPageTempletResponse("/apps/business/customer/edit"));
return request(super.createView("/apps/customer/edit"));
}
@RequestMapping("/update")
@ -350,14 +350,14 @@ public class CustomerController extends Handler {
customerGroupForm.getEntcustomer().setPinyin(PinYinTools.getInstance().getFirstPinYin(customerGroupForm.getEntcustomer().getName()));
entCustomerRes.save(customerGroupForm.getEntcustomer());
return request(super.createRequestPageTempletResponse("redirect:/apps/customer/index.html?ekind=" + ekindId + "&msg=" + msg));
return request(super.createView("redirect:/apps/customer/index.html?ekind=" + ekindId + "&msg=" + msg));
}
@RequestMapping("/imp")
@Menu(type = "customer", subtype = "customer")
public ModelAndView imp(ModelMap map, HttpServletRequest request, @Valid String ekind) {
map.addAttribute("ekind", ekind);
return request(super.createRequestPageTempletResponse("/apps/business/customer/imp"));
return request(super.createView("/apps/customer/imp"));
}
@RequestMapping("/impsave")
@ -390,7 +390,7 @@ public class CustomerController extends Handler {
new ExcelImportProecess(event).process(); //启动导入任务
}
return request(super.createRequestPageTempletResponse("redirect:/apps/customer/index.html"));
return request(super.createView("redirect:/apps/customer/index.html"));
}
@RequestMapping("/expids")

View File

@ -17,10 +17,12 @@
package com.chatopera.cc.controller.apps;
import com.alibaba.fastjson.JSONObject;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.controller.api.request.RestUtils;
import com.chatopera.cc.model.*;
import com.chatopera.cc.peer.PeerSyncEntIM;
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
@ -37,6 +39,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils;
@ -120,7 +125,7 @@ public class EntIMController extends Handler {
@RequestMapping("/index")
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/index"));
ModelAndView view = request(super.createView("/apps/entim/index"));
User logined = super.getUser(request);
@ -145,7 +150,7 @@ public class EntIMController extends Handler {
@RequestMapping("/skin")
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView skin(HttpServletRequest request, HttpServletResponse response) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/skin"));
ModelAndView view = request(super.createView("/apps/entim/skin"));
return view;
}
@ -153,7 +158,7 @@ public class EntIMController extends Handler {
@RequestMapping("/point")
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView point(HttpServletRequest request, HttpServletResponse response) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/point"));
ModelAndView view = request(super.createView("/apps/entim/point"));
view.addObject(
"recentUserList",
recentUserRes.findByCreaterAndOrgi(super.getUser(request).getId(), super.getOrgi(request))
@ -164,14 +169,14 @@ public class EntIMController extends Handler {
@RequestMapping("/expand")
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView expand(HttpServletRequest request, HttpServletResponse response) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/expand"));
ModelAndView view = request(super.createView("/apps/entim/expand"));
return view;
}
@RequestMapping("/chat")
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView chat(HttpServletRequest request, HttpServletResponse response, @Valid String userid) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/chat"));
ModelAndView view = request(super.createView("/apps/entim/chat"));
User entImUser = userRes.findById(userid);
if (entImUser != null) {
@ -226,7 +231,7 @@ public class EntIMController extends Handler {
HttpServletRequest request, HttpServletResponse response, @Valid String userid,
@Valid Date createtime
) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/more"));
ModelAndView view = request(super.createView("/apps/entim/more"));
Page<ChatMessage> chatMessageList = chatMessageRes.findByContextidAndUseridAndOrgiAndCreatetimeLessThan(userid,
super.getUser(request).getId(), super.getOrgi(request), createtime,
@ -240,7 +245,7 @@ public class EntIMController extends Handler {
@RequestMapping("/group")
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView groupMore(HttpServletRequest request, HttpServletResponse response, @Valid String id) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/group/index"));
ModelAndView view = request(super.createView("/apps/entim/group/index"));
IMGroup imGroup = imGroupRes.findById(id);
view.addObject("imGroup", imGroup);
view.addObject("imGroupUserList", imGroupUserRes.findByImgroupAndOrgi(imGroup, super.getOrgi(request)));
@ -257,7 +262,7 @@ public class EntIMController extends Handler {
HttpServletRequest request, HttpServletResponse response, @Valid String id,
@Valid Date createtime
) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/group/more"));
ModelAndView view = request(super.createView("/apps/entim/group/more"));
view.addObject("chatMessageList", chatMessageRes.findByContextidAndOrgiAndCreatetimeLessThan(id,
super.getOrgi(request), createtime, new PageRequest(0, 20, Sort.Direction.DESC, "createtime")
));
@ -267,7 +272,7 @@ public class EntIMController extends Handler {
@RequestMapping("/group/user")
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView user(HttpServletRequest request, HttpServletResponse response, @Valid String id) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/group/user"));
ModelAndView view = request(super.createView("/apps/entim/group/user"));
User logined = super.getUser(request);
HashSet<String> affiliates = logined.getAffiliates();
@ -328,7 +333,7 @@ public class EntIMController extends Handler {
HttpServletRequest request, HttpServletResponse response, @Valid String id,
@Valid String tipmsg
) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/group/tipmsg"));
ModelAndView view = request(super.createView("/apps/entim/group/tipmsg"));
IMGroup imGroup = imGroupRes.findById(id);
if (imGroup != null) {
imGroup.setTipmessage(tipmsg);
@ -341,7 +346,7 @@ public class EntIMController extends Handler {
@RequestMapping("/group/save")
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView groupsave(HttpServletRequest request, HttpServletResponse response, @Valid IMGroup group) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/group/grouplist"));
ModelAndView view = request(super.createView("/apps/entim/group/grouplist"));
if (!StringUtils.isBlank(group.getName())
&& imGroupRes.countByNameAndOrgi(group.getName(), super.getOrgi(request)) == 0) {
group.setOrgi(super.getUser(request).getOrgi());
@ -387,16 +392,17 @@ public class EntIMController extends Handler {
@RequestMapping("/image/upload")
@Menu(type = "im", subtype = "image", access = true)
public ModelAndView upload(
public ResponseEntity<String> upload(
ModelMap map, HttpServletRequest request,
@RequestParam(value = "imgFile", required = false) MultipartFile multipart, @Valid String group,
@Valid String userid, @Valid String username, @Valid String orgi, @Valid String paste
) throws IOException {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload"));
ModelAndView view = request(super.createView("/apps/im/upload"));
final User logined = super.getUser(request);
UploadStatus upload = null;
String fileName = null;
JSONObject result = new JSONObject();
HttpHeaders headers = RestUtils.header();
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0
&& StringUtils.isNotBlank(userid)) {
@ -425,7 +431,8 @@ public class EntIMController extends Handler {
sf.setThumbnail(jpaBlobHelper.createBlobWithFile(thumbnail));
streamingFileRepository.save(sf);
String fileUrl = "/res/image.html?id=" + fileid;
upload = new UploadStatus("0", fileUrl);
result.put("error", 0);
result.put("url", fileUrl);
if (paste == null) {
ChatMessage fileMessage = createFileMessage(fileUrl, (int) multipart.getSize(), multipart.getName(), MainContext.MediaType.IMAGE.toString(), userid, fileid, super.getOrgi(request));
@ -433,7 +440,8 @@ public class EntIMController extends Handler {
peerSyncEntIM.send(logined.getId(), group, orgi, MainContext.MessageType.MESSAGE, fileMessage);
}
} else {
upload = new UploadStatus(invalid);
result.put("error", 1);
result.put("message", invalid);
}
} else {
String invalid = StreamingFileUtil.getInstance().validate(Constants.ATTACHMENT_TYPE_FILE, multipart.getOriginalFilename());
@ -444,22 +452,25 @@ public class EntIMController extends Handler {
String id = attachmentProxy.processAttachmentFile(multipart,
fileid, logined.getOrgi(), logined.getId()
);
upload = new UploadStatus("0", "/res/file.html?id=" + id);
result.put("error", 0);
result.put("url", "/res/file.html?id=" + id);
String file = "/res/file.html?id=" + id;
ChatMessage fileMessage = createFileMessage(file, (int) multipart.getSize(), multipart.getOriginalFilename(), MainContext.MediaType.FILE.toString(), userid, fileid, super.getOrgi(request));
fileMessage.setUsername(logined.getUname());
peerSyncEntIM.send(logined.getId(), group, orgi, MainContext.MessageType.MESSAGE, fileMessage);
} else {
upload = new UploadStatus(invalid);
result.put("error", 1);
result.put("message", invalid);
}
}
} else {
upload = new UploadStatus("请选择文件");
result.put("error", 1);
result.put("message", "请选择文件");
}
map.addAttribute("upload", upload);
return view;
return new ResponseEntity<>(result.toString(), headers, HttpStatus.OK);
}
}

View File

@ -17,6 +17,7 @@
package com.chatopera.cc.controller.apps;
import com.alibaba.fastjson.JSONObject;
import com.chatopera.cc.acd.ACDPolicyService;
import com.chatopera.cc.acd.ACDWorkMonitor;
import com.chatopera.cc.basic.Constants;
@ -24,6 +25,7 @@ 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.*;
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
import com.chatopera.cc.persistence.es.ContactsRepository;
@ -31,7 +33,7 @@ import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.socketio.util.RichMediaUtils;
import com.chatopera.cc.util.*;
import freemarker.template.TemplateException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@ -41,6 +43,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -152,6 +157,42 @@ public class IMController extends Handler {
private void init() {
}
@RequestMapping("/{id}")
@Menu(type = "im", subtype = "point", access = true)
public ModelAndView loader(
HttpServletRequest request, HttpServletResponse response,
@PathVariable String id,
@Valid String userid,
@Valid String title,
@Valid String aiid) {
ModelAndView view = request(super.createView("/apps/im/loader"));
view.addObject("hostname", request.getServerName());
SystemConfig systemConfig = MainUtils.getSystemConfig();
if (systemConfig != null && systemConfig.isEnablessl()) {
view.addObject("schema", "https");
if (request.getServerPort() == 80) {
view.addObject("port", 443);
} else {
view.addObject("port", request.getServerPort());
}
} else {
view.addObject("schema", request.getScheme());
String header = request.getHeader("X-Forwarded-Proto");
if (header != null) {
view.addObject("schema", header);
}
view.addObject("port", request.getServerPort());
}
view.addObject("appid", id);
view.addObject("userid", userid);
view.addObject("title", title);
view.addObject("aiid", aiid);
return view;
}
/**
* 在客户或第三方网页内写入聊天控件
*
@ -163,7 +204,7 @@ public class IMController extends Handler {
* @param aiid
* @return
*/
@RequestMapping("/{id}")
@RequestMapping("/point/{id}")
@Menu(type = "im", subtype = "point", access = true)
public ModelAndView point(
HttpServletRequest request, HttpServletResponse response,
@ -171,7 +212,7 @@ public class IMController extends Handler {
@Valid String userid,
@Valid String title,
@Valid String aiid) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/point"));
ModelAndView view = request(super.createView("/apps/im/point"));
view.addObject("channelVisitorSeparate", channelWebIMVisitorSeparate);
final String sessionid = MainUtils.getContextID(request.getSession().getId());
@ -352,8 +393,8 @@ public class IMController extends Handler {
String sid,
String system_name,
Boolean whitelist_mode,
@RequestParam String sessionid) throws IOException, TemplateException {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/point"));
@RequestParam String sessionid) throws IOException {
ModelAndView view = request(super.createView("/apps/im/point"));
final User logined = super.getUser(request);
request.getSession().setAttribute("Sessionuid", uid);
@ -575,6 +616,8 @@ public class IMController extends Handler {
traceid, isInvite, exchange);
Map<String, String> sessionMessageObj = cache.findOneSystemMapByIdAndOrgi(sessionid, orgi);
map.put("pugHelper", new PugHelper());
if (sessionMessageObj != null) {
request.getSession().setAttribute("Sessionusername", sessionMessageObj.get("username"));
request.getSession().setAttribute("Sessioncid", sessionMessageObj.get("cid"));
@ -585,7 +628,7 @@ public class IMController extends Handler {
request.getSession().setAttribute("Sessionuid", sessionMessageObj.get("uid"));
}
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/index"));
ModelAndView view = request(super.createView("/apps/im/index"));
Optional<BlackEntity> blackOpt = cache.findOneBlackEntityByUserIdAndOrgi(userid, Constants.SYSTEM_ORGI);
CousultInvite invite = OnlineUserProxy.consult(appid, orgi);
if (StringUtils.isNotBlank(
@ -688,7 +731,7 @@ public class IMController extends Handler {
isLeavemsg = true;
boolean isInWorkingHours = MainUtils.isInWorkingHours(sessionConfig.getWorkinghours());
map.addAttribute("isInWorkingHours", isInWorkingHours);
view = request(super.createRequestPageTempletResponse("/apps/im/leavemsg"));
view = request(super.createView("/apps/im/leavemsg"));
} else if (invite.isConsult_info()) { //启用了信息收集从Request获取 或从 Cookies 里去
// 验证 OnlineUser 信息
if (contacts != null && StringUtils.isNotBlank(
@ -770,7 +813,7 @@ public class IMController extends Handler {
}
if (StringUtils.isBlank(contacts.getName())) {
consult = false;
view = request(super.createRequestPageTempletResponse("/apps/im/collecting"));
view = request(super.createView("/apps/im/collecting"));
}
}
} else {
@ -877,10 +920,10 @@ public class IMController extends Handler {
if (chatbotConfig != null) {
map.addAttribute("chatbotConfig", chatbotConfig);
}
view = request(super.createRequestPageTempletResponse("/apps/im/chatbot/index"));
view = request(super.createView("/apps/im/chatbot/index"));
if (MobileDevice.isMobile(request.getHeader("User-Agent")) || StringUtils.isNotBlank(
mobile)) {
view = request(super.createRequestPageTempletResponse(
view = request(super.createView(
"/apps/im/chatbot/mobile")); // 智能机器人 移动端
}
} else {
@ -888,7 +931,7 @@ public class IMController extends Handler {
if (!isLeavemsg && (MobileDevice.isMobile(
request.getHeader("User-Agent")) || StringUtils.isNotBlank(mobile))) {
view = request(
super.createRequestPageTempletResponse("/apps/im/mobile")); // WebIM移动端再次点选技能组
super.createView("/apps/im/mobile")); // WebIM移动端再次点选技能组
}
}
@ -960,7 +1003,7 @@ public class IMController extends Handler {
@Valid String imgurl,
@Valid String pid,
@Valid String purl) throws Exception {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/text"));
ModelAndView view = request(super.createView("/apps/im/text"));
CousultInvite invite = OnlineUserProxy.consult(
appid, StringUtils.isBlank(orgi) ? Constants.SYSTEM_ORGI : orgi);
@ -1051,7 +1094,7 @@ public class IMController extends Handler {
}
});
}
return request(super.createRequestPageTempletResponse("/apps/im/leavemsgsave"));
return request(super.createView("/apps/im/leavemsgsave"));
}
@RequestMapping("/refuse")
@ -1098,7 +1141,7 @@ public class IMController extends Handler {
@RequestMapping("/image/upload")
@Menu(type = "im", subtype = "image", access = true)
public ModelAndView upload(
public ResponseEntity<String> upload(
ModelMap map, HttpServletRequest request,
@RequestParam(value = "imgFile", required = false) MultipartFile multipart,
@Valid String channel,
@ -1107,11 +1150,11 @@ public class IMController extends Handler {
@Valid String appid,
@Valid String orgi,
@Valid String paste) throws IOException {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload"));
final User logined = super.getUser(request);
UploadStatus upload = null;
String fileName = null;
JSONObject result = new JSONObject();
HttpHeaders headers = RestUtils.header();
// String multipartLast = null;
// if ( multipart != null && multipart.getOriginalFilename() != null ){
// Number multipartLenght = multipart.getOriginalFilename().split("\\.").length - 1;
@ -1156,7 +1199,8 @@ public class IMController extends Handler {
sf.setThumbnail(jpaBlobHelper.createBlobWithFile(thumbnail));
streamingFileRepository.save(sf);
String fileUrl = "/res/image.html?id=" + fileid;
upload = new UploadStatus("0", fileUrl);
result.put("error", 0);
result.put("url", fileUrl);
if (paste == null) {
if (StringUtils.isNotBlank(channel)) {
@ -1169,7 +1213,8 @@ public class IMController extends Handler {
}
}
} else {
upload = new UploadStatus(invalid);
result.put("error", 1);
result.put("message", invalid);
}
} else {
String invalid = StreamingFileUtil.getInstance().validate(
@ -1182,7 +1227,8 @@ public class IMController extends Handler {
// 存储到本地硬盘
String id = processAttachmentFile(multipart,
fileid, logined.getOrgi(), logined.getId());
upload = new UploadStatus("0", "/res/file.html?id=" + id);
result.put("error", 0);
result.put("url", "/res/file.html?id=" + id);
String file = "/res/file.html?id=" + id;
File tempFile = new File(multipart.getOriginalFilename());
@ -1194,11 +1240,13 @@ public class IMController extends Handler {
RichMediaUtils.uploadFile(file, (int) multipart.getSize(), tempFile.getName(), userid, id);
}
} else {
upload = new UploadStatus(invalid);
result.put("error", 1);
result.put("message", invalid);
}
}
} else {
upload = new UploadStatus("请选择文件");
result.put("error", 1);
result.put("message", "请选择文件");
}
// }else {
// upload = new UploadStatus("请上传格式为jpgpngjpegbmp类型图片");
@ -1206,8 +1254,8 @@ public class IMController extends Handler {
// } else {
// upload = new UploadStatus("请上传格式为jpgpngjpegbmp类型图片");
// }
map.addAttribute("upload", upload);
return view;
return new ResponseEntity<>(result.toString(), headers, HttpStatus.OK);
}

View File

@ -1,91 +0,0 @@
/*
* 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.apps;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.JobDetail;
import com.chatopera.cc.model.JobTask;
import com.chatopera.cc.persistence.repository.JobDetailRepository;
import com.chatopera.cc.util.Menu;
import com.fasterxml.jackson.databind.ObjectMapper;
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.text.ParseException;
import java.util.Date;
@Controller
@RequestMapping("/apps/job")
public class JobController extends Handler {
@Autowired
private JobDetailRepository jobRes ;
/**
* 跳转到修改执行时间的页面
* @param request
* @param orgi
* @param id
* @return
* @throws Exception
*/
@RequestMapping({"/setting"})
@Menu(type="job", subtype="setting")
public ModelAndView setting(ModelMap map , HttpServletRequest request , @Valid String id) throws Exception {
JobDetail detail = jobRes.findByIdAndOrgi(id, super.getOrgi(request)) ;
if(detail.getTaskinfo() != null && detail.getTaskinfo() != ""){
ObjectMapper objectMapper = new ObjectMapper();
JobTask taskInfo = objectMapper.readValue(detail.getTaskinfo(), JobTask.class) ;
map.put("taskinfo",taskInfo);
}
map.put("job", detail);
return request(super.createRequestPageTempletResponse("/apps/business/job/setting"));
}
@RequestMapping({"/save"})
@Menu(type="job", subtype="save")
public ModelAndView save(HttpServletRequest request,
@Valid JobTask taskinfo,@Valid Boolean plantask, @Valid String id) throws ParseException {
JobDetail detail = jobRes.findByIdAndOrgi(id, super.getOrgi(request)) ;
if(detail != null ){
try {
detail.setPlantask(plantask) ;
ObjectMapper mapper = new ObjectMapper();
detail.setTaskinfo(mapper.writeValueAsString(taskinfo));
detail.setCronexp(MainUtils.convertCrond(taskinfo));
/**
* 设定触发时间
*/
detail.setNextfiretime(new Date());
detail.setNextfiretime(MainUtils.updateTaskNextFireTime(detail));
} catch (Exception e) {
e.printStackTrace();
}
jobRes.save(detail) ;
}
return request(super.createRequestPageTempletResponse("/public/success"));
}
}

View File

@ -1,182 +0,0 @@
/*
* 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.apps;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.AttachmentFile;
import com.chatopera.cc.model.KbsTopic;
import com.chatopera.cc.model.KbsType;
import com.chatopera.cc.persistence.es.KbsTopicRepository;
import com.chatopera.cc.persistence.repository.AttachmentRepository;
import com.chatopera.cc.persistence.repository.KbsTypeRepository;
import com.chatopera.cc.persistence.repository.TagRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.io.FileUtils;
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.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;
import java.util.Date;
@Controller
@RequestMapping({"/apps/kbs"})
public class KbsController extends Handler {
@Autowired
private TagRepository tagRes ;
@Autowired
private KbsTypeRepository kbsTypeRes ;
@Autowired
private KbsTopicRepository kbsTopicRes ;
@Autowired
private AttachmentRepository attachementRes;
@Value("${web.upload-path}")
private String path;
@RequestMapping({"/index"})
@Menu(type="apps", subtype="kbs")
public ModelAndView index(ModelMap map , HttpServletRequest request){
return request(super.createAppsTempletResponse("/apps/business/kbs/index"));
}
@RequestMapping({"/list"})
@Menu(type="apps", subtype="kbs")
public ModelAndView list(ModelMap map , HttpServletRequest request){
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createAppsTempletResponse("/apps/business/kbs/list"));
}
@RequestMapping({"/list/type"})
@Menu(type="apps", subtype="kbs")
public ModelAndView listtype(ModelMap map , HttpServletRequest request,@Valid String typeid){
if(!StringUtils.isBlank(typeid) && !typeid.equals("0")){
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
}
return request(super.createRequestPageTempletResponse("/apps/business/kbs/typelist"));
}
@RequestMapping({"/addtype"})
@Menu(type="apps", subtype="kbs")
public ModelAndView addtype(ModelMap map , HttpServletRequest request ){
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/business/kbs/addtype"));
}
@RequestMapping("/type/save")
@Menu(type = "apps" , subtype = "kbs")
public ModelAndView typesave(HttpServletRequest request ,@Valid KbsType kbsType) {
int count = kbsTypeRes.countByOrgiAndNameAndParentid(super.getOrgi(request), kbsType.getName(), kbsType.getParentid()) ;
if(count == 0){
kbsType.setOrgi(super.getOrgi(request));
kbsType.setCreater(super.getUser(request).getId());
kbsType.setCreatetime(new Date());
kbsTypeRes.save(kbsType) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/kbs/list.html"));
}
@RequestMapping({"/add"})
@Menu(type="apps", subtype="kbs")
public ModelAndView add(ModelMap map , HttpServletRequest request ,@Valid String typeid){
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request))) ;
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.KBS.toString())) ;
if(!StringUtils.isBlank(typeid) && !typeid.equals("0")){
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
}
return request(super.createRequestPageTempletResponse("/apps/business/kbs/add"));
}
@RequestMapping("/save")
@Menu(type = "topic" , subtype = "save" , access = false)
public ModelAndView save(HttpServletRequest request ,
final @Valid KbsTopic topic ,
@RequestParam(value = "files", required = false) MultipartFile[] files) throws IOException {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/apps/kbs/index.html"));
topic.setOrgi(super.getOrgi(request));
topic.setCreater(super.getUser(request).getId());
topic.setUsername(super.getUser(request).getUsername());
processAttachmentFile(files, topic, request, topic.getId(), topic.getId());
KbsType workOrderType = kbsTypeRes.findByIdAndOrgi(topic.getTptype(), super.getOrgi(request)) ;
// 知识处理流程如果知识分类需要审批则触发知识流程
if(workOrderType.isApproval()){
topic.setApproval(false);
}else{
topic.setApproval(true);
}
kbsTopicRes.save(topic) ;
return view;
}
private void processAttachmentFile(MultipartFile[] files , KbsTopic topic, HttpServletRequest request , String dataid , String modelid) throws IOException{
if(files!=null && files.length > 0){
topic.setAttachment(""); //序列化 附件文件方便显示避免多一次查询 附件的操作
//保存附件
for(MultipartFile file : files){
if(file.getSize() > 0){ //文件尺寸 限制 启动 配置中 设置 的最大值其他地方不做限制
String fileid = MainUtils.md5(file.getBytes()) ; //使用 文件的 MD5作为 ID避免重复上传大文件
if(!StringUtils.isBlank(fileid)){
AttachmentFile attachmentFile = new AttachmentFile() ;
attachmentFile.setCreater(super.getUser(request).getId());
attachmentFile.setOrgi(super.getOrgi(request));
attachmentFile.setDataid(dataid);
attachmentFile.setModelid(modelid);
attachmentFile.setModel(MainContext.ModelType.WORKORDERS.toString());
attachmentFile.setFilelength((int) file.getSize());
if(file.getContentType()!=null && file.getContentType().length() > 255){
attachmentFile.setFiletype(file.getContentType().substring(0 , 255));
}else{
attachmentFile.setFiletype(file.getContentType());
}
if(file.getOriginalFilename()!=null && file.getOriginalFilename().length() > 255){
attachmentFile.setTitle(file.getOriginalFilename().substring(0 , 255));
}else{
attachmentFile.setTitle(file.getOriginalFilename());
}
if(!StringUtils.isBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0){
attachmentFile.setImage(true);
}
attachmentFile.setFileid(fileid);
attachementRes.save(attachmentFile) ;
FileUtils.writeByteArrayToFile(new File(path , "app/kbs/"+fileid), file.getBytes());
}
}
}
}
}
}

View File

@ -33,6 +33,6 @@ public class MessageController extends Handler{
@RequestMapping("/ping")
@Menu(type = "message" , subtype = "ping" , admin= true)
public ModelAndView ping(ModelMap map , HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/apps/message/ping"));
return request(super.createView("/apps/message/ping"));
}
}

View File

@ -1,335 +0,0 @@
/*
* 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.apps;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.MetadataTable;
import com.chatopera.cc.model.QuickReply;
import com.chatopera.cc.persistence.es.QuickReplyRepository;
import com.chatopera.cc.persistence.repository.MetadataRepository;
import com.chatopera.cc.persistence.repository.QuickTypeRepository;
import com.chatopera.cc.persistence.repository.ReporterRepository;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.dsdata.DSData;
import com.chatopera.cc.util.dsdata.DSDataEvent;
import com.chatopera.cc.util.dsdata.ExcelImportProecess;
import com.chatopera.cc.util.dsdata.export.ExcelExporterProcess;
import com.chatopera.cc.util.dsdata.process.QuickReplyProcess;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@RequestMapping("/setting/quickreply")
public class QuickReplyController extends Handler {
@Autowired
private QuickReplyRepository quickReplyRes ;
@Autowired
private QuickTypeRepository quickTypeRes ;
@Autowired
private MetadataRepository metadataRes ;
@Autowired
private ReporterRepository reporterRes ;
@Value("${web.upload-path}")
private String path;
@RequestMapping("/index")
@Menu(type = "setting" , subtype = "quickreply" , admin= true)
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String typeid) {
List<com.chatopera.cc.model.QuickType> quickTypeList = quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request) , MainContext.QuickType.PUB.toString()) ;
if(!StringUtils.isBlank(typeid)){
map.put("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
map.put("quickReplyList", quickReplyRes.getByOrgiAndCate(super.getOrgi(request) , typeid , null , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("quickReplyList", quickReplyRes.getByOrgiAndType(super.getOrgi(request) , MainContext.QuickType.PUB.toString(), null, new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("pubQuickTypeList", quickTypeList) ;
return request(super.createAppsTempletResponse("/apps/setting/quickreply/index"));
}
@RequestMapping("/replylist")
@Menu(type = "setting" , subtype = "quickreply" , admin= true)
public ModelAndView list(ModelMap map , HttpServletRequest request , @Valid String typeid) {
if(!StringUtils.isBlank(typeid) && !typeid.equals("0")){
map.put("quickReplyList", quickReplyRes.getByOrgiAndCate(super.getOrgi(request) , typeid, null, new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("quickReplyList", quickReplyRes.getByOrgiAndType(super.getOrgi(request), MainContext.QuickType.PUB.toString() , null , new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/setting/quickreply/replylist"));
}
@RequestMapping("/add")
@Menu(type = "setting" , subtype = "quickreplyadd" , admin= true)
public ModelAndView quickreplyadd(ModelMap map , HttpServletRequest request , @Valid String parentid) {
if(!StringUtils.isBlank(parentid)){
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(parentid, super.getOrgi(request))) ;
}
map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request) , MainContext.QuickType.PUB.toString())) ;
return request(super.createRequestPageTempletResponse("/apps/setting/quickreply/add"));
}
@RequestMapping("/save")
@Menu(type = "setting" , subtype = "quickreply" , admin= true)
public ModelAndView quickreplysave(ModelMap map , HttpServletRequest request , @Valid QuickReply quickReply) {
if(!StringUtils.isBlank(quickReply.getTitle()) && !StringUtils.isBlank(quickReply.getContent())){
quickReply.setOrgi(super.getOrgi(request));
quickReply.setCreater(super.getUser(request).getId());
quickReply.setType(MainContext.QuickType.PUB.toString());
quickReplyRes.save(quickReply) ;
}
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html?typeid="+quickReply.getCate()));
}
@RequestMapping("/delete")
@Menu(type = "setting" , subtype = "quickreply" , admin= true)
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
QuickReply quickReply = quickReplyRes.findOne(id) ;
if(quickReply!=null){
quickReplyRes.delete(quickReply);
}
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html?typeid="+quickReply.getCate()));
}
@RequestMapping("/edit")
@Menu(type = "setting" , subtype = "quickreply" , admin= true)
public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) {
QuickReply quickReply = quickReplyRes.findOne(id) ;
map.put("quickReply", quickReply) ;
if(quickReply!=null){
map.put("quickType", quickTypeRes.findByIdAndOrgi(quickReply.getCate(), super.getOrgi(request))) ;
}
map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request) , MainContext.QuickType.PUB.toString())) ;
return request(super.createRequestPageTempletResponse("/apps/setting/quickreply/edit"));
}
@RequestMapping("/update")
@Menu(type = "setting" , subtype = "quickreply" , admin= true)
public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid QuickReply quickReply) {
if(!StringUtils.isBlank(quickReply.getId())){
QuickReply temp = quickReplyRes.findOne(quickReply.getId()) ;
quickReply.setOrgi(super.getOrgi(request));
quickReply.setCreater(super.getUser(request).getId());
if(temp!=null){
quickReply.setCreatetime(temp.getCreatetime());
}
quickReply.setType(MainContext.QuickType.PUB.toString());
quickReplyRes.save(quickReply) ;
}
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html?typeid="+quickReply.getCate()));
}
@RequestMapping({"/addtype"})
@Menu(type="apps", subtype="kbs")
public ModelAndView addtype(ModelMap map , HttpServletRequest request , @Valid String typeid){
map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request) , MainContext.QuickType.PUB.toString())) ;
if(!StringUtils.isBlank(typeid)){
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
}
return request(super.createRequestPageTempletResponse("/apps/setting/quickreply/addtype"));
}
@RequestMapping("/type/save")
@Menu(type = "apps" , subtype = "kbs")
public ModelAndView typesave(HttpServletRequest request ,@Valid com.chatopera.cc.model.QuickType quickType) {
com.chatopera.cc.model.QuickType qr = quickTypeRes.findByOrgiAndName(super.getOrgi(request), quickType.getName()) ;
if(qr==null){
quickType.setOrgi(super.getOrgi(request));
quickType.setCreater(super.getUser(request).getId());
quickType.setCreatetime(new Date());
quickType.setQuicktype(MainContext.QuickType.PUB.toString());
quickTypeRes.save(quickType) ;
}else {
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html?msg=qr_type_exist"));
}
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html"));
}
@RequestMapping({"/edittype"})
@Menu(type="apps", subtype="kbs")
public ModelAndView edittype(ModelMap map , HttpServletRequest request , String id){
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(id, super.getOrgi(request))) ;
map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request) , MainContext.QuickType.PUB.toString())) ;
return request(super.createRequestPageTempletResponse("/apps/setting/quickreply/edittype"));
}
@RequestMapping("/type/update")
@Menu(type = "apps" , subtype = "kbs")
public ModelAndView typeupdate(HttpServletRequest request ,@Valid com.chatopera.cc.model.QuickType quickType) {
com.chatopera.cc.model.QuickType tempQuickType = quickTypeRes.findByIdAndOrgi(quickType.getId(), super.getOrgi(request)) ;
if(tempQuickType !=null){
//判断名称是否重复
com.chatopera.cc.model.QuickType qr = quickTypeRes.findByOrgiAndName(super.getOrgi(request), quickType.getName());
if(qr!=null && !qr.getId().equals(quickType.getId())) {
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html?msg=qr_type_exist&typeid="+quickType.getId()));
}
tempQuickType.setName(quickType.getName());
tempQuickType.setDescription(quickType.getDescription());
tempQuickType.setInx(quickType.getInx());
tempQuickType.setParentid(quickType.getParentid());
quickTypeRes.save(tempQuickType) ;
}
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html?typeid="+quickType.getId()));
}
@RequestMapping({"/deletetype"})
@Menu(type="apps", subtype="kbs")
public ModelAndView deletetype(ModelMap map , HttpServletRequest request , @Valid String id){
if(!StringUtils.isBlank(id)){
com.chatopera.cc.model.QuickType tempQuickType = quickTypeRes.findByIdAndOrgi(id, super.getOrgi(request)) ;
quickTypeRes.delete(tempQuickType);
Page<QuickReply> quickReplyList = quickReplyRes.getByOrgiAndCate(super.getOrgi(request), id, null, new PageRequest(0, 10000)) ;
quickReplyRes.delete(quickReplyList.getContent());
}
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html"));
}
@RequestMapping("/imp")
@Menu(type = "setting" , subtype = "quickreplyimp")
public ModelAndView imp(ModelMap map , HttpServletRequest request , @Valid String type) {
map.addAttribute("type", type) ;
return request(super.createRequestPageTempletResponse("/apps/setting/quickreply/imp"));
}
@RequestMapping("/impsave")
@Menu(type = "setting" , subtype = "quickreplyimpsave")
public ModelAndView impsave(ModelMap map , HttpServletRequest request , @RequestParam(value = "cusfile", required = false) MultipartFile cusfile , @Valid String type) throws IOException {
DSDataEvent event = new DSDataEvent();
String fileName = "quickreply/"+ MainUtils.getUUID()+cusfile.getOriginalFilename().substring(cusfile.getOriginalFilename().lastIndexOf(".")) ;
File excelFile = new File(path , fileName) ;
if(!excelFile.getParentFile().exists()){
excelFile.getParentFile().mkdirs() ;
}
MetadataTable table = metadataRes.findByTablename("uk_quickreply") ;
if(table!=null){
FileUtils.writeByteArrayToFile(new File(path , fileName), cusfile.getBytes());
event.setDSData(new DSData(table,excelFile , cusfile.getContentType(), super.getUser(request)));
event.getDSData().setClazz(QuickReply.class);
event.setOrgi(super.getOrgi(request));
if(!StringUtils.isBlank(type)){
event.getValues().put("cate", type) ;
}else{
event.getValues().put("cate", Constants.DEFAULT_TYPE) ;
}
event.getValues().put("type", MainContext.QuickType.PUB.toString()) ;
event.getValues().put("creater", super.getUser(request).getId()) ;
event.getDSData().setProcess(new QuickReplyProcess(quickReplyRes));
reporterRes.save(event.getDSData().getReport()) ;
new ExcelImportProecess(event).process() ; //启动导入任务
}
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html"+(!StringUtils.isBlank(type)? "?typeid="+type:"")));
}
@RequestMapping("/batdelete")
@Menu(type = "setting" , subtype = "quickreplybatdelete")
public ModelAndView batdelete(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String[] ids ,@Valid String type) throws IOException {
if(ids!=null && ids.length > 0){
Iterable<QuickReply> topicList = quickReplyRes.findAll(Arrays.asList(ids)) ;
quickReplyRes.delete(topicList);
}
return request(super.createRequestPageTempletResponse("redirect:/setting/quickreply/index.html"+(!StringUtils.isBlank(type) ? "?typeid="+type:"")));
}
@RequestMapping("/expids")
@Menu(type = "setting" , subtype = "quickreplyexpids")
public void expids(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String[] ids) throws IOException {
if(ids!=null && ids.length > 0){
Iterable<QuickReply> topicList = quickReplyRes.findAll(Arrays.asList(ids)) ;
MetadataTable table = metadataRes.findByTablename("uk_quickreply") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(QuickReply topic : topicList){
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
}
return ;
}
@RequestMapping("/expall")
@Menu(type = "setting" , subtype = "quickreplyexpall")
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response,@Valid String type) throws IOException {
Iterable<QuickReply> topicList = quickReplyRes.getQuickReplyByOrgi(super.getOrgi(request) , !StringUtils.isBlank(type) ? type : null, MainContext.QuickType.PUB.toString(), null) ;
MetadataTable table = metadataRes.findByTablename("uk_quickreply") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(QuickReply topic : topicList){
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
return ;
}
@RequestMapping("/expsearch")
@Menu(type = "setting" , subtype = "quickreplyexpsearch")
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String q , @Valid String type) throws IOException {
Iterable<QuickReply> topicList = quickReplyRes.getQuickReplyByOrgi(super.getOrgi(request) , type, MainContext.QuickType.PUB.toString(), q) ;
MetadataTable table = metadataRes.findByTablename("uk_quickreply") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(QuickReply topic : topicList){
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
return ;
}
}

View File

@ -1,457 +0,0 @@
/*
* 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.apps;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.es.TopicRepository;
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.dsdata.DSData;
import com.chatopera.cc.util.dsdata.DSDataEvent;
import com.chatopera.cc.util.dsdata.ExcelImportProecess;
import com.chatopera.cc.util.dsdata.export.ExcelExporterProcess;
import com.chatopera.cc.util.dsdata.process.TopicProcess;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@RequestMapping("/apps")
public class TopicController extends Handler{
@Value("${web.upload-path}")
private String path;
@Value("${uk.im.server.port}")
private Integer port;
@Autowired
private KnowledgeTypeRepository knowledgeTypeRes ;
@Autowired
private AreaTypeRepository areaRepository;
@Autowired
private SysDicRepository sysDicRepository;
@Autowired
private TopicRepository topicRes;
@Autowired
private MetadataRepository metadataRes ;
@Autowired
private TopicItemRepository topicItemRes ;
@Autowired
private ReporterRepository reporterRes ;
@RequestMapping("/topic")
@Menu(type = "xiaoe" , subtype = "knowledge")
public ModelAndView knowledge(ModelMap map , HttpServletRequest request , @Valid String q , @Valid String type, @Valid String aiid) {
List<KnowledgeType> knowledgeTypeList = knowledgeTypeRes.findByOrgi(super.getOrgi(request)) ;
map.put("knowledgeTypeList", knowledgeTypeList);
KnowledgeType ktype = null ;
if(!StringUtils.isBlank(type)){
for(KnowledgeType knowledgeType : knowledgeTypeList){
if(knowledgeType.getId().equals(type)){
ktype = knowledgeType ;
break ;
}
}
}
if(!StringUtils.isBlank(q)){
map.put("q", q) ;
}
if(ktype!=null){
map.put("curtype", ktype) ;
map.put("topicList", topicRes.getTopicByCateAndOrgi(ktype.getId(),super.getOrgi(request), q, super.getP(request), super.getPs(request))) ;
}else{
map.put("topicList", topicRes.getTopicByCateAndOrgi(Constants.DEFAULT_TYPE,super.getOrgi(request), q, super.getP(request), super.getPs(request))) ;
}
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi(request))) ;
return request(super.createAppsTempletResponse("/apps/business/topic/index"));
}
@RequestMapping("/topic/add")
@Menu(type = "xiaoe" , subtype = "knowledgeadd")
public ModelAndView knowledgeadd(ModelMap map , HttpServletRequest request , @Valid String type, @Valid String aiid) {
map.put("type", type);
map.put("aiid", aiid);
return request(super.createRequestPageTempletResponse("/apps/business/topic/add"));
}
@RequestMapping("/topic/save")
@Menu(type = "xiaoe" , subtype = "knowledgesave")
public ModelAndView knowledgesave(HttpServletRequest request , @Valid Topic topic , @Valid String type , @Valid String aiid) {
if(!StringUtils.isBlank(topic.getTitle())){
if(!StringUtils.isBlank(type)){
topic.setCate(type);
}else{
topic.setCate(Constants.DEFAULT_TYPE);
}
topic.setOrgi(super.getOrgi(request));
topicRes.save(topic) ;
List<TopicItem> topicItemList = new ArrayList<TopicItem>();
for(String item : topic.getSilimar()) {
TopicItem topicItem = new TopicItem();
topicItem.setTitle(item);
topicItem.setTopicid(topic.getId());
topicItem.setOrgi(topic.getOrgi());
topicItem.setCreater(topic.getCreater());
topicItem.setCreatetime(new Date());
topicItemList.add(topicItem) ;
}
if(topicItemList.size() > 0) {
topicItemRes.save(topicItemList) ;
}
/**
* 重新缓存
*
*/
OnlineUserProxy.resetHotTopic((DataExchangeInterface) MainContext.getContext().getBean("topic") , super.getUser(request) , super.getOrgi(request) , aiid) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html"+(!StringUtils.isBlank(type) ? "?type="+type : "")));
}
@RequestMapping("/topic/edit")
@Menu(type = "xiaoe" , subtype = "knowledgeedit")
public ModelAndView knowledgeedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String type, @Valid String aiid) {
map.put("type", type);
if(!StringUtils.isBlank(id)){
map.put("topic", topicRes.findOne(id)) ;
}
List<KnowledgeType> knowledgeTypeList = knowledgeTypeRes.findByOrgi(super.getOrgi(request)) ;
map.put("knowledgeTypeList", knowledgeTypeList);
return request(super.createRequestPageTempletResponse("/apps/business/topic/edit"));
}
@RequestMapping("/topic/update")
@Menu(type = "xiaoe" , subtype = "knowledgeupdate")
public ModelAndView knowledgeupdate(HttpServletRequest request ,@Valid Topic topic , @Valid String type, @Valid String aiid) {
Topic temp = topicRes.findOne(topic.getId()) ;
if(!StringUtils.isBlank(topic.getTitle())){
if(!StringUtils.isBlank(type)){
topic.setCate(type);
}else{
topic.setCate(Constants.DEFAULT_TYPE);
}
topic.setCreater(temp.getCreater());
topic.setCreatetime(temp.getCreatetime());
topic.setOrgi(super.getOrgi(request));
topicRes.save(topic) ;
topicItemRes.delete(topicItemRes.findByTopicid(topic.getId())) ;
List<TopicItem> topicItemList = new ArrayList<TopicItem>();
for(String item : topic.getSilimar()) {
TopicItem topicItem = new TopicItem();
topicItem.setTitle(item);
topicItem.setTopicid(topic.getId());
topicItem.setOrgi(topic.getOrgi());
topicItem.setCreater(topic.getCreater());
topicItem.setCreatetime(new Date());
topicItemList.add(topicItem) ;
}
if(topicItemList.size() > 0) {
topicItemRes.save(topicItemList) ;
}
/**
* 重新缓存
*
*/
OnlineUserProxy.resetHotTopic((DataExchangeInterface) MainContext.getContext().getBean("topic") , super.getUser(request) , super.getOrgi(request),aiid) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html"+(!StringUtils.isBlank(type) ? "?type="+type : "")));
}
@RequestMapping("/topic/delete")
@Menu(type = "xiaoe" , subtype = "knowledgedelete")
public ModelAndView knowledgedelete(HttpServletRequest request ,@Valid String id , @Valid String type, @Valid String aiid) {
if(!StringUtils.isBlank(id)){
topicRes.delete(topicRes.findOne(id));
/**
* 重新缓存
*
*/
topicItemRes.delete(topicItemRes.findByTopicid(id)) ;
OnlineUserProxy.resetHotTopic((DataExchangeInterface) MainContext.getContext().getBean("topic") , super.getUser(request) , super.getOrgi(request) , aiid) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html"+(!StringUtils.isBlank(type) ? "?type="+type : "")));
}
@RequestMapping("/topic/type/add")
@Menu(type = "xiaoe" , subtype = "knowledgetypeadd")
public ModelAndView knowledgetypeadd(ModelMap map , HttpServletRequest request ,@Valid String type, @Valid String aiid) {
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi(request))) ;
List<KnowledgeType> knowledgeTypeList = knowledgeTypeRes.findByOrgi(super.getOrgi(request)) ;
map.put("knowledgeTypeList", knowledgeTypeList);
map.put("aiid", aiid);
if(!StringUtils.isBlank(type)){
map.put("type", type) ;
}
return request(super.createRequestPageTempletResponse("/apps/business/topic/addtype"));
}
@RequestMapping("/topic/type/save")
@Menu(type = "xiaoe" , subtype = "knowledgetypesave")
public ModelAndView knowledgetypesave(HttpServletRequest request ,@Valid KnowledgeType type, @Valid String aiid) {
//int tempTypeCount = knowledgeTypeRes.countByNameAndOrgiAndParentidNot(type.getName(), super.getOrgi(request) , !StringUtils.isBlank(type.getParentid()) ? type.getParentid() : "0") ;
KnowledgeType knowledgeType = knowledgeTypeRes.findByNameAndOrgi(type.getName(), super.getOrgi(request)) ;
if(knowledgeType == null){
type.setOrgi(super.getOrgi(request));
type.setCreatetime(new Date());
type.setId(MainUtils.getUUID());
type.setTypeid(type.getId());
type.setUpdatetime(new Date());
if(StringUtils.isBlank(type.getParentid())){
type.setParentid("0");
}else{
type.setTypeid(type.getParentid());
}
type.setCreater(super.getUser(request).getId());
knowledgeTypeRes.save(type) ;
OnlineUserProxy.resetHotTopicType((DataExchangeInterface) MainContext.getContext().getBean("topictype") , super.getUser(request), super.getOrgi(request) , aiid);
}else {
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html?aiid="+aiid+"&msg=k_type_exist"));
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html?aiid="+aiid));
}
@RequestMapping("/topic/type/edit")
@Menu(type = "xiaoe" , subtype = "knowledgetypeedit")
public ModelAndView knowledgetypeedit(ModelMap map , HttpServletRequest request, @Valid String type , @Valid String aiid) {
map.put("knowledgeType", knowledgeTypeRes.findOne(type)) ;
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi(request))) ;
map.put("aiid", aiid);
List<KnowledgeType> knowledgeTypeList = knowledgeTypeRes.findByOrgi(super.getOrgi(request)) ;
map.put("knowledgeTypeList", knowledgeTypeList);
return request(super.createRequestPageTempletResponse("/apps/business/topic/edittype"));
}
@RequestMapping("/topic/type/update")
@Menu(type = "xiaoe" , subtype = "knowledgetypeupdate")
public ModelAndView knowledgetypeupdate(HttpServletRequest request ,@Valid KnowledgeType type, @Valid String aiid) {
//int tempTypeCount = knowledgeTypeRes.countByNameAndOrgiAndIdNot(type.getName(), super.getOrgi(request) , type.getId()) ;
KnowledgeType knowledgeType = knowledgeTypeRes.findByNameAndOrgiAndIdNot(type.getName(), super.getOrgi(request),type.getId()) ;
if(knowledgeType == null){
KnowledgeType temp = knowledgeTypeRes.findByIdAndOrgi(type.getId(), super.getOrgi(request)) ;
temp.setName(type.getName());
temp.setParentid(type.getParentid());
if(StringUtils.isBlank(type.getParentid()) || type.getParentid().equals("0")){
temp.setParentid("0");
temp.setTypeid(temp.getId());
}else{
temp.setParentid(type.getParentid());
temp.setTypeid(type.getParentid());
}
knowledgeTypeRes.save(temp) ;
OnlineUserProxy.resetHotTopicType((DataExchangeInterface) MainContext.getContext().getBean("topictype") , super.getUser(request), super.getOrgi(request) , aiid);
}else {
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html?aiid="+aiid+"&msg=k_type_exist&type="+type.getId()));
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html?aiid="+aiid+"type="+type.getId()));
}
@RequestMapping("/topic/type/delete")
@Menu(type = "xiaoe" , subtype = "knowledgedelete")
public ModelAndView knowledgetypedelete(HttpServletRequest request ,@Valid String id , @Valid String type, @Valid String aiid) {
Page<Topic> page = topicRes.getTopicByCateAndOrgi(type,super.getOrgi(request), null, super.getP(request), super.getPs(request)) ;
String msg = null ;
if(page.getTotalElements() == 0){
if(!StringUtils.isBlank(id)){
knowledgeTypeRes.delete(id);
OnlineUserProxy.resetHotTopicType((DataExchangeInterface) MainContext.getContext().getBean("topictype") , super.getUser(request), super.getOrgi(request) , aiid);
}
}else{
msg = "notempty" ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html"+(msg!=null ? "?msg=notempty" : "")));
}
@RequestMapping("/topic/area")
@Menu(type = "admin" , subtype = "area")
public ModelAndView area(ModelMap map ,HttpServletRequest request , @Valid String id, @Valid String aiid) {
SysDic sysDic = sysDicRepository.findByCode(Constants.CSKEFU_SYSTEM_AREA_DIC) ;
if(sysDic!=null){
map.addAttribute("sysarea", sysDic) ;
map.addAttribute("areaList", sysDicRepository.findByDicid(sysDic.getId())) ;
}
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC)) ;
map.put("knowledgeType", knowledgeTypeRes.findOne(id)) ;
return request(super.createRequestPageTempletResponse("/apps/business/topic/area"));
}
@RequestMapping("/topic/area/update")
@Menu(type = "admin" , subtype = "organ")
public ModelAndView areaupdate(HttpServletRequest request ,@Valid KnowledgeType type, @Valid String aiid) {
KnowledgeType temp = knowledgeTypeRes.findByIdAndOrgi(type.getId(), super.getOrgi(request)) ;
if(temp != null){
temp.setArea(type.getArea());
knowledgeTypeRes.save(temp) ;
OnlineUserProxy.resetHotTopicType((DataExchangeInterface) MainContext.getContext().getBean("topictype") , super.getUser(request), super.getOrgi(request) , aiid);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html?type="+type.getId()));
}
@RequestMapping("/topic/imp")
@Menu(type = "xiaoe" , subtype = "knowledge")
public ModelAndView imp(ModelMap map , HttpServletRequest request , @Valid String type, @Valid String aiid) {
map.addAttribute("type", type) ;
return request(super.createRequestPageTempletResponse("/apps/business/topic/imp"));
}
@RequestMapping("/topic/impsave")
@Menu(type = "xiaoe" , subtype = "knowledge")
public ModelAndView impsave(ModelMap map , HttpServletRequest request , @RequestParam(value = "cusfile", required = false) MultipartFile cusfile , @Valid String type, @Valid String aiid) throws IOException {
DSDataEvent event = new DSDataEvent();
String fileName = "xiaoe/"+ MainUtils.getUUID()+cusfile.getOriginalFilename().substring(cusfile.getOriginalFilename().lastIndexOf(".")) ;
File excelFile = new File(path , fileName) ;
if(!excelFile.getParentFile().exists()){
excelFile.getParentFile().mkdirs() ;
}
MetadataTable table = metadataRes.findByTablename("uk_xiaoe_topic") ;
if(table!=null){
FileUtils.writeByteArrayToFile(new File(path , fileName), cusfile.getBytes());
event.setDSData(new DSData(table,excelFile , cusfile.getContentType(), super.getUser(request)));
event.getDSData().setClazz(Topic.class);
event.setOrgi(super.getOrgi(request));
if(!StringUtils.isBlank(type)){
event.getValues().put("cate", type) ;
}else{
event.getValues().put("cate", Constants.DEFAULT_TYPE) ;
}
event.getValues().put("creater", super.getUser(request).getId()) ;
event.getDSData().setProcess(new TopicProcess(topicRes));
reporterRes.save(event.getDSData().getReport()) ;
new ExcelImportProecess(event).process() ; //启动导入任务
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html?type="+type));
}
@RequestMapping("/topic/batdelete")
@Menu(type = "xiaoe" , subtype = "knowledge")
public ModelAndView batdelete(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String[] ids ,@Valid String type, @Valid String aiid) throws IOException {
if(ids!=null && ids.length > 0){
Iterable<Topic> topicList = topicRes.findAll(Arrays.asList(ids)) ;
topicRes.delete(topicList);
for(Topic topic : topicList) {
topicItemRes.delete(topicItemRes.findByTopicid(topic.getId())) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/topic.html"+(!StringUtils.isBlank(type) ? "?type="+type:"")));
}
@RequestMapping("/topic/expids")
@Menu(type = "xiaoe" , subtype = "knowledge")
public void expids(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String[] ids, @Valid String aiid) throws IOException {
if(ids!=null && ids.length > 0){
Iterable<Topic> topicList = topicRes.findAll(Arrays.asList(ids)) ;
MetadataTable table = metadataRes.findByTablename("uk_xiaoe_topic") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(Topic topic : topicList){
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKefu-Contacts-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
}
return ;
}
@RequestMapping("/topic/expall")
@Menu(type = "xiaoe" , subtype = "knowledge")
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response,@Valid String type, @Valid String aiid) throws IOException {
Iterable<Topic> topicList = topicRes.getTopicByOrgi(super.getOrgi(request) ,type , null) ;
MetadataTable table = metadataRes.findByTablename("uk_xiaoe_topic") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(Topic topic : topicList){
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-XiaoE-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
return ;
}
@RequestMapping("/topic/expsearch")
@Menu(type = "xiaoe" , subtype = "knowledge")
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String q , @Valid String type, @Valid String aiid) throws IOException {
Iterable<Topic> topicList = topicRes.getTopicByOrgi(super.getOrgi(request) , type , q) ;
MetadataTable table = metadataRes.findByTablename("uk_xiaoe_topic") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(Topic topic : topicList){
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-XiaoE-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
return ;
}
}

View File

@ -1,563 +0,0 @@
/*
* 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.apps.report;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.util.Menu;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/apps/report/cube")
public class CubeController extends Handler{
@Autowired
private CubeTypeRepository cubeTypeRes;
@Autowired
private CubeRepository cubeRes;
@Autowired
private DimensionRepository dimensionRes;
@Autowired
private CubeMeasureRepository cubeMeasureRes;
@Autowired
private CubeLevelRepository cubeLevelRes;
@Autowired
private CubeMetadataRepository cubeMetadataRes;
@Autowired
private MetadataRepository metadataRes;
@Autowired
private PublishedCubeRepository publishedCubeRes;
@RequestMapping({"/type/add"})
@Menu(type="report", subtype="cube")
public ModelAndView addtype(ModelMap map , HttpServletRequest request , @Valid String typeid){
map.addAttribute("cubeTypeList", cubeTypeRes.findByOrgi(super.getOrgi(request))) ;
if(!StringUtils.isBlank(typeid)){
map.addAttribute("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
}
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/type/add"));
}
@RequestMapping("/type/save")
@Menu(type = "report" , subtype = "cube")
public ModelAndView typesave(HttpServletRequest request ,@Valid CubeType cubeType) {
CubeType ct = cubeTypeRes.findByOrgiAndName(super.getOrgi(request),cubeType.getName()) ;
if(ct==null){
cubeType.setOrgi(super.getOrgi(request));
cubeType.setCreater(super.getUser(request).getId());
cubeType.setCreatetime(new Date());
cubeTypeRes.save(cubeType) ;
}else {
return request(super.createRequestPageTempletResponse("redirect:/apps/business/report/cube/index.html?msg=ct_type_exist"));
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/index.html"));
}
@RequestMapping({"/type/edit"})
@Menu(type="report", subtype="cube")
public ModelAndView edittype(ModelMap map , HttpServletRequest request , String id){
map.addAttribute("cubeType", cubeTypeRes.findByIdAndOrgi(id, super.getOrgi(request))) ;
map.addAttribute("cubeTypeList",cubeTypeRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/type/edit"));
}
@RequestMapping("/type/update")
@Menu(type = "report" , subtype = "cube")
public ModelAndView typeupdate(HttpServletRequest request ,@Valid CubeType cubeType) {
CubeType tempCubeType = cubeTypeRes.findByIdAndOrgi(cubeType.getId(), super.getOrgi(request)) ;
if(tempCubeType !=null){
//判断名称是否重复
CubeType ct = cubeTypeRes.findByOrgiAndName(super.getOrgi(request),cubeType.getName());
if(ct!=null && !ct.getId().equals(cubeType.getId())) {
return request(super.createRequestPageTempletResponse("redirect:/apps/business/report/cube/index.html?msg=ct_type_exist&typeid="+cubeType.getId()));
}
tempCubeType.setName(cubeType.getName());
tempCubeType.setDescription(cubeType.getDescription());
tempCubeType.setInx(cubeType.getInx());
tempCubeType.setParentid(cubeType.getParentid());
cubeTypeRes.save(tempCubeType) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/business/report/cube/index.html?typeid="+cubeType.getId()));
}
@RequestMapping({"/type/delete"})
@Menu(type="report", subtype="cube")
public ModelAndView deletetype(ModelMap map , HttpServletRequest request , @Valid String id){
if(!StringUtils.isBlank(id)){
CubeType tempCubeType = cubeTypeRes.findByIdAndOrgi(id, super.getOrgi(request)) ;
cubeTypeRes.delete(tempCubeType);
List<Cube> cubeList = cubeRes.findByOrgiAndTypeid(super.getOrgi(request) , id);
if(!cubeList.isEmpty()) {
cubeRes.delete(cubeList);
for(Cube c:cubeList) {
Cube cube = getCube(c.getId());
cubeMetadataRes.delete(cube.getMetadata());
cubeMeasureRes.delete(cube.getMeasure());
dimensionRes.delete(cube.getDimension());
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/index.html"));
}
@RequestMapping("/index")
@Menu(type = "report" , subtype = "cube" )
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String typeid,@Valid String msg) {
List<CubeType> cubeTypeList = cubeTypeRes.findByOrgi(super.getOrgi(request)) ;
if(!StringUtils.isBlank(typeid)){
map.put("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
map.put("cubeList", cubeRes.getByOrgiAndTypeid(super.getOrgi(request) , typeid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("cubeList", cubeRes.getByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("pubCubeTypeList", cubeTypeList) ;
map.put("typeid", typeid);
map.put("msg", msg);
return request(super.createAppsTempletResponse("/apps/business/report/cube/index"));
}
@RequestMapping("/list")
@Menu(type = "report" , subtype = "cube" )
public ModelAndView list(ModelMap map , HttpServletRequest request , @Valid String typeid) {
//List<CubeType> cubeTypeList = cubeTypeRes.findByOrgi(super.getOrgi(request)) ;
if(!StringUtils.isBlank(typeid)){
map.put("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
map.put("cubeList", cubeRes.getByOrgiAndTypeid(super.getOrgi(request) , typeid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("cubeList", cubeRes.getByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)))) ;
}
//map.put("pubCubeTypeList", cubeTypeList) ;
map.put("typeid", typeid);
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/list"));
}
@RequestMapping("/add")
@Menu(type = "report" , subtype = "cube")
public ModelAndView cubeadd(ModelMap map , HttpServletRequest request , @Valid String typeid) {
if(!StringUtils.isBlank(typeid)){
map.addAttribute("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
}
map.addAttribute("cubeTypeList", cubeTypeRes.findByOrgi(super.getOrgi(request))) ;
map.addAttribute("typeid", typeid);
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/add"));
}
@RequestMapping("/save")
@Menu(type = "report" , subtype = "cube" )
public ModelAndView cubesave(ModelMap map , HttpServletRequest request , @Valid Cube cube) {
if(!StringUtils.isBlank(cube.getName())){
cube.setOrgi(super.getOrgi(request));
cube.setCreater(super.getUser(request).getId());
cubeRes.save(cube) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/index.html?typeid="+cube.getTypeid()));
}
@RequestMapping("/delete")
@Menu(type = "report" , subtype = "cube" )
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
Cube cube = cubeRes.findOne(id) ;
if(cube!=null){
cubeRes.delete(cube);
dimensionRes.delete(dimensionRes.findByCubeid(cube.getId()));
cubeLevelRes.delete(cubeLevelRes.findByCubeid(cube.getId()));
cubeMeasureRes.delete(cubeMeasureRes.findByCubeid(cube.getId()));
cubeMetadataRes.delete(cubeMetadataRes.findByCubeid(cube.getId()));
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/index.html?typeid="+cube.getTypeid()));
}
@RequestMapping("/edit")
@Menu(type = "report" , subtype = "cube" , admin= true)
public ModelAndView cubeedit(ModelMap map , HttpServletRequest request , @Valid String id) {
Cube cube = cubeRes.findOne(id) ;
map.put("cube", cube) ;
if(cube!=null){
map.put("cubeType", cubeTypeRes.findByIdAndOrgi(cube.getTypeid(), super.getOrgi(request))) ;
}
map.addAttribute("cubeTypeList", cubeTypeRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/edit"));
}
@RequestMapping("/update")
@Menu(type = "report" , subtype = "cube" , admin= true)
public ModelAndView cubeupdate(ModelMap map , HttpServletRequest request , @Valid Cube cube) {
if(!StringUtils.isBlank(cube.getId())){
Cube temp = cubeRes.findOne(cube.getId()) ;
cube.setOrgi(super.getOrgi(request));
cube.setCreater(super.getUser(request).getId());
if(temp!=null){
cube.setCreatetime(temp.getCreatetime());
}
cube.setUpdatetime(new Date());
cubeRes.save(cube);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/index.html?typeid="+cube.getTypeid()));
}
@RequestMapping("/imptb")
@Menu(type = "report" , subtype = "metadata" , admin = true)
public ModelAndView imptb(final ModelMap map , HttpServletRequest request,@Valid String cubeid) throws Exception {
map.put("tablesList", metadataRes.findByOrgi(super.getOrgi(request)));
map.put("cubeid",cubeid );
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemetadata/imptb"));
}
@RequestMapping("/imptbsave")
@Menu(type = "report" , subtype = "metadata" , admin = true)
public ModelAndView imptb(ModelMap map , HttpServletRequest request , final @Valid String[] tables,@Valid String cubeid) throws Exception {
final User user = super.getUser(request) ;
for(String tableid : tables){
MetadataTable tb = new MetadataTable();
tb.setId(tableid);
int count = cubeMetadataRes.countByTbAndCubeid(tb,cubeid);
if(count == 0) {
CubeMetadata cubeMetaData = new CubeMetadata();
cubeMetaData.setCubeid(cubeid) ;
cubeMetaData.setOrgi(super.getOrgi(request)) ;
cubeMetaData.setTb(tb);
cubeMetaData.setCreater(user.getId());
cubeMetaData.setMtype("1");
cubeMetadataRes.save(cubeMetaData);
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeid));
}
@RequestMapping("/metadata/edit")
@Menu(type = "report" , subtype = "metadata" , admin = true)
public ModelAndView metadataedit(ModelMap map , HttpServletRequest request , final @Valid String id,@Valid String cubeid) throws Exception {
map.put("cubeMetadata", cubeMetadataRes.findOne(id));
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemetadata/edit"));
}
@RequestMapping("/metadata/update")
@Menu(type = "report" , subtype = "metadata" , admin = true)
public ModelAndView metadataedit(ModelMap map , HttpServletRequest request ,@Valid CubeMetadata cubeMetadata) throws Exception {
if(!StringUtils.isBlank(cubeMetadata.getId())){
CubeMetadata temp = cubeMetadataRes.findOne(cubeMetadata.getId()) ;
temp.setNamealias(cubeMetadata.getNamealias());
if("0".equals(cubeMetadata.getMtype())) {
List<CubeMetadata> list = cubeMetadataRes.findByCubeid(temp.getCubeid());
if(!list.isEmpty()) {
//设置其他数据表为从表
for(CubeMetadata cm:list) {
if(!cm.getId().equals(temp.getId())) {
cm.setMtype("1");
cubeMetadataRes.save(cm);
}
}
}
}
temp.setMtype(cubeMetadata.getMtype());
temp.setParameters(cubeMetadata.getParameters());
cubeMetadataRes.save(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeMetadata.getCubeid()));
}
@RequestMapping("/metadata/del")
@Menu(type = "report" , subtype = "metadata" , admin = true)
public ModelAndView metadatadel(ModelMap map , HttpServletRequest request ,@Valid CubeMetadata cubeMetadata) throws Exception {
String msg = "";
if(!StringUtils.isBlank(cubeMetadata.getId())){
boolean flag = true;
CubeMetadata temp = cubeMetadataRes.findOne(cubeMetadata.getId()) ;
String tablename = null;
String tableid = null;
if(temp.getTb()!=null) {
tablename = temp.getTb().getName();
tableid = temp.getTb().getId();
}
if(!StringUtils.isBlank(tableid) ) {
if(dimensionRes.countByFktable(tableid) > 0) {
flag = false;
}
}
if(!StringUtils.isBlank(tablename) ) {
if(cubeLevelRes.countByTablename(tablename) > 0) {
flag = false;
}
if(cubeMeasureRes.countByTablename(tablename) > 0) {
flag = false;
}
}
if(flag) {
cubeMetadataRes.delete(temp);
}else {
msg = "CM_DEL_FAILED";
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeMetadata.getCubeid()+"&msg="+msg));
}
@RequestMapping("/detail")
@Menu(type = "report" , subtype = "cube" )
public ModelAndView detail(ModelMap map , HttpServletRequest request , @Valid String id,@Valid String dimensionId,@Valid String msg) {
List<Dimension> dimensionList = dimensionRes.findByCubeid(id);
map.put("dimensionList", dimensionList);
if(!dimensionList.isEmpty()) {
if(StringUtils.isBlank(dimensionId)) {
dimensionId = dimensionList.get(0).getId();
}
map.put("cubeLevelList", cubeLevelRes.findByOrgiAndDimid(super.getOrgi(request), dimensionId));
}
if(!StringUtils.isBlank(dimensionId) && "cubemeasure".equals(dimensionId)) {
List<CubeMeasure> cubeMeasureList = cubeMeasureRes.findByCubeid(id);
map.put("cubeMeasureList", cubeMeasureList);
}
map.put("cubeMetadataList", cubeMetadataRes.findByCubeid(id));
map.put("cubeid", id);
map.put("dimensionId", dimensionId);
map.put("msg", msg);
return request(super.createAppsTempletResponse("/apps/business/report/cube/detail"));
}
/**
* 模型验证
* @param map
* @param request
* @param id
* @return
*/
@RequestMapping("/cubevalid")
@Menu(type = "report" , subtype = "cube" )
public ModelAndView cubevalid(ModelMap map , HttpServletRequest request , @Valid String id) {
boolean hasMasterTable = false ;
Cube cube = cubeRes.findOne(id);
List<CubeMetadata> cubeMetadataList = cubeMetadataRes.findByCubeid(id);
if(!cubeMetadataList.isEmpty()) {
for(CubeMetadata cm:cubeMetadataList) {
//至少一个主表
if("0".equals(cm.getMtype())) {
hasMasterTable = true;
break;
}
}
}
boolean hasLeastMeasure = false ;
if("cube".equals(cube.getModeltype())) {
//立方体必须至少一个指标
List<CubeMeasure> cubeMeasureList = cubeMeasureRes.findByCubeid(id);
if(!cubeMeasureList.isEmpty()) {
hasLeastMeasure = true;
}
}
String msg = "";
if(!hasMasterTable) {
msg = "CUBE_VALID_FAILED_1";
}else if(!hasLeastMeasure) {
msg = "CUBE_VALID_FAILED_2";
}
map.put("msg", msg);
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+id+"&msg="+msg));
}
/**
* 模型发布页面加载
* @param request
* @param cubeid
* @return
* @throws Exception
*/
@RequestMapping("/cubepublish")
@Menu(type = "report" , subtype = "cube" )
public ModelAndView cubepublish(ModelMap map ,HttpServletRequest request , @Valid String cubeid,@Valid String isRecover) throws Exception{
map.put("cubeid", cubeid);
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubepublish"));
}
/**
* 模型发布
* @param request
* @param cubeid
* @return
* @throws Exception
*/
@RequestMapping("/cubepublished")
@Menu(type = "report" , subtype = "cube" )
public ModelAndView cubepublished(ModelMap map ,HttpServletRequest request , @Valid String cubeid,@Valid String isRecover) throws Exception{
this.cubevalid(map,request, cubeid) ;
if(!StringUtils.isBlank((String)map.get("msg"))) {
map.put("cubeid", cubeid);
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/index.html?msg="+ map.get("msg")));
}
User user = super.getUser(request);
Cube cube =this.getCube(cubeid);
PublishedCube publishCube = new PublishedCube();
MainUtils.copyProperties(cube, publishCube, "");
publishCube.setId(null);
Base64 base64 = new Base64();
publishCube.setCubecontent(base64.encodeToString(MainUtils.toBytes(cube))) ;
publishCube.setDataid(cubeid);
publishCube.setUserid(user.getId());
publishCube.setUsername(user.getUsername());
publishCube.setCreatetime(new Date());
List<PublishedCube> pbCubeList = publishedCubeRes.findByOrgiAndDataidOrderByDataversionDesc(super.getOrgi(request), cubeid);
if(!pbCubeList.isEmpty()){
int maxVersion = pbCubeList.get(0).getDataversion() ;
if("yes".equals(isRecover)){
publishCube.setId(pbCubeList.get(0).getId()) ;
publishCube.setDataversion(pbCubeList.get(0).getDataversion());
publishedCubeRes.save(publishCube);
}else if("no".equals(isRecover)){
publishCube.setDataversion(maxVersion+1) ;
publishedCubeRes.save(publishCube);
}else{
publishedCubeRes.delete(pbCubeList);
publishCube.setDataversion(1) ;
publishedCubeRes.save(publishCube);
}
}else{
publishCube.setDataversion(1) ;
publishedCubeRes.save(publishCube);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/index.html?typeid="+cube.getTypeid()));
}
/**
* 已发布模型列表
* @param map
* @param request
* @param typeid
* @param msg
* @return
*/
@RequestMapping("/pbcubeindex")
@Menu(type = "report" , subtype = "pbcube" )
public ModelAndView pbcubeindex(ModelMap map , HttpServletRequest request , @Valid String typeid) {
List<CubeType> cubeTypeList = cubeTypeRes.findByOrgi(super.getOrgi(request)) ;
if(!StringUtils.isBlank(typeid)){
map.put("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
map.put("cubeList", publishedCubeRes.getByOrgiAndTypeid(super.getOrgi(request) , typeid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("cubeList", publishedCubeRes.getByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("pubCubeTypeList", cubeTypeList) ;
map.put("typeid", typeid);
return request(super.createAppsTempletResponse("/apps/business/report/cube/pbCubeIndex"));
}
/**
* 已发布模型列表
* @param map
* @param request
* @param typeid
* @param msg
* @return
*/
@RequestMapping("/pbcubelist")
@Menu(type = "report" , subtype = "pbcube" )
public ModelAndView pbcubelist(ModelMap map , HttpServletRequest request , @Valid String typeid) {
if(!StringUtils.isBlank(typeid)){
map.put("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
map.put("cubeList", publishedCubeRes.getByOrgiAndTypeid(super.getOrgi(request) , typeid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("cubeList", publishedCubeRes.getByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("typeid", typeid);
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/pbcubelist"));
}
/**
* 已发布模型列表
* @param map
* @param request
* @param typeid
* @param msg
* @return
*/
@RequestMapping("/pbcubedelete")
@Menu(type = "report" , subtype = "pbcube" )
public ModelAndView pbcubedelete(ModelMap map , HttpServletRequest request , @Valid String id) {
PublishedCube pbCube = publishedCubeRes.findOne(id);
String typeid = "";
if(pbCube!=null) {
typeid = pbCube.getTypeid();
publishedCubeRes.delete(pbCube);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/pbcubeindex.html?typeid="+typeid));
}
/**
* 选择已发布模型列表
* @param map
* @param request
* @param typeid
* @param msg
* @return
*/
@RequestMapping("/selpbcubeindex")
@Menu(type = "report" , subtype = "pbcube" )
public ModelAndView selpbcubeindex(ModelMap map , HttpServletRequest request , @Valid String typeid,@Valid String mid) {
List<CubeType> cubeTypeList = cubeTypeRes.findByOrgi(super.getOrgi(request)) ;
if(!StringUtils.isBlank(typeid)){
map.put("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
map.put("cubeList", publishedCubeRes.getByOrgiAndTypeid(super.getOrgi(request) , typeid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("cubeList", publishedCubeRes.getByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("pubCubeTypeList", cubeTypeList) ;
map.put("typeid", typeid);
map.put("mid", mid);
return request(super.createRequestPageTempletResponse("/apps/business/report/design/cube/pbCubeIndex"));
}
/**
* 选择已发布模型列表
* @param map
* @param request
* @param typeid
* @param msg
* @return
*/
@RequestMapping("/selpbcubelist")
@Menu(type = "report" , subtype = "pbcube" )
public ModelAndView selpbcubelist(ModelMap map , HttpServletRequest request , @Valid String typeid, @Valid String mid) {
if(!StringUtils.isBlank(typeid)){
map.put("cubeType", cubeTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
map.put("cubeList", publishedCubeRes.getByOrgiAndTypeid(super.getOrgi(request) , typeid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("cubeList", publishedCubeRes.getByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("typeid", typeid);
map.put("mid", mid);
return request(super.createRequestPageTempletResponse("/apps/business/report/design/cube/pbcubelist"));
}
private Cube getCube(String id){
Cube cube = cubeRes.findOne(id);
if(cube!=null) {
cube.setMetadata(cubeMetadataRes.findByCubeid(id));
cube.setMeasure(cubeMeasureRes.findByCubeid(id));
cube.setDimension(dimensionRes.findByCubeid(id));
}
return cube;
}
}

View File

@ -1,161 +0,0 @@
/*
* 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.apps.report;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CubeLevel;
import com.chatopera.cc.model.CubeMetadata;
import com.chatopera.cc.model.Dimension;
import com.chatopera.cc.model.TableProperties;
import com.chatopera.cc.persistence.repository.CubeLevelRepository;
import com.chatopera.cc.persistence.repository.CubeMetadataRepository;
import com.chatopera.cc.persistence.repository.DimensionRepository;
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
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("/apps/report/cubelevel")
public class CubeLevelController extends Handler{
@Autowired
private CubeLevelRepository cubeLevelRes;
@Autowired
private DimensionRepository dimensionRes;
@Autowired
private TablePropertiesRepository tablePropertiesRes;
@Autowired
private CubeMetadataRepository cubeMetadataRes;
@RequestMapping("/add")
@Menu(type = "report" , subtype = "cubelevel")
public ModelAndView cubeLeveladd(ModelMap map , HttpServletRequest request , @Valid String cubeid,@Valid String dimid) {
map.addAttribute("cubeid", cubeid);
map.addAttribute("dimid", dimid);
//map.addAttribute("fktableList",cubeMetadataRes.findByCubeid(cubeid));
Dimension dim = dimensionRes.findByIdAndOrgi(dimid,super.getOrgi(request));
if(dim!=null){
if(!StringUtils.isBlank(dim.getFktable())) {
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dim.getFktable()));
}else {
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeid,"0");
if(!cmList.isEmpty() && cmList.get(0)!=null) {
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
}
}
}
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/add"));
}
@RequestMapping("/save")
@Menu(type = "report" , subtype = "cubelevel" )
public ModelAndView cubeLevelsave(ModelMap map , HttpServletRequest request , @Valid CubeLevel cubeLevel,@Valid String tableid) {
if(!StringUtils.isBlank(cubeLevel.getName())){
cubeLevel.setOrgi(super.getOrgi(request));
cubeLevel.setCreater(super.getUser(request).getId());
cubeLevel.setCode(cubeLevel.getColumname());
if(!StringUtils.isBlank(tableid)) {
TableProperties tb = new TableProperties();
tb.setId(tableid);
TableProperties t = tablePropertiesRes.findById(tableid);
cubeLevel.setTablename(t.getTablename());
cubeLevel.setCode(t.getFieldname());
cubeLevel.setColumname(t.getFieldname());
cubeLevel.setTableproperty(tb);
}
cubeLevelRes.save(cubeLevel) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeLevel.getCubeid()+"&dimensionId="+cubeLevel.getDimid()));
}
@RequestMapping("/delete")
@Menu(type = "report" , subtype = "cubelevel" )
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
CubeLevel cubeLevel = cubeLevelRes.findOne(id) ;
if(cubeLevel!=null){
cubeLevelRes.delete(cubeLevel);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeLevel.getCubeid()+"&dimensionId="+cubeLevel.getDimid()));
}
@RequestMapping("/edit")
@Menu(type = "report" , subtype = "cubelevel" , admin= true)
public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) {
CubeLevel cubeLevel = cubeLevelRes.findOne(id) ;
map.put("cubeLevel", cubeLevel) ;
Dimension dim = dimensionRes.findByIdAndOrgi(cubeLevel.getDimid(),super.getOrgi(request));
if(dim!=null){
if(!StringUtils.isBlank(dim.getFktable())) {
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dim.getFktable()));
map.addAttribute("tableid", dim.getFktable());
}else {
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeLevel.getCubeid(),"0");
if(!cmList.isEmpty() && cmList.get(0)!=null) {
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
map.addAttribute("tableid", cmList.get(0).getId());
}
}
}
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/edit"));
}
@RequestMapping("/update")
@Menu(type = "report" , subtype = "cubelevel" , admin= true)
public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid CubeLevel cubeLevel,@Valid String tableid) {
if(!StringUtils.isBlank(cubeLevel.getId())){
CubeLevel temp = cubeLevelRes.findOne(cubeLevel.getId()) ;
cubeLevel.setOrgi(super.getOrgi(request));
cubeLevel.setCreater(super.getUser(request).getId());
if(temp!=null){
cubeLevel.setCreatetime(temp.getCreatetime());
}
if(!StringUtils.isBlank(tableid)) {
TableProperties tb = new TableProperties();
tb.setId(tableid);
TableProperties t = tablePropertiesRes.findById(tableid);
cubeLevel.setTablename(t.getTablename());
cubeLevel.setCode(t.getFieldname());
cubeLevel.setColumname(t.getFieldname());
cubeLevel.setTableproperty(tb);
}
cubeLevelRes.save(cubeLevel) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeLevel.getCubeid()+"&dimensionId="+cubeLevel.getDimid()));
}
@RequestMapping("/fktableid")
@Menu(type = "report" , subtype = "cubelevel" , admin= true)
public ModelAndView fktableid(ModelMap map , HttpServletRequest request , @Valid String tableid) {
if(!StringUtils.isBlank(tableid)){
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
}
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/fktableiddiv"));
}
}

View File

@ -1,121 +0,0 @@
/*
* 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.apps.report;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CubeMeasure;
import com.chatopera.cc.model.CubeMetadata;
import com.chatopera.cc.persistence.repository.CubeMeasureRepository;
import com.chatopera.cc.persistence.repository.CubeMetadataRepository;
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
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("/apps/report/cubemeasure")
public class CubeMeasureController extends Handler{
@Autowired
private CubeMeasureRepository cubeMeasureRes;
@Autowired
private TablePropertiesRepository tablePropertiesRes;
@Autowired
private CubeMetadataRepository cubeMetadataRes;
@RequestMapping("/add")
@Menu(type = "report" , subtype = "cubemeasure")
public ModelAndView cubeMeasureadd(ModelMap map , HttpServletRequest request , @Valid String cubeid) {
map.addAttribute("cubeid", cubeid);
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeid,"0");
if(!cmList.isEmpty() && cmList.get(0)!=null) {
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
map.put("table", cmList.get(0).getTb());
}
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/add"));
}
@RequestMapping("/save")
@Menu(type = "report" , subtype = "cubemeasure" )
public ModelAndView cubeMeasuresave(ModelMap map , HttpServletRequest request , @Valid CubeMeasure cubeMeasure) {
if(!StringUtils.isBlank(cubeMeasure.getName())){
cubeMeasure.setOrgi(super.getOrgi(request));
cubeMeasure.setCreater(super.getUser(request).getId());
cubeMeasure.setCode(cubeMeasure.getColumname());
cubeMeasureRes.save(cubeMeasure) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id="+cubeMeasure.getCubeid()));
}
@RequestMapping("/delete")
@Menu(type = "report" , subtype = "cubemeasure" )
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
CubeMeasure cubeMeasure = cubeMeasureRes.findOne(id) ;
if(cubeMeasure!=null){
cubeMeasureRes.delete(cubeMeasure);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id="+cubeMeasure.getCubeid()));
}
@RequestMapping("/edit")
@Menu(type = "report" , subtype = "cubemeasure" , admin= true)
public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) {
CubeMeasure cubeMeasure = cubeMeasureRes.findOne(id) ;
map.put("cubemeasure", cubeMeasure) ;
if(cubeMeasure!=null) {
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeMeasure.getCubeid(),"0");
if(!cmList.isEmpty() && cmList.get(0)!=null) {
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
map.put("table", cmList.get(0).getTb());
}
}
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/edit"));
}
@RequestMapping("/update")
@Menu(type = "report" , subtype = "cubemeasure" , admin= true)
public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid CubeMeasure cubeMeasure) {
if(!StringUtils.isBlank(cubeMeasure.getId())){
CubeMeasure temp = cubeMeasureRes.findOne(cubeMeasure.getId()) ;
cubeMeasure.setOrgi(super.getOrgi(request));
cubeMeasure.setCreater(super.getUser(request).getId());
if(temp!=null){
cubeMeasure.setCreatetime(temp.getCreatetime());
}
cubeMeasure.setCode(cubeMeasure.getColumname());
cubeMeasureRes.save(cubeMeasure) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id="+cubeMeasure.getCubeid()));
}
@RequestMapping("/fktableid")
@Menu(type = "report" , subtype = "cubemeasure" , admin= true)
public ModelAndView fktableid(ModelMap map , HttpServletRequest request , @Valid String tableid) {
if(!StringUtils.isBlank(tableid)){
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
}
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/fktableiddiv"));
}
}

View File

@ -1,124 +0,0 @@
/*
* 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.apps.report;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CubeLevel;
import com.chatopera.cc.model.CubeMetadata;
import com.chatopera.cc.model.Dimension;
import com.chatopera.cc.persistence.repository.CubeLevelRepository;
import com.chatopera.cc.persistence.repository.CubeMetadataRepository;
import com.chatopera.cc.persistence.repository.DimensionRepository;
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
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("/apps/report/dimension")
public class DimensionController extends Handler{
@Autowired
private DimensionRepository dimensionRes;
@Autowired
private CubeLevelRepository cubeLevelRes;
@Autowired
private CubeMetadataRepository cubeMetadataRes;
@Autowired
private TablePropertiesRepository tablePropertiesRes;
@RequestMapping("/add")
@Menu(type = "report" , subtype = "dimension")
public ModelAndView dimensionadd(ModelMap map , HttpServletRequest request , @Valid String cubeid) {
map.addAttribute("cubeid", cubeid);
map.addAttribute("fkfieldList",cubeMetadataRes.findByCubeidAndMtype(cubeid,"0"));
map.addAttribute("fktableList",cubeMetadataRes.findByCubeidAndMtypeNot(cubeid,"0"));
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/add"));
}
@RequestMapping("/save")
@Menu(type = "report" , subtype = "dimension" )
public ModelAndView dimensionsave(ModelMap map , HttpServletRequest request , @Valid Dimension dimension) {
if(!StringUtils.isBlank(dimension.getName())){
dimension.setOrgi(super.getOrgi(request));
dimension.setCreater(super.getUser(request).getId());
dimensionRes.save(dimension) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+dimension.getCubeid()+"&dimensionId="+dimension.getId()));
}
@RequestMapping("/delete")
@Menu(type = "report" , subtype = "dimension" )
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
Dimension dimension = dimensionRes.findOne(id) ;
if(dimension!=null){
dimensionRes.delete(dimension);
List<CubeLevel> cubeLevelList = cubeLevelRes.findByOrgiAndDimid(super.getOrgi(request), id);
if(!cubeLevelList.isEmpty()) {
cubeLevelRes.delete(cubeLevelList);
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+dimension.getCubeid()));
}
@RequestMapping("/edit")
@Menu(type = "report" , subtype = "dimension" , admin= true)
public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) {
Dimension dimension = dimensionRes.findOne(id) ;
map.put("dimension", dimension) ;
String cubeid = dimension.getCubeid();
map.addAttribute("cubeid", cubeid);
map.addAttribute("fkfieldList",cubeMetadataRes.findByCubeidAndMtype(cubeid,"0"));
List<CubeMetadata> fktableList = cubeMetadataRes.findByCubeidAndMtypeNot(cubeid,"0");
map.addAttribute("fktableList",fktableList);
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dimension.getFktable()));
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/edit"));
}
@RequestMapping("/update")
@Menu(type = "report" , subtype = "dimension" , admin= true)
public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid Dimension dimension) {
if(!StringUtils.isBlank(dimension.getId())){
Dimension temp = dimensionRes.findOne(dimension.getId()) ;
dimension.setOrgi(super.getOrgi(request));
dimension.setCreater(super.getUser(request).getId());
if(temp!=null){
dimension.setCreatetime(temp.getCreatetime());
}
dimensionRes.save(dimension) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+dimension.getCubeid()+"&dimensionId="+dimension.getId()));
}
@RequestMapping("/fktableid")
@Menu(type = "report" , subtype = "dimension" , admin= true)
public ModelAndView fktableid(ModelMap map , HttpServletRequest request , @Valid String tableid) {
if(!StringUtils.isBlank(tableid)){
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
}
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/fktableiddiv"));
}
}

View File

@ -1,387 +0,0 @@
/*
* 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.apps.report;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.dsdata.DSData;
import com.chatopera.cc.util.dsdata.DSDataEvent;
import com.chatopera.cc.util.dsdata.ExcelImportProecess;
import com.chatopera.cc.util.dsdata.export.ExcelExporterProcess;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@RequestMapping("/apps/report")
public class ReportController extends Handler{
@Value("${web.upload-path}")
private String path;
@Value("${uk.im.server.port}")
private Integer port;
@Autowired
private DataDicRepository dataDicRes;
@Autowired
private ReportRepository reportRes;
@Autowired
private PublishedReportRepository publishedReportRes;
@Autowired
private MetadataRepository metadataRes ;
@Autowired
private ReportCubeService reportCubeService;
@RequestMapping("/index")
@Menu(type = "setting" , subtype = "report" , admin= true)
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String dicid) {
if(!StringUtils.isBlank(dicid) && !"0".equals(dicid)){
map.put("dataDic", dataDicRes.findByIdAndOrgi(dicid, super.getOrgi(request))) ;
map.put("reportList", reportRes.findByOrgiAndDicid(super.getOrgi(request) , dicid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("reportList", reportRes.findByOrgi(super.getOrgi(request) , new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("dataDicList", dataDicRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createAppsTempletResponse("/apps/business/report/index"));
}
@RequestMapping("/add")
@Menu(type = "setting" , subtype = "reportadd" , admin= true)
public ModelAndView quickreplyadd(ModelMap map , HttpServletRequest request , @Valid String dicid) {
if(!StringUtils.isBlank(dicid)){
map.addAttribute("dataDic", dataDicRes.findByIdAndOrgi(dicid, super.getOrgi(request))) ;
}
map.addAttribute("dataDicList", dataDicRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/business/report/add"));
}
@RequestMapping("/save")
@Menu(type = "setting" , subtype = "report" , admin= true)
public ModelAndView quickreplysave(ModelMap map , HttpServletRequest request , @Valid Report report) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?dicid="+report.getDicid()));
if(!StringUtils.isBlank(report.getName())){
int count = reportRes.countByOrgiAndName(super.getOrgi(request), report.getName()) ;
if(count == 0) {
report.setOrgi(super.getOrgi(request));
report.setCreater(super.getUser(request).getId());
report.setReporttype(MainContext.ReportType.REPORT.toString());
report.setCode(MainUtils.genID());
reportRes.save(report) ;
}else {
view = request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?msg=rt_name_exist&dicid="+report.getDicid()));
}
}
return view ;
}
@RequestMapping("/delete")
@Menu(type = "setting" , subtype = "report" , admin= true)
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
Report report = reportRes.findOne(id) ;
if(report!=null){
reportRes.delete(report);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?dicid="+report.getDicid()));
}
@RequestMapping("/edit")
@Menu(type = "setting" , subtype = "report" , admin= true)
public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) {
Report report = reportRes.findOne(id) ;
map.put("report", report) ;
if(report!=null){
map.put("dataDic", dataDicRes.findByIdAndOrgi(report.getDicid(), super.getOrgi(request))) ;
}
map.addAttribute("dataDicList", dataDicRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/business/report/edit"));
}
@RequestMapping("/update")
@Menu(type = "setting" , subtype = "report" , admin= true)
public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid Report report) {
if(!StringUtils.isBlank(report.getId())){
Report temp = reportRes.findOne(report.getId()) ;
if(temp!=null) {
temp.setName(report.getName());
temp.setCode(report.getCode());
temp.setDicid(report.getDicid());
temp.setUpdatetime(new Date());
temp.setDescription(report.getDescription());
reportRes.save(temp) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?dicid="+report.getDicid()));
}
@RequestMapping({"/addtype"})
@Menu(type="apps", subtype="kbs")
public ModelAndView addtype(ModelMap map , HttpServletRequest request , @Valid String dicid){
map.addAttribute("dataDicList", dataDicRes.findByOrgi(super.getOrgi(request))) ;
if(!StringUtils.isBlank(dicid)){
map.addAttribute("dataDic", dataDicRes.findByIdAndOrgi(dicid, super.getOrgi(request))) ;
}
return request(super.createRequestPageTempletResponse("/apps/business/report/addtype"));
}
@RequestMapping("/type/save")
@Menu(type = "apps" , subtype = "report")
public ModelAndView typesave(HttpServletRequest request ,@Valid DataDic dataDic) {
List<DataDic> dicList = dataDicRes.findByOrgiAndName(super.getOrgi(request),dataDic.getName()) ;
if(dicList!=null && dicList.size() > 0){
return request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?dicid="+dataDic.getParentid()+"&msg=qr_type_exist"));
}else {
dataDic.setOrgi(super.getOrgi(request));
dataDic.setCreater(super.getUser(request).getId());
dataDic.setCreatetime(new Date());
dataDic.setTabtype(MainContext.QuickType.PUB.toString());
dataDicRes.save(dataDic) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?dicid="+dataDic.getId()));
}
@RequestMapping({"/edittype"})
@Menu(type="apps", subtype="kbs")
public ModelAndView edittype(ModelMap map , HttpServletRequest request , String id){
DataDic dataDic = dataDicRes.findByIdAndOrgi(id, super.getOrgi(request)) ;
map.addAttribute("dataDic", dataDic) ;
if(dataDic!=null) {
map.addAttribute("parentDataDic", dataDicRes.findByIdAndOrgi(dataDic.getParentid(), super.getOrgi(request))) ;
}
map.addAttribute("dataDicList", dataDicRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/business/report/edittype"));
}
@RequestMapping("/type/update")
@Menu(type = "apps" , subtype = "report")
public ModelAndView typeupdate(HttpServletRequest request ,@Valid DataDic dataDic) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?dicid="+dataDic.getId()));
DataDic tempDataDic= dataDicRes.findByIdAndOrgi(dataDic.getId(), super.getOrgi(request)) ;
if(tempDataDic !=null){
//判断名称是否重复
List<DataDic> dicList = dataDicRes.findByOrgiAndNameAndIdNot(super.getOrgi(request) , dataDic.getName() , dataDic.getId()) ;
if(dicList!=null && dicList.size() > 0) {
view = request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?msg=qr_type_exist&dicid="+dataDic.getId()));
}else {
tempDataDic.setName(dataDic.getName());
tempDataDic.setDescription(dataDic.getDescription());
tempDataDic.setParentid(dataDic.getParentid());
dataDicRes.save(tempDataDic) ;
}
}
return view ;
}
@RequestMapping({"/deletetype"})
@Menu(type="apps", subtype="kbs")
public ModelAndView deletetype(ModelMap map , HttpServletRequest request , @Valid String id){
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?dicid="+id));
if(!StringUtils.isBlank(id)){
DataDic tempDataDic = dataDicRes.findByIdAndOrgi(id, super.getOrgi(request)) ;
int count = reportRes.countByOrgiAndDicid(super.getOrgi(request), id) ;
if(count == 0) {
dataDicRes.delete(tempDataDic);
view = request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?dicid="+tempDataDic.getParentid()));
}else {
view = request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html?msg=report_exist&dicid="+id));
}
}
return view ;
}
@RequestMapping("/imp")
@Menu(type = "setting" , subtype = "reportimp")
public ModelAndView imp(ModelMap map , HttpServletRequest request , @Valid String type) {
map.addAttribute("type", type) ;
return request(super.createRequestPageTempletResponse("/apps/business/report/imp"));
}
@RequestMapping("/impsave")
@Menu(type = "setting" , subtype = "reportimpsave")
public ModelAndView impsave(ModelMap map , HttpServletRequest request , @RequestParam(value = "cusfile", required = false) MultipartFile cusfile , @Valid String type) throws IOException {
DSDataEvent event = new DSDataEvent();
String fileName = "quickreply/"+ MainUtils.getUUID()+cusfile.getOriginalFilename().substring(cusfile.getOriginalFilename().lastIndexOf(".")) ;
File excelFile = new File(path , fileName) ;
if(!excelFile.getParentFile().exists()){
excelFile.getParentFile().mkdirs() ;
}
MetadataTable table = metadataRes.findByTablename("uk_report") ;
if(table!=null){
FileUtils.writeByteArrayToFile(new File(path , fileName), cusfile.getBytes());
event.setDSData(new DSData(table,excelFile , cusfile.getContentType(), super.getUser(request)));
event.getDSData().setClazz(Report.class);
event.setOrgi(super.getOrgi(request));
if(!StringUtils.isBlank(type)){
event.getValues().put("cate", type) ;
}else{
event.getValues().put("cate", Constants.DEFAULT_TYPE) ;
}
event.getValues().put("type", MainContext.QuickType.PUB.toString()) ;
event.getValues().put("creater", super.getUser(request).getId()) ;
// exchange.getDSData().setProcess(new QuickReplyProcess(reportRes));
// reporterRes.save(exchange.getDSData().getReport()) ;
new ExcelImportProecess(event).process() ; //启动导入任务
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html"+(!StringUtils.isBlank(type)? "?dicid="+type:"")));
}
@RequestMapping("/batdelete")
@Menu(type = "setting" , subtype = "reportbatdelete")
public ModelAndView batdelete(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String[] ids ,@Valid String type) throws IOException {
if(ids!=null && ids.length > 0){
Iterable<Report> topicList = reportRes.findAll(Arrays.asList(ids)) ;
reportRes.delete(topicList);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/index.html"+(!StringUtils.isBlank(type) ? "?dicid="+type:"")));
}
@RequestMapping("/expids")
@Menu(type = "setting" , subtype = "reportexpids")
public void expids(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String[] ids) throws IOException {
if(ids!=null && ids.length > 0){
Iterable<Report> topicList = reportRes.findAll(Arrays.asList(ids)) ;
MetadataTable table = metadataRes.findByTablename("uk_report") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(Report topic : topicList){
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Report-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
}
return ;
}
@RequestMapping("/expall")
@Menu(type = "setting" , subtype = "reportexpall")
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response,@Valid String type) throws IOException {
List<Report> reportList = reportRes.findByOrgiAndDicid(super.getOrgi(request) , type) ;
MetadataTable table = metadataRes.findByTablename("uk_report") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(Report report : reportList){
values.add(MainUtils.transBean2Map(report)) ;
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Report-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
return ;
}
@RequestMapping("/pbreportindex")
@Menu(type = "setting" , subtype = "pbreport" , admin= true)
public ModelAndView pbreportindex(ModelMap map , HttpServletRequest request , @Valid String dicid) {
if(!StringUtils.isBlank(dicid) && !"0".equals(dicid)){
map.put("dataDic", dataDicRes.findByIdAndOrgi(dicid, super.getOrgi(request))) ;
map.put("reportList", publishedReportRes.findByOrgiAndDicid(super.getOrgi(request) , dicid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("reportList", publishedReportRes.findByOrgi(super.getOrgi(request) , new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("dataDicList", dataDicRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createAppsTempletResponse("/apps/business/report/pbreportindex"));
}
@RequestMapping("/pbreportlist")
@Menu(type = "setting" , subtype = "pbreport" , admin= true)
public ModelAndView pbreportlist(ModelMap map , HttpServletRequest request , @Valid String dicid) {
if(!StringUtils.isBlank(dicid) && !"0".equals(dicid)){
map.put("dataDic", dataDicRes.findByIdAndOrgi(dicid, super.getOrgi(request))) ;
map.put("reportList", publishedReportRes.findByOrgiAndDicid(super.getOrgi(request) , dicid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("reportList", publishedReportRes.findByOrgi(super.getOrgi(request) , new PageRequest(super.getP(request), super.getPs(request)))) ;
}
map.put("dataDicList", dataDicRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/business/report/pbreportlist"));
}
@RequestMapping("/pbdelete")
@Menu(type = "setting" , subtype = "pbreport" , admin= true)
public ModelAndView pbdelete(ModelMap map , HttpServletRequest request , @Valid String id) {
PublishedReport report = publishedReportRes.findOne(id) ;
if(report!=null){
publishedReportRes.delete(report);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/report/pbreportindex.html?dicid="+report.getDicid()));
}
/**
* 报表
* @param map
* @param request
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/view")
@Menu(type = "report", subtype = "report")
public ModelAndView view(ModelMap map, HttpServletRequest request, @Valid String id) throws Exception {
if (!StringUtils.isBlank(id)) {
PublishedReport publishedReport = publishedReportRes.findById(id);
if(publishedReport!=null) {
map.addAttribute("publishedReport", publishedReport);
map.addAttribute("report", publishedReport.getReport());
map.addAttribute("reportModels", publishedReport.getReport().getReportModels());
List<ReportFilter> listFilters = publishedReport.getReport().getReportFilters();
if(!listFilters.isEmpty()) {
Map<String,ReportFilter> filterMap = new HashMap<String,ReportFilter>();
for(ReportFilter rf:listFilters) {
filterMap.put(rf.getId(), rf);
}
for(ReportFilter rf:listFilters) {
if(!StringUtils.isBlank(rf.getCascadeid())) {
rf.setChildFilter(filterMap.get(rf.getCascadeid()));
}
}
}
map.addAttribute("reportFilters", reportCubeService.fillReportFilterData(listFilters, request));
}
}
return request(super.createRequestPageTempletResponse("/apps/business/report/view"));
}
}

View File

@ -1,106 +0,0 @@
/*
* 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.apps.report;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PublishedReport;
import com.chatopera.cc.model.ReportFilter;
import com.chatopera.cc.persistence.repository.DataDicRepository;
import com.chatopera.cc.persistence.repository.PublishedReportRepository;
import com.chatopera.cc.persistence.repository.ReportCubeService;
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.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/apps/view")
public class ReportViewController extends Handler{
@Value("${web.upload-path}")
private String path;
@Value("${uk.im.server.port}")
private Integer port;
@Autowired
private DataDicRepository dataDicRes;
@Autowired
private PublishedReportRepository publishedReportRes;
@Autowired
private ReportCubeService reportCubeService;
@RequestMapping("/index")
@Menu(type = "setting" , subtype = "report" , admin= true)
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String dicid , @Valid String id) throws Exception {
Page<PublishedReport> publishedReportList = null ;
if(!StringUtils.isBlank(dicid) && !"0".equals(dicid)){
map.put("dataDic", dataDicRes.findByIdAndOrgi(dicid, super.getOrgi(request))) ;
map.put("reportList", publishedReportList = publishedReportRes.findByOrgiAndDicid(super.getOrgi(request) , dicid , new PageRequest(super.getP(request), super.getPs(request)))) ;
}else{
map.put("reportList", publishedReportList = publishedReportRes.findByOrgi(super.getOrgi(request) , new PageRequest(super.getP(request), super.getPs(request)))) ;
}
if(publishedReportList!=null && publishedReportList.getContent().size() > 0) {
PublishedReport publishedReport = publishedReportList.getContent().get(0);
if(!StringUtils.isBlank(id)) {
for(PublishedReport report : publishedReportList) {
if(report.getId().equals(id)) {
publishedReport = report ; break ;
}
}
}
map.put("report", publishedReport) ;
if(publishedReport!=null) {
map.addAttribute("publishedReport", publishedReport);
map.addAttribute("report", publishedReport.getReport());
map.addAttribute("reportModels", publishedReport.getReport().getReportModels());
List<ReportFilter> listFilters = publishedReport.getReport().getReportFilters();
if(!listFilters.isEmpty()) {
Map<String,ReportFilter> filterMap = new HashMap<String,ReportFilter>();
for(ReportFilter rf:listFilters) {
filterMap.put(rf.getId(), rf);
}
for(ReportFilter rf:listFilters) {
if(!StringUtils.isBlank(rf.getCascadeid())) {
rf.setChildFilter(filterMap.get(rf.getCascadeid()));
}
}
}
map.addAttribute("reportFilters", reportCubeService.fillReportFilterData(listFilters, request));
}
}
map.put("dataDicList", dataDicRes.findByOrgi(super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/apps/business/view/index"));
}
}

View File

@ -121,7 +121,7 @@ public class AgentSummaryController extends Handler{
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ;
return request(super.createAppsTempletResponse("/apps/service/summary/index"));
return request(super.createView("/apps/service/summary/index"));
}
@RequestMapping(value = "/process")
@ -139,7 +139,7 @@ public class AgentSummaryController extends Handler{
}
}
return request(super.createRequestPageTempletResponse("/apps/service/summary/process"));
return request(super.createView("/apps/service/summary/process"));
}
@RequestMapping(value = "/save")
@ -154,7 +154,7 @@ public class AgentSummaryController extends Handler{
serviceSummaryRes.save(oldSummary) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/agent/summary/index.html"));
return request(super.createView("redirect:/apps/agent/summary/index.html"));
}
@RequestMapping("/expids")

View File

@ -163,7 +163,7 @@ public class ChatServiceController extends Handler {
map.put("deptlist", organs.values());
map.put("userlist", userProxy.findUserInOrgans(organs.keySet()));
return request(super.createAppsTempletResponse("/apps/service/history/index"));
return request(super.createView("/apps/service/history/index"));
}
@RequestMapping("/current/index")
@ -181,7 +181,7 @@ public class ChatServiceController extends Handler {
super.getPs(request), Direction.DESC,
"createtime")));
return request(super.createAppsTempletResponse("/apps/service/current/index"));
return request(super.createView("/apps/service/current/index"));
}
@RequestMapping("/current/trans")
@ -224,7 +224,7 @@ public class ChatServiceController extends Handler {
map.addAttribute("currentorgan", currentOrgan);
}
return request(super.createRequestPageTempletResponse("/apps/service/current/transfer"));
return request(super.createView("/apps/service/current/transfer"));
}
@RequestMapping(value = "/transfer/save")
@ -317,7 +317,7 @@ public class ChatServiceController extends Handler {
}
}
return request(super.createRequestPageTempletResponse("redirect:/service/current/index.html"));
return request(super.createView("redirect:/service/current/index.html"));
}
@RequestMapping("/current/end")
@ -336,7 +336,7 @@ public class ChatServiceController extends Handler {
agentServiceRes.save(agentService);
}
}
return request(super.createRequestPageTempletResponse("redirect:/service/current/index.html"));
return request(super.createView("redirect:/service/current/index.html"));
}
/**
@ -395,7 +395,7 @@ public class ChatServiceController extends Handler {
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/service/current/index.html"));
return request(super.createView("redirect:/service/current/index.html"));
}
@ -429,7 +429,7 @@ public class ChatServiceController extends Handler {
}
map.put("agentUserList", agentUserList);
return request(super.createAppsTempletResponse("/apps/service/quene/index"));
return request(super.createView("/apps/service/quene/index"));
}
@RequestMapping("/quene/transfer")
@ -469,7 +469,7 @@ public class ChatServiceController extends Handler {
map.addAttribute("skillGroups", skillGroups);
map.addAttribute("currentorgan", currentOrgan);
}
return request(super.createRequestPageTempletResponse("/apps/service/quene/transfer"));
return request(super.createView("/apps/service/quene/transfer"));
}
@RequestMapping("/quene/transfer/save")
@ -484,7 +484,7 @@ public class ChatServiceController extends Handler {
agentUser, false, MainContext.ChatInitiatorType.USER.toString());
acdVisitorDispatcher.enqueue(ctx);
}
return request(super.createRequestPageTempletResponse("redirect:/service/quene/index.html"));
return request(super.createView("redirect:/service/quene/index.html"));
}
@RequestMapping("/quene/invite")
@ -496,7 +496,7 @@ public class ChatServiceController extends Handler {
if (agentUser != null && agentUser.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())) {
acdAgentService.assignVisitorAsInvite(logined.getId(), agentUser, orgi);
}
return request(super.createRequestPageTempletResponse("redirect:/service/quene/index.html"));
return request(super.createView("redirect:/service/quene/index.html"));
}
/**
@ -522,7 +522,7 @@ public class ChatServiceController extends Handler {
}
}
map.put("agentStatusList", lis);
return request(super.createAppsTempletResponse("/apps/service/agent/index"));
return request(super.createView("/apps/service/agent/index"));
}
/**
@ -546,7 +546,7 @@ public class ChatServiceController extends Handler {
agentStatusProxy.broadcastAgentsStatus(
super.getOrgi(request), "agent", "offline", super.getUser(request).getId());
return request(super.createRequestPageTempletResponse("redirect:/service/agent/index.html"));
return request(super.createView("redirect:/service/agent/index.html"));
}
/**
@ -576,7 +576,7 @@ public class ChatServiceController extends Handler {
map.put("userList", userList);
map.put("onlines", onlines);
return request(super.createAppsTempletResponse("/apps/service/user/index"));
return request(super.createView("/apps/service/user/index"));
}
@RequestMapping("/leavemsg/index")
@ -593,7 +593,7 @@ public class ChatServiceController extends Handler {
}
map.put("leaveMsgList", leaveMsgs);
return request(super.createAppsTempletResponse("/apps/service/leavemsg/index"));
return request(super.createView("/apps/service/leavemsg/index"));
}
@RequestMapping("/leavemsg/delete")
@ -602,6 +602,6 @@ public class ChatServiceController extends Handler {
if (StringUtils.isNotBlank(id)) {
leaveMsgRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/service/leavemsg/index.html"));
return request(super.createView("redirect:/service/leavemsg/index"));
}
}

View File

@ -50,6 +50,6 @@ public class CommentController extends Handler{
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<AgentService> agentServiceList = agentServiceRes.findByOrgiAndSatisfactionAndSkillIn(super.getOrgi(request) , true ,organs.keySet(),new PageRequest(super.getP(request), super.getPs(request))) ;
map.addAttribute("serviceList", agentServiceList) ;
return request(super.createAppsTempletResponse("/apps/service/comment/index"));
return request(super.createView("/apps/service/comment/index"));
}
}

View File

@ -174,11 +174,12 @@ public class OnlineUserController extends Handler {
cache.findOneAgentUserByUserIdAndOrgi(userid, orgi).ifPresent(agentUser -> {
map.put("agentUser", agentUser);
map.put("curagentuser", agentUser);
});
}
return request(super.createAppsTempletResponse("/apps/service/online/index"));
return request(super.createView("/apps/service/online/index"));
}
@RequestMapping("/online/chatmsg")
@ -187,7 +188,7 @@ public class OnlineUserController extends Handler {
AgentService agentService = agentServiceRes.getOne(id);
map.put("curAgentService", agentService);
cache.findOneAgentUserByUserIdAndOrgi(agentService.getUserid(), super.getOrgi(request)).ifPresent(p -> {
map.put("curragentuser", p);
map.put("curagentuser", p);
});
if (StringUtils.isNotBlank(title)) {
@ -213,7 +214,7 @@ public class OnlineUserController extends Handler {
new PageRequest(0, 50, Direction.DESC,
"updatetime")));
return request(super.createRequestPageTempletResponse("/apps/service/online/chatmsg"));
return request(super.createView("/apps/service/online/chatmsg"));
}
@RequestMapping("/trace")
@ -228,6 +229,6 @@ public class OnlineUserController extends Handler {
"traceHisList", userEventRes.findBySessionidAndOrgi(sessionid, super.getOrgi(request),
new PageRequest(0, 100)));
}
return request(super.createRequestPageTempletResponse("/apps/service/online/trace"));
return request(super.createView("/apps/service/online/trace"));
}
}

View File

@ -125,7 +125,7 @@ public class ProcessedSummaryController extends Handler {
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString()));
return request(super.createAppsTempletResponse("/apps/service/processed/index"));
return request(super.createView("/apps/service/processed/index"));
}
@ -144,7 +144,7 @@ public class ProcessedSummaryController extends Handler {
}
}
return request(super.createRequestPageTempletResponse("/apps/service/processed/process"));
return request(super.createView("/apps/service/processed/process"));
}
@RequestMapping(value = "/save")
@ -159,7 +159,7 @@ public class ProcessedSummaryController extends Handler {
serviceSummaryRes.save(oldSummary);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/agent/processed/index.html"));
return request(super.createView("redirect:/apps/agent/processed/index.html"));
}
@RequestMapping("/expids")

View File

@ -90,7 +90,7 @@ public class StatsController extends Handler {
mapR.put("skill", organs.keySet().stream().map(p -> "'" + p + "'").collect(Collectors.joining(",")));
}
ReportData reportData = new CubeService("coment.xml", path, dataSource, mapR).execute("SELECT [comment].[满意度].members on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [满意度]");
ReportData reportData = new CubeService("coment.pug", path, dataSource, mapR).execute("SELECT [comment].[满意度].members on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [满意度]");
List<SysDic> dicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_DIC);
for (Level title : reportData.getCol().getChilderen()) {
@ -120,7 +120,7 @@ public class StatsController extends Handler {
*/
map.addAttribute("skillGroups", organs.values());
return request(super.createAppsTempletResponse("/apps/service/stats/coment"));
return request(super.createView("/apps/service/stats/coment"));
}
@RequestMapping("/stats/coment/exp")
@ -138,7 +138,7 @@ public class StatsController extends Handler {
mapR.put("skill", organs.keySet().stream().map(p -> "'" + p + "'").collect(Collectors.joining(",")));
}
mapR.put("orgi", super.getOrgi(request));
ReportData reportData = new CubeService("coment.xml", path, dataSource, mapR).execute("SELECT [comment].[满意度].members on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [满意度]");
ReportData reportData = new CubeService("coment.pug", path, dataSource, mapR).execute("SELECT [comment].[满意度].members on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [满意度]");
List<SysDic> dicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_DIC);
for (Level title : reportData.getCol().getChilderen()) {
@ -173,7 +173,7 @@ public class StatsController extends Handler {
mapR.put("skill", organs.keySet().stream().map(p -> "'" + p + "'").collect(Collectors.joining(",")));
}
mapR.put("orgi", super.getOrgi(request));
ReportData reportData = new CubeService("consult.xml", path, dataSource, mapR).execute("SELECT {[Measures].[咨询数量],[Measures].[平均等待时长(秒)],[Measures].[平均咨询时长(秒)]} on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [咨询]");
ReportData reportData = new CubeService("consult.pug", path, dataSource, mapR).execute("SELECT {[Measures].[咨询数量],[Measures].[平均等待时长(秒)],[Measures].[平均咨询时长(秒)]} on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [咨询]");
map.addAttribute("reportData", reportData);
if (StringUtils.isNotBlank(agent)) {
@ -189,7 +189,7 @@ public class StatsController extends Handler {
* 查询 技能组 缓存
*/
map.addAttribute("skillGroups", organs.values());
return request(super.createAppsTempletResponse("/apps/service/stats/consult"));
return request(super.createView("/apps/service/stats/consult"));
}
@RequestMapping("/stats/agent/exp")
@ -207,7 +207,7 @@ public class StatsController extends Handler {
mapR.put("skill", organs.keySet().stream().map(p -> "'" + p + "'").collect(Collectors.joining(",")));
}
mapR.put("orgi", super.getOrgi(request));
ReportData reportData = new CubeService("consult.xml", path, dataSource, mapR).execute("SELECT {[Measures].[咨询数量],[Measures].[平均等待时长(秒)],[Measures].[平均咨询时长(秒)]} on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [咨询]");
ReportData reportData = new CubeService("consult.pug", path, dataSource, mapR).execute("SELECT {[Measures].[咨询数量],[Measures].[平均等待时长(秒)],[Measures].[平均咨询时长(秒)]} on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [咨询]");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Report-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
new UKExcelUtil(reportData, response.getOutputStream(), "客服坐席统计").createFile();
return;

View File

@ -16,6 +16,8 @@
*/
package com.chatopera.cc.controller.resource;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.User;
@ -27,6 +29,7 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.persistence.criteria.CriteriaBuilder;
@ -41,43 +44,54 @@ import java.util.List;
@Controller
public class CallAgentResourceController extends Handler {
@Autowired
private UserRepository userRes ;
@RequestMapping("/res/agent")
@Menu(type = "res" , subtype = "agent")
public ModelAndView add(ModelMap map , HttpServletRequest request , @Valid String q) {
if(q==null){
q = "" ;
}
final String search = q;
final String orgi = super.getOrgi(request);
final List<String> organList = CallCenterUtils.getExistOrgan(super.getUser(request));
map.put("owneruserList", userRes.findAll(new Specification<User>(){
@Override
public Predicate toPredicate(Root<User> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
In<Object> in = cb.in(root.get("organ"));
list.add(cb.equal(root.get("orgi").as(String.class),orgi ));
list.add(cb.or(cb.like(root.get("username").as(String.class),"%"+search+"%" ),cb.like(root.get("uname").as(String.class),"%"+search+"%" )));
if(organList.size() > 0){
for(String id : organList){
in.value(id) ;
}
}else{
in.value(Constants.CSKEFU_SYSTEM_NO_DAT) ;
}
list.add(in) ;
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}}));
return request(super.createRequestPageTempletResponse("/public/agent"));
@Autowired
private UserRepository userRes;
@RequestMapping("/res/agent")
@Menu(type = "res", subtype = "agent")
@ResponseBody
public String add(ModelMap map, HttpServletRequest request, @Valid String q) {
if (q == null) {
q = "";
}
final String search = q;
final String orgi = super.getOrgi(request);
final List<String> organList = CallCenterUtils.getExistOrgan(super.getUser(request));
List<User> owneruserList = userRes.findAll(new Specification<User>() {
@Override
public Predicate toPredicate(Root<User> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
In<Object> in = cb.in(root.get("organ"));
list.add(cb.equal(root.get("orgi").as(String.class), orgi));
list.add(cb.or(cb.like(root.get("username").as(String.class), "%" + search + "%"), cb.like(root.get("uname").as(String.class), "%" + search + "%")));
if (organList.size() > 0) {
for (String id : organList) {
in.value(id);
}
} else {
in.value(Constants.CSKEFU_SYSTEM_NO_DAT);
}
list.add(in);
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
});
JSONArray result = new JSONArray();
for (User owneruser : owneruserList) {
JSONObject item = new JSONObject();
item.put("id", owneruser.getId());
item.put("text", owneruser.getUsername());
result.add(item);
}
return result.toJSONString();
}
}

View File

@ -16,32 +16,48 @@
*/
package com.chatopera.cc.controller.resource;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Contacts;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.es.ContactsRepository;
import com.chatopera.cc.util.Menu;
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;
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;
@Controller
public class ContactsResourceController extends Handler{
@Autowired
private ContactsRepository contactsRes ;
@RequestMapping("/res/contacts")
@Menu(type = "res" , subtype = "contacts")
public ModelAndView add(ModelMap map , HttpServletRequest request , @Valid String q) {
if(q==null){
q = "" ;
}
map.addAttribute("contactsList", contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(),super.getUser(request).getId(),super.getOrgi(request), false , q , new PageRequest(0, 10))) ;
return request(super.createRequestPageTempletResponse("/public/contacts"));
public class ContactsResourceController extends Handler {
@Autowired
private ContactsRepository contactsRes;
@RequestMapping("/res/contacts")
@Menu(type = "res", subtype = "contacts")
@ResponseBody
public String add(ModelMap map, HttpServletRequest request, @Valid String q) {
if (q == null) {
q = "";
}
Page<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), false, q, new PageRequest(0, 10));
JSONArray result = new JSONArray();
for (Contacts contact : contactsList.getContent()) {
JSONObject item = new JSONObject();
item.put("id", contact.getId());
item.put("text", contact.getName());
result.add(item);
}
return result.toJSONString();
}
}

View File

@ -33,13 +33,13 @@ public class CssResourceController extends Handler{
@Menu(type = "resouce" , subtype = "css" , access = true)
public ModelAndView index(HttpServletResponse response, @Valid String id) throws IOException {
response.setContentType("text/css ; charset=UTF-8");
return request(super.createRequestPageTempletResponse("/resource/css/ukefu"));
return request(super.createView("/resource/css/ukefu"));
}
@RequestMapping("/res/css/system")
@Menu(type = "resouce" , subtype = "css" , access = true)
public ModelAndView system(HttpServletResponse response, @Valid String id) throws IOException {
response.setContentType("text/css ; charset=UTF-8");
return request(super.createRequestPageTempletResponse("/resource/css/system"));
return request(super.createView("/resource/css/system"));
}
}

View File

@ -16,8 +16,10 @@
*/
package com.chatopera.cc.controller.resource;
import com.alibaba.fastjson.JSONObject;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.controller.api.request.RestUtils;
import com.chatopera.cc.model.AttachmentFile;
import com.chatopera.cc.model.StreamingFile;
import com.chatopera.cc.model.UploadStatus;
@ -32,6 +34,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
@ -118,11 +123,11 @@ public class MediaController extends Handler {
@RequestMapping("/image/upload")
@Menu(type = "resouce", subtype = "imageupload", access = false)
public ModelAndView upload(ModelMap map,
HttpServletRequest request,
@RequestParam(value = "imgFile", required = false) MultipartFile multipart) throws IOException {
ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload"));
UploadStatus notify = null;
public ResponseEntity<String> upload(ModelMap map,
HttpServletRequest request,
@RequestParam(value = "imgFile", required = false) MultipartFile multipart) throws IOException {
JSONObject result = new JSONObject();
HttpHeaders headers = RestUtils.header();
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) {
File uploadDir = new File(path, "upload");
if (!uploadDir.exists()) {
@ -136,12 +141,15 @@ public class MediaController extends Handler {
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
streamingFileRes.save(sf);
String fileURL = "/res/image.html?id=" + fileid;
notify = new UploadStatus("0", fileURL); //图片直接发送给 客户不用返回
result.put("error", 0);
result.put("url", fileURL); //图片直接发送给 客户不用返回
} else {
notify = new UploadStatus("请选择图片文件");
result.put("error", 1);
result.put("message", "请选择图片文件");
}
map.addAttribute("upload", notify);
return view;
return new ResponseEntity<>(result.toString(), headers, HttpStatus.OK);
}
@RequestMapping("/file")

View File

@ -1,44 +0,0 @@
/*
* 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.resource;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.util.Menu;
import freemarker.template.TemplateException;
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.io.IOException;
@Controller
public class QuickReplyResourceController extends Handler{
@RequestMapping("/res/quickreply")
@Menu(type = "res" , subtype = "quickreply")
public ModelAndView add(ModelMap map , HttpServletRequest request , @Valid String q) throws IOException, TemplateException {
if(q==null){
q = "" ;
}
// map.addAttribute("quickReplyList", OnlineUserProxy.search(q, super.getOrgi(request), super.getUser(request))) ;
return request(super.createRequestPageTempletResponse("/public/quickreply"));
}
}

View File

@ -53,7 +53,7 @@ public class SysDicResourceController extends Handler{
map.addAttribute("name", name) ;
map.addAttribute("attr", attr) ;
map.addAttribute("style", style) ;
return request(super.createRequestPageTempletResponse("/public/select"));
return request(super.createView("/public/select"));
}
}

View File

@ -16,9 +16,11 @@
*/
package com.chatopera.cc.controller.resource;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Contacts;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.OrgiSkillRel;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.OrganRepository;
import com.chatopera.cc.persistence.repository.OrgiSkillRelRepository;
@ -31,11 +33,11 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
@Controller
@ -55,12 +57,21 @@ public class UsersResourceController extends Handler {
@RequestMapping("/users")
@Menu(type = "res", subtype = "users")
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String id) {
@ResponseBody
public String add(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String id) {
if (q == null) {
q = "";
}
map.addAttribute("usersList", getUsers(request, q));
return request(super.createRequestPageTempletResponse("/public/users"));
Page<User> usersList = getUsers(request, q);
JSONArray result = new JSONArray();
for (User user : usersList.getContent()) {
JSONObject item = new JSONObject();
item.put("id", user.getId());
item.put("text", user.getUsername() + "(" + user.getUname() + ")");
result.add(item);
}
return result.toJSONString();
}
@RequestMapping("/bpm/users")
@ -70,7 +81,7 @@ public class UsersResourceController extends Handler {
q = "";
}
map.addAttribute("usersList", getUsers(request, q));
return request(super.createRequestPageTempletResponse("/public/bpmusers"));
return request(super.createView("/public/bpmusers"));
}
@RequestMapping("/bpm/organ")
@ -79,7 +90,7 @@ public class UsersResourceController extends Handler {
map.addAttribute("organList", getOrgans(request));
map.addAttribute("usersList", getUsers(request));
map.addAttribute("ids", ids);
return request(super.createRequestPageTempletResponse("/public/organ"));
return request(super.createView("/public/organ"));
}
private List<User> getUsers(HttpServletRequest request) {

View File

@ -25,6 +25,7 @@ import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.User;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.PugHelper;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -153,6 +154,8 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
view.addObject("advTypeList", Dict.getInstance().getDic("com.dic.adv.type"));
view.addObject("ip", request.getRemoteAddr());
view.addObject("pugHelper", new PugHelper());
}
}

View File

@ -22,7 +22,7 @@ import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_xiaoe_config")
@Table(name = "cs_chatbot_config")
@org.hibernate.annotations.Proxy(lazy = false)
public class AiConfig implements java.io.Serializable{
/**

View File

@ -0,0 +1,157 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "cs_fb_messenger")
@org.hibernate.annotations.Proxy(lazy = false)
public class FbMessenger implements Serializable {
private String id;
private String pageId;
private String token;
private String verifyToken;
private String name;
private String status;
private String organ;
private String aiid;
private boolean aisuggest;
private boolean ai;
private Date createtime;
private Date updatetime;
private String config;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "assigned")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPageId() {
return pageId;
}
public void setPageId(String pageId) {
this.pageId = pageId;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getVerifyToken() {
return verifyToken;
}
public void setVerifyToken(String verifyToken) {
this.verifyToken = verifyToken;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getOrgan() {
return organ;
}
public void setOrgan(String organ) {
this.organ = organ;
}
public String getAiid() {
return aiid;
}
public void setAiid(String aiid) {
this.aiid = aiid;
}
public boolean isAi() {
return ai;
}
public void setAi(boolean ai) {
this.ai = ai;
}
public boolean isAisuggest() {
return aisuggest;
}
public void setAisuggest(boolean aisuggest) {
this.aisuggest = aisuggest;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
}

View File

@ -0,0 +1,165 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "cs_fb_otn")
@org.hibernate.annotations.Proxy(lazy = false)
public class FbOTN implements Serializable {
private String id;
private String name;
private String pageId;
private String preSubMessage;
private String subMessage;
private String successMessage;
private String otnMessage;
private String status;
private Date createtime;
private Date updatetime;
private Date sendtime;
private Integer subNum;
private FbMessenger fbMessenger;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "assigned")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPageId() {
return pageId;
}
public void setPageId(String pageId) {
this.pageId = pageId;
}
public String getPreSubMessage() {
return preSubMessage;
}
public void setPreSubMessage(String preSubMessage) {
this.preSubMessage = preSubMessage;
}
public String getSubMessage() {
return subMessage;
}
public void setSubMessage(String subMessage) {
this.subMessage = subMessage;
}
public String getSuccessMessage() {
return successMessage;
}
public void setSuccessMessage(String successMessage) {
this.successMessage = successMessage;
}
public String getOtnMessage() {
return otnMessage;
}
public void setOtnMessage(String otnMessage) {
this.otnMessage = otnMessage;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public Date getSendtime() {
return sendtime;
}
public void setSendtime(Date sendtime) {
this.sendtime = sendtime;
}
public Integer getSubNum() {
return subNum;
}
public void setSubNum(Integer subNum) {
this.subNum = subNum;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "pageId", referencedColumnName = "pageId", insertable = false, updatable = false)
@NotFound(action = NotFoundAction.IGNORE)
public FbMessenger getFbMessenger() {
return fbMessenger;
}
public void setFbMessenger(FbMessenger fbMessenger) {
this.fbMessenger = fbMessenger;
}
}

View File

@ -0,0 +1,114 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "cs_fb_otn_follow")
@org.hibernate.annotations.Proxy(lazy = false)
public class FbOtnFollow {
private String id;
private String pageId;
private String otnId;
private String userId;
private String otnToken;
private Date createtime;
private Date updatetime;
private Date sendtime;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "assigned")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPageId() {
return pageId;
}
public void setPageId(String pageId) {
this.pageId = pageId;
}
public String getOtnId() {
return otnId;
}
public void setOtnId(String otnId) {
this.otnId = otnId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getOtnToken() {
return otnToken;
}
public void setOtnToken(String otnToken) {
this.otnToken = otnToken;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public Date getSendtime() {
return sendtime;
}
public void setSendtime(Date sendtime) {
this.sendtime = sendtime;
}
}

View File

@ -1,82 +0,0 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_kbs_expert")
@org.hibernate.annotations.Proxy(lazy = false)
public class KbsExpert implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 707069993826500239L;
private String id ;
private User user ;
private String kbstype ;
private String creater ;
private String orgi ;
private Date createtime = new Date();
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@OneToOne(optional = true)
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getKbstype() {
return kbstype;
}
public void setKbstype(String kbstype) {
this.kbstype = kbstype;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
}

View File

@ -1,443 +0,0 @@
/*
* 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.model;
import com.chatopera.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import java.util.Date;
/**
*
*/
@Document(indexName = "cskefu", type = "kbs_topic")
@Entity
@Table(name = "uk_kbs_topic")
@org.hibernate.annotations.Proxy(lazy = false)
public class KbsTopic extends ESBean implements java.io.Serializable , UKAgg{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
private String id = MainUtils.getUUID();
private String sessionid ;
private String title ; //标题
private String content ; //内容
private String weixin; //微信渠道回复
private String email ; //邮件渠道回复
private String sms ; //短信回复
private String tts ; //语音播报回复
private float price ; //问题价格
private String keyword ; //关键词
private String summary ; //摘要
private String tags ; //标签
private boolean anonymous ; //是否匿名提问
private boolean datastatus ; //逻辑删除
private boolean approval ; //是否已经审批通过
private Date begintime ; //有效期开始
private Date endtime ; //有效期结束
private boolean top ; //是否置顶
private boolean essence ; //是否精华
private boolean accept ; //是否已采纳最佳答案
private boolean finish ; //结贴
private int answers ; //回答数量
@Column(name="sviews")
private int views ; //阅读数量
private int followers ; //关注数量
private int collections; //收藏数量
private int comments ; //评论数量
private boolean frommobile ; //是否移动端提问
private String status ; // 状态
private String tptype; //知识分类
private String cate ; //知识 栏目
private String attachment ; //附件
private String username ;
private String orgi ;
private String creater;
private Date createtime = new Date();
private Date updatetime = new Date();
private String memo;
private String organ;
private int rowcount ;
private String key ;
private User user ;
/**
* @return the id
*/
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "assigned")
public String getId() {
return id;
}
@Transient
public String getSessionid() {
return sessionid;
}
public void setSessionid(String sessionid) {
this.sessionid = sessionid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public boolean isAnonymous() {
return anonymous;
}
public void setAnonymous(boolean anonymous) {
this.anonymous = anonymous;
}
public String getTptype() {
return tptype;
}
public void setTptype(String tptype) {
this.tptype = tptype;
}
public int getAnswers() {
return answers;
}
public void setAnswers(int answers) {
this.answers = answers;
}
public int getViews() {
return views;
}
public void setViews(int views) {
this.views = views;
}
public int getFollowers() {
return followers;
}
public void setFollowers(int followers) {
this.followers = followers;
}
public int getCollections() {
return collections;
}
public void setCollections(int collections) {
this.collections = collections;
}
public int getComments() {
return comments;
}
public void setComments(int comments) {
this.comments = comments;
}
public boolean isFrommobile() {
return frommobile;
}
public void setFrommobile(boolean frommobile) {
this.frommobile = frommobile;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public String getOrgan() {
return organ;
}
public void setOrgan(String organ) {
this.organ = organ;
}
public void setId(String id) {
this.id = id;
}
public String getCate() {
return cate;
}
public void setCate(String cate) {
this.cate = cate;
}
public boolean isTop() {
return top;
}
public void setTop(boolean top) {
this.top = top;
}
public boolean isEssence() {
return essence;
}
public void setEssence(boolean essence) {
this.essence = essence;
}
public boolean isAccept() {
return accept;
}
public void setAccept(boolean accept) {
this.accept = accept;
}
public boolean isFinish() {
return finish;
}
public void setFinish(boolean finish) {
this.finish = finish;
}
@Transient
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Date getBegintime() {
return begintime;
}
public void setBegintime(Date begintime) {
this.begintime = begintime;
}
public Date getEndtime() {
return endtime;
}
public void setEndtime(Date endtime) {
this.endtime = endtime;
}
public String getWeixin() {
return weixin;
}
public void setWeixin(String weixin) {
this.weixin = weixin;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSms() {
return sms;
}
public void setSms(String sms) {
this.sms = sms;
}
public String getTts() {
return tts;
}
public void setTts(String tts) {
this.tts = tts;
}
@Transient
public int getRowcount() {
return rowcount;
}
public void setRowcount(int rowcount) {
this.rowcount = rowcount;
}
@Transient
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
public String getAttachment() {
return attachment;
}
public void setAttachment(String attachment) {
this.attachment = attachment;
}
public boolean isDatastatus() {
return datastatus;
}
public void setDatastatus(boolean datastatus) {
this.datastatus = datastatus;
}
public boolean isApproval() {
return approval;
}
public void setApproval(boolean approval) {
this.approval = approval;
}
}

View File

@ -1,225 +0,0 @@
/*
* 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.model;
import com.chatopera.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;
@Document(indexName = "cskefu", type = "kbs_topiccomment")
public class KbsTopicComment implements UKAgg{
/**
*
*/
private static final long serialVersionUID = -4911955236794918875L;
private String id = MainUtils.getUUID();
private String username;
private String creater ;
private Date createtime = new Date() ;
@Field(index = FieldIndex.not_analyzed , type = FieldType.String)
private String dataid ;
private String content ; //评论内容
private Date updatetime = new Date() ;
private boolean optimal ; //是否最佳答案
private int up ; //点赞数量
private int comments ; //回复数量
private boolean admin ;
private String cate ;
private String optype ;
private String ipcode ;
private String country ;
private String province ;
private String city ;
private String isp ;
private String region ;
private int rowcount ;
private String key ;
private Topic topic ;
private User user ;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getIpcode() {
return ipcode;
}
public void setIpcode(String ipcode) {
this.ipcode = ipcode;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getIsp() {
return isp;
}
public void setIsp(String isp) {
this.isp = isp;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getDataid() {
return dataid;
}
public void setDataid(String dataid) {
this.dataid = dataid;
}
public String getOptype() {
return optype;
}
public void setOptype(String optype) {
this.optype = optype;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public boolean isOptimal() {
return optimal;
}
public void setOptimal(boolean optimal) {
this.optimal = optimal;
}
public boolean isAdmin() {
return admin;
}
public void setAdmin(boolean admin) {
this.admin = admin;
}
public int getUp() {
return up;
}
public void setUp(int up) {
this.up = up;
}
public int getComments() {
return comments;
}
public void setComments(int comments) {
this.comments = comments;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
@Transient
public Topic getTopic() {
return topic;
}
public void setTopic(Topic topic) {
this.topic = topic;
}
@Transient
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getCate() {
return cate;
}
public void setCate(String cate) {
this.cate = cate;
}
@Transient
public int getRowcount() {
return rowcount;
}
public void setRowcount(int rowcount) {
this.rowcount = rowcount;
}
@Transient
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}

View File

@ -1,176 +0,0 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_kbs_type")
@org.hibernate.annotations.Proxy(lazy = false)
public class KbsType implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 1115593425069549681L;
private String id ;
private String name ;
private String code ;
private boolean approval ; //是否需要专家审批
private boolean bpm ; //是否需要流程审批
private String bpmid ; //知识审批流程ID
private String pc ; //知识分类负责人
private int inx; //知识分类排序位置
private Date createtime ;
private String creater;
private String username ;
private Date startdate; //有效期开始
private Date enddate ; //有效期结束
private boolean enable ; //状态是否可用
private String description ;//分类备注描述信息
private Date updatetime ;
private String parentid ; //父级ID
private String orgi ;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getParentid() {
return parentid;
}
public void setParentid(String parentid) {
this.parentid = parentid;
}
public boolean isApproval() {
return approval;
}
public void setApproval(boolean approval) {
this.approval = approval;
}
public String getBpmid() {
return bpmid;
}
public void setBpmid(String bpmid) {
this.bpmid = bpmid;
}
public String getPc() {
return pc;
}
public void setPc(String pc) {
this.pc = pc;
}
public int getInx() {
return inx;
}
public void setInx(int inx) {
this.inx = inx;
}
public Date getStartdate() {
return startdate;
}
public void setStartdate(Date startdate) {
this.startdate = startdate;
}
public Date getEnddate() {
return enddate;
}
public void setEnddate(Date enddate) {
this.enddate = enddate;
}
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isBpm() {
return bpm;
}
public void setBpm(boolean bpm) {
this.bpm = bpm;
}
}

View File

@ -1,117 +0,0 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_xiaoe_kbs_type")
@org.hibernate.annotations.Proxy(lazy = false)
public class KnowledgeType implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 1115593425069549681L;
private String id ;
private String name ;
private String code ;
private Date createtime ;
private String parentid ;
private String typeid ;
private String creater;
private String username ;
private Date updatetime ;
private String orgi ;
private String area ;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "assigned")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getParentid() {
return parentid;
}
public void setParentid(String parentid) {
this.parentid = parentid;
}
public String getTypeid() {
return typeid;
}
public void setTypeid(String typeid) {
this.typeid = typeid;
}
}

View File

@ -26,7 +26,7 @@ import java.util.Date;
@Entity
@Table(name = "uk_onlineuser")
@Proxy(lazy = false)
public class OnlineUser implements java.io.Serializable {
public class OnlineUser implements java.io.Serializable {
/**
*
*/
@ -75,7 +75,7 @@ public class OnlineUser implements java.io.Serializable {
private String useragent;
private String phone;
private String contactsid;
private String headimgurl;
private int invitetimes; // 邀请次数
private String invitestatus; // 邀请状态
@ -83,6 +83,14 @@ public class OnlineUser implements java.io.Serializable {
private Contacts contacts;
public String getHeadimgurl() {
return headimgurl;
}
public void setHeadimgurl(String headimgurl) {
this.headimgurl = headimgurl;
}
public String getCreater() {
return this.creater;
}
@ -463,4 +471,6 @@ public class OnlineUser implements java.io.Serializable {
public void setPhone(String phone) {
this.phone = phone;
}
}

View File

@ -1,113 +0,0 @@
/*
* 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.model;
import com.chatopera.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import java.util.Date;
@Document(indexName = "cskefu", type = "quickreply")
@Entity
@Table(name = "uk_quickreply")
@org.hibernate.annotations.Proxy(lazy = false)
public class QuickReply {
private String id = MainUtils.getUUID();
private String title ; //标题
private String content ; //内容
private String type ; //公用 /私有
private String creater; //创建人
private Date createtime = new Date(); //创建时间
private String orgi ; //
private String cate ; //所属分类
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "assigned")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getCate() {
return cate;
}
public void setCate(String cate) {
this.cate = cate;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
}

View File

@ -1,150 +0,0 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_quick_type")
@org.hibernate.annotations.Proxy(lazy = false)
public class QuickType implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 1115593425069549681L;
private String id ;
private String name ;
private String code ;
private int inx; //知识分类排序位置
private String quicktype ; //个人/公共
private Date createtime ;
private String creater;
private String username ;
private Date startdate; //有效期开始
private Date enddate ; //有效期结束
private boolean enable ; //状态是否可用
private String description ;//分类备注描述信息
private Date updatetime ;
private String parentid ; //父级ID
private String orgi ;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public int getInx() {
return inx;
}
public void setInx(int inx) {
this.inx = inx;
}
public String getQuicktype() {
return quicktype;
}
public void setQuicktype(String quicktype) {
this.quicktype = quicktype;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Date getStartdate() {
return startdate;
}
public void setStartdate(Date startdate) {
this.startdate = startdate;
}
public Date getEnddate() {
return enddate;
}
public void setEnddate(Date enddate) {
this.enddate = enddate;
}
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getParentid() {
return parentid;
}
public void setParentid(String parentid) {
this.parentid = parentid;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
}

View File

@ -1,387 +0,0 @@
/*
* 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.model;
import com.chatopera.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
*
*/
@Entity
@Table(name = "uk_xiaoe_scene")
@org.hibernate.annotations.Proxy(lazy = false)
public class Scene implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
private String id = MainUtils.getUUID();
private String sessionid ;
private String title ; //标题
private String content ; //内容
private float price ; //问题价格
private String keyword ; //关键词
private String summary ; //摘要
private boolean anonymous ; //是否匿名提问
private Date begintime ; //有效期开始
private Date endtime ; //有效期结束
private boolean top ; //是否置顶
private boolean essence ; //是否精华
private boolean accept ; //是否已采纳最佳答案
private boolean finish ; //结贴
private String replaytype ; //回复方式 random ; order
private boolean allowask ; //允许AI自动询问用户
private String inputcon ; //输入条件
private String outputcon ; //输出条件
private String userinput ; //用户输入的提问 首条
private String aireply ; //AI回复的 首条
private int answers ; //回答数量
private int views ; //阅读数量
private int followers ; //关注数量
private int collections; //收藏数量
private int comments ; //评论数量
private boolean frommobile ; //是否移动端提问
private String status ; // 状态
private String tptype; //主题类型 问答:分享:讨论
private String cate ; //主题 栏目
private String username ;
private String orgi ;
private String creater;
private Date createtime = new Date();
private Date updatetime = new Date();
private String memo;
private String organ;
/**
* @return the id
*/
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "assigned")
public String getId() {
return id;
}
@Transient
public String getSessionid() {
return sessionid;
}
public void setSessionid(String sessionid) {
this.sessionid = sessionid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public boolean isAnonymous() {
return anonymous;
}
public void setAnonymous(boolean anonymous) {
this.anonymous = anonymous;
}
public String getTptype() {
return tptype;
}
public void setTptype(String tptype) {
this.tptype = tptype;
}
public int getAnswers() {
return answers;
}
public void setAnswers(int answers) {
this.answers = answers;
}
@Column(name="sviews")
public int getViews() {
return views;
}
public void setViews(int views) {
this.views = views;
}
public int getFollowers() {
return followers;
}
public void setFollowers(int followers) {
this.followers = followers;
}
public int getCollections() {
return collections;
}
public void setCollections(int collections) {
this.collections = collections;
}
public int getComments() {
return comments;
}
public void setComments(int comments) {
this.comments = comments;
}
public boolean isFrommobile() {
return frommobile;
}
public void setFrommobile(boolean frommobile) {
this.frommobile = frommobile;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public String getOrgan() {
return organ;
}
public void setOrgan(String organ) {
this.organ = organ;
}
public void setId(String id) {
this.id = id;
}
public String getCate() {
return cate;
}
public void setCate(String cate) {
this.cate = cate;
}
public boolean isTop() {
return top;
}
public void setTop(boolean top) {
this.top = top;
}
public boolean isEssence() {
return essence;
}
public void setEssence(boolean essence) {
this.essence = essence;
}
public boolean isAccept() {
return accept;
}
public void setAccept(boolean accept) {
this.accept = accept;
}
public boolean isFinish() {
return finish;
}
public void setFinish(boolean finish) {
this.finish = finish;
}
public Date getBegintime() {
return begintime;
}
public void setBegintime(Date begintime) {
this.begintime = begintime;
}
public Date getEndtime() {
return endtime;
}
public void setEndtime(Date endtime) {
this.endtime = endtime;
}
public String getReplaytype() {
return replaytype;
}
public void setReplaytype(String replaytype) {
this.replaytype = replaytype;
}
public boolean isAllowask() {
return allowask;
}
public void setAllowask(boolean allowask) {
this.allowask = allowask;
}
public String getInputcon() {
return inputcon;
}
public void setInputcon(String inputcon) {
this.inputcon = inputcon;
}
public String getOutputcon() {
return outputcon;
}
public void setOutputcon(String outputcon) {
this.outputcon = outputcon;
}
public String getUserinput() {
return userinput;
}
public void setUserinput(String userinput) {
this.userinput = userinput;
}
public String getAireply() {
return aireply;
}
public void setAireply(String aireply) {
this.aireply = aireply;
}
}

View File

@ -1,103 +0,0 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_xiaoe_scene_type")
@org.hibernate.annotations.Proxy(lazy = false)
public class SceneType implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 1115593425069549681L;
private String id ;
private String name ;
private String code ;
private Date createtime ;
private String creater;
private String username ;
private Date updatetime ;
private String orgi ;
private String area ;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
}

View File

@ -1,413 +0,0 @@
/*
* 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.model;
import com.chatopera.cc.basic.MainUtils;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* uk_xiaoe_topic
*/
@Document(indexName = "cskefu", type = "xiaoe_topic")
@Entity
@Table(name = "uk_xiaoe_topic")
@org.hibernate.annotations.Proxy(lazy = false)
public class Topic implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
private String id = MainUtils.getUUID();
private String sessionid ;
private String title ; //标题
private String content ; //内容
private String weixin; //微信渠道回复
private String email ; //邮件渠道回复
private String sms ; //短信回复
private String tts ; //语音播报回复
private float price ; //问题价格
private String keyword ; //关键词
private String summary ; //摘要
private boolean anonymous ; //是否匿名提问
private Date begintime ; //有效期开始
private Date endtime ; //有效期结束
private boolean top ; //是否置顶
private boolean essence ; //是否精华
private boolean accept ; //是否已采纳最佳答案
private boolean finish ; //结贴
@Transient
private List<String> silimar = new ArrayList<String>();
private int answers ; //回答数量
private int views ; //阅读数量
private int followers ; //关注数量
private int collections; //收藏数量
private int comments ; //评论数量
private boolean mobile ; //是否移动端提问
private String status ; // 状态
private String tptype; //主题类型 问答:分享:讨论
private String cate ; //主题 栏目
private String username ;
private String orgi ;
private String creater;
private Date createtime = new Date();
private Date updatetime = new Date();
private String memo;
private String organ;
private String aiid ; //机器人ID
private User user ;
/**
* @return the id
*/
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "assigned")
public String getId() {
return id;
}
@Transient
public String getSessionid() {
return sessionid;
}
public void setSessionid(String sessionid) {
this.sessionid = sessionid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public boolean isAnonymous() {
return anonymous;
}
public void setAnonymous(boolean anonymous) {
this.anonymous = anonymous;
}
public String getTptype() {
return tptype;
}
public void setTptype(String tptype) {
this.tptype = tptype;
}
public int getAnswers() {
return answers;
}
public void setAnswers(int answers) {
this.answers = answers;
}
@Column(name="sviews")
public int getViews() {
return views;
}
public void setViews(int views) {
this.views = views;
}
public int getFollowers() {
return followers;
}
public void setFollowers(int followers) {
this.followers = followers;
}
public int getCollections() {
return collections;
}
public void setCollections(int collections) {
this.collections = collections;
}
public int getComments() {
return comments;
}
public void setComments(int comments) {
this.comments = comments;
}
public boolean isMobile() {
return mobile;
}
public void setMobile(boolean mobile) {
this.mobile = mobile;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public String getOrgan() {
return organ;
}
public void setOrgan(String organ) {
this.organ = organ;
}
public void setId(String id) {
this.id = id;
}
public String getCate() {
return cate;
}
public void setCate(String cate) {
this.cate = cate;
}
public boolean isTop() {
return top;
}
public void setTop(boolean top) {
this.top = top;
}
public boolean isEssence() {
return essence;
}
public void setEssence(boolean essence) {
this.essence = essence;
}
public boolean isAccept() {
return accept;
}
public void setAccept(boolean accept) {
this.accept = accept;
}
public boolean isFinish() {
return finish;
}
public void setFinish(boolean finish) {
this.finish = finish;
}
@Transient
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Date getBegintime() {
return begintime;
}
public void setBegintime(Date begintime) {
this.begintime = begintime;
}
public Date getEndtime() {
return endtime;
}
public void setEndtime(Date endtime) {
this.endtime = endtime;
}
public String getWeixin() {
return weixin;
}
public void setWeixin(String weixin) {
this.weixin = weixin;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSms() {
return sms;
}
public void setSms(String sms) {
this.sms = sms;
}
public String getTts() {
return tts;
}
public void setTts(String tts) {
this.tts = tts;
}
@Transient
public List<String> getSilimar() {
return silimar;
}
public void setSilimar(List<String> silimar) {
this.silimar = silimar;
}
public String getAiid() {
return aiid;
}
public void setAiid(String aiid) {
this.aiid = aiid;
}
}

View File

@ -1,82 +0,0 @@
/*
* 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.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_xiaoe_topic_item")
@org.hibernate.annotations.Proxy(lazy = false)
public class TopicItem implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 1115593425069549681L;
private String id ;
private String topicid ;
private String title ;
private Date createtime ;
private String creater;
private String orgi ;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTopicid() {
return topicid;
}
public void setTopicid(String topicid) {
this.topicid = topicid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
}

View File

@ -35,6 +35,7 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@ -68,6 +69,8 @@ public class PeerSyncIM implements ApplicationContextAware {
@PostConstruct
public void postConstruct() {
applicationContext.getBeansWithAnnotation(Configuration.class);
composer = new Composer<>();
/**
@ -85,6 +88,11 @@ public class PeerSyncIM implements ApplicationContextAware {
p.getPluginId() + PluginRegistry.PLUGIN_CHANNEL_MESSAGER_SUFFIX));
});
pluginRegistry.getPlugin(Constants.CSKEFU_MODULE_MESSENGER).ifPresent(p -> {
composer.use((Middleware) applicationContext.getBean(
p.getPluginId() + PluginRegistry.PLUGIN_CHANNEL_MESSAGER_SUFFIX));
});
composer.use(imMw3);
}

View File

@ -1,36 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.KbsTopicComment;
import org.springframework.data.domain.Page;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import java.util.List;
public interface KbsTopicCommentEsCommonRepository {
Page<KbsTopicComment> findByDataid(String id, int p, int ps) ;
List<KbsTopicComment> findByOptimal(String dataid) ;
Page<KbsTopicComment> findByCon(NativeSearchQueryBuilder searchQueryBuilder, String q, int p, int ps);
Page<KbsTopicComment> findByCon(NativeSearchQueryBuilder searchQueryBuilder, String field, String aggname, String q, int p, int ps);
Page<KbsTopicComment> countByCon(NativeSearchQueryBuilder searchQuery, String q, int p, int ps);
}

View File

@ -1,23 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.KbsTopicComment;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
public interface KbsTopicCommentRepository extends ElasticsearchRepository<KbsTopicComment, String> , KbsTopicCommentEsCommonRepository {
}

View File

@ -1,107 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.KbsTopicComment;
import com.chatopera.cc.model.Topic;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.index.query.QueryStringQueryBuilder.Operator;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.stereotype.Component;
import java.util.List;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@Component
public class KbsTopicCommentRepositoryImpl implements KbsTopicCommentEsCommonRepository{
private ElasticsearchTemplate elasticsearchTemplate;
@Autowired
public void setElasticsearchTemplate(ElasticsearchTemplate elasticsearchTemplate) {
this.elasticsearchTemplate = elasticsearchTemplate;
}
@Override
public Page<KbsTopicComment> findByDataid(String id , int p , int ps) {
Page<KbsTopicComment> pages = null ;
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(termQuery("dataid" , id)).withSort(new FieldSortBuilder("optimal").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)).build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(KbsTopicComment.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopicComment.class);
}
return pages ;
}
@Override
public List<KbsTopicComment> findByOptimal(String dataid) {
List<KbsTopicComment> commentList = null ;
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(termQuery("dataid" , dataid)).withQuery(termQuery("optimal" , true)).build();
if(elasticsearchTemplate.indexExists(KbsTopicComment.class)){
commentList = elasticsearchTemplate.queryForList(searchQuery, KbsTopicComment.class);
}
return commentList ;
}
@Override
public Page<KbsTopicComment> findByCon(NativeSearchQueryBuilder searchQueryBuilder , String field , String aggname, String q , final int p , final int ps) {
Page<KbsTopicComment> pages = null ;
if(!StringUtils.isBlank(q)){
searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
SearchQuery searchQuery = searchQueryBuilder.build();
if(elasticsearchTemplate.indexExists(KbsTopicComment.class)){
if(!StringUtils.isBlank(q)){
pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopicComment.class , new UKResultMapper());
}else{
pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopicComment.class , new UKAggTopResultExtractor(field , aggname));
}
}
return pages ;
}
@Override
public Page<KbsTopicComment> findByCon(
NativeSearchQueryBuilder searchQueryBuilder, String q, int p, int ps) {
searchQueryBuilder.withPageable(new PageRequest(p, ps)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)) ;
searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("content").fragmentSize(200)) ;
if(!StringUtils.isBlank(q)){
searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
return elasticsearchTemplate.queryForPage(searchQueryBuilder.build(), KbsTopicComment.class , new UKResultMapper()) ;
}
@Override
public Page<KbsTopicComment> countByCon(
NativeSearchQueryBuilder searchQueryBuilder, String q, int p, int ps) {
Page<KbsTopicComment> pages = null ;
if(!StringUtils.isBlank(q)){
searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps));
if(elasticsearchTemplate.indexExists(Topic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopicComment.class , new UKAggResultExtractor("creater") );
}
return pages ;
}
}

View File

@ -1,35 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.KbsTopic;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.springframework.data.domain.Page;
import java.util.List;
public interface KbsTopicEsCommonRepository {
Page<KbsTopic> getTopicByCate(String cate, String q, int p, int ps) ;
Page<KbsTopic> getTopicByTop(boolean top, int p, int ps) ;
List<KbsTopic> getTopicByOrgi(String orgi, String type, String q) ;
Page<KbsTopic> getTopicByCateAndUser(String cate, String q, String user, int p, int ps) ;
Page<KbsTopic> getTopicByCon(BoolQueryBuilder booleanQueryBuilder, int p, int ps) ;
}

View File

@ -1,24 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.KbsTopic;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
public interface KbsTopicRepository extends ElasticsearchRepository<KbsTopic, String> , KbsTopicEsCommonRepository {
}

View File

@ -1,152 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.KbsTopic;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.index.query.QueryStringQueryBuilder.Operator;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@Component
public class KbsTopicRepositoryImpl implements KbsTopicEsCommonRepository{
private ElasticsearchTemplate elasticsearchTemplate;
@Autowired
public void setElasticsearchTemplate(ElasticsearchTemplate elasticsearchTemplate) {
this.elasticsearchTemplate = elasticsearchTemplate;
}
@Override
public Page<KbsTopic> getTopicByCate(String cate , String q, final int p , final int ps) {
Page<KbsTopic> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("cate" , cate)) ;
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)) ;
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(KbsTopic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopic.class , new UKResultMapper());
}
return pages ;
}
@SuppressWarnings("deprecation")
@Override
public Page<KbsTopic> getTopicByTop(boolean top , final int p , final int ps) {
Page<KbsTopic> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("top" , top)) ;
QueryBuilder beginFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("begintime")).should(QueryBuilders.rangeQuery("begintime").from(new Date().getTime())) ;
QueryBuilder endFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("endtime")).should(QueryBuilders.rangeQuery("endtime").to(new Date().getTime())) ;
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withFilter(QueryBuilders.boolQuery().must(beginFilter).must(endFilter)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)) ;
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(KbsTopic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopic.class , new UKResultMapper());
}
return pages ;
}
@Override
public Page<KbsTopic> getTopicByCateAndUser(String cate , String q , String user ,final int p , final int ps) {
Page<KbsTopic> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("cate" , cate)) ;
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withQuery(termQuery("creater" , user)).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps));
if(elasticsearchTemplate.indexExists(KbsTopic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopic.class, new UKResultMapper());
}
return pages ;
}
@SuppressWarnings("deprecation")
@Override
public Page<KbsTopic> getTopicByCon(BoolQueryBuilder boolQueryBuilder, final int p , final int ps) {
Page<KbsTopic> pages = null ;
QueryBuilder beginFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("begintime")).should(QueryBuilders.rangeQuery("begintime").from(new Date().getTime())) ;
QueryBuilder endFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("endtime")).should(QueryBuilders.rangeQuery("endtime").to(new Date().getTime())) ;
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withFilter(QueryBuilders.boolQuery().must(beginFilter).must(endFilter)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(KbsTopic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopic.class);
}
return pages ;
}
@Override
public List<KbsTopic> getTopicByOrgi(String orgi , String type, String q) {
List<KbsTopic> list = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("orgi" , orgi)) ;
if(!StringUtils.isBlank(type)){
boolQueryBuilder.must(termQuery("cate" , type)) ;
}
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build();
if(elasticsearchTemplate.indexExists(KbsTopic.class)){
list = elasticsearchTemplate.queryForList(searchQuery, KbsTopic.class);
}
return list ;
}
}

View File

@ -1,43 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.QuickReply;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
public interface QuickReplyEsCommonRepository {
Page<QuickReply> getByOrgiAndCate(String orgi, String cate, String q, Pageable page) ;
Page<QuickReply> getByQuicktype(String quicktype, int p, int ps) ;
Page<QuickReply> getByOrgiAndType(String orgi, String type, String q, Pageable page) ;
List<QuickReply> findByOrgiAndCreater(String orgi, String creater, String q) ;
Page<QuickReply> getByCateAndUser(String cate, String q, String user, int p, int ps) ;
Page<QuickReply> getByCon(BoolQueryBuilder booleanQueryBuilder, int p, int ps) ;
void deleteByCate(String cate, String orgi) ;
List<QuickReply> getQuickReplyByOrgi(String orgi, String cate, String type, String q);
}

View File

@ -1,24 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.QuickReply;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
public interface QuickReplyRepository extends ElasticsearchRepository<QuickReply, String> , QuickReplyEsCommonRepository {
}

View File

@ -1,219 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.model.QuickReply;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.index.query.QueryStringQueryBuilder.Operator;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@Component
public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository{
private ElasticsearchTemplate elasticsearchTemplate;
@Autowired
public void setElasticsearchTemplate(ElasticsearchTemplate elasticsearchTemplate) {
this.elasticsearchTemplate = elasticsearchTemplate ;
}
@Override
public Page<QuickReply> getByOrgiAndCate(String orgi , String cate , String q, Pageable page) {
Page<QuickReply> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("cate" , cate)) ;
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)) ;
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(page) ;
if(elasticsearchTemplate.indexExists(QuickReply.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class , new UKResultMapper());
}
return pages ;
}
@Override
public List<QuickReply> findByOrgiAndCreater(String orgi ,String creater , String q) {
List<QuickReply> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("orgi" , orgi)) ;
BoolQueryBuilder quickQueryBuilder = QueryBuilders.boolQuery();
quickQueryBuilder.should(termQuery("type" , MainContext.QuickType.PUB.toString())) ;
BoolQueryBuilder priQueryBuilder = QueryBuilders.boolQuery();
priQueryBuilder.must(termQuery("type" , MainContext.QuickType.PRI.toString())) ;
priQueryBuilder.must(termQuery("creater" , creater)) ;
quickQueryBuilder.should(priQueryBuilder) ;
boolQueryBuilder.must(quickQueryBuilder) ;
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)) ;
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(0, 10000)) ;
if(elasticsearchTemplate.indexExists(QuickReply.class)){
pages = elasticsearchTemplate.queryForList(searchQuery, QuickReply.class);
}
return pages ;
}
@Override
public Page<QuickReply> getByQuicktype(String quicktype , final int p , final int ps) {
Page<QuickReply> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("type" , quicktype)) ;
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)) ;
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(QuickReply.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class , new UKResultMapper());
}
return pages ;
}
@Override
public Page<QuickReply> getByCateAndUser(String cate , String q , String user ,final int p , final int ps) {
Page<QuickReply> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("cate" , cate)) ;
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withQuery(termQuery("creater" , user)).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps));
if(elasticsearchTemplate.indexExists(QuickReply.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class, new UKResultMapper());
}
return pages ;
}
@SuppressWarnings("deprecation")
@Override
public Page<QuickReply> getByCon(BoolQueryBuilder boolQueryBuilder, final int p , final int ps) {
Page<QuickReply> pages = null ;
QueryBuilder beginFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("begintime")).should(QueryBuilders.rangeQuery("begintime").from(new Date().getTime())) ;
QueryBuilder endFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("endtime")).should(QueryBuilders.rangeQuery("endtime").to(new Date().getTime())) ;
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withFilter(QueryBuilders.boolQuery().must(beginFilter).must(endFilter)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(QuickReply.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class);
}
return pages ;
}
@Override
public Page<QuickReply> getByOrgiAndType(String orgi ,String type, String q , Pageable page) {
Page<QuickReply> list = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("orgi" , orgi)) ;
if(!StringUtils.isBlank(type)) {
boolQueryBuilder.must(termQuery("type" , type)) ;
}
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(page);
if(elasticsearchTemplate.indexExists(QuickReply.class)){
list = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class);
}
return list ;
}
@Override
public void deleteByCate(String cate ,String orgi) {
DeleteQuery deleteQuery = new DeleteQuery();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("orgi" , orgi)) ;
boolQueryBuilder.must(termQuery("cate" , cate)) ;
deleteQuery.setQuery(boolQueryBuilder);
elasticsearchTemplate.delete(deleteQuery);
}
@Override
public List<QuickReply> getQuickReplyByOrgi(String orgi , String cate,String type, String q) {
List<QuickReply> list = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("orgi" , orgi)) ;
if(!StringUtils.isBlank(cate)){
boolQueryBuilder.must(termQuery("cate" , cate)) ;
}
if(!StringUtils.isBlank(type)){
boolQueryBuilder.must(termQuery("type" , type)) ;
}
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(0, 10000));
if(elasticsearchTemplate.indexExists(QuickReply.class)){
list = elasticsearchTemplate.queryForList(searchQuery, QuickReply.class);
}
return list ;
}
}

View File

@ -1,35 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.Topic;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.springframework.data.domain.Page;
import java.util.List;
public interface TopicEsCommonRepository {
Page<Topic> getTopicByCateAndOrgi(String cate, String orgi, String q, int p, int ps) ;
Page<Topic> getTopicByTopAndOrgi(boolean top, String orgi, String aiid, int p, int ps) ;
List<Topic> getTopicByOrgi(String orgi, String type, String q) ;
Page<Topic> getTopicByCateAndUser(String cate, String q, String user, int p, int ps) ;
Page<Topic> getTopicByCon(BoolQueryBuilder booleanQueryBuilder, int p, int ps) ;
}

View File

@ -1,24 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.Topic;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
public interface TopicRepository extends ElasticsearchRepository<Topic, String> , TopicEsCommonRepository {
}

View File

@ -1,159 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.Topic;
import com.chatopera.cc.persistence.repository.XiaoEUKResultMapper;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.index.query.QueryStringQueryBuilder.Operator;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@Component
public class TopicRepositoryImpl implements TopicEsCommonRepository{
private ElasticsearchTemplate elasticsearchTemplate;
@Autowired
public void setElasticsearchTemplate(ElasticsearchTemplate elasticsearchTemplate) {
this.elasticsearchTemplate = elasticsearchTemplate;
}
@Override
public Page<Topic> getTopicByCateAndOrgi(String cate ,String orgi, String q, final int p , final int ps) {
Page<Topic> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
if(!StringUtils.isBlank(cate)) {
boolQueryBuilder.must(termQuery("cate" , cate)) ;
}
boolQueryBuilder.must(termQuery("orgi" , orgi)) ;
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)) ;
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(Topic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class , new XiaoEUKResultMapper());
}
return pages ;
}
@SuppressWarnings("deprecation")
@Override
public Page<Topic> getTopicByTopAndOrgi(boolean top ,String orgi, String aiid ,final int p , final int ps) {
Page<Topic> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("top" , top)) ;
boolQueryBuilder.must(termQuery("orgi" , orgi)) ;
if(!StringUtils.isBlank(aiid)) {
boolQueryBuilder.must(termQuery("aiid" , aiid)) ;
}
QueryBuilder beginFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("begintime")).should(QueryBuilders.rangeQuery("begintime").to(new Date().getTime())) ;
QueryBuilder endFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("endtime")).should(QueryBuilders.rangeQuery("endtime").from(new Date().getTime())) ;
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withFilter(QueryBuilders.boolQuery().must(beginFilter).must(endFilter)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)) ;
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(Topic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class , new XiaoEUKResultMapper());
}
return pages ;
}
@Override
public Page<Topic> getTopicByCateAndUser(String cate , String q , String user ,final int p , final int ps) {
Page<Topic> pages = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("cate" , cate)) ;
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withQuery(termQuery("creater" , user)).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps));
if(elasticsearchTemplate.indexExists(Topic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class, new XiaoEUKResultMapper());
}
return pages ;
}
@SuppressWarnings("deprecation")
@Override
public Page<Topic> getTopicByCon(BoolQueryBuilder boolQueryBuilder, final int p , final int ps) {
Page<Topic> pages = null ;
QueryBuilder beginFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("begintime")).should(QueryBuilders.rangeQuery("begintime").to(new Date().getTime())) ;
QueryBuilder endFilter = QueryBuilders.boolQuery().should(QueryBuilders.missingQuery("endtime")).should(QueryBuilders.rangeQuery("endtime").from(new Date().getTime())) ;
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withFilter(QueryBuilders.boolQuery().must(beginFilter).must(endFilter)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
if(elasticsearchTemplate.indexExists(Topic.class)){
pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class);
}
return pages ;
}
@Override
public List<Topic> getTopicByOrgi(String orgi , String type, String q) {
List<Topic> list = null ;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(termQuery("orgi" , orgi)) ;
if(!StringUtils.isBlank(type)){
boolQueryBuilder.must(termQuery("cate" , type)) ;
}
if(!StringUtils.isBlank(q)){
boolQueryBuilder.must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC));
SearchQuery searchQuery = searchQueryBuilder.build();
if(elasticsearchTemplate.indexExists(Topic.class)){
list = elasticsearchTemplate.queryForList(searchQuery, Topic.class);
}
return list ;
}
}

View File

@ -1,87 +0,0 @@
/*
* 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.persistence.es;
import com.chatopera.cc.model.KbsTopic;
import com.chatopera.cc.model.KbsTopicComment;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.histogram.InternalDateHistogram;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.aggregation.AggregatedPage;
import org.springframework.data.elasticsearch.core.aggregation.impl.AggregatedPageImpl;
import java.util.ArrayList;
import java.util.List;
public class UKAggResultExtractor extends UKResultMapper{
private String term ;
public UKAggResultExtractor(String term){
this.term = term ;
}
@SuppressWarnings("unchecked")
@Override
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
Aggregations aggregations = response.getAggregations();
List<T> results = new ArrayList<T>();
long total = 0 ;
if(aggregations!=null && aggregations.get(term)!=null){
if(aggregations.get(term) instanceof Terms){
Terms agg = aggregations.get(term) ;
if(agg!=null){
total = agg.getSumOfOtherDocCounts() ;
if(agg.getBuckets()!=null && agg.getBuckets().size()>0){
for (Terms.Bucket entry : agg.getBuckets()) {
if(clazz.equals(KbsTopic.class)){
KbsTopic topic = new KbsTopic();
topic.setCreater(entry.getKeyAsString());
topic.setRowcount((int) entry.getDocCount());
results.add((T) topic) ;
}else if(clazz.equals(KbsTopicComment.class)){
KbsTopicComment topicComment = new KbsTopicComment();
topicComment.setCreater(entry.getKeyAsString());
topicComment.setRowcount((int) entry.getDocCount());
results.add((T) topicComment) ;
}
}
}
}
}else if(aggregations.get(term) instanceof InternalDateHistogram){
InternalDateHistogram agg = aggregations.get(term) ;
total = response.getHits().getTotalHits() ;
if(agg!=null){
// if(agg.getBuckets()!=null && agg.getBuckets().size()>0){
// for (DateHistogram.Bucket entry : agg.getBuckets()) {
// if(clazz.equals(KbsTopic.class)){
// KbsTopic topic = new KbsTopic();
// topic.setKey(entry.getKey().substring(0 , 10));
// topic.setRowcount((int) entry.getDocCount());
// results.add((T) topic) ;
// }
// }
// }
}
}
}
return new AggregatedPageImpl<T>(results, pageable, total);
}
}

View File

@ -1,46 +0,0 @@
/*
* 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.persistence.impl;
import com.chatopera.cc.model.QuickType;
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
import com.chatopera.cc.persistence.repository.QuickTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.List;
@Service("quicktypedata")
public class QuickTypeDataExchangeImpl implements DataExchangeInterface {
@Autowired
private QuickTypeRepository quickTypeRes ;
public String getDataByIdAndOrgi(String id, String orgi){
QuickType quickType = quickTypeRes.findByIdAndOrgi(id,orgi);
return quickType!=null ? quickType.getName() : id;
}
@Override
public List<Serializable> getListDataByIdAndOrgi(String id , String creater, String orgi) {
return null ;
}
public void process(Object data , String orgi) {
}
}

View File

@ -1,44 +0,0 @@
/*
* 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.persistence.impl;
import com.chatopera.cc.model.Topic;
import com.chatopera.cc.persistence.es.TopicRepository;
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("topic")
public class TopicDataExchangeImpl implements DataExchangeInterface{
@Autowired
private TopicRepository topicRes ;
public Topic getDataByIdAndOrgi(String id, String orgi){
return topicRes.findOne(id) ;
}
@Override
public List<Topic> getListDataByIdAndOrgi(String id , String creater, String orgi) {
return topicRes.getTopicByTopAndOrgi(true,orgi , id , 0, 10).getContent() ;
}
public void process(Object data , String orgi) {
}
}

View File

@ -1,47 +0,0 @@
/*
* 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.persistence.impl;
import com.chatopera.cc.model.TopicItem;
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
import com.chatopera.cc.persistence.repository.TopicItemRepository;
import com.chatopera.cc.util.dsdata.process.TopicProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("topicmore")
public class TopicMoreDataExchangeImpl implements DataExchangeInterface{
@Autowired
private TopicItemRepository topicItemRes ;
private TopicProcess topicProcess = new TopicProcess();
public TopicItem getDataByIdAndOrgi(String id, String orgi){
return topicItemRes.findByIdAndOrgi(id, orgi) ;
}
@Override
public List<TopicItem> getListDataByIdAndOrgi(String id , String creater, String orgi) {
return null ;
}
public void process(Object data , String orgi) {
topicProcess.process(data, orgi);
}
}

View File

@ -1,44 +0,0 @@
/*
* 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.persistence.impl;
import com.chatopera.cc.model.KnowledgeType;
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
import com.chatopera.cc.persistence.repository.KnowledgeTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("topictype")
public class TopicTypeDataExchangeImpl implements DataExchangeInterface{
@Autowired
private KnowledgeTypeRepository knowledgeTypeRes ;
public KnowledgeType getDataByIdAndOrgi(String id, String orgi){
return knowledgeTypeRes.findByIdAndOrgi(id, orgi) ;
}
@Override
public List<KnowledgeType> getListDataByIdAndOrgi(String id , String creater, String orgi) {
return knowledgeTypeRes.findByOrgi(orgi) ;
}
public void process(Object data , String orgi) {
}
}

Some files were not shown because too many files have changed in this diff Show More