diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/AdminController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/AdminController.java index da7905a9..60f2a608 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/AdminController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/AdminController.java @@ -1,186 +1,186 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.chatopera.cc.controller.admin; - -import com.chatopera.cc.acd.ACDWorkMonitor; -import com.chatopera.cc.basic.Constants; -import com.chatopera.cc.basic.MainContext; -import com.chatopera.cc.basic.MainUtils; -import com.chatopera.cc.cache.Cache; -import com.chatopera.cc.controller.Handler; -import com.chatopera.cc.model.SysDic; -import com.chatopera.cc.model.User; -import com.chatopera.cc.persistence.repository.OnlineUserRepository; -import com.chatopera.cc.persistence.repository.SysDicRepository; -import com.chatopera.cc.persistence.repository.UserEventRepository; -import com.chatopera.cc.persistence.repository.UserRepository; -import com.chatopera.cc.proxy.OnlineUserProxy; -import com.chatopera.cc.socketio.client.NettyClients; -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.ArrayList; -import java.util.Date; -import java.util.List; - -@Controller -public class AdminController extends Handler { - - @Autowired - private ACDWorkMonitor acdWorkMonitor; - - @Autowired - private UserRepository userRes; - - @Autowired - private OnlineUserRepository onlineUserRes; - - @Autowired - private UserEventRepository userEventRes; - - @Autowired - private SysDicRepository sysDicRes; - - @Autowired - private Cache cache; - - @RequestMapping("/admin") - public ModelAndView index(ModelMap map, HttpServletRequest request) { - ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/")); - User user = super.getUser(request); - view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(user.getOrgi())); - view.addObject("agentStatus", cache.findOneAgentStatusByAgentnoAndOrig(user.getId(), user.getOrgi())); - return view; - } - - private void aggValues(ModelMap map, HttpServletRequest request) { - String orgi = super.getOrgi(request); - map.put("onlineUserCache", cache.getOnlineUserSizeByOrgi(orgi)); - map.put("onlineUserClients", OnlineUserProxy.webIMClients.size()); - map.put("chatClients", NettyClients.getInstance().size()); - map.put("systemCaches", cache.getSystemSizeByOrgi(MainContext.SYSTEM_ORGI)); - - map.put("agentReport", acdWorkMonitor.getAgentReport(orgi)); - map.put("webIMReport", MainUtils.getWebIMReport(userEventRes.findByOrgiAndCreatetimeRange(super.getOrgi(request), MainUtils.getStartTime(), MainUtils.getEndTime()))); - - map.put("agents", getAgent(request).size()); - - map.put("webIMInvite", MainUtils.getWebIMInviteStatus(onlineUserRes.findByOrgiAndStatus(super.getOrgi(request), MainContext.OnlineUserStatusEnum.ONLINE.toString()))); - - map.put("inviteResult", MainUtils.getWebIMInviteResult(onlineUserRes.findByOrgiAndAgentnoAndCreatetimeRange(super.getOrgi(request), super.getUser(request).getId(), MainUtils.getStartTime(), MainUtils.getEndTime()))); - - map.put("agentUserCount", onlineUserRes.countByAgentForAgentUser(super.getOrgi(request), MainContext.AgentUserStatusEnum.INSERVICE.toString(), super.getUser(request).getId(), MainUtils.getStartTime(), MainUtils.getEndTime())); - - map.put("agentServicesCount", onlineUserRes.countByAgentForAgentUser(super.getOrgi(request), MainContext.AgentUserStatusEnum.END.toString(), super.getUser(request).getId(), MainUtils.getStartTime(), MainUtils.getEndTime())); - - map.put("agentServicesAvg", onlineUserRes.countByAgentForAvagTime(super.getOrgi(request), MainContext.AgentUserStatusEnum.END.toString(), super.getUser(request).getId(), MainUtils.getStartTime(), MainUtils.getEndTime())); - - map.put("webInviteReport", MainUtils.getWebIMInviteAgg(onlineUserRes.findByOrgiAndCreatetimeRange(super.getOrgi(request), MainContext.ChannelType.WEBIM.toString(), MainUtils.getLast30Day(), MainUtils.getEndTime()))); - - map.put("agentConsultReport", MainUtils.getWebIMDataAgg(onlineUserRes.findByOrgiAndCreatetimeRangeForAgent(super.getOrgi(request), MainUtils.getLast30Day(), MainUtils.getEndTime()))); - - map.put("clentConsultReport", MainUtils.getWebIMDataAgg(onlineUserRes.findByOrgiAndCreatetimeRangeForClient(super.getOrgi(request), MainUtils.getLast30Day(), MainUtils.getEndTime(), MainContext.ChannelType.WEBIM.toString()))); - - map.put("browserConsultReport", MainUtils.getWebIMDataAgg(onlineUserRes.findByOrgiAndCreatetimeRangeForBrowser(super.getOrgi(request), MainUtils.getLast30Day(), MainUtils.getEndTime(), MainContext.ChannelType.WEBIM.toString()))); - } - - private List getAgent(HttpServletRequest request) { - //获取当前产品or租户坐席数 - List userList = new ArrayList<>(); - if (super.isEnabletneant()) { - userList = userRes.findByOrgidAndAgentAndDatastatus(super.getOrgid(request), true, false); - } else { - userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false); - } - return userList.isEmpty() ? new ArrayList() : userList; - } - - @RequestMapping("/admin/content") - @Menu(type = "admin", subtype = "content") - public ModelAndView content(ModelMap map, HttpServletRequest request) { - aggValues(map, request); - return request(super.createAdminTempletResponse("/admin/content")); - /*if(super.getUser(request).isSuperuser()) { - aggValues(map, request); - return request(super.createAdminTempletResponse("/admin/content")); - }else { - return request(super.createAdminTempletResponse("/admin/user/index")); - }*/ - } - - @RequestMapping("/admin/auth/infoacq") - @Menu(type = "admin", subtype = "infoacq", access = false, admin = true) - public ModelAndView infoacq(ModelMap map, HttpServletRequest request) { - String inacq = (String) request.getSession().getAttribute(Constants.CSKEFU_SYSTEM_INFOACQ); - if (StringUtils.isNotBlank(inacq)) { - request.getSession().removeAttribute(Constants.CSKEFU_SYSTEM_INFOACQ); - } else { - request.getSession().setAttribute(Constants.CSKEFU_SYSTEM_INFOACQ, "true"); - } - return request(super.createRequestPageTempletResponse("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 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")); - } - -} \ No newline at end of file +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.chatopera.cc.controller.admin; + +import com.chatopera.cc.acd.ACDWorkMonitor; +import com.chatopera.cc.basic.Constants; +import com.chatopera.cc.basic.MainContext; +import com.chatopera.cc.basic.MainUtils; +import com.chatopera.cc.cache.Cache; +import com.chatopera.cc.controller.Handler; +import com.chatopera.cc.model.SysDic; +import com.chatopera.cc.model.User; +import com.chatopera.cc.persistence.repository.OnlineUserRepository; +import com.chatopera.cc.persistence.repository.SysDicRepository; +import com.chatopera.cc.persistence.repository.UserEventRepository; +import com.chatopera.cc.persistence.repository.UserRepository; +import com.chatopera.cc.proxy.OnlineUserProxy; +import com.chatopera.cc.socketio.client.NettyClients; +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.ArrayList; +import java.util.Date; +import java.util.List; + +@Controller +public class AdminController extends Handler { + + @Autowired + private ACDWorkMonitor acdWorkMonitor; + + @Autowired + private UserRepository userRes; + + @Autowired + private OnlineUserRepository onlineUserRes; + + @Autowired + private UserEventRepository userEventRes; + + @Autowired + private SysDicRepository sysDicRes; + + @Autowired + private Cache cache; + + @RequestMapping("/admin") + public ModelAndView index(ModelMap map, HttpServletRequest request) { + ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/")); + User user = super.getUser(request); + view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(user.getOrgi())); + view.addObject("agentStatus", cache.findOneAgentStatusByAgentnoAndOrig(user.getId(), user.getOrgi())); + return view; + } + + private void aggValues(ModelMap map, HttpServletRequest request) { + String orgi = super.getOrgi(request); + map.put("onlineUserCache", cache.getOnlineUserSizeByOrgi(orgi)); + map.put("onlineUserClients", OnlineUserProxy.webIMClients.size()); + map.put("chatClients", NettyClients.getInstance().size()); + map.put("systemCaches", cache.getSystemSizeByOrgi(MainContext.SYSTEM_ORGI)); + + map.put("agentReport", acdWorkMonitor.getAgentReport(orgi)); + map.put("webIMReport", MainUtils.getWebIMReport(userEventRes.findByOrgiAndCreatetimeRange(super.getOrgi(request), MainUtils.getStartTime(), MainUtils.getEndTime()))); + + map.put("agents", getAgent(request).size()); + + map.put("webIMInvite", MainUtils.getWebIMInviteStatus(onlineUserRes.findByOrgiAndStatus(super.getOrgi(request), MainContext.OnlineUserStatusEnum.ONLINE.toString()))); + + map.put("inviteResult", MainUtils.getWebIMInviteResult(onlineUserRes.findByOrgiAndAgentnoAndCreatetimeRange(super.getOrgi(request), super.getUser(request).getId(), MainUtils.getStartTime(), MainUtils.getEndTime()))); + + map.put("agentUserCount", onlineUserRes.countByAgentForAgentUser(super.getOrgi(request), MainContext.AgentUserStatusEnum.INSERVICE.toString(), super.getUser(request).getId(), MainUtils.getStartTime(), MainUtils.getEndTime())); + + map.put("agentServicesCount", onlineUserRes.countByAgentForAgentUser(super.getOrgi(request), MainContext.AgentUserStatusEnum.END.toString(), super.getUser(request).getId(), MainUtils.getStartTime(), MainUtils.getEndTime())); + + map.put("agentServicesAvg", onlineUserRes.countByAgentForAvagTime(super.getOrgi(request), MainContext.AgentUserStatusEnum.END.toString(), super.getUser(request).getId(), MainUtils.getStartTime(), MainUtils.getEndTime())); + + map.put("webInviteReport", MainUtils.getWebIMInviteAgg(onlineUserRes.findByOrgiAndCreatetimeRange(super.getOrgi(request), MainContext.ChannelType.WEBIM.toString(), MainUtils.getLast30Day(), MainUtils.getEndTime()))); + + map.put("agentConsultReport", MainUtils.getWebIMDataAgg(onlineUserRes.findByOrgiAndCreatetimeRangeForAgent(super.getOrgi(request), MainUtils.getLast30Day(), MainUtils.getEndTime()))); + + map.put("clentConsultReport", MainUtils.getWebIMDataAgg(onlineUserRes.findByOrgiAndCreatetimeRangeForClient(super.getOrgi(request), MainUtils.getLast30Day(), MainUtils.getEndTime(), MainContext.ChannelType.WEBIM.toString()))); + + map.put("browserConsultReport", MainUtils.getWebIMDataAgg(onlineUserRes.findByOrgiAndCreatetimeRangeForBrowser(super.getOrgi(request), MainUtils.getLast30Day(), MainUtils.getEndTime(), MainContext.ChannelType.WEBIM.toString()))); + } + + private List getAgent(HttpServletRequest request) { + //获取当前产品or租户坐席数 + List userList = new ArrayList<>(); + if (super.isEnabletneant()) { + userList = userRes.findByOrgidAndAgentAndDatastatus(super.getOrgid(request), true, false); + } else { + userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false); + } + return userList.isEmpty() ? new ArrayList() : userList; + } + + @RequestMapping("/admin/content") + @Menu(type = "admin", subtype = "content") + public ModelAndView content(ModelMap map, HttpServletRequest request) { + aggValues(map, request); + return request(super.createAdminTempletResponse("/admin/content")); + /*if(super.getUser(request).isSuperuser()) { + aggValues(map, request); + return request(super.createAdminTempletResponse("/admin/content")); + }else { + return request(super.createAdminTempletResponse("/admin/user/index")); + }*/ + } + + @RequestMapping("/admin/auth/infoacq") + @Menu(type = "admin", subtype = "infoacq", admin = true) + public ModelAndView infoacq(ModelMap map, HttpServletRequest request) { + String inacq = (String) request.getSession().getAttribute(Constants.CSKEFU_SYSTEM_INFOACQ); + if (StringUtils.isNotBlank(inacq)) { + request.getSession().removeAttribute(Constants.CSKEFU_SYSTEM_INFOACQ); + } else { + request.getSession().setAttribute(Constants.CSKEFU_SYSTEM_INFOACQ, "true"); + } + return request(super.createRequestPageTempletResponse("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 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")); + } + +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterIvrController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterIvrController.java index 2c6ee16e..ba1da3cf 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterIvrController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterIvrController.java @@ -79,7 +79,7 @@ public class CallCenterIvrController extends Handler { @RequestMapping(value = "/ivr/delete") - @Menu(type = "callcenter", subtype = "ivr", access = false, admin = true) + @Menu(type = "callcenter", subtype = "ivr", admin = true) public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) { if (!StringUtils.isBlank(id)) { extentionRes.deleteById(id); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterMediaController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterMediaController.java index 8594140c..026e3ec1 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterMediaController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterMediaController.java @@ -55,7 +55,7 @@ public class CallCenterMediaController extends Handler { private String path; @RequestMapping(value = "/media") - @Menu(type = "callcenter", subtype = "callcentermedia", access = false, admin = true) + @Menu(type = "callcenter", subtype = "callcentermedia", admin = true) public ModelAndView media(ModelMap map, HttpServletRequest request, @Valid String hostid) { if (!StringUtils.isBlank(hostid)) { map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -65,14 +65,14 @@ public class CallCenterMediaController extends Handler { } @RequestMapping(value = "/media/add") - @Menu(type = "callcenter", subtype = "media", access = false, admin = true) + @Menu(type = "callcenter", subtype = "media", admin = true) public ModelAndView mediaadd(ModelMap map, HttpServletRequest request, @Valid String hostid) { map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); return request(super.createRequestPageTempletResponse("/admin/callcenter/media/add")); } @RequestMapping(value = "/media/save") - @Menu(type = "callcenter", subtype = "media", access = false, admin = true) + @Menu(type = "callcenter", subtype = "media", admin = true) public ModelAndView mediasave(HttpServletRequest request, @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException { Media media = new Media(); media.setName(request.getParameter("name")); @@ -105,7 +105,7 @@ public class CallCenterMediaController extends Handler { } @RequestMapping(value = "/media/edit") - @Menu(type = "callcenter", subtype = "media", access = false, admin = true) + @Menu(type = "callcenter", subtype = "media", admin = true) public ModelAndView mediaedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -113,7 +113,7 @@ public class CallCenterMediaController extends Handler { } @RequestMapping(value = "/media/update") - @Menu(type = "callcenter", subtype = "media", access = false, admin = true) + @Menu(type = "callcenter", subtype = "media", admin = true) public ModelAndView pbxhostupdate(HttpServletRequest request, @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException { Media media = new Media(); media.setName(request.getParameter("name")); @@ -149,7 +149,7 @@ public class CallCenterMediaController extends Handler { } @RequestMapping(value = "/media/delete") - @Menu(type = "callcenter", subtype = "media", access = false, admin = true) + @Menu(type = "callcenter", subtype = "media", admin = true) public ModelAndView mediadelete(@Valid String id, @Valid String hostid) { if (!StringUtils.isBlank(id)) { mediaRes.deleteById(id); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterResourceController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterResourceController.java index 3d38c5c5..cdc29875 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterResourceController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterResourceController.java @@ -52,7 +52,7 @@ public class CallCenterResourceController extends Handler { private final ServiceAiRepository serviceAiRes; @RequestMapping(value = "/resource") - @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true) + @Menu(type = "callcenter", subtype = "callcenter", admin = true) public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String hostid) { List pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); map.addAttribute("pbxHostList", pbxHostList); @@ -69,7 +69,7 @@ public class CallCenterResourceController extends Handler { } @RequestMapping(value = "/resource/config") - @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true) + @Menu(type = "callcenter", subtype = "callcenter", admin = true) public ModelAndView config(ModelMap map, HttpServletRequest request, @Valid String hostid) { List pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); map.addAttribute("pbxHostList", pbxHostList); @@ -83,7 +83,7 @@ public class CallCenterResourceController extends Handler { } @RequestMapping(value = "/resource/save") - @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true) + @Menu(type = "callcenter", subtype = "callcenter", admin = true) public ModelAndView save(HttpServletRequest request, @Valid PbxHost pbxHost) throws Exception { PbxHost tempPbxHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request)); if (tempPbxHost != null) { @@ -106,7 +106,7 @@ public class CallCenterResourceController extends Handler { } @RequestMapping(value = "/resource/pbxhost") - @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true) + @Menu(type = "callcenter", subtype = "callcenter", admin = true) public ModelAndView resourcepbx(ModelMap map, HttpServletRequest request, @Valid String hostid) { List pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); map.addAttribute("pbxHostList", pbxHostList); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterRouterController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterRouterController.java index 03186444..68d08c6b 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterRouterController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterRouterController.java @@ -47,7 +47,7 @@ public class CallCenterRouterController extends Handler { @RequestMapping(value = "/router") - @Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true) + @Menu(type = "callcenter", subtype = "callcenterresource", admin = true) public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) { List pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); map.addAttribute("pbxHostList", pbxHostList); @@ -59,14 +59,14 @@ public class CallCenterRouterController extends Handler { } @RequestMapping(value = "/router/add") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) { map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/add")); } @RequestMapping(value = "/router/save") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentionsave(HttpServletRequest request, @Valid RouterRules router) { if (!StringUtils.isBlank(router.getName())) { int count = routerRulesRes.countByNameAndOrgi(router.getName(), super.getOrgi(request)); @@ -80,7 +80,7 @@ public class CallCenterRouterController extends Handler { } @RequestMapping(value = "/router/edit") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView routeredit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { map.addAttribute("routerRules", routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -88,7 +88,7 @@ public class CallCenterRouterController extends Handler { } @RequestMapping(value = "/router/update") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid RouterRules router) { if (!StringUtils.isBlank(router.getId())) { RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)); @@ -105,7 +105,7 @@ public class CallCenterRouterController extends Handler { } @RequestMapping(value = "/router/code") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView routercode(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { map.addAttribute("routerRules", routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -113,7 +113,7 @@ public class CallCenterRouterController extends Handler { } @RequestMapping(value = "/router/code/update") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView routercodeupdate(HttpServletRequest request, @Valid RouterRules router) { if (!StringUtils.isBlank(router.getId())) { RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)); @@ -126,7 +126,7 @@ public class CallCenterRouterController extends Handler { } @RequestMapping(value = "/router/delete") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) { if (!StringUtils.isBlank(id)) { routerRulesRes.deleteById(id); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterSipTrunkController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterSipTrunkController.java index ff805227..45096ed9 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterSipTrunkController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterSipTrunkController.java @@ -48,7 +48,7 @@ public class CallCenterSipTrunkController extends Handler { private final Cache cache; @RequestMapping(value = "/siptrunk") - @Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true) + @Menu(type = "callcenter", subtype = "callcenterresource", admin = true) public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) { if (!StringUtils.isBlank(hostid)) { map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -58,14 +58,14 @@ public class CallCenterSipTrunkController extends Handler { } @RequestMapping(value = "/siptrunk/add") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) { map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/add")); } @RequestMapping(value = "/siptrunk/save") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentionsave(HttpServletRequest request, @Valid SipTrunk siptrunk) { if (!StringUtils.isBlank(siptrunk.getName())) { int count = sipTrunkRes.countByNameAndOrgi(siptrunk.getName(), super.getOrgi(request)); @@ -81,7 +81,7 @@ public class CallCenterSipTrunkController extends Handler { } @RequestMapping(value = "/siptrunk/edit") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView siptrunkedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -89,7 +89,7 @@ public class CallCenterSipTrunkController extends Handler { } @RequestMapping(value = "/siptrunk/update") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid SipTrunk siptrunk) { if (!StringUtils.isBlank(siptrunk.getId())) { SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request)); @@ -122,7 +122,7 @@ public class CallCenterSipTrunkController extends Handler { } @RequestMapping(value = "/siptrunk/code") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView siptrunkcode(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -130,7 +130,7 @@ public class CallCenterSipTrunkController extends Handler { } @RequestMapping(value = "/siptrunk/code/update") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView siptrunkcodeupdate(HttpServletRequest request, @Valid SipTrunk siptrunk) { if (!StringUtils.isBlank(siptrunk.getId())) { SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request)); @@ -144,7 +144,7 @@ public class CallCenterSipTrunkController extends Handler { } @RequestMapping(value = "/siptrunk/delete") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) { if (!StringUtils.isBlank(id)) { sipTrunkRes.deleteById(id); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterSkillController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterSkillController.java index 0e45bfc5..c0eca9cf 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterSkillController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/callcenter/CallCenterSkillController.java @@ -56,7 +56,7 @@ public class CallCenterSkillController extends Handler { private final SkillExtentionRepository skillExtentionRes; @RequestMapping(value = "/skill") - @Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true) + @Menu(type = "callcenter", subtype = "callcenterresource", admin = true) public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) { List pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); map.addAttribute("pbxHostList", pbxHostList); @@ -83,14 +83,14 @@ public class CallCenterSkillController extends Handler { } @RequestMapping(value = "/skill/add") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) { map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/add")); } @RequestMapping(value = "/skill/save") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentionsave(HttpServletRequest request, @Valid CallCenterSkill skill) { if (!StringUtils.isBlank(skill.getSkill())) { int count = skillRes.countBySkillAndOrgi(skill.getSkill(), super.getOrgi(request)); @@ -104,7 +104,7 @@ public class CallCenterSkillController extends Handler { } @RequestMapping(value = "/skill/edit") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentionedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -112,7 +112,7 @@ public class CallCenterSkillController extends Handler { } @RequestMapping(value = "/skill/update") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid Extention extention) { if (!StringUtils.isBlank(extention.getId())) { Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)); @@ -129,7 +129,7 @@ public class CallCenterSkillController extends Handler { } @RequestMapping(value = "/skill/delete") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) { if (!StringUtils.isBlank(id)) { extentionRes.deleteById(id); @@ -138,7 +138,7 @@ public class CallCenterSkillController extends Handler { } @RequestMapping(value = "/skill/imp") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView skillimp(ModelMap map, HttpServletRequest request, @Valid String hostid) { if (!StringUtils.isBlank(hostid)) { map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @@ -149,7 +149,7 @@ public class CallCenterSkillController extends Handler { } @RequestMapping(value = "/skill/extention/delete") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView skillextentiondelete(@Valid String id, @Valid String hostid) { if (!StringUtils.isBlank(id)) { skillExtentionRes.deleteById(id); @@ -158,7 +158,7 @@ public class CallCenterSkillController extends Handler { } @RequestMapping(value = "/skill/extention/save") - @Menu(type = "callcenter", subtype = "extention", access = false, admin = true) + @Menu(type = "callcenter", subtype = "extention", admin = true) public ModelAndView skillextentionsave(HttpServletRequest request, @Valid SkillExtention skillExtention, @Valid String hostid, @Valid String[] exts) { if (exts != null && exts.length > 0) { List skillExtentionList = skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/channel/SNSAccountIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/channel/SNSAccountIMController.java index de1b6ec5..c904e128 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/channel/SNSAccountIMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/channel/SNSAccountIMController.java @@ -61,7 +61,7 @@ public class SNSAccountIMController extends Handler { private SecretRepository secRes; @RequestMapping("/index") - @Menu(type = "admin", subtype = "im", access = false, admin = true) + @Menu(type = "admin", subtype = "im", admin = true) public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute,@RequestParam(name = "status",required = false) String status ) { map.addAttribute("snsAccountList", snsAccountRes.findBySnstypeAndOrgi(MainContext.ChannelType.WEBIM.toString(), super.getOrgi(request), PageRequest.of(super.getP(request), super.getPs(request)))); map.addAttribute("status", status); @@ -76,7 +76,7 @@ public class SNSAccountIMController extends Handler { } @RequestMapping("/add") - @Menu(type = "admin", subtype = "send", access = false, admin = true) + @Menu(type = "admin", subtype = "send", admin = true) public ModelAndView add(ModelMap map, HttpServletRequest request) { return request(super.createRequestPageTempletResponse("/admin/channel/im/add")); } @@ -140,14 +140,14 @@ public class SNSAccountIMController extends Handler { } @RequestMapping("/edit") - @Menu(type = "admin", subtype = "send", access = false, admin = true) + @Menu(type = "admin", subtype = "send", 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")); } @RequestMapping("/update") - @Menu(type = "admin", subtype = "send", access = false, admin = true) + @Menu(type = "admin", subtype = "send", admin = true) public ModelAndView update(HttpServletRequest request, @Valid SNSAccount snsAccount) throws NoSuchAlgorithmException { SNSAccount oldSnsAccount = snsAccountRes.findByIdAndOrgi(snsAccount.getId(), super.getOrgi(request)); if (oldSnsAccount != null) { diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/config/SystemConfigController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/config/SystemConfigController.java index 6c9c596f..fa135862 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/config/SystemConfigController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/admin/config/SystemConfigController.java @@ -1,282 +1,282 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.chatopera.cc.controller.admin.config; - -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.Dict; -import com.chatopera.cc.model.Secret; -import com.chatopera.cc.model.SysDic; -import com.chatopera.cc.model.SystemConfig; -import com.chatopera.cc.persistence.repository.SecretRepository; -import com.chatopera.cc.persistence.repository.SystemConfigRepository; -import com.chatopera.cc.persistence.repository.SystemMessageRepository; -import com.chatopera.cc.persistence.repository.TemplateRepository; -import com.chatopera.cc.util.Menu; -import com.corundumstudio.socketio.SocketIOServer; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.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.validation.BindingResult; -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.FileOutputStream; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.Properties; - -@Controller -@RequestMapping("/admin/config") -public class SystemConfigController extends Handler { - - @Value("${uk.im.server.port}") - private Integer port; - - @Value("${web.upload-path}") - private String path; - - @Autowired - private SocketIOServer server; - - @Autowired - private SystemConfigRepository systemConfigRes; - - - @Autowired - private SystemMessageRepository systemMessageRes; - - @Autowired - private SecretRepository secRes; - - @Autowired - private TemplateRepository templateRes; - - @RequestMapping("/index") - @Menu(type = "admin", subtype = "config", admin = true) - public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute) throws SQLException { - map.addAttribute("server", server); - if (MainContext.hasModule(Constants.CSKEFU_MODULE_ENTIM)) { - map.addAttribute(Constants.CSKEFU_MODULE_ENTIM, true); - } - if (request.getSession().getAttribute(Constants.CSKEFU_SYSTEM_INFOACQ) != null) { - map.addAttribute( - Constants.CSKEFU_MODULE_ENTIM, request.getSession().getAttribute(Constants.CSKEFU_SYSTEM_INFOACQ)); - } - map.addAttribute("server", server); - map.addAttribute("imServerStatus", MainContext.getIMServerStatus()); - List secretConfig = secRes.findByOrgi(super.getOrgi(request)); - if (secretConfig != null && secretConfig.size() > 0) { - map.addAttribute("secret", secretConfig.get(0)); - } - List dicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC); - SysDic callCenterDic = null, workOrderDic = null, smsDic = null; - for (SysDic dic : dicList) { - if (dic.getCode().equals(Constants.CSKEFU_SYSTEM_CALLCENTER)) { - callCenterDic = dic; - } - if (dic.getCode().equals(Constants.CSKEFU_SYSTEM_WORKORDEREMAIL)) { - workOrderDic = dic; - } - if (dic.getCode().equals(Constants.CSKEFU_SYSTEM_SMSEMAIL)) { - smsDic = dic; - } - } - if (callCenterDic != null) { - map.addAttribute( - "templateList", - templateRes.findByTemplettypeAndOrgi(callCenterDic.getId(), super.getOrgi(request))); - } - if (workOrderDic != null) { - map.addAttribute( - "workOrderList", - templateRes.findByTemplettypeAndOrgi(workOrderDic.getId(), super.getOrgi(request))); - } - if (smsDic != null) { - map.addAttribute("smsList", templateRes.findByTemplettypeAndOrgi(smsDic.getId(), super.getOrgi(request))); - } - - map.addAttribute( - "sysMessageList", systemMessageRes.findByMsgtypeAndOrgi(MainContext.SystemMessageType.EMAIL.toString(), - super.getOrgi(request))); - - if (StringUtils.isNotBlank(execute) && execute.equals("false")) { - map.addAttribute("execute", execute); - } - if (StringUtils.isNotBlank(request.getParameter("msg"))) { - map.addAttribute("msg", request.getParameter("msg")); - } - return request(super.createAdminTempletResponse("/admin/config/index")); - } - - @RequestMapping("/stopimserver") - @Menu(type = "admin", subtype = "stopimserver", access = false, admin = true) - public ModelAndView stopimserver(ModelMap map, HttpServletRequest request, @Valid String confirm) throws SQLException { - boolean execute; - if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) { - server.stop(); - MainContext.setIMServerStatus(false); - } - return request(super.createRequestPageTempletResponse("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")); - } - - @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")); - } - - /** - * 危险操作,请谨慎调用 , WebLogic/WebSphere/Oracle等中间件服务器禁止调用 - * - * @param map - * @param request - * @return - * @throws SQLException - */ - @RequestMapping("/stop") - @Menu(type = "admin", subtype = "stop", access = false, admin = true) - public ModelAndView stop(ModelMap map, HttpServletRequest request, @Valid String confirm) throws SQLException { - boolean execute = false; - if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) { - server.stop(); - MainContext.setIMServerStatus(false); - System.exit(0); - } - return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute)); - } - - - @RequestMapping("/save") - @Menu(type = "admin", subtype = "save", admin = true) - public ModelAndView save( - ModelMap map, HttpServletRequest request, - @Valid SystemConfig config, BindingResult result, - @RequestParam(value = "keyfile", required = false) MultipartFile keyfile, - @RequestParam(value = "loginlogo", required = false) MultipartFile loginlogo, - @RequestParam(value = "consolelogo", required = false) MultipartFile consolelogo, - @RequestParam(value = "favlogo", required = false) MultipartFile favlogo, - @Valid Secret secret) throws SQLException, IOException, NoSuchAlgorithmException { - /*SystemConfig systemConfig = systemConfigRes.findByOrgi(super.getOrgi(request)) ; - config.setOrgi(super.getOrgi(request));*/ - SystemConfig systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI); - config.setOrgi(MainContext.SYSTEM_ORGI); - String msg = "0"; - if (StringUtils.isBlank(config.getJkspassword())) { - config.setJkspassword(null); - } - if (systemConfig == null) { - config.setCreater(super.getUser(request).getId()); - config.setCreatetime(new Date()); - systemConfig = config; - } else { - MainUtils.copyProperties(config, systemConfig); - } - if (config.isEnablessl()) { - if (keyfile != null && keyfile.getBytes() != null && keyfile.getBytes().length > 0 && keyfile.getOriginalFilename() != null && keyfile.getOriginalFilename().length() > 0) { - FileUtils.writeByteArrayToFile( - new File(path, "ssl/" + keyfile.getOriginalFilename()), keyfile.getBytes()); - systemConfig.setJksfile(keyfile.getOriginalFilename()); - File sslFilePath = new File(path, "ssl/https.properties"); - if (!sslFilePath.getParentFile().exists()) { - sslFilePath.getParentFile().mkdirs(); - } - Properties prop = new Properties(); - FileOutputStream oFile = new FileOutputStream(sslFilePath);//true表示追加打开 - prop.setProperty("key-store-password", MainUtils.encryption(systemConfig.getJkspassword())); - prop.setProperty("key-store", systemConfig.getJksfile()); - prop.store(oFile, "SSL Properties File"); - oFile.close(); - } - } else if (new File(path, "ssl").exists()) { - File[] sslFiles = new File(path, "ssl").listFiles(); - for (File sslFile : sslFiles) { - sslFile.delete(); - } - } - - if (loginlogo != null && StringUtils.isNotBlank( - loginlogo.getOriginalFilename()) && loginlogo.getOriginalFilename().lastIndexOf(".") > 0) { - systemConfig.setLoginlogo(super.saveImageFileWithMultipart(loginlogo)); - } - if (consolelogo != null && StringUtils.isNotBlank( - consolelogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) { - systemConfig.setConsolelogo(super.saveImageFileWithMultipart(consolelogo)); - } - if (favlogo != null && StringUtils.isNotBlank( - favlogo.getOriginalFilename()) && favlogo.getOriginalFilename().lastIndexOf(".") > 0) { - systemConfig.setFavlogo(super.saveImageFileWithMultipart(favlogo)); - } - - if (secret != null && StringUtils.isNotBlank(secret.getPassword())) { - List secretConfig = secRes.findByOrgi(super.getOrgi(request)); - String repassword = request.getParameter("repassword"); - if (StringUtils.isNotBlank(repassword) && repassword.equals(secret.getPassword())) { - if (secretConfig != null && secretConfig.size() > 0) { - Secret tempSecret = secretConfig.get(0); - String oldpass = request.getParameter("oldpass"); - if (StringUtils.isNotBlank(oldpass) && MainUtils.md5(oldpass).equals(tempSecret.getPassword())) { - tempSecret.setPassword(MainUtils.md5(secret.getPassword())); - msg = "1"; - tempSecret.setEnable(true); - secRes.save(tempSecret); - } else { - msg = "3"; - } - } else { - secret.setOrgi(super.getOrgi(request)); - secret.setCreater(super.getUser(request).getId()); - secret.setCreatetime(new Date()); - secret.setPassword(MainUtils.md5(secret.getPassword())); - secret.setEnable(true); - msg = "1"; - secRes.save(secret); - } - } else { - msg = "2"; - } - map.addAttribute("msg", msg); - } - systemConfigRes.save(systemConfig); - - MainContext.getCache().putSystemByIdAndOrgi("systemConfig", super.getOrgi(request), systemConfig); - map.addAttribute("imServerStatus", MainContext.getIMServerStatus()); - - return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?msg=" + msg)); - } -} \ No newline at end of file +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.chatopera.cc.controller.admin.config; + +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.Dict; +import com.chatopera.cc.model.Secret; +import com.chatopera.cc.model.SysDic; +import com.chatopera.cc.model.SystemConfig; +import com.chatopera.cc.persistence.repository.SecretRepository; +import com.chatopera.cc.persistence.repository.SystemConfigRepository; +import com.chatopera.cc.persistence.repository.SystemMessageRepository; +import com.chatopera.cc.persistence.repository.TemplateRepository; +import com.chatopera.cc.util.Menu; +import com.corundumstudio.socketio.SocketIOServer; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.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.validation.BindingResult; +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.FileOutputStream; +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.sql.SQLException; +import java.util.Date; +import java.util.List; +import java.util.Properties; + +@Controller +@RequestMapping("/admin/config") +public class SystemConfigController extends Handler { + + @Value("${uk.im.server.port}") + private Integer port; + + @Value("${web.upload-path}") + private String path; + + @Autowired + private SocketIOServer server; + + @Autowired + private SystemConfigRepository systemConfigRes; + + + @Autowired + private SystemMessageRepository systemMessageRes; + + @Autowired + private SecretRepository secRes; + + @Autowired + private TemplateRepository templateRes; + + @RequestMapping("/index") + @Menu(type = "admin", subtype = "config", admin = true) + public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute) throws SQLException { + map.addAttribute("server", server); + if (MainContext.hasModule(Constants.CSKEFU_MODULE_ENTIM)) { + map.addAttribute(Constants.CSKEFU_MODULE_ENTIM, true); + } + if (request.getSession().getAttribute(Constants.CSKEFU_SYSTEM_INFOACQ) != null) { + map.addAttribute( + Constants.CSKEFU_MODULE_ENTIM, request.getSession().getAttribute(Constants.CSKEFU_SYSTEM_INFOACQ)); + } + map.addAttribute("server", server); + map.addAttribute("imServerStatus", MainContext.getIMServerStatus()); + List secretConfig = secRes.findByOrgi(super.getOrgi(request)); + if (secretConfig != null && secretConfig.size() > 0) { + map.addAttribute("secret", secretConfig.get(0)); + } + List dicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC); + SysDic callCenterDic = null, workOrderDic = null, smsDic = null; + for (SysDic dic : dicList) { + if (dic.getCode().equals(Constants.CSKEFU_SYSTEM_CALLCENTER)) { + callCenterDic = dic; + } + if (dic.getCode().equals(Constants.CSKEFU_SYSTEM_WORKORDEREMAIL)) { + workOrderDic = dic; + } + if (dic.getCode().equals(Constants.CSKEFU_SYSTEM_SMSEMAIL)) { + smsDic = dic; + } + } + if (callCenterDic != null) { + map.addAttribute( + "templateList", + templateRes.findByTemplettypeAndOrgi(callCenterDic.getId(), super.getOrgi(request))); + } + if (workOrderDic != null) { + map.addAttribute( + "workOrderList", + templateRes.findByTemplettypeAndOrgi(workOrderDic.getId(), super.getOrgi(request))); + } + if (smsDic != null) { + map.addAttribute("smsList", templateRes.findByTemplettypeAndOrgi(smsDic.getId(), super.getOrgi(request))); + } + + map.addAttribute( + "sysMessageList", systemMessageRes.findByMsgtypeAndOrgi(MainContext.SystemMessageType.EMAIL.toString(), + super.getOrgi(request))); + + if (StringUtils.isNotBlank(execute) && execute.equals("false")) { + map.addAttribute("execute", execute); + } + if (StringUtils.isNotBlank(request.getParameter("msg"))) { + map.addAttribute("msg", request.getParameter("msg")); + } + return request(super.createAdminTempletResponse("/admin/config/index")); + } + + @RequestMapping("/stopimserver") + @Menu(type = "admin", subtype = "stopimserver", admin = true) + public ModelAndView stopimserver(ModelMap map, HttpServletRequest request, @Valid String confirm) throws SQLException { + boolean execute; + if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) { + server.stop(); + MainContext.setIMServerStatus(false); + } + return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute)); + } + + @RequestMapping("/startentim") + @Menu(type = "admin", subtype = "startentim", 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")); + } + + @RequestMapping("/stopentim") + @Menu(type = "admin", subtype = "stopentim", 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")); + } + + /** + * 危险操作,请谨慎调用 , WebLogic/WebSphere/Oracle等中间件服务器禁止调用 + * + * @param map + * @param request + * @return + * @throws SQLException + */ + @RequestMapping("/stop") + @Menu(type = "admin", subtype = "stop", admin = true) + public ModelAndView stop(ModelMap map, HttpServletRequest request, @Valid String confirm) throws SQLException { + boolean execute = false; + if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) { + server.stop(); + MainContext.setIMServerStatus(false); + System.exit(0); + } + return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute)); + } + + + @RequestMapping("/save") + @Menu(type = "admin", subtype = "save", admin = true) + public ModelAndView save( + ModelMap map, HttpServletRequest request, + @Valid SystemConfig config, BindingResult result, + @RequestParam(value = "keyfile", required = false) MultipartFile keyfile, + @RequestParam(value = "loginlogo", required = false) MultipartFile loginlogo, + @RequestParam(value = "consolelogo", required = false) MultipartFile consolelogo, + @RequestParam(value = "favlogo", required = false) MultipartFile favlogo, + @Valid Secret secret) throws SQLException, IOException, NoSuchAlgorithmException { + /*SystemConfig systemConfig = systemConfigRes.findByOrgi(super.getOrgi(request)) ; + config.setOrgi(super.getOrgi(request));*/ + SystemConfig systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI); + config.setOrgi(MainContext.SYSTEM_ORGI); + String msg = "0"; + if (StringUtils.isBlank(config.getJkspassword())) { + config.setJkspassword(null); + } + if (systemConfig == null) { + config.setCreater(super.getUser(request).getId()); + config.setCreatetime(new Date()); + systemConfig = config; + } else { + MainUtils.copyProperties(config, systemConfig); + } + if (config.isEnablessl()) { + if (keyfile != null && keyfile.getBytes() != null && keyfile.getBytes().length > 0 && keyfile.getOriginalFilename() != null && keyfile.getOriginalFilename().length() > 0) { + FileUtils.writeByteArrayToFile( + new File(path, "ssl/" + keyfile.getOriginalFilename()), keyfile.getBytes()); + systemConfig.setJksfile(keyfile.getOriginalFilename()); + File sslFilePath = new File(path, "ssl/https.properties"); + if (!sslFilePath.getParentFile().exists()) { + sslFilePath.getParentFile().mkdirs(); + } + Properties prop = new Properties(); + FileOutputStream oFile = new FileOutputStream(sslFilePath);//true表示追加打开 + prop.setProperty("key-store-password", MainUtils.encryption(systemConfig.getJkspassword())); + prop.setProperty("key-store", systemConfig.getJksfile()); + prop.store(oFile, "SSL Properties File"); + oFile.close(); + } + } else if (new File(path, "ssl").exists()) { + File[] sslFiles = new File(path, "ssl").listFiles(); + for (File sslFile : sslFiles) { + sslFile.delete(); + } + } + + if (loginlogo != null && StringUtils.isNotBlank( + loginlogo.getOriginalFilename()) && loginlogo.getOriginalFilename().lastIndexOf(".") > 0) { + systemConfig.setLoginlogo(super.saveImageFileWithMultipart(loginlogo)); + } + if (consolelogo != null && StringUtils.isNotBlank( + consolelogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) { + systemConfig.setConsolelogo(super.saveImageFileWithMultipart(consolelogo)); + } + if (favlogo != null && StringUtils.isNotBlank( + favlogo.getOriginalFilename()) && favlogo.getOriginalFilename().lastIndexOf(".") > 0) { + systemConfig.setFavlogo(super.saveImageFileWithMultipart(favlogo)); + } + + if (secret != null && StringUtils.isNotBlank(secret.getPassword())) { + List secretConfig = secRes.findByOrgi(super.getOrgi(request)); + String repassword = request.getParameter("repassword"); + if (StringUtils.isNotBlank(repassword) && repassword.equals(secret.getPassword())) { + if (secretConfig != null && secretConfig.size() > 0) { + Secret tempSecret = secretConfig.get(0); + String oldpass = request.getParameter("oldpass"); + if (StringUtils.isNotBlank(oldpass) && MainUtils.md5(oldpass).equals(tempSecret.getPassword())) { + tempSecret.setPassword(MainUtils.md5(secret.getPassword())); + msg = "1"; + tempSecret.setEnable(true); + secRes.save(tempSecret); + } else { + msg = "3"; + } + } else { + secret.setOrgi(super.getOrgi(request)); + secret.setCreater(super.getUser(request).getId()); + secret.setCreatetime(new Date()); + secret.setPassword(MainUtils.md5(secret.getPassword())); + secret.setEnable(true); + msg = "1"; + secRes.save(secret); + } + } else { + msg = "2"; + } + map.addAttribute("msg", msg); + } + systemConfigRes.save(systemConfig); + + MainContext.getCache().putSystemByIdAndOrgi("systemConfig", super.getOrgi(request), systemConfig); + map.addAttribute("imServerStatus", MainContext.getIMServerStatus()); + + return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?msg=" + msg)); + } +}