1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00

Fix PbxHostRepository related class

This commit is contained in:
dengchao@xgtl 2020-04-16 14:04:04 +08:00
parent 57b376f3aa
commit 75f7ce79d4
11 changed files with 1648 additions and 1619 deletions

View File

@ -1,106 +1,108 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Acl; import com.chatopera.cc.model.Acl;
import com.chatopera.cc.persistence.repository.AclRepository; import com.chatopera.cc.persistence.repository.AclRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository; import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter") @Controller
public class CallCenterAclController extends Handler { @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
@Autowired public class CallCenterAclController extends Handler {
private PbxHostRepository pbxHostRes ;
@NonNull
@Autowired private final PbxHostRepository pbxHostRes;
private AclRepository aclRes ;
@NonNull
@RequestMapping(value = "/acl") private final AclRepository aclRes;
@Menu(type = "callcenter" , subtype = "callcenteracl" , access = false , admin = true)
public ModelAndView acl(ModelMap map , HttpServletRequest request , @Valid String hostid) { @RequestMapping(value = "/acl")
if(!StringUtils.isBlank(hostid)){ @Menu(type = "callcenter", subtype = "callcenteracl", admin = true)
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); public ModelAndView acl(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.addAttribute("aclList" , aclRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); if (!StringUtils.isBlank(hostid)) {
} map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/index")); map.addAttribute("aclList", aclRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
} }
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/index"));
@RequestMapping(value = "/acl/add") }
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acladd(ModelMap map , HttpServletRequest request , @Valid String hostid) { @RequestMapping(value = "/acl/add")
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; @Menu(type = "callcenter", subtype = "acl", admin = true)
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/add")); public ModelAndView acladd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/add"));
@RequestMapping(value = "/acl/save") }
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView aclsave(ModelMap map , HttpServletRequest request , @Valid Acl acl) { @RequestMapping(value = "/acl/save")
if(!StringUtils.isBlank(acl.getName())){ @Menu(type = "callcenter", subtype = "acl", admin = true)
int count = aclRes.countByNameAndOrgi(acl.getName(), super.getOrgi(request)) ; public ModelAndView aclsave(HttpServletRequest request, @Valid Acl acl) {
if(count == 0){ if (!StringUtils.isBlank(acl.getName())) {
acl.setOrgi(super.getOrgi(request)); int count = aclRes.countByNameAndOrgi(acl.getName(), super.getOrgi(request));
acl.setCreater(super.getUser(request).getId()); if (count == 0) {
aclRes.save(acl) ; acl.setOrgi(super.getOrgi(request));
} acl.setCreater(super.getUser(request).getId());
} aclRes.save(acl);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+acl.getHostid())); }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid=" + acl.getHostid()));
@RequestMapping(value = "/acl/edit") }
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acledit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @RequestMapping(value = "/acl/edit")
map.addAttribute("acl" , aclRes.findByIdAndOrgi(id, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "acl", admin = true)
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; public ModelAndView acledit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/edit")); map.addAttribute("acl", aclRes.findByIdAndOrgi(id, super.getOrgi(request)));
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/edit"));
@RequestMapping(value = "/acl/update") }
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid Acl acl) { @RequestMapping(value = "/acl/update")
if(!StringUtils.isBlank(acl.getId())){ @Menu(type = "callcenter", subtype = "acl", admin = true)
Acl oldAcl = aclRes.findByIdAndOrgi(acl.getId(), super.getOrgi(request)) ; public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid Acl acl) {
if(oldAcl!=null){ if (!StringUtils.isBlank(acl.getId())) {
oldAcl.setName(acl.getName()); Acl oldAcl = aclRes.findByIdAndOrgi(acl.getId(), super.getOrgi(request));
oldAcl.setDefaultvalue(acl.getDefaultvalue()); if (oldAcl != null) {
oldAcl.setStrategy(acl.getStrategy()); oldAcl.setName(acl.getName());
aclRes.save(oldAcl); oldAcl.setDefaultvalue(acl.getDefaultvalue());
} oldAcl.setStrategy(acl.getStrategy());
} aclRes.save(oldAcl);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+acl.getHostid())); }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid=" + acl.getHostid()));
@RequestMapping(value = "/acl/delete") }
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acldelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @RequestMapping(value = "/acl/delete")
if(!StringUtils.isBlank(id)){ @Menu(type = "callcenter", subtype = "acl", admin = true)
aclRes.delete(id); public ModelAndView acldelete(@Valid String id, @Valid String hostid) {
} if (!StringUtils.isBlank(id)) {
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+hostid)); aclRes.deleteById(id);
} }
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid=" + hostid));
}
}

View File

@ -1,173 +1,180 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.basic.Constants; import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext; import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost; import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.persistence.interfaces.CallCenterInterface; import com.chatopera.cc.persistence.interfaces.CallCenterInterface;
import com.chatopera.cc.persistence.repository.PbxHostRepository; import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletRequest;
import java.util.List; import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter") @Controller
public class CallCenterController extends Handler { @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
@Autowired public class CallCenterController extends Handler {
private PbxHostRepository pbxHostRes;
@NonNull
@RequestMapping(value = "/index") private final PbxHostRepository pbxHostRes;
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String msg) { @RequestMapping(value = "/index")
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); @Menu(type = "callcenter", subtype = "callcenter", admin = true)
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { public ModelAndView index(ModelMap map, HttpServletRequest request) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter"); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
for (PbxHost pbxHost : pbxHostList) { CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter");
if (callCenterImpl != null) {
pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId())); for (PbxHost pbxHost : pbxHostList) {
} //noinspection ConstantConditions
} if (callCenterImpl != null) {
} pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
map.addAttribute("pbxHostList", pbxHostList); }
return request(super.createAdminTempletResponse("/admin/callcenter/index")); }
} }
map.addAttribute("pbxHostList", pbxHostList);
@RequestMapping(value = "/pbxhost") return request(super.createAdminTempletResponse("/admin/callcenter/index"));
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) }
public ModelAndView pbxhost(ModelMap map, HttpServletRequest request) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); @RequestMapping(value = "/pbxhost")
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter"); public ModelAndView pbxhost(ModelMap map, HttpServletRequest request) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
for (PbxHost pbxHost : pbxHostList) { if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
if (callCenterImpl != null) { CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter");
pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
} for (PbxHost pbxHost : pbxHostList) {
} //noinspection ConstantConditions
} if (callCenterImpl != null) {
map.addAttribute("pbxHostList", pbxHostList); pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/index")); }
} }
}
@RequestMapping(value = "/pbxhost/add") map.addAttribute("pbxHostList", pbxHostList);
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/index"));
public ModelAndView pbxhostadd(ModelMap map, HttpServletRequest request) { }
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/add"));
} @RequestMapping(value = "/pbxhost/add")
@Menu(type = "callcenter", subtype = "pbxhost", admin = true)
@RequestMapping(value = "/pbxhost/save") public ModelAndView pbxhostadd() {
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/add"));
public ModelAndView pbxhostsave(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) { }
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
String msg = null; @RequestMapping(value = "/pbxhost/save")
if (!StringUtils.isBlank(pbxHost.getName())) { @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
int count = pbxHostRes.countByHostnameAndOrgi(pbxHost.getHostname(), super.getOrgi(request)); public ModelAndView pbxhostsave(HttpServletRequest request, @Valid PbxHost pbxHost) {
if (count == 0) { ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
pbxHost.setOrgi(super.getOrgi(request)); String msg = null;
pbxHost.setCreater(super.getUser(request).getId()); if (!StringUtils.isBlank(pbxHost.getName())) {
pbxHostRes.save(pbxHost); int count = pbxHostRes.countByHostnameAndOrgi(pbxHost.getHostname(), super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { if (count == 0) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean( pbxHost.setOrgi(super.getOrgi(request));
"callcenter"); pbxHost.setCreater(super.getUser(request).getId());
if (callCenterImpl != null) { pbxHostRes.save(pbxHost);
try { if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
callCenterImpl.init(pbxHost); CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
} catch (Exception ex) { "callcenter");
msg = ex.getMessage(); //noinspection ConstantConditions
ex.printStackTrace(); if (callCenterImpl != null) {
} try {
} callCenterImpl.init(pbxHost);
} } catch (Exception ex) {
} msg = ex.getMessage();
} ex.printStackTrace();
if (!StringUtils.isBlank(msg)) { }
view = request( }
super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html?msg=" + msg)); }
} }
return view; }
} if (!StringUtils.isBlank(msg)) {
view = request(
@RequestMapping(value = "/pbxhost/edit") super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html?msg=" + msg));
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) }
public ModelAndView pbxhostedit(ModelMap map, HttpServletRequest request, @Valid String id) { return view;
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(id, super.getOrgi(request))); }
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/edit"));
} @RequestMapping(value = "/pbxhost/edit")
@Menu(type = "callcenter", subtype = "pbxhost", admin = true)
@RequestMapping(value = "/pbxhost/update") public ModelAndView pbxhostedit(ModelMap map, HttpServletRequest request, @Valid String id) {
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(id, super.getOrgi(request)));
public ModelAndView pbxhostupdate(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) { return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/edit"));
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html")); }
String msg = null;
if (!StringUtils.isBlank(pbxHost.getId())) { @RequestMapping(value = "/pbxhost/update")
PbxHost destHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request)); @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
destHost.setHostname(pbxHost.getHostname()); public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid PbxHost pbxHost) {
destHost.setIpaddr(pbxHost.getIpaddr()); ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
destHost.setName(pbxHost.getName()); String msg = null;
destHost.setPort(pbxHost.getPort()); if (!StringUtils.isBlank(pbxHost.getId())) {
if (!StringUtils.isBlank(pbxHost.getPassword())) { PbxHost destHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request));
destHost.setPassword(pbxHost.getPassword()); destHost.setHostname(pbxHost.getHostname());
} destHost.setIpaddr(pbxHost.getIpaddr());
pbxHostRes.save(destHost); destHost.setName(pbxHost.getName());
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { destHost.setPort(pbxHost.getPort());
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean( if (!StringUtils.isBlank(pbxHost.getPassword())) {
"callcenter"); destHost.setPassword(pbxHost.getPassword());
if (callCenterImpl != null) { }
try { pbxHostRes.save(destHost);
callCenterImpl.init(destHost); if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
} catch (Exception ex) { CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
msg = ex.getMessage(); "callcenter");
ex.printStackTrace(); //noinspection ConstantConditions
} if (callCenterImpl != null) {
} try {
} callCenterImpl.init(destHost);
} } catch (Exception ex) {
if (!StringUtils.isBlank(msg)) { msg = ex.getMessage();
view = request( ex.printStackTrace();
super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html?msg=" + msg)); }
} }
return view; }
} }
if (!StringUtils.isBlank(msg)) {
@RequestMapping(value = "/pbxhost/delete") view = request(
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html?msg=" + msg));
public ModelAndView mediadelete(ModelMap map, HttpServletRequest request, @Valid String id) { }
if (!StringUtils.isBlank(id)) { return view;
pbxHostRes.delete(id); }
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean( @RequestMapping(value = "/pbxhost/delete")
"callcenter"); @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
if (callCenterImpl != null) { public ModelAndView mediadelete(@Valid String id) {
callCenterImpl.remove(id); if (!StringUtils.isBlank(id)) {
} pbxHostRes.deleteById(id);
} if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
} CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html")); "callcenter");
} //noinspection ConstantConditions
} if (callCenterImpl != null) {
callCenterImpl.remove(id);
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
}
}

View File

@ -1,248 +1,248 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.cache.Cache; import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Extention; import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost; import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.User; import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.*; import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.CallcenterOutboundProxy; import com.chatopera.cc.proxy.CallcenterOutboundProxy;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.freeswitch.model.CallCenterAgent; import com.chatopera.cc.util.freeswitch.model.CallCenterAgent;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletRequest;
import java.util.Date; import javax.validation.Valid;
import java.util.List; import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter") @Controller
public class CallCenterExtentionController extends Handler { @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
@Autowired public class CallCenterExtentionController extends Handler {
private PbxHostRepository pbxHostRes;
@NonNull
@Autowired private final PbxHostRepository pbxHostRes;
private ExtentionRepository extentionRes;
@NonNull
@Autowired private final ExtentionRepository extentionRes;
private SipTrunkRepository sipTrunkRes;
@NonNull
@Autowired private final SipTrunkRepository sipTrunkRes;
private MediaRepository mediaRes;
@NonNull
@Autowired private final MediaRepository mediaRes;
private ServiceAiRepository serviceAiRes;
@NonNull
@Autowired private final ServiceAiRepository serviceAiRes;
private ProductRepository productRes;
@NonNull
@Autowired private final ProductRepository productRes;
private QueSurveyProcessRepository queSurveyProcessRes;
@NonNull
@Autowired private final QueSurveyProcessRepository queSurveyProcessRes;
private Cache cache;
@NonNull
private final Cache cache;
@RequestMapping(value = "/extention")
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
public ModelAndView extention(ModelMap map, HttpServletRequest request, @Valid String hostid) { @RequestMapping(value = "/extention")
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); @Menu(type = "callcenter", subtype = "callcenterresource", admin = true)
map.addAttribute("pbxHostList", pbxHostList); public ModelAndView extention(ModelMap map, HttpServletRequest request, @Valid String hostid) {
PbxHost pbxHost = null; List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (pbxHostList.size() > 0) { map.addAttribute("pbxHostList", pbxHostList);
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); PbxHost pbxHost;
map.addAttribute("extentionList", extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request))); if (pbxHostList.size() > 0) {
} map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/index")); map.addAttribute("extentionList", extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
} }
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/index"));
private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) { }
PbxHost pbxHost = pbxHostList.get(0);
if (StringUtils.isNotBlank(hostid)) { private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) {
for (PbxHost pbx : pbxHostList) { PbxHost pbxHost = pbxHostList.get(0);
if (pbx.getId().equals(hostid)) { if (StringUtils.isNotBlank(hostid)) {
pbxHost = pbx; for (PbxHost pbx : pbxHostList) {
break; if (pbx.getId().equals(hostid)) {
} pbxHost = pbx;
} break;
} }
return pbxHost; }
} }
return pbxHost;
@RequestMapping(value = "/extention/add") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) { @RequestMapping(value = "/extention/add")
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "extention", admin = true)
public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/add"));
} map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/add"));
@RequestMapping(value = "/extention/save") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map, HttpServletRequest request, @Valid Extention extention) { @RequestMapping(value = "/extention/save")
if (StringUtils.isNotBlank(extention.getExtention()) && StringUtils.isNotBlank(extention.getPassword())) { @Menu(type = "callcenter", subtype = "extention", admin = true)
String[] extstr = extention.getExtention().split("[, ]"); public ModelAndView extentionsave(HttpServletRequest request, @Valid Extention extention) {
int extnum = 0; if (StringUtils.isNotBlank(extention.getExtention()) && StringUtils.isNotBlank(extention.getPassword())) {
for (String ext : extstr) { String[] extstr = extention.getExtention().split("[, ]");
if (ext.matches("[\\d]{3,8}")) { //分机号码最少3位数字 for (String ext : extstr) {
createNewExtention(ext, super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention); if (ext.matches("[\\d]{3,8}")) { //分机号码最少3位数字
} else { createNewExtention(ext, super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention);
String[] ph = ext.split("[~-]"); } else {
if (ph.length == 2 && ph[0].matches("[\\d]{3,8}") && ph[1].matches("[\\d]{3,8}") && ph[0].length() == ph[1].length()) { String[] ph = ext.split("[~-]");
int start = Integer.parseInt(ph[0]); if (ph.length == 2 && ph[0].matches("[\\d]{3,8}") && ph[1].matches("[\\d]{3,8}") && ph[0].length() == ph[1].length()) {
int end = Integer.parseInt(ph[1]); int start = Integer.parseInt(ph[0]);
int end = Integer.parseInt(ph[1]);
for (int i = start; i <= end && extnum < 100; i++) { //最大一次批量生产的 分机号不超过100个
createNewExtention(String.valueOf(i), super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention); for (int i = start; i <= end; i++) { //最大一次批量生产的 分机号不超过100个
} createNewExtention(String.valueOf(i), super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention);
} }
} }
} }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid())); }
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
}
private Extention createNewExtention(String num, User user, String hostid, String password, String orgi, Extention src) {
Extention extno = new Extention(); private void createNewExtention(String num, User user, String hostid, String password, String orgi, Extention src) {
extno.setExtention(num); Extention extno = new Extention();
extno.setOrgi(orgi); extno.setExtention(num);
extno.setCreater(user.getId()); extno.setOrgi(orgi);
extno.setHostid(hostid); extno.setCreater(user.getId());
extno.setPassword(password); extno.setHostid(hostid);
extno.setPassword(password);
extno.setPlaynum(src.isPlaynum());
extno.setCallout(src.isCallout()); extno.setPlaynum(src.isPlaynum());
extno.setRecord(src.isRecord()); extno.setCallout(src.isCallout());
extno.setExtype(src.getExtype()); extno.setRecord(src.isRecord());
extno.setMediapath(src.getMediapath()); extno.setExtype(src.getExtype());
extno.setMediapath(src.getMediapath());
extno.setSiptrunk(src.getSiptrunk());
extno.setEnablewebrtc(src.isEnablewebrtc()); extno.setSiptrunk(src.getSiptrunk());
int count = extentionRes.countByExtentionAndHostidAndOrgi(extno.getExtention(), hostid, orgi); extno.setEnablewebrtc(src.isEnablewebrtc());
if (count == 0) { int count = extentionRes.countByExtentionAndHostidAndOrgi(extno.getExtention(), hostid, orgi);
extentionRes.save(extno); if (count == 0) {
} extentionRes.save(extno);
return extno; }
} }
@RequestMapping(value = "/extention/edit") @RequestMapping(value = "/extention/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) { public ModelAndView extentionedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/edit")); return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/edit"));
} }
@RequestMapping(value = "/extention/update") @RequestMapping(value = "/extention/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", admin = true)
public ModelAndView extentionupdate(ModelMap map, HttpServletRequest request, @Valid Extention extention) { public ModelAndView extentionupdate(HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getId())) { if (StringUtils.isNotBlank(extention.getId())) {
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)); Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
if (ext != null) { if (ext != null) {
// ext.setExtention(extention.getExtention());//分机号不能修改 // ext.setExtention(extention.getExtention());//分机号不能修改
if (StringUtils.isNotBlank(extention.getPassword())) { if (StringUtils.isNotBlank(extention.getPassword())) {
ext.setPassword(extention.getPassword()); ext.setPassword(extention.getPassword());
} }
ext.setPlaynum(extention.isPlaynum()); ext.setPlaynum(extention.isPlaynum());
ext.setCallout(extention.isCallout()); ext.setCallout(extention.isCallout());
ext.setRecord(extention.isRecord()); ext.setRecord(extention.isRecord());
ext.setExtype(extention.getExtype()); ext.setExtype(extention.getExtype());
ext.setSubtype(extention.getSubtype()); ext.setSubtype(extention.getSubtype());
ext.setDescription(extention.getDescription()); ext.setDescription(extention.getDescription());
ext.setMediapath(extention.getMediapath()); ext.setMediapath(extention.getMediapath());
ext.setSiptrunk(extention.getSiptrunk()); ext.setSiptrunk(extention.getSiptrunk());
ext.setEnablewebrtc(extention.isEnablewebrtc()); ext.setEnablewebrtc(extention.isEnablewebrtc());
ext.setUpdatetime(new Date()); ext.setUpdatetime(new Date());
extentionRes.save(ext); extentionRes.save(ext);
List<CallCenterAgent> callOutAgentList = CallcenterOutboundProxy.extention(ext.getExtention()); List<CallCenterAgent> callOutAgentList = CallcenterOutboundProxy.extention(ext.getExtention());
for (CallCenterAgent callOutAgent : callOutAgentList) { for (CallCenterAgent callOutAgent : callOutAgentList) {
callOutAgent.setSiptrunk(ext.getSiptrunk()); callOutAgent.setSiptrunk(ext.getSiptrunk());
cache.putCallCenterAgentByIdAndOrgi(callOutAgent.getUserid(), callOutAgent.getOrgi(), callOutAgent); cache.putCallCenterAgentByIdAndOrgi(callOutAgent.getUserid(), callOutAgent.getOrgi(), callOutAgent);
} }
} }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid())); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
} }
@RequestMapping(value = "/extention/ivr") @RequestMapping(value = "/extention/ivr")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", admin = true)
public ModelAndView ivr(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { public ModelAndView ivr(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request))); map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request)));
map.put("queList", queSurveyProcessRes.findByOrgi(super.getOrgi(request))); map.put("queList", queSurveyProcessRes.findByOrgi(super.getOrgi(request)));
map.put("productList", productRes.findByOrgi(super.getOrgi(request))); map.put("productList", productRes.findByOrgi(super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/ivr")); return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/ivr"));
} }
@RequestMapping(value = "/extention/ivr/update") @RequestMapping(value = "/extention/ivr/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", admin = true)
public ModelAndView ivrupdate(ModelMap map, HttpServletRequest request, @Valid Extention extention) { public ModelAndView ivrupdate(HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getId())) { if (StringUtils.isNotBlank(extention.getId())) {
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)); Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
if (ext != null) { if (ext != null) {
ext.setEnableai(extention.getEnableai()); ext.setEnableai(extention.getEnableai());
ext.setAiid(extention.getAiid()); ext.setAiid(extention.getAiid());
ext.setSceneid(extention.getSceneid()); ext.setSceneid(extention.getSceneid());
ext.setWelcomemsg(extention.getWelcomemsg()); ext.setWelcomemsg(extention.getWelcomemsg());
ext.setWaitmsg(extention.getWaitmsg()); ext.setWaitmsg(extention.getWaitmsg());
ext.setTipmessage(extention.getTipmessage()); ext.setTipmessage(extention.getTipmessage());
ext.setAitype(extention.getAitype()); ext.setAitype(extention.getAitype());
ext.setBustype(extention.getBustype()); ext.setBustype(extention.getBustype());
ext.setProid(extention.getProid()); ext.setProid(extention.getProid());
ext.setQueid(extention.getQueid()); ext.setQueid(extention.getQueid());
extentionRes.save(ext); extentionRes.save(ext);
} }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid())); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
} }
@RequestMapping(value = "/extention/delete") @RequestMapping(value = "/extention/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", admin = true)
public ModelAndView extentiondelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) {
if (StringUtils.isNotBlank(id)) { if (StringUtils.isNotBlank(id)) {
extentionRes.delete(id); extentionRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + hostid)); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + hostid));
} }
} }

View File

@ -1,106 +1,108 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Extention; import com.chatopera.cc.model.Extention;
import com.chatopera.cc.persistence.repository.ExtentionRepository; import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.IvrMenuRepository; import com.chatopera.cc.persistence.repository.IvrMenuRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository; import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter") @Controller
public class CallCenterIvrController extends Handler{ @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
@Autowired public class CallCenterIvrController extends Handler {
private PbxHostRepository pbxHostRes ;
@NonNull
@Autowired private final PbxHostRepository pbxHostRes;
private ExtentionRepository extentionRes ;
@NonNull
@Autowired private final ExtentionRepository extentionRes;
private IvrMenuRepository ivrMenuRes;
@NonNull
@RequestMapping(value = "/ivr") private final IvrMenuRepository ivrMenuRes;
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView ivr(ModelMap map , HttpServletRequest request , @Valid String hostid) { @RequestMapping(value = "/ivr")
if(!StringUtils.isBlank(hostid)){ @Menu(type = "callcenter", subtype = "callcenterivr", admin = true)
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); public ModelAndView ivr(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.addAttribute("ivrList" , extentionRes.findByExtypeAndOrgi("ivr", super.getOrgi(request))); if (!StringUtils.isBlank(hostid)) {
} map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/index")); map.addAttribute("ivrList", extentionRes.findByExtypeAndOrgi("ivr", super.getOrgi(request)));
} }
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/index"));
@RequestMapping(value = "/ivr/edit") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @RequestMapping(value = "/ivr/edit")
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "extention", admin = true)
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; public ModelAndView extentionedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/edit")); map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/edit"));
@RequestMapping(value = "/ivr/update") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionupdate(ModelMap map , HttpServletRequest request , @Valid Extention extention) { @RequestMapping(value = "/ivr/update")
if(!StringUtils.isBlank(extention.getId())){ @Menu(type = "callcenter", subtype = "extention", admin = true)
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)) ; public ModelAndView extentionupdate(HttpServletRequest request, @Valid Extention extention) {
ext.setExtention(extention.getExtention()); if (!StringUtils.isBlank(extention.getId())) {
ext.setDescription(extention.getDescription()); Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
extentionRes.save(ext) ; ext.setExtention(extention.getExtention());
} ext.setDescription(extention.getDescription());
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid="+extention.getHostid())); extentionRes.save(ext);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid=" + extention.getHostid()));
}
@RequestMapping(value = "/ivr/delete")
@Menu(type = "callcenter" , subtype = "ivr" , access = false , admin = true)
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @RequestMapping(value = "/ivr/delete")
if(!StringUtils.isBlank(id)){ @Menu(type = "callcenter", subtype = "ivr", access = false, admin = true)
extentionRes.delete(id); public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) {
} if (!StringUtils.isBlank(id)) {
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid="+hostid)); extentionRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid=" + hostid));
@RequestMapping(value = "/ivr/design") }
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView design(ModelMap map , HttpServletRequest request , @Valid String hostid , @Valid String id) { @RequestMapping(value = "/ivr/design")
if(!StringUtils.isBlank(hostid)){ @Menu(type = "callcenter", subtype = "callcenterivr", admin = true)
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request))); public ModelAndView design(ModelMap map, HttpServletRequest request, @Valid String hostid, @Valid String id) {
map.addAttribute("ivrMenuList" , ivrMenuRes.findByExtentionidAndHostidAndOrgi(id, hostid, super.getOrgi(request))); if (!StringUtils.isBlank(hostid)) {
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
} map.addAttribute("ivrMenuList", ivrMenuRes.findByExtentionidAndHostidAndOrgi(id, hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/design")); map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
} }
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/design"));
@RequestMapping(value = "/ivr/menu/add") }
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView ivrmenuadd(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid , @Valid String parentid) { @RequestMapping(value = "/ivr/menu/add")
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "callcenterivr", admin = true)
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; public ModelAndView ivrmenuadd(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/menuadd")); map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
} return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/menuadd"));
}
}

View File

@ -1,158 +1,166 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.basic.MainUtils; import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Media; import com.chatopera.cc.model.Media;
import com.chatopera.cc.persistence.repository.MediaRepository; import com.chatopera.cc.persistence.repository.MediaRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository; import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletRequest;
import java.io.File; import javax.validation.Valid;
import java.io.IOException; import java.io.File;
import java.io.IOException;
@Controller import java.util.Objects;
@RequestMapping("/admin/callcenter")
public class CallCenterMediaController extends Handler{ @Controller
@RequestMapping("/admin/callcenter")
@Autowired @RequiredArgsConstructor
private PbxHostRepository pbxHostRes ; public class CallCenterMediaController extends Handler {
@Autowired @NonNull
private MediaRepository mediaRes ; private final PbxHostRepository pbxHostRes;
@Value("${web.upload-path}") @NonNull
private String path; private final MediaRepository mediaRes;
@RequestMapping(value = "/media") @Value("${web.upload-path}")
@Menu(type = "callcenter" , subtype = "callcentermedia" , access = false , admin = true) private String path;
public ModelAndView media(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){ @RequestMapping(value = "/media")
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "callcentermedia", access = false, admin = true)
map.addAttribute("mediaList" , mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); public ModelAndView media(ModelMap map, HttpServletRequest request, @Valid String hostid) {
} if (!StringUtils.isBlank(hostid)) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/index")); map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
} map.addAttribute("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
@RequestMapping(value = "/media/add") return request(super.createRequestPageTempletResponse("/admin/callcenter/media/index"));
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true) }
public ModelAndView mediaadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; @RequestMapping(value = "/media/add")
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/add")); @Menu(type = "callcenter", subtype = "media", access = false, admin = true)
} public ModelAndView mediaadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
@RequestMapping(value = "/media/save") return request(super.createRequestPageTempletResponse("/admin/callcenter/media/add"));
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true) }
public ModelAndView mediasave(ModelMap map , HttpServletRequest request , @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
Media media = new Media(); @RequestMapping(value = "/media/save")
media.setName(request.getParameter("name")); @Menu(type = "callcenter", subtype = "media", access = false, admin = true)
media.setHostid(request.getParameter("hostid")); public ModelAndView mediasave(HttpServletRequest request, @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
if(!StringUtils.isBlank(media.getName())){ Media media = new Media();
int count = mediaRes.countByNameAndOrgi(media.getName(), super.getOrgi(request)) ; media.setName(request.getParameter("name"));
if(count == 0){ media.setHostid(request.getParameter("hostid"));
String fileName = "media/"+ MainUtils.getUUID()+mediafile.getOriginalFilename().substring(mediafile.getOriginalFilename().lastIndexOf(".")) ; if (!StringUtils.isBlank(media.getName())) {
int count = mediaRes.countByNameAndOrgi(media.getName(), super.getOrgi(request));
media.setOrgi(super.getOrgi(request)); if (count == 0) {
media.setCreater(super.getUser(request).getId()); String fileName = "media/" + MainUtils.getUUID() + Objects.requireNonNull(mediafile.getOriginalFilename())
media.setFilelength((int) mediafile.getSize()); .substring(mediafile.getOriginalFilename().lastIndexOf("."));
media.setContent(mediafile.getContentType());
media.setFilename(fileName); media.setOrgi(super.getOrgi(request));
media.setCreater(super.getUser(request).getId());
if(mediafile!=null && mediafile.getOriginalFilename().lastIndexOf(".") > 0){ media.setFilelength((int) mediafile.getSize());
File logoDir = new File(path , "media"); media.setContent(mediafile.getContentType());
if(!logoDir.exists()){ media.setFilename(fileName);
logoDir.mkdirs() ;
} if (mediafile.getOriginalFilename().lastIndexOf(".") > 0) {
FileCopyUtils.copy(mediafile.getBytes(), new File(path , fileName)); File logoDir = new File(path, "media");
} if (!logoDir.exists()) {
//noinspection ResultOfMethodCallIgnored
mediaRes.save(media) ; logoDir.mkdirs();
} }
} FileCopyUtils.copy(mediafile.getBytes(), new File(path, fileName));
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+media.getHostid())); }
}
mediaRes.save(media);
@RequestMapping(value = "/media/edit") }
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true) }
public ModelAndView mediaedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid=" + media.getHostid()));
map.addAttribute("media" , mediaRes.findByIdAndOrgi(id, super.getOrgi(request))); }
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/edit")); @RequestMapping(value = "/media/edit")
} @Menu(type = "callcenter", subtype = "media", access = false, admin = true)
public ModelAndView mediaedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
@RequestMapping(value = "/media/update") map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request)));
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true) map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException { return request(super.createRequestPageTempletResponse("/admin/callcenter/media/edit"));
Media media = new Media(); }
media.setName(request.getParameter("name"));
media.setHostid(request.getParameter("hostid")); @RequestMapping(value = "/media/update")
media.setId(request.getParameter("id")); @Menu(type = "callcenter", subtype = "media", access = false, admin = true)
if(!StringUtils.isBlank(media.getId())){ public ModelAndView pbxhostupdate(HttpServletRequest request, @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
Media oldMedia = mediaRes.findByIdAndOrgi(media.getId(), super.getOrgi(request)) ; Media media = new Media();
if(oldMedia!=null){ media.setName(request.getParameter("name"));
if(mediafile!=null && mediafile.getSize() > 0){ media.setHostid(request.getParameter("hostid"));
File wavFile = new File(path , oldMedia.getFilename()); media.setId(request.getParameter("id"));
if(!wavFile.exists()){ if (!StringUtils.isBlank(media.getId())) {
wavFile.deleteOnExit(); Media oldMedia = mediaRes.findByIdAndOrgi(media.getId(), super.getOrgi(request));
} if (oldMedia != null) {
if (mediafile != null && mediafile.getSize() > 0) {
String fileName = "media/"+ MainUtils.getUUID()+mediafile.getOriginalFilename().substring(mediafile.getOriginalFilename().lastIndexOf(".")) ; File wavFile = new File(path, oldMedia.getFilename());
oldMedia.setFilename(fileName); if (!wavFile.exists()) {
wavFile.deleteOnExit();
if(mediafile!=null && mediafile.getOriginalFilename().lastIndexOf(".") > 0){ }
File mediaDir = new File(path , "media");
if(!mediaDir.exists()){ String fileName = "media/" + MainUtils.getUUID() + Objects.requireNonNull(mediafile.getOriginalFilename())
mediaDir.mkdirs() ; .substring(mediafile.getOriginalFilename().lastIndexOf("."));
} oldMedia.setFilename(fileName);
FileCopyUtils.copy(mediafile.getBytes(), new File(path , fileName));
} if (mediafile.getOriginalFilename().lastIndexOf(".") > 0) {
} File mediaDir = new File(path, "media");
oldMedia.setName(media.getName()); if (!mediaDir.exists()) {
mediaRes.save(oldMedia); //noinspection ResultOfMethodCallIgnored
} mediaDir.mkdirs();
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+media.getHostid())); FileCopyUtils.copy(mediafile.getBytes(), new File(path, fileName));
} }
}
@RequestMapping(value = "/media/delete") oldMedia.setName(media.getName());
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true) mediaRes.save(oldMedia);
public ModelAndView mediadelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { }
if(!StringUtils.isBlank(id)){ }
mediaRes.delete(id); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid=" + media.getHostid()));
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+hostid));
} @RequestMapping(value = "/media/delete")
@RequestMapping(value = "/play") @Menu(type = "callcenter", subtype = "media", access = false, admin = true)
@Menu(type = "callcenter" , subtype = "play" , access = false) public ModelAndView mediadelete(@Valid String id, @Valid String hostid) {
public ModelAndView play(ModelMap map , HttpServletRequest request ,@Valid final String id ,@Valid final String hostid) { if (!StringUtils.isBlank(id)) {
map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request))) ; mediaRes.deleteById(id);
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/play")); }
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid=" + hostid));
} }
@RequestMapping(value = "/play")
@Menu(type = "callcenter", subtype = "play", access = false)
public ModelAndView play(ModelMap map, HttpServletRequest request, @Valid final String id) {
map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/play"));
}
}

View File

@ -1,133 +1,135 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.basic.Constants; import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext; import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost; import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.persistence.interfaces.CallCenterInterface; import com.chatopera.cc.persistence.interfaces.CallCenterInterface;
import com.chatopera.cc.persistence.repository.ExtentionRepository; import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository; import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.ServiceAiRepository; import com.chatopera.cc.persistence.repository.ServiceAiRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletRequest;
import java.util.List; import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter") @Controller
public class CallCenterResourceController extends Handler { @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
@Autowired public class CallCenterResourceController extends Handler {
private PbxHostRepository pbxHostRes;
@NonNull
@Autowired private final PbxHostRepository pbxHostRes;
private ExtentionRepository extentionRes;
@NonNull
@Autowired private final ExtentionRepository extentionRes;
private ServiceAiRepository serviceAiRes;
@NonNull
@RequestMapping(value = "/resource") private final ServiceAiRepository serviceAiRes;
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String hostid) { @RequestMapping(value = "/resource")
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
map.addAttribute("pbxHostList", pbxHostList); public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request))); map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null; map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request)));
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); PbxHost pbxHost;
map.addAttribute("extentionList", if (pbxHostList.size() > 0) {
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request))); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
} map.addAttribute("extentionList",
return request(super.createAdminTempletResponse("/admin/callcenter/resource/index")); extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
} }
return request(super.createAdminTempletResponse("/admin/callcenter/resource/index"));
@RequestMapping(value = "/resource/config") }
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView config(ModelMap map, HttpServletRequest request, @Valid String hostid) { @RequestMapping(value = "/resource/config")
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
map.addAttribute("pbxHostList", pbxHostList); public ModelAndView config(ModelMap map, HttpServletRequest request, @Valid String hostid) {
PbxHost pbxHost = null; List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (pbxHostList.size() > 0) { map.addAttribute("pbxHostList", pbxHostList);
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); PbxHost pbxHost;
map.addAttribute("extentionList", if (pbxHostList.size() > 0) {
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request))); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
} map.addAttribute("extentionList",
return request(super.createRequestPageTempletResponse("/admin/callcenter/resource/config")); extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
} }
return request(super.createRequestPageTempletResponse("/admin/callcenter/resource/config"));
@RequestMapping(value = "/resource/save") }
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) throws Exception { @RequestMapping(value = "/resource/save")
PbxHost tempPbxHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request)); @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
if (tempPbxHost != null) { public ModelAndView save(HttpServletRequest request, @Valid PbxHost pbxHost) throws Exception {
pbxHost.setCreater(tempPbxHost.getCreater()); PbxHost tempPbxHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request));
pbxHost.setCreatetime(tempPbxHost.getCreatetime()); if (tempPbxHost != null) {
if (StringUtils.isBlank(pbxHost.getPassword())) { pbxHost.setCreater(tempPbxHost.getCreater());
pbxHost.setPassword(tempPbxHost.getPassword()); pbxHost.setCreatetime(tempPbxHost.getCreatetime());
} if (StringUtils.isBlank(pbxHost.getPassword())) {
pbxHost.setOrgi(super.getOrgi(request)); pbxHost.setPassword(tempPbxHost.getPassword());
pbxHostRes.save(pbxHost); }
pbxHost.setOrgi(super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { pbxHostRes.save(pbxHost);
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter"); if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
callCenterImpl.init(pbxHost); CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
} "callcenter");
} callCenterImpl.init(pbxHost);
return request(super.createRequestPageTempletResponse( }
"redirect:/admin/callcenter/resource.html?hostid=" + pbxHost.getId())); }
} return request(super.createRequestPageTempletResponse(
"redirect:/admin/callcenter/resource.html?hostid=" + pbxHost.getId()));
@RequestMapping(value = "/resource/pbxhost") }
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView resourcepbx(ModelMap map, HttpServletRequest request, @Valid String hostid) { @RequestMapping(value = "/resource/pbxhost")
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
map.addAttribute("pbxHostList", pbxHostList); public ModelAndView resourcepbx(ModelMap map, HttpServletRequest request, @Valid String hostid) {
PbxHost pbxHost = null; List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (pbxHostList.size() > 0) { map.addAttribute("pbxHostList", pbxHostList);
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); PbxHost pbxHost;
map.addAttribute("extentionList", if (pbxHostList.size() > 0) {
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request))); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
} map.addAttribute("extentionList",
return request(super.createAdminTempletResponse("/admin/callcenter/resource/pbxhost")); extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
} }
return request(super.createAdminTempletResponse("/admin/callcenter/resource/pbxhost"));
private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) { }
PbxHost pbxHost = pbxHostList.get(0);
if (!StringUtils.isBlank(hostid)) { private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) {
for (PbxHost pbx : pbxHostList) { PbxHost pbxHost = pbxHostList.get(0);
if (pbx.getId().equals(hostid)) { if (!StringUtils.isBlank(hostid)) {
pbxHost = pbx; for (PbxHost pbx : pbxHostList) {
break; if (pbx.getId().equals(hostid)) {
} pbxHost = pbx;
} break;
} }
return pbxHost; }
} }
return pbxHost;
} }
}

View File

@ -1,135 +1,136 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost; import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.RouterRules; import com.chatopera.cc.model.RouterRules;
import com.chatopera.cc.persistence.repository.PbxHostRepository; import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.RouterRulesRepository; import com.chatopera.cc.persistence.repository.RouterRulesRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletRequest;
import java.util.List; import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter") @Controller
public class CallCenterRouterController extends Handler{ @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
@Autowired public class CallCenterRouterController extends Handler {
private PbxHostRepository pbxHostRes ;
@NonNull
private final PbxHostRepository pbxHostRes;
@Autowired
private RouterRulesRepository routerRulesRes ; @NonNull
private final RouterRulesRepository routerRulesRes;
@RequestMapping(value = "/router")
@Menu(type = "callcenter" , subtype = "callcenterresource" , access = false , admin = true) @RequestMapping(value = "/router")
public ModelAndView skill(ModelMap map , HttpServletRequest request , @Valid String hostid) { @Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)) ; public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.addAttribute("pbxHostList" , pbxHostList); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if(pbxHostList.size() > 0){ map.addAttribute("pbxHostList", pbxHostList);
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); if (pbxHostList.size() > 0) {
map.addAttribute("routerRulesList" , routerRulesRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
} map.addAttribute("routerRulesList", routerRulesRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/index")); }
} return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/index"));
}
@RequestMapping(value = "/router/add")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true) @RequestMapping(value = "/router/add")
public ModelAndView extentionadd(ModelMap map , HttpServletRequest request , @Valid String hostid) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/add")); 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) @RequestMapping(value = "/router/save")
public ModelAndView extentionsave(ModelMap map , HttpServletRequest request , @Valid RouterRules router) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
if(!StringUtils.isBlank(router.getName())){ public ModelAndView extentionsave(HttpServletRequest request, @Valid RouterRules router) {
int count = routerRulesRes.countByNameAndOrgi(router.getName(), super.getOrgi(request)) ; if (!StringUtils.isBlank(router.getName())) {
if(count == 0){ int count = routerRulesRes.countByNameAndOrgi(router.getName(), super.getOrgi(request));
router.setOrgi(super.getOrgi(request)); if (count == 0) {
router.setCreater(super.getUser(request).getId()); router.setOrgi(super.getOrgi(request));
routerRulesRes.save(router) ; router.setCreater(super.getUser(request).getId());
} routerRulesRes.save(router);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid())); }
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid=" + router.getHostid()));
}
@RequestMapping(value = "/router/edit")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true) @RequestMapping(value = "/router/edit")
public ModelAndView routeredit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
map.addAttribute("routerRules" , routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request))); public ModelAndView routeredit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; map.addAttribute("routerRules", routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/edit")); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
} return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/edit"));
}
@RequestMapping(value = "/router/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true) @RequestMapping(value = "/router/update")
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid RouterRules router) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
if(!StringUtils.isBlank(router.getId())){ public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid RouterRules router) {
RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)) ; if (!StringUtils.isBlank(router.getId())) {
if(oldRouter!=null){ RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request));
oldRouter.setName(router.getName()); if (oldRouter != null) {
oldRouter.setField(router.getField()); oldRouter.setName(router.getName());
oldRouter.setRegex(router.getRegex()); oldRouter.setField(router.getField());
oldRouter.setRouterinx(router.getRouterinx()); oldRouter.setRegex(router.getRegex());
oldRouter.setFalsebreak(router.isFalsebreak()); oldRouter.setRouterinx(router.getRouterinx());
routerRulesRes.save(oldRouter); oldRouter.setFalsebreak(router.isFalsebreak());
} routerRulesRes.save(oldRouter);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid())); }
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid=" + router.getHostid()));
}
@RequestMapping(value = "/router/code")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true) @RequestMapping(value = "/router/code")
public ModelAndView routercode(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
map.addAttribute("routerRules" , routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request))); public ModelAndView routercode(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; map.addAttribute("routerRules", routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/code")); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
} return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/code"));
}
@RequestMapping(value = "/router/code/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true) @RequestMapping(value = "/router/code/update")
public ModelAndView routercodeupdate(ModelMap map , HttpServletRequest request , @Valid RouterRules router) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
if(!StringUtils.isBlank(router.getId())){ public ModelAndView routercodeupdate(HttpServletRequest request, @Valid RouterRules router) {
RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)) ; if (!StringUtils.isBlank(router.getId())) {
if(!StringUtils.isBlank(router.getRoutercontent())){ RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request));
oldRouter.setRoutercontent(router.getRoutercontent()); if (!StringUtils.isBlank(router.getRoutercontent())) {
routerRulesRes.save(oldRouter); oldRouter.setRoutercontent(router.getRoutercontent());
} routerRulesRes.save(oldRouter);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid())); }
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid=" + router.getHostid()));
}
@RequestMapping(value = "/router/delete")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true) @RequestMapping(value = "/router/delete")
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
if(!StringUtils.isBlank(id)){ public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) {
routerRulesRes.delete(id); if (!StringUtils.isBlank(id)) {
} routerRulesRes.deleteById(id);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+hostid)); }
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid=" + hostid));
} }
}

View File

@ -1,152 +1,154 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.cache.Cache; import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.SipTrunk; import com.chatopera.cc.model.SipTrunk;
import com.chatopera.cc.persistence.repository.PbxHostRepository; import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.SipTrunkRepository; import com.chatopera.cc.persistence.repository.SipTrunkRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter") @Controller
public class CallCenterSipTrunkController extends Handler { @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
@Autowired public class CallCenterSipTrunkController extends Handler {
private PbxHostRepository pbxHostRes;
@NonNull
@Autowired private final PbxHostRepository pbxHostRes;
private SipTrunkRepository sipTrunkRes;
@NonNull
@Autowired private final SipTrunkRepository sipTrunkRes;
private Cache cache;
@NonNull
@RequestMapping(value = "/siptrunk") private final Cache cache;
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) { @RequestMapping(value = "/siptrunk")
if (!StringUtils.isBlank(hostid)) { @Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); if (!StringUtils.isBlank(hostid)) {
} map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/index")); map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
} }
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/index"));
@RequestMapping(value = "/siptrunk/add") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) { @RequestMapping(value = "/siptrunk/add")
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/add")); public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/add"));
@RequestMapping(value = "/siptrunk/save") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) { @RequestMapping(value = "/siptrunk/save")
if (!StringUtils.isBlank(siptrunk.getName())) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
int count = sipTrunkRes.countByNameAndOrgi(siptrunk.getName(), super.getOrgi(request)); public ModelAndView extentionsave(HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (count == 0) { if (!StringUtils.isBlank(siptrunk.getName())) {
siptrunk.setOrgi(super.getOrgi(request)); int count = sipTrunkRes.countByNameAndOrgi(siptrunk.getName(), super.getOrgi(request));
siptrunk.setCreater(super.getUser(request).getId()); if (count == 0) {
sipTrunkRes.save(siptrunk); siptrunk.setOrgi(super.getOrgi(request));
siptrunk.setCreater(super.getUser(request).getId());
cache.putSystemByIdAndOrgi(siptrunk.getId(), siptrunk.getOrgi(), siptrunk); sipTrunkRes.save(siptrunk);
}
} cache.putSystemByIdAndOrgi(siptrunk.getId(), siptrunk.getOrgi(), siptrunk);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid())); }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
@RequestMapping(value = "/siptrunk/edit") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { @RequestMapping(value = "/siptrunk/edit")
map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); public ModelAndView siptrunkedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/edit")); map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request)));
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/edit"));
@RequestMapping(value = "/siptrunk/update") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) { @RequestMapping(value = "/siptrunk/update")
if (!StringUtils.isBlank(siptrunk.getId())) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request)); public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (oldSipTrunk != null) { if (!StringUtils.isBlank(siptrunk.getId())) {
oldSipTrunk.setName(siptrunk.getName()); SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request));
oldSipTrunk.setSipserver(siptrunk.getSipserver()); if (oldSipTrunk != null) {
oldSipTrunk.setPort(siptrunk.getPort()); oldSipTrunk.setName(siptrunk.getName());
oldSipTrunk.setProtocol(siptrunk.getProtocol()); oldSipTrunk.setSipserver(siptrunk.getSipserver());
oldSipTrunk.setRegister(siptrunk.isRegister()); oldSipTrunk.setPort(siptrunk.getPort());
oldSipTrunk.setDefaultsip(siptrunk.isDefaultsip()); oldSipTrunk.setProtocol(siptrunk.getProtocol());
oldSipTrunk.setTitle(siptrunk.getTitle()); oldSipTrunk.setRegister(siptrunk.isRegister());
oldSipTrunk.setDefaultsip(siptrunk.isDefaultsip());
oldSipTrunk.setEnablecallagent(siptrunk.isEnablecallagent()); oldSipTrunk.setTitle(siptrunk.getTitle());
oldSipTrunk.setOutnumber(siptrunk.getOutnumber()); oldSipTrunk.setEnablecallagent(siptrunk.isEnablecallagent());
oldSipTrunk.setBusyext(siptrunk.getBusyext());
oldSipTrunk.setNotready(siptrunk.getNotready()); oldSipTrunk.setOutnumber(siptrunk.getOutnumber());
oldSipTrunk.setBusyext(siptrunk.getBusyext());
oldSipTrunk.setNoname(siptrunk.getNoname()); oldSipTrunk.setNotready(siptrunk.getNotready());
oldSipTrunk.setProvince(siptrunk.getProvince()); oldSipTrunk.setNoname(siptrunk.getNoname());
oldSipTrunk.setCity(siptrunk.getCity());
oldSipTrunk.setPrefix(siptrunk.getPrefix()); oldSipTrunk.setProvince(siptrunk.getProvince());
oldSipTrunk.setCity(siptrunk.getCity());
sipTrunkRes.save(oldSipTrunk); oldSipTrunk.setPrefix(siptrunk.getPrefix());
cache.putSystemByIdAndOrgi(oldSipTrunk.getId(), oldSipTrunk.getOrgi(), oldSipTrunk);
} sipTrunkRes.save(oldSipTrunk);
} cache.putSystemByIdAndOrgi(oldSipTrunk.getId(), oldSipTrunk.getOrgi(), oldSipTrunk);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid())); }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
@RequestMapping(value = "/siptrunk/code") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkcode(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { @RequestMapping(value = "/siptrunk/code")
map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); public ModelAndView siptrunkcode(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/code")); map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request)));
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/code"));
@RequestMapping(value = "/siptrunk/code/update") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkcodeupdate(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) { @RequestMapping(value = "/siptrunk/code/update")
if (!StringUtils.isBlank(siptrunk.getId())) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request)); public ModelAndView siptrunkcodeupdate(HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getSipcontent())) { if (!StringUtils.isBlank(siptrunk.getId())) {
oldSipTrunk.setSipcontent(siptrunk.getSipcontent()); SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request));
sipTrunkRes.save(oldSipTrunk); if (!StringUtils.isBlank(siptrunk.getSipcontent())) {
cache.putSystemByIdAndOrgi(oldSipTrunk.getId(), oldSipTrunk.getOrgi(), oldSipTrunk); oldSipTrunk.setSipcontent(siptrunk.getSipcontent());
} sipTrunkRes.save(oldSipTrunk);
} cache.putSystemByIdAndOrgi(oldSipTrunk.getId(), oldSipTrunk.getOrgi(), oldSipTrunk);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid())); }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
@RequestMapping(value = "/siptrunk/delete") }
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentiondelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { @RequestMapping(value = "/siptrunk/delete")
if (!StringUtils.isBlank(id)) { @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
sipTrunkRes.delete(id); public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) {
} if (!StringUtils.isBlank(id)) {
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + hostid)); sipTrunkRes.deleteById(id);
} }
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + hostid));
}
}

View File

@ -1,186 +1,189 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.admin.callcenter; package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CallCenterSkill; import com.chatopera.cc.model.CallCenterSkill;
import com.chatopera.cc.model.Extention; import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost; import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.SkillExtention; import com.chatopera.cc.model.SkillExtention;
import com.chatopera.cc.persistence.repository.CallCenterSkillRepository; import com.chatopera.cc.persistence.repository.CallCenterSkillRepository;
import com.chatopera.cc.persistence.repository.ExtentionRepository; import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository; import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.SkillExtentionRepository; import com.chatopera.cc.persistence.repository.SkillExtentionRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
public class CallCenterSkillController extends Handler { @RequiredArgsConstructor
public class CallCenterSkillController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes ; @org.springframework.lang.NonNull
private final PbxHostRepository pbxHostRes;
@Autowired
private ExtentionRepository extentionRes; @org.springframework.lang.NonNull
private final ExtentionRepository extentionRes;
@Autowired
private CallCenterSkillRepository skillRes ; @org.springframework.lang.NonNull
private final CallCenterSkillRepository skillRes;
@Autowired
private SkillExtentionRepository skillExtentionRes; @org.springframework.lang.NonNull
private final SkillExtentionRepository skillExtentionRes;
@RequestMapping(value = "/skill")
@Menu(type = "callcenter" , subtype = "callcenterresource" , access = false , admin = true) @RequestMapping(value = "/skill")
public ModelAndView skill(ModelMap map , HttpServletRequest request , @Valid String hostid) { @Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)) ; public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.addAttribute("pbxHostList" , pbxHostList); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
PbxHost pbxHost = null ; map.addAttribute("pbxHostList", pbxHostList);
if(pbxHostList.size() > 0){ PbxHost pbxHost;
map.addAttribute("pbxHost" , pbxHost = getPbxHost(pbxHostList, hostid)); if (pbxHostList.size() > 0) {
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("skillExtentionList" , skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request))); map.addAttribute("skillGroups", skillRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
} map.addAttribute("skillExtentionList", skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/index")); }
} return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/index"));
}
private PbxHost getPbxHost(List<PbxHost> pbxHostList ,String hostid){
PbxHost pbxHost = pbxHostList.get(0) ; private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) {
if(!StringUtils.isBlank(hostid)){ PbxHost pbxHost = pbxHostList.get(0);
for(PbxHost pbx : pbxHostList){ if (!StringUtils.isBlank(hostid)) {
if(pbx.getId().equals(hostid)){ for (PbxHost pbx : pbxHostList) {
pbxHost = pbx; break ; if (pbx.getId().equals(hostid)) {
} pbxHost = pbx;
} break;
} }
return pbxHost ; }
} }
return pbxHost;
@RequestMapping(value = "/skill/add") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionadd(ModelMap map , HttpServletRequest request , @Valid String hostid) { @RequestMapping(value = "/skill/add")
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/add")); public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/add"));
@RequestMapping(value = "/skill/save") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionsave(ModelMap map , HttpServletRequest request , @Valid CallCenterSkill skill) { @RequestMapping(value = "/skill/save")
if(!StringUtils.isBlank(skill.getSkill())){ @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
int count = skillRes.countBySkillAndOrgi(skill.getSkill(), super.getOrgi(request)) ; public ModelAndView extentionsave(HttpServletRequest request, @Valid CallCenterSkill skill) {
if(count == 0){ if (!StringUtils.isBlank(skill.getSkill())) {
skill.setOrgi(super.getOrgi(request)); int count = skillRes.countBySkillAndOrgi(skill.getSkill(), super.getOrgi(request));
skill.setCreater(super.getUser(request).getId()); if (count == 0) {
skillRes.save(skill) ; skill.setOrgi(super.getOrgi(request));
} skill.setCreater(super.getUser(request).getId());
} skillRes.save(skill);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+skill.getHostid())); }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + skill.getHostid()));
@RequestMapping(value = "/skill/edit") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @RequestMapping(value = "/skill/edit")
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request))); @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; public ModelAndView extentionedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/edit")); map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
} map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/edit"));
@RequestMapping(value = "/skill/update") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid Extention extention) { @RequestMapping(value = "/skill/update")
if(!StringUtils.isBlank(extention.getId())){ @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)) ; public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid Extention extention) {
if(ext!=null && !StringUtils.isBlank(ext.getExtention()) && ext.getExtention().matches("[\\d]{3,8}")){ if (!StringUtils.isBlank(extention.getId())) {
ext.setExtention(extention.getExtention()); Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
if(!StringUtils.isBlank(extention.getPassword())){ if (ext != null && !StringUtils.isBlank(ext.getExtention()) && ext.getExtention().matches("[\\d]{3,8}")) {
ext.setPassword(extention.getPassword()); ext.setExtention(extention.getExtention());
} if (!StringUtils.isBlank(extention.getPassword())) {
ext.setUpdatetime(new Date()); ext.setPassword(extention.getPassword());
extentionRes.save(ext) ; }
} ext.setUpdatetime(new Date());
} extentionRes.save(ext);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+extention.getHostid())); }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + extention.getHostid()));
@RequestMapping(value = "/skill/delete") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @RequestMapping(value = "/skill/delete")
if(!StringUtils.isBlank(id)){ @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
extentionRes.delete(id); public ModelAndView extentiondelete(@Valid String id, @Valid String hostid) {
} if (!StringUtils.isBlank(id)) {
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid)); extentionRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + hostid));
@RequestMapping(value = "/skill/imp") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillimp(ModelMap map , HttpServletRequest request , @Valid String hostid) { @RequestMapping(value = "/skill/imp")
if(!StringUtils.isBlank(hostid)){ @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ; public ModelAndView skillimp(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.put("extentionList", extentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request))) ; if (!StringUtils.isBlank(hostid)) {
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(hostid , super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
} map.put("extentionList", extentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/imp")); map.addAttribute("skillGroups", skillRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
} }
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/imp"));
@RequestMapping(value = "/skill/extention/delete") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillextentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { @RequestMapping(value = "/skill/extention/delete")
if(!StringUtils.isBlank(id)){ @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
skillExtentionRes.delete(id); public ModelAndView skillextentiondelete(@Valid String id, @Valid String hostid) {
} if (!StringUtils.isBlank(id)) {
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid)); skillExtentionRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + hostid));
@RequestMapping(value = "/skill/extention/save") }
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillextentionsave(ModelMap map , HttpServletRequest request , @Valid SkillExtention skillExtention, @Valid String hostid , @Valid String[] exts) { @RequestMapping(value = "/skill/extention/save")
if(exts!=null && exts.length > 0){ @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
List<SkillExtention> skillExtentionList = skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)) ; public ModelAndView skillextentionsave(HttpServletRequest request, @Valid SkillExtention skillExtention, @Valid String hostid, @Valid String[] exts) {
for(String ext :exts){ if (exts != null && exts.length > 0) {
SkillExtention skillExt = new SkillExtention() ; List<SkillExtention> skillExtentionList = skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request));
skillExt.setOrgi(super.getOrgi(request)); for (String ext : exts) {
skillExt.setCreater(super.getUser(request).getId()); SkillExtention skillExt = new SkillExtention();
skillExt.setCreatetime(new Date()); skillExt.setOrgi(super.getOrgi(request));
skillExt.setExtention(ext); skillExt.setCreater(super.getUser(request).getId());
skillExt.setHostid(hostid); skillExt.setCreatetime(new Date());
skillExt.setSkillid(skillExtention.getSkillid()); skillExt.setExtention(ext);
skillExt.setUpdatetime(new Date()); skillExt.setHostid(hostid);
boolean ingroup = false; skillExt.setSkillid(skillExtention.getSkillid());
for(SkillExtention temp : skillExtentionList){ skillExt.setUpdatetime(new Date());
if(temp.getSkillid().equals(skillExt.getSkillid()) && temp.getExtention().equals(skillExt.getExtention())){ boolean ingroup = false;
ingroup = true ; for (SkillExtention temp : skillExtentionList) {
} if (temp.getSkillid().equals(skillExt.getSkillid()) && temp.getExtention().equals(skillExt.getExtention())) {
} ingroup = true;
if(ingroup == false){ break;
skillExtentionRes.save(skillExt) ; }
} }
} if (!ingroup) {
} skillExtentionRes.save(skillExt);
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid)); }
} }
}
} return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + hostid));
}
}

View File

@ -1,189 +1,188 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.controller.apps; package com.chatopera.cc.controller.apps;
import com.chatopera.cc.basic.MainContext; import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils; import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Extention; import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost; import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.SystemConfig; import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.Template; import com.chatopera.cc.model.Template;
import com.chatopera.cc.persistence.repository.*; import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.lang.NonNull;
import org.springframework.ui.ModelMap; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.servlet.http.HttpServletResponse;
import java.util.List; import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/apps/callcenter") @Controller
public class ExtentionController extends Handler{ @RequestMapping("/apps/callcenter")
@RequiredArgsConstructor
@Autowired public class ExtentionController extends Handler {
private PbxHostRepository pbxHostRes ;
@NonNull
@Autowired private final PbxHostRepository pbxHostRes;
private ExtentionRepository extentionRes;
@NonNull
@Autowired private final ExtentionRepository extentionRes;
private AclRepository aclRes;
@NonNull
@Autowired private final AclRepository aclRes;
private RouterRulesRepository routerRes;
@NonNull
@Autowired private final RouterRulesRepository routerRes;
private SkillExtentionRepository skillExtentionRes ;
@NonNull
@Autowired private final SkillExtentionRepository skillExtentionRes;
private CallCenterSkillRepository skillRes ;
@NonNull
@Autowired private final CallCenterSkillRepository skillRes;
private SipTrunkRepository sipTrunkRes ;
@NonNull
@RequestMapping(value = "/extention") private final SipTrunkRepository sipTrunkRes;
@Menu(type = "callcenter" , subtype = "extention" , access = true)
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value) { @RequestMapping(value = "/extention")
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/index")) ; @Menu(type = "callcenter", subtype = "extention", access = true)
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname) ; public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String hostname) {
PbxHost pbxHost = null ; ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/index"));
SystemConfig systemConfig = MainUtils.getSystemConfig() ; List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname);
if(pbxHostList!=null && pbxHostList.size() > 0){ PbxHost pbxHost;
pbxHost = pbxHostList.get(0) ; SystemConfig systemConfig = MainUtils.getSystemConfig();
map.addAttribute("pbxHost" , pbxHost); if (pbxHostList != null && pbxHostList.size() > 0) {
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); pbxHost = pbxHostList.get(0);
map.addAttribute("extentionList" , extentionRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); map.addAttribute("pbxHost", pbxHost);
} map.addAttribute("skillGroups", skillRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
if(systemConfig!=null && systemConfig.isCallcenter()){ map.addAttribute("extentionList", extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
if(!StringUtils.isBlank(systemConfig.getCc_extention())){ }
Template template = MainUtils.getTemplate(systemConfig.getCc_extention()) ; if (systemConfig != null && systemConfig.isCallcenter()) {
if(template!=null){ if (!StringUtils.isBlank(systemConfig.getCc_extention())) {
map.addAttribute("template" , template); Template template = MainUtils.getTemplate(systemConfig.getCc_extention());
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template")) ; if (template != null) {
} map.addAttribute("template", template);
} view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template"));
} }
return view ; }
} }
return view;
@RequestMapping(value = "/configuration") }
@Menu(type = "callcenter" , subtype = "configuration" , access = true)
public ModelAndView configuration(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value , @Valid String profile) { @RequestMapping(value = "/configuration")
@Menu(type = "callcenter", subtype = "configuration", access = true)
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname) ; public ModelAndView configuration(ModelMap map, HttpServletRequest request, @Valid String hostname, @Valid String key_value) {
PbxHost pbxHost = null ;
SystemConfig systemConfig = MainUtils.getSystemConfig() ; List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname);
if(pbxHostList!=null && pbxHostList.size() > 0){ PbxHost pbxHost;
pbxHost = pbxHostList.get(0) ; SystemConfig systemConfig = MainUtils.getSystemConfig();
map.addAttribute("pbxHost" , pbxHost); if (pbxHostList != null && pbxHostList.size() > 0) {
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); pbxHost = pbxHostList.get(0);
map.addAttribute("skillExtentionList" , skillExtentionRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); map.addAttribute("pbxHost", pbxHost);
map.addAttribute("extentionList" , extentionRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); map.addAttribute("skillGroups", skillRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
map.addAttribute("aclList" , aclRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); map.addAttribute("skillExtentionList", skillExtentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
map.addAttribute("sipTrunkList" , sipTrunkRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); map.addAttribute("extentionList", extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
} map.addAttribute("aclList", aclRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
Template template = null ; map.addAttribute("sipTrunkList", sipTrunkRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/notfound")); }
if(key_value!=null && key_value.equals("callcenter.conf")){ Template template = null;
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/callcenter")); ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/notfound"));
if(systemConfig!=null && systemConfig.isCallcenter()){ if (key_value != null && key_value.equals("callcenter.conf")) {
if(!StringUtils.isBlank(systemConfig.getCc_quene())){ view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/callcenter"));
template = MainUtils.getTemplate(systemConfig.getCc_quene()) ; if (systemConfig != null && systemConfig.isCallcenter()) {
} if (!StringUtils.isBlank(systemConfig.getCc_quene())) {
} template = MainUtils.getTemplate(systemConfig.getCc_quene());
}else if(key_value!=null && key_value.equals("acl.conf")){ }
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/acl")); }
if(systemConfig!=null && systemConfig.isCallcenter()){ } else if (key_value != null && key_value.equals("acl.conf")) {
if(!StringUtils.isBlank(systemConfig.getCc_acl())){ view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/acl"));
template = MainUtils.getTemplate(systemConfig.getCc_acl()) ; if (systemConfig != null && systemConfig.isCallcenter()) {
} if (!StringUtils.isBlank(systemConfig.getCc_acl())) {
} template = MainUtils.getTemplate(systemConfig.getCc_acl());
}else if(key_value!=null && key_value.equals("ivr.conf")){ }
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/ivr")); }
if(systemConfig!=null && systemConfig.isCallcenter()){ } else if (key_value != null && key_value.equals("ivr.conf")) {
if(!StringUtils.isBlank(systemConfig.getCc_ivr())){ view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/ivr"));
template = MainUtils.getTemplate(systemConfig.getCc_ivr()) ; if (systemConfig != null && systemConfig.isCallcenter()) {
} if (!StringUtils.isBlank(systemConfig.getCc_ivr())) {
} template = MainUtils.getTemplate(systemConfig.getCc_ivr());
} }
if(template!=null){ }
map.addAttribute("template" , template); }
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template")) ; if (template != null) {
} map.addAttribute("template", template);
return view; view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template"));
} }
return view;
@RequestMapping(value = "/dialplan") }
@Menu(type = "callcenter" , subtype = "dialplan" , access = true)
public ModelAndView dialplan(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value) { @RequestMapping(value = "/dialplan")
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/dialplan/index")); @Menu(type = "callcenter", subtype = "dialplan", access = true)
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname) ; public ModelAndView dialplan(ModelMap map, HttpServletRequest request, @Valid String hostname) {
PbxHost pbxHost = null ; ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/dialplan/index"));
SystemConfig systemConfig = MainUtils.getSystemConfig() ; List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname);
Template template = null ; PbxHost pbxHost;
if(pbxHostList!=null && pbxHostList.size() > 0){ SystemConfig systemConfig = MainUtils.getSystemConfig();
pbxHost = pbxHostList.get(0) ; Template template = null;
map.addAttribute("pbxHost" , pbxHost); if (pbxHostList != null && pbxHostList.size() > 0) {
map.addAttribute("routerList" , routerRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request))); pbxHost = pbxHostList.get(0);
} map.addAttribute("pbxHost", pbxHost);
if(systemConfig!=null && systemConfig.isCallcenter()){ map.addAttribute("routerList", routerRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
if(!StringUtils.isBlank(systemConfig.getCc_siptrunk())){ }
template = MainUtils.getTemplate(systemConfig.getCc_router()) ; if (systemConfig != null && systemConfig.isCallcenter()) {
} if (!StringUtils.isBlank(systemConfig.getCc_siptrunk())) {
if(template!=null){ template = MainUtils.getTemplate(systemConfig.getCc_router());
map.addAttribute("template" , template); }
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template")) ; if (template != null) {
} map.addAttribute("template", template);
} view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template"));
}
return view; }
}
return view;
@RequestMapping(value = "/extention/detail") }
@Menu(type = "callcenter" , subtype = "extention" , access = false)
public ModelAndView detail(ModelMap map , HttpServletRequest request , HttpServletResponse response ,@Valid String extno) { @RequestMapping(value = "/extention/detail")
List<Extention> extentionList = extentionRes.findByExtentionAndOrgi(extno, super.getOrgi(request)) ; @Menu(type = "callcenter", subtype = "extention")
if(extentionList!=null && extentionList.size() == 1){ public ModelAndView detail(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String extno) {
Extention extention = extentionList.get(0) ; List<Extention> extentionList = extentionRes.findByExtentionAndOrgi(extno, super.getOrgi(request));
if(!StringUtils.isBlank(extention.getHostid())) { if (extentionList != null && extentionList.size() == 1) {
PbxHost pbxHost = pbxHostRes.findById(extention.getHostid()) ; Extention extention = extentionList.get(0);
if(pbxHost!=null) { if (!StringUtils.isBlank(extention.getHostid())) {
map.addAttribute("pbxhost" , pbxHost); pbxHostRes.findById(extention.getHostid()).ifPresent(it -> map.addAttribute("pbxhost", it));
} }
} map.addAttribute("extention", extention);
map.addAttribute("extention" , extention); }
} response.setContentType("Content-type: text/json; charset=utf-8");
response.setContentType("Content-type: text/json; charset=utf-8"); return request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/detail"));
return request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/detail")); }
}
@RequestMapping(value = "/ivr")
@RequestMapping(value = "/ivr") @Menu(type = "callcenter", subtype = "ivr")
@Menu(type = "callcenter" , subtype = "ivr" , access = false) public ModelAndView ivr(ModelMap map, HttpServletRequest request, @Valid String hostid) {
public ModelAndView ivr(ModelMap map , HttpServletRequest request , HttpServletResponse response ,@Valid String hostid) { map.addAttribute("ivrList", extentionRes.findByHostidAndExtypeAndOrgi(hostid, MainContext.ExtentionType.BUSINESS.toString(), super.getOrgi(request)));
map.addAttribute("ivrList" , extentionRes.findByHostidAndExtypeAndOrgi(hostid, MainContext.ExtentionType.BUSINESS.toString() , super.getOrgi(request))); return request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/ivr"));
return request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/ivr")); }
}
}
}

View File

@ -1,33 +1,36 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.persistence.repository; package com.chatopera.cc.persistence.repository;
import com.chatopera.cc.model.PbxHost; import com.chatopera.cc.model.PbxHost;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
public interface PbxHostRepository extends JpaRepository<PbxHost, String> { public interface PbxHostRepository extends JpaRepository<PbxHost, String> {
PbxHost findByIdAndOrgi(String id, String orgi); PbxHost findByIdAndOrgi(String id, String orgi);
PbxHost findById(String id);
List<PbxHost> findByOrgi(String orgi); // PbxHost findById(String id);
List<PbxHost> findByHostnameOrIpaddr(String hostname, String ip);
List<PbxHost> findByOrgi(String orgi);
int countByHostnameAndOrgi(String hostname, String orgi) ;
List<PbxHost> findByHostnameOrIpaddr(String hostname, String ip);
}
int countByHostnameAndOrgi(String hostname, String orgi);
}