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

@ -21,8 +21,9 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull;
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;
@ -33,16 +34,17 @@ import javax.validation.Valid;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterAclController extends Handler { public class CallCenterAclController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes ; private final PbxHostRepository pbxHostRes;
@Autowired @NonNull
private AclRepository aclRes ; private final AclRepository aclRes;
@RequestMapping(value = "/acl") @RequestMapping(value = "/acl")
@Menu(type = "callcenter" , subtype = "callcenteracl" , access = false , admin = true) @Menu(type = "callcenter", subtype = "callcenteracl", admin = true)
public ModelAndView acl(ModelMap map, HttpServletRequest request, @Valid String hostid) { public ModelAndView acl(ModelMap map, HttpServletRequest request, @Valid String hostid) {
if (!StringUtils.isBlank(hostid)) { if (!StringUtils.isBlank(hostid)) {
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
@ -52,15 +54,15 @@ public class CallCenterAclController extends Handler {
} }
@RequestMapping(value = "/acl/add") @RequestMapping(value = "/acl/add")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true) @Menu(type = "callcenter", subtype = "acl", admin = true)
public ModelAndView acladd(ModelMap map, HttpServletRequest request, @Valid String hostid) { public ModelAndView acladd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/add")); return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/add"));
} }
@RequestMapping(value = "/acl/save") @RequestMapping(value = "/acl/save")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true) @Menu(type = "callcenter", subtype = "acl", admin = true)
public ModelAndView aclsave(ModelMap map , HttpServletRequest request , @Valid Acl acl) { public ModelAndView aclsave(HttpServletRequest request, @Valid Acl acl) {
if (!StringUtils.isBlank(acl.getName())) { if (!StringUtils.isBlank(acl.getName())) {
int count = aclRes.countByNameAndOrgi(acl.getName(), super.getOrgi(request)); int count = aclRes.countByNameAndOrgi(acl.getName(), super.getOrgi(request));
if (count == 0) { if (count == 0) {
@ -73,7 +75,7 @@ public class CallCenterAclController extends Handler {
} }
@RequestMapping(value = "/acl/edit") @RequestMapping(value = "/acl/edit")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true) @Menu(type = "callcenter", subtype = "acl", admin = true)
public ModelAndView acledit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) { public ModelAndView acledit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("acl", aclRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("acl", aclRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
@ -81,8 +83,8 @@ public class CallCenterAclController extends Handler {
} }
@RequestMapping(value = "/acl/update") @RequestMapping(value = "/acl/update")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true) @Menu(type = "callcenter", subtype = "acl", admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid Acl acl) { public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid Acl acl) {
if (!StringUtils.isBlank(acl.getId())) { if (!StringUtils.isBlank(acl.getId())) {
Acl oldAcl = aclRes.findByIdAndOrgi(acl.getId(), super.getOrgi(request)); Acl oldAcl = aclRes.findByIdAndOrgi(acl.getId(), super.getOrgi(request));
if (oldAcl != null) { if (oldAcl != null) {
@ -96,10 +98,10 @@ public class CallCenterAclController extends Handler {
} }
@RequestMapping(value = "/acl/delete") @RequestMapping(value = "/acl/delete")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true) @Menu(type = "callcenter", subtype = "acl", admin = true)
public ModelAndView acldelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { public ModelAndView acldelete(@Valid String id, @Valid String hostid) {
if (!StringUtils.isBlank(id)) { if (!StringUtils.isBlank(id)) {
aclRes.delete(id); aclRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid=" + hostid)); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid=" + hostid));
} }

View File

@ -23,8 +23,9 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull;
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;
@ -36,19 +37,21 @@ import java.util.List;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterController extends Handler { public class CallCenterController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes; private final PbxHostRepository pbxHostRes;
@RequestMapping(value = "/index") @RequestMapping(value = "/index")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true) @Menu(type = "callcenter", subtype = "callcenter", admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String msg) { public ModelAndView index(ModelMap map, HttpServletRequest request) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter"); CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter");
for (PbxHost pbxHost : pbxHostList) { for (PbxHost pbxHost : pbxHostList) {
//noinspection ConstantConditions
if (callCenterImpl != null) { if (callCenterImpl != null) {
pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId())); pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
} }
@ -59,13 +62,14 @@ public class CallCenterController extends Handler {
} }
@RequestMapping(value = "/pbxhost") @RequestMapping(value = "/pbxhost")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
public ModelAndView pbxhost(ModelMap map, HttpServletRequest request) { public ModelAndView pbxhost(ModelMap map, HttpServletRequest request) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter"); CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter");
for (PbxHost pbxHost : pbxHostList) { for (PbxHost pbxHost : pbxHostList) {
//noinspection ConstantConditions
if (callCenterImpl != null) { if (callCenterImpl != null) {
pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId())); pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
} }
@ -76,14 +80,14 @@ public class CallCenterController extends Handler {
} }
@RequestMapping(value = "/pbxhost/add") @RequestMapping(value = "/pbxhost/add")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
public ModelAndView pbxhostadd(ModelMap map, HttpServletRequest request) { public ModelAndView pbxhostadd() {
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/add")); return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/add"));
} }
@RequestMapping(value = "/pbxhost/save") @RequestMapping(value = "/pbxhost/save")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
public ModelAndView pbxhostsave(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) { public ModelAndView pbxhostsave(HttpServletRequest request, @Valid PbxHost pbxHost) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html")); ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
String msg = null; String msg = null;
if (!StringUtils.isBlank(pbxHost.getName())) { if (!StringUtils.isBlank(pbxHost.getName())) {
@ -95,6 +99,7 @@ public class CallCenterController extends Handler {
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean( CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter"); "callcenter");
//noinspection ConstantConditions
if (callCenterImpl != null) { if (callCenterImpl != null) {
try { try {
callCenterImpl.init(pbxHost); callCenterImpl.init(pbxHost);
@ -114,15 +119,15 @@ public class CallCenterController extends Handler {
} }
@RequestMapping(value = "/pbxhost/edit") @RequestMapping(value = "/pbxhost/edit")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
public ModelAndView pbxhostedit(ModelMap map, HttpServletRequest request, @Valid String id) { public ModelAndView pbxhostedit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/edit")); return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/edit"));
} }
@RequestMapping(value = "/pbxhost/update") @RequestMapping(value = "/pbxhost/update")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
public ModelAndView pbxhostupdate(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) { public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid PbxHost pbxHost) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html")); ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
String msg = null; String msg = null;
if (!StringUtils.isBlank(pbxHost.getId())) { if (!StringUtils.isBlank(pbxHost.getId())) {
@ -138,6 +143,7 @@ public class CallCenterController extends Handler {
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean( CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter"); "callcenter");
//noinspection ConstantConditions
if (callCenterImpl != null) { if (callCenterImpl != null) {
try { try {
callCenterImpl.init(destHost); callCenterImpl.init(destHost);
@ -156,13 +162,14 @@ public class CallCenterController extends Handler {
} }
@RequestMapping(value = "/pbxhost/delete") @RequestMapping(value = "/pbxhost/delete")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true) @Menu(type = "callcenter", subtype = "pbxhost", admin = true)
public ModelAndView mediadelete(ModelMap map, HttpServletRequest request, @Valid String id) { public ModelAndView mediadelete(@Valid String id) {
if (!StringUtils.isBlank(id)) { if (!StringUtils.isBlank(id)) {
pbxHostRes.delete(id); pbxHostRes.deleteById(id);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) { if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean( CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter"); "callcenter");
//noinspection ConstantConditions
if (callCenterImpl != null) { if (callCenterImpl != null) {
callCenterImpl.remove(id); callCenterImpl.remove(id);
} }

View File

@ -25,8 +25,9 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull;
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;
@ -39,39 +40,40 @@ import java.util.List;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterExtentionController extends Handler { public class CallCenterExtentionController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes; private final PbxHostRepository pbxHostRes;
@Autowired @NonNull
private ExtentionRepository extentionRes; private final ExtentionRepository extentionRes;
@Autowired @NonNull
private SipTrunkRepository sipTrunkRes; private final SipTrunkRepository sipTrunkRes;
@Autowired @NonNull
private MediaRepository mediaRes; private final MediaRepository mediaRes;
@Autowired @NonNull
private ServiceAiRepository serviceAiRes; private final ServiceAiRepository serviceAiRes;
@Autowired @NonNull
private ProductRepository productRes; private final ProductRepository productRes;
@Autowired @NonNull
private QueSurveyProcessRepository queSurveyProcessRes; private final QueSurveyProcessRepository queSurveyProcessRes;
@Autowired @NonNull
private Cache cache; private final Cache cache;
@RequestMapping(value = "/extention") @RequestMapping(value = "/extention")
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true) @Menu(type = "callcenter", subtype = "callcenterresource", admin = true)
public ModelAndView extention(ModelMap map, HttpServletRequest request, @Valid String hostid) { public ModelAndView extention(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList); map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null; PbxHost pbxHost;
if (pbxHostList.size() > 0) { if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList", extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request))); map.addAttribute("extentionList", extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
@ -93,7 +95,7 @@ public class CallCenterExtentionController extends Handler {
} }
@RequestMapping(value = "/extention/add") @RequestMapping(value = "/extention/add")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", admin = true)
public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) { public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
@ -104,11 +106,10 @@ public class CallCenterExtentionController extends Handler {
} }
@RequestMapping(value = "/extention/save") @RequestMapping(value = "/extention/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", admin = true)
public ModelAndView extentionsave(ModelMap map, HttpServletRequest request, @Valid Extention extention) { public ModelAndView extentionsave(HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getExtention()) && StringUtils.isNotBlank(extention.getPassword())) { if (StringUtils.isNotBlank(extention.getExtention()) && StringUtils.isNotBlank(extention.getPassword())) {
String[] extstr = extention.getExtention().split("[, ]"); String[] extstr = extention.getExtention().split("[, ]");
int extnum = 0;
for (String ext : extstr) { for (String ext : extstr) {
if (ext.matches("[\\d]{3,8}")) { //分机号码最少3位数字 if (ext.matches("[\\d]{3,8}")) { //分机号码最少3位数字
createNewExtention(ext, super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention); createNewExtention(ext, super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention);
@ -118,7 +119,7 @@ public class CallCenterExtentionController extends Handler {
int start = Integer.parseInt(ph[0]); int start = Integer.parseInt(ph[0]);
int end = Integer.parseInt(ph[1]); int end = Integer.parseInt(ph[1]);
for (int i = start; i <= end && extnum < 100; i++) { //最大一次批量生产的 分机号不超过100个 for (int i = start; i <= end; i++) { //最大一次批量生产的 分机号不超过100个
createNewExtention(String.valueOf(i), super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention); createNewExtention(String.valueOf(i), super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention);
} }
} }
@ -128,7 +129,7 @@ public class CallCenterExtentionController extends Handler {
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) { private void createNewExtention(String num, User user, String hostid, String password, String orgi, Extention src) {
Extention extno = new Extention(); Extention extno = new Extention();
extno.setExtention(num); extno.setExtention(num);
extno.setOrgi(orgi); extno.setOrgi(orgi);
@ -148,11 +149,10 @@ public class CallCenterExtentionController extends Handler {
if (count == 0) { if (count == 0) {
extentionRes.save(extno); 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)));
@ -163,8 +163,8 @@ public class CallCenterExtentionController extends Handler {
} }
@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) {
@ -198,7 +198,7 @@ public class CallCenterExtentionController extends Handler {
} }
@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)));
@ -213,8 +213,8 @@ public class CallCenterExtentionController extends Handler {
} }
@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) {
@ -238,10 +238,10 @@ public class CallCenterExtentionController extends Handler {
} }
@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

@ -22,8 +22,9 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull;
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;
@ -34,19 +35,20 @@ import javax.validation.Valid;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterIvrController extends Handler { public class CallCenterIvrController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes ; private final PbxHostRepository pbxHostRes;
@Autowired @NonNull
private ExtentionRepository extentionRes ; private final ExtentionRepository extentionRes;
@Autowired @NonNull
private IvrMenuRepository ivrMenuRes; private final IvrMenuRepository ivrMenuRes;
@RequestMapping(value = "/ivr") @RequestMapping(value = "/ivr")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true) @Menu(type = "callcenter", subtype = "callcenterivr", admin = true)
public ModelAndView ivr(ModelMap map, HttpServletRequest request, @Valid String hostid) { public ModelAndView ivr(ModelMap map, HttpServletRequest request, @Valid String hostid) {
if (!StringUtils.isBlank(hostid)) { if (!StringUtils.isBlank(hostid)) {
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))); map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
@ -56,7 +58,7 @@ public class CallCenterIvrController extends Handler{
} }
@RequestMapping(value = "/ivr/edit") @RequestMapping(value = "/ivr/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)));
@ -64,8 +66,8 @@ public class CallCenterIvrController extends Handler{
} }
@RequestMapping(value = "/ivr/update") @RequestMapping(value = "/ivr/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.isBlank(extention.getId())) { if (!StringUtils.isBlank(extention.getId())) {
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)); Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
ext.setExtention(extention.getExtention()); ext.setExtention(extention.getExtention());
@ -78,15 +80,15 @@ public class CallCenterIvrController extends Handler{
@RequestMapping(value = "/ivr/delete") @RequestMapping(value = "/ivr/delete")
@Menu(type = "callcenter", subtype = "ivr", access = false, admin = true) @Menu(type = "callcenter", subtype = "ivr", access = false, 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.isBlank(id)) { if (!StringUtils.isBlank(id)) {
extentionRes.delete(id); extentionRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid=" + hostid)); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid=" + hostid));
} }
@RequestMapping(value = "/ivr/design") @RequestMapping(value = "/ivr/design")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true) @Menu(type = "callcenter", subtype = "callcenterivr", admin = true)
public ModelAndView design(ModelMap map, HttpServletRequest request, @Valid String hostid, @Valid String id) { public ModelAndView design(ModelMap map, HttpServletRequest request, @Valid String hostid, @Valid String id) {
if (!StringUtils.isBlank(hostid)) { if (!StringUtils.isBlank(hostid)) {
map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
@ -97,8 +99,8 @@ public class CallCenterIvrController extends Handler{
} }
@RequestMapping(value = "/ivr/menu/add") @RequestMapping(value = "/ivr/menu/add")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true) @Menu(type = "callcenter", subtype = "callcenterivr", admin = true)
public ModelAndView ivrmenuadd(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid , @Valid String parentid) { public ModelAndView ivrmenuadd(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)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/menuadd")); return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/menuadd"));

View File

@ -22,9 +22,10 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
@ -37,16 +38,18 @@ import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterMediaController extends Handler { public class CallCenterMediaController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes ; private final PbxHostRepository pbxHostRes;
@Autowired @NonNull
private MediaRepository mediaRes ; private final MediaRepository mediaRes;
@Value("${web.upload-path}") @Value("${web.upload-path}")
private String path; private String path;
@ -70,14 +73,15 @@ public class CallCenterMediaController extends Handler{
@RequestMapping(value = "/media/save") @RequestMapping(value = "/media/save")
@Menu(type = "callcenter", subtype = "media", access = false, admin = true) @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 { public ModelAndView mediasave(HttpServletRequest request, @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
Media media = new Media(); Media media = new Media();
media.setName(request.getParameter("name")); media.setName(request.getParameter("name"));
media.setHostid(request.getParameter("hostid")); media.setHostid(request.getParameter("hostid"));
if (!StringUtils.isBlank(media.getName())) { if (!StringUtils.isBlank(media.getName())) {
int count = mediaRes.countByNameAndOrgi(media.getName(), super.getOrgi(request)); int count = mediaRes.countByNameAndOrgi(media.getName(), super.getOrgi(request));
if (count == 0) { if (count == 0) {
String fileName = "media/"+ MainUtils.getUUID()+mediafile.getOriginalFilename().substring(mediafile.getOriginalFilename().lastIndexOf(".")) ; String fileName = "media/" + MainUtils.getUUID() + Objects.requireNonNull(mediafile.getOriginalFilename())
.substring(mediafile.getOriginalFilename().lastIndexOf("."));
media.setOrgi(super.getOrgi(request)); media.setOrgi(super.getOrgi(request));
media.setCreater(super.getUser(request).getId()); media.setCreater(super.getUser(request).getId());
@ -85,9 +89,10 @@ public class CallCenterMediaController extends Handler{
media.setContent(mediafile.getContentType()); media.setContent(mediafile.getContentType());
media.setFilename(fileName); media.setFilename(fileName);
if(mediafile!=null && mediafile.getOriginalFilename().lastIndexOf(".") > 0){ if (mediafile.getOriginalFilename().lastIndexOf(".") > 0) {
File logoDir = new File(path, "media"); File logoDir = new File(path, "media");
if (!logoDir.exists()) { if (!logoDir.exists()) {
//noinspection ResultOfMethodCallIgnored
logoDir.mkdirs(); logoDir.mkdirs();
} }
FileCopyUtils.copy(mediafile.getBytes(), new File(path, fileName)); FileCopyUtils.copy(mediafile.getBytes(), new File(path, fileName));
@ -109,7 +114,7 @@ public class CallCenterMediaController extends Handler{
@RequestMapping(value = "/media/update") @RequestMapping(value = "/media/update")
@Menu(type = "callcenter", subtype = "media", access = false, admin = true) @Menu(type = "callcenter", subtype = "media", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException { public ModelAndView pbxhostupdate(HttpServletRequest request, @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
Media media = new Media(); Media media = new Media();
media.setName(request.getParameter("name")); media.setName(request.getParameter("name"));
media.setHostid(request.getParameter("hostid")); media.setHostid(request.getParameter("hostid"));
@ -123,12 +128,14 @@ public class CallCenterMediaController extends Handler{
wavFile.deleteOnExit(); wavFile.deleteOnExit();
} }
String fileName = "media/"+ MainUtils.getUUID()+mediafile.getOriginalFilename().substring(mediafile.getOriginalFilename().lastIndexOf(".")) ; String fileName = "media/" + MainUtils.getUUID() + Objects.requireNonNull(mediafile.getOriginalFilename())
.substring(mediafile.getOriginalFilename().lastIndexOf("."));
oldMedia.setFilename(fileName); oldMedia.setFilename(fileName);
if(mediafile!=null && mediafile.getOriginalFilename().lastIndexOf(".") > 0){ if (mediafile.getOriginalFilename().lastIndexOf(".") > 0) {
File mediaDir = new File(path, "media"); File mediaDir = new File(path, "media");
if (!mediaDir.exists()) { if (!mediaDir.exists()) {
//noinspection ResultOfMethodCallIgnored
mediaDir.mkdirs(); mediaDir.mkdirs();
} }
FileCopyUtils.copy(mediafile.getBytes(), new File(path, fileName)); FileCopyUtils.copy(mediafile.getBytes(), new File(path, fileName));
@ -143,15 +150,16 @@ public class CallCenterMediaController extends Handler{
@RequestMapping(value = "/media/delete") @RequestMapping(value = "/media/delete")
@Menu(type = "callcenter", subtype = "media", access = false, admin = true) @Menu(type = "callcenter", subtype = "media", access = false, admin = true)
public ModelAndView mediadelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { public ModelAndView mediadelete(@Valid String id, @Valid String hostid) {
if (!StringUtils.isBlank(id)) { if (!StringUtils.isBlank(id)) {
mediaRes.delete(id); mediaRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid=" + hostid)); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid=" + hostid));
} }
@RequestMapping(value = "/play") @RequestMapping(value = "/play")
@Menu(type = "callcenter", subtype = "play", access = false) @Menu(type = "callcenter", subtype = "play", access = false)
public ModelAndView play(ModelMap map , HttpServletRequest request ,@Valid final String id ,@Valid final String hostid) { public ModelAndView play(ModelMap map, HttpServletRequest request, @Valid final String id) {
map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/play")); return request(super.createRequestPageTempletResponse("/admin/callcenter/media/play"));
} }

View File

@ -25,8 +25,9 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull;
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;
@ -38,16 +39,17 @@ import java.util.List;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterResourceController extends Handler { public class CallCenterResourceController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes; private final PbxHostRepository pbxHostRes;
@Autowired @NonNull
private ExtentionRepository extentionRes; private final ExtentionRepository extentionRes;
@Autowired @NonNull
private ServiceAiRepository serviceAiRes; private final ServiceAiRepository serviceAiRes;
@RequestMapping(value = "/resource") @RequestMapping(value = "/resource")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true) @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
@ -57,7 +59,7 @@ public class CallCenterResourceController extends Handler {
map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request))); map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request)));
PbxHost pbxHost = null; PbxHost pbxHost;
if (pbxHostList.size() > 0) { if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList", map.addAttribute("extentionList",
@ -71,7 +73,7 @@ public class CallCenterResourceController extends Handler {
public ModelAndView config(ModelMap map, HttpServletRequest request, @Valid String hostid) { public ModelAndView config(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList); map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null; PbxHost pbxHost;
if (pbxHostList.size() > 0) { if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList", map.addAttribute("extentionList",
@ -82,7 +84,7 @@ public class CallCenterResourceController extends Handler {
@RequestMapping(value = "/resource/save") @RequestMapping(value = "/resource/save")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true) @Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) throws Exception { public ModelAndView save(HttpServletRequest request, @Valid PbxHost pbxHost) throws Exception {
PbxHost tempPbxHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request)); PbxHost tempPbxHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request));
if (tempPbxHost != null) { if (tempPbxHost != null) {
pbxHost.setCreater(tempPbxHost.getCreater()); pbxHost.setCreater(tempPbxHost.getCreater());
@ -108,7 +110,7 @@ public class CallCenterResourceController extends Handler {
public ModelAndView resourcepbx(ModelMap map, HttpServletRequest request, @Valid String hostid) { public ModelAndView resourcepbx(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList); map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null; PbxHost pbxHost;
if (pbxHostList.size() > 0) { if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList", map.addAttribute("extentionList",

View File

@ -22,8 +22,9 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull;
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;
@ -35,14 +36,14 @@ import java.util.List;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterRouterController extends Handler { public class CallCenterRouterController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes ; private final PbxHostRepository pbxHostRes;
@NonNull
@Autowired private final RouterRulesRepository routerRulesRes;
private RouterRulesRepository routerRulesRes ;
@RequestMapping(value = "/router") @RequestMapping(value = "/router")
@ -66,7 +67,7 @@ public class CallCenterRouterController extends Handler{
@RequestMapping(value = "/router/save") @RequestMapping(value = "/router/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map , HttpServletRequest request , @Valid RouterRules router) { public ModelAndView extentionsave(HttpServletRequest request, @Valid RouterRules router) {
if (!StringUtils.isBlank(router.getName())) { if (!StringUtils.isBlank(router.getName())) {
int count = routerRulesRes.countByNameAndOrgi(router.getName(), super.getOrgi(request)); int count = routerRulesRes.countByNameAndOrgi(router.getName(), super.getOrgi(request));
if (count == 0) { if (count == 0) {
@ -88,7 +89,7 @@ public class CallCenterRouterController extends Handler{
@RequestMapping(value = "/router/update") @RequestMapping(value = "/router/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid RouterRules router) { public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid RouterRules router) {
if (!StringUtils.isBlank(router.getId())) { if (!StringUtils.isBlank(router.getId())) {
RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)); RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request));
if (oldRouter != null) { if (oldRouter != null) {
@ -113,7 +114,7 @@ public class CallCenterRouterController extends Handler{
@RequestMapping(value = "/router/code/update") @RequestMapping(value = "/router/code/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView routercodeupdate(ModelMap map , HttpServletRequest request , @Valid RouterRules router) { public ModelAndView routercodeupdate(HttpServletRequest request, @Valid RouterRules router) {
if (!StringUtils.isBlank(router.getId())) { if (!StringUtils.isBlank(router.getId())) {
RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)); RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request));
if (!StringUtils.isBlank(router.getRoutercontent())) { if (!StringUtils.isBlank(router.getRoutercontent())) {
@ -126,9 +127,9 @@ public class CallCenterRouterController extends Handler{
@RequestMapping(value = "/router/delete") @RequestMapping(value = "/router/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, 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.isBlank(id)) { if (!StringUtils.isBlank(id)) {
routerRulesRes.delete(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

@ -22,8 +22,9 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull;
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;
@ -34,16 +35,17 @@ import javax.validation.Valid;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterSipTrunkController extends Handler { public class CallCenterSipTrunkController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes; private final PbxHostRepository pbxHostRes;
@Autowired @NonNull
private SipTrunkRepository sipTrunkRes; private final SipTrunkRepository sipTrunkRes;
@Autowired @NonNull
private Cache cache; private final Cache cache;
@RequestMapping(value = "/siptrunk") @RequestMapping(value = "/siptrunk")
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true) @Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
@ -64,7 +66,7 @@ public class CallCenterSipTrunkController extends Handler {
@RequestMapping(value = "/siptrunk/save") @RequestMapping(value = "/siptrunk/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) { public ModelAndView extentionsave(HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getName())) { if (!StringUtils.isBlank(siptrunk.getName())) {
int count = sipTrunkRes.countByNameAndOrgi(siptrunk.getName(), super.getOrgi(request)); int count = sipTrunkRes.countByNameAndOrgi(siptrunk.getName(), super.getOrgi(request));
if (count == 0) { if (count == 0) {
@ -88,7 +90,7 @@ public class CallCenterSipTrunkController extends Handler {
@RequestMapping(value = "/siptrunk/update") @RequestMapping(value = "/siptrunk/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) { public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getId())) { if (!StringUtils.isBlank(siptrunk.getId())) {
SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request)); SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request));
if (oldSipTrunk != null) { if (oldSipTrunk != null) {
@ -129,7 +131,7 @@ public class CallCenterSipTrunkController extends Handler {
@RequestMapping(value = "/siptrunk/code/update") @RequestMapping(value = "/siptrunk/code/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkcodeupdate(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) { public ModelAndView siptrunkcodeupdate(HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getId())) { if (!StringUtils.isBlank(siptrunk.getId())) {
SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request)); SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request));
if (!StringUtils.isBlank(siptrunk.getSipcontent())) { if (!StringUtils.isBlank(siptrunk.getSipcontent())) {
@ -143,9 +145,9 @@ public class CallCenterSipTrunkController extends Handler {
@RequestMapping(value = "/siptrunk/delete") @RequestMapping(value = "/siptrunk/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, 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.isBlank(id)) { if (!StringUtils.isBlank(id)) {
sipTrunkRes.delete(id); sipTrunkRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + hostid)); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + hostid));
} }

View File

@ -26,8 +26,8 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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;
@ -40,26 +40,27 @@ import java.util.List;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
@RequiredArgsConstructor
public class CallCenterSkillController extends Handler { public class CallCenterSkillController extends Handler {
@Autowired @org.springframework.lang.NonNull
private PbxHostRepository pbxHostRes ; private final PbxHostRepository pbxHostRes;
@Autowired @org.springframework.lang.NonNull
private ExtentionRepository extentionRes; private final ExtentionRepository extentionRes;
@Autowired @org.springframework.lang.NonNull
private CallCenterSkillRepository skillRes ; private final CallCenterSkillRepository skillRes;
@Autowired @org.springframework.lang.NonNull
private SkillExtentionRepository skillExtentionRes; private final SkillExtentionRepository skillExtentionRes;
@RequestMapping(value = "/skill") @RequestMapping(value = "/skill")
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true) @Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) { public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)); List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList); map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null ; PbxHost pbxHost;
if (pbxHostList.size() > 0) { if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid)); map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("skillGroups", skillRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request))); map.addAttribute("skillGroups", skillRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
@ -73,7 +74,8 @@ public class CallCenterSkillController extends Handler {
if (!StringUtils.isBlank(hostid)) { if (!StringUtils.isBlank(hostid)) {
for (PbxHost pbx : pbxHostList) { for (PbxHost pbx : pbxHostList) {
if (pbx.getId().equals(hostid)) { if (pbx.getId().equals(hostid)) {
pbxHost = pbx; break ; pbxHost = pbx;
break;
} }
} }
} }
@ -89,7 +91,7 @@ public class CallCenterSkillController extends Handler {
@RequestMapping(value = "/skill/save") @RequestMapping(value = "/skill/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map , HttpServletRequest request , @Valid CallCenterSkill skill) { public ModelAndView extentionsave(HttpServletRequest request, @Valid CallCenterSkill skill) {
if (!StringUtils.isBlank(skill.getSkill())) { if (!StringUtils.isBlank(skill.getSkill())) {
int count = skillRes.countBySkillAndOrgi(skill.getSkill(), super.getOrgi(request)); int count = skillRes.countBySkillAndOrgi(skill.getSkill(), super.getOrgi(request));
if (count == 0) { if (count == 0) {
@ -111,7 +113,7 @@ public class CallCenterSkillController extends Handler {
@RequestMapping(value = "/skill/update") @RequestMapping(value = "/skill/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid Extention extention) { public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid Extention extention) {
if (!StringUtils.isBlank(extention.getId())) { if (!StringUtils.isBlank(extention.getId())) {
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)); Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
if (ext != null && !StringUtils.isBlank(ext.getExtention()) && ext.getExtention().matches("[\\d]{3,8}")) { if (ext != null && !StringUtils.isBlank(ext.getExtention()) && ext.getExtention().matches("[\\d]{3,8}")) {
@ -128,9 +130,9 @@ public class CallCenterSkillController extends Handler {
@RequestMapping(value = "/skill/delete") @RequestMapping(value = "/skill/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, 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.isBlank(id)) { if (!StringUtils.isBlank(id)) {
extentionRes.delete(id); extentionRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + hostid)); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + hostid));
} }
@ -148,16 +150,16 @@ public class CallCenterSkillController extends Handler {
@RequestMapping(value = "/skill/extention/delete") @RequestMapping(value = "/skill/extention/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView skillextentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) { public ModelAndView skillextentiondelete(@Valid String id, @Valid String hostid) {
if (!StringUtils.isBlank(id)) { if (!StringUtils.isBlank(id)) {
skillExtentionRes.delete(id); skillExtentionRes.deleteById(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + hostid)); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid=" + hostid));
} }
@RequestMapping(value = "/skill/extention/save") @RequestMapping(value = "/skill/extention/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true) @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) { public ModelAndView skillextentionsave(HttpServletRequest request, @Valid SkillExtention skillExtention, @Valid String hostid, @Valid String[] exts) {
if (exts != null && exts.length > 0) { if (exts != null && exts.length > 0) {
List<SkillExtention> skillExtentionList = skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)); List<SkillExtention> skillExtentionList = skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request));
for (String ext : exts) { for (String ext : exts) {
@ -173,9 +175,10 @@ public class CallCenterSkillController extends Handler {
for (SkillExtention temp : skillExtentionList) { for (SkillExtention temp : skillExtentionList) {
if (temp.getSkillid().equals(skillExt.getSkillid()) && temp.getExtention().equals(skillExt.getExtention())) { if (temp.getSkillid().equals(skillExt.getSkillid()) && temp.getExtention().equals(skillExt.getExtention())) {
ingroup = true; ingroup = true;
break;
} }
} }
if(ingroup == false){ if (!ingroup) {
skillExtentionRes.save(skillExt); skillExtentionRes.save(skillExt);
} }
} }

View File

@ -26,8 +26,9 @@ 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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull;
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;
@ -40,35 +41,36 @@ import java.util.List;
@Controller @Controller
@RequestMapping("/apps/callcenter") @RequestMapping("/apps/callcenter")
@RequiredArgsConstructor
public class ExtentionController extends Handler { public class ExtentionController extends Handler {
@Autowired @NonNull
private PbxHostRepository pbxHostRes ; private final PbxHostRepository pbxHostRes;
@Autowired @NonNull
private ExtentionRepository extentionRes; private final ExtentionRepository extentionRes;
@Autowired @NonNull
private AclRepository aclRes; private final AclRepository aclRes;
@Autowired @NonNull
private RouterRulesRepository routerRes; private final RouterRulesRepository routerRes;
@Autowired @NonNull
private SkillExtentionRepository skillExtentionRes ; private final SkillExtentionRepository skillExtentionRes;
@Autowired @NonNull
private CallCenterSkillRepository skillRes ; private final CallCenterSkillRepository skillRes;
@Autowired @NonNull
private SipTrunkRepository sipTrunkRes ; private final SipTrunkRepository sipTrunkRes;
@RequestMapping(value = "/extention") @RequestMapping(value = "/extention")
@Menu(type = "callcenter", subtype = "extention", access = true) @Menu(type = "callcenter", subtype = "extention", access = true)
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value) { public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String hostname) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/index")); ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/index"));
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname); List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname);
PbxHost pbxHost = null ; PbxHost pbxHost;
SystemConfig systemConfig = MainUtils.getSystemConfig(); SystemConfig systemConfig = MainUtils.getSystemConfig();
if (pbxHostList != null && pbxHostList.size() > 0) { if (pbxHostList != null && pbxHostList.size() > 0) {
pbxHost = pbxHostList.get(0); pbxHost = pbxHostList.get(0);
@ -90,10 +92,10 @@ public class ExtentionController extends Handler{
@RequestMapping(value = "/configuration") @RequestMapping(value = "/configuration")
@Menu(type = "callcenter", subtype = "configuration", access = true) @Menu(type = "callcenter", subtype = "configuration", access = true)
public ModelAndView configuration(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value , @Valid String profile) { public ModelAndView configuration(ModelMap map, HttpServletRequest request, @Valid String hostname, @Valid String key_value) {
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname); List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname);
PbxHost pbxHost = null ; PbxHost pbxHost;
SystemConfig systemConfig = MainUtils.getSystemConfig(); SystemConfig systemConfig = MainUtils.getSystemConfig();
if (pbxHostList != null && pbxHostList.size() > 0) { if (pbxHostList != null && pbxHostList.size() > 0) {
pbxHost = pbxHostList.get(0); pbxHost = pbxHostList.get(0);
@ -137,10 +139,10 @@ public class ExtentionController extends Handler{
@RequestMapping(value = "/dialplan") @RequestMapping(value = "/dialplan")
@Menu(type = "callcenter", subtype = "dialplan", access = true) @Menu(type = "callcenter", subtype = "dialplan", access = true)
public ModelAndView dialplan(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value) { public ModelAndView dialplan(ModelMap map, HttpServletRequest request, @Valid String hostname) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/dialplan/index")); ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/dialplan/index"));
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname); List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname);
PbxHost pbxHost = null ; PbxHost pbxHost;
SystemConfig systemConfig = MainUtils.getSystemConfig(); SystemConfig systemConfig = MainUtils.getSystemConfig();
Template template = null; Template template = null;
if (pbxHostList != null && pbxHostList.size() > 0) { if (pbxHostList != null && pbxHostList.size() > 0) {
@ -162,16 +164,13 @@ public class ExtentionController extends Handler{
} }
@RequestMapping(value = "/extention/detail") @RequestMapping(value = "/extention/detail")
@Menu(type = "callcenter" , subtype = "extention" , access = false) @Menu(type = "callcenter", subtype = "extention")
public ModelAndView detail(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String extno) { public ModelAndView detail(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String extno) {
List<Extention> extentionList = extentionRes.findByExtentionAndOrgi(extno, super.getOrgi(request)); List<Extention> extentionList = extentionRes.findByExtentionAndOrgi(extno, super.getOrgi(request));
if (extentionList != null && extentionList.size() == 1) { if (extentionList != null && extentionList.size() == 1) {
Extention extention = extentionList.get(0); Extention extention = extentionList.get(0);
if (!StringUtils.isBlank(extention.getHostid())) { if (!StringUtils.isBlank(extention.getHostid())) {
PbxHost pbxHost = pbxHostRes.findById(extention.getHostid()) ; pbxHostRes.findById(extention.getHostid()).ifPresent(it -> map.addAttribute("pbxhost", it));
if(pbxHost!=null) {
map.addAttribute("pbxhost" , pbxHost);
}
} }
map.addAttribute("extention", extention); map.addAttribute("extention", extention);
} }
@ -180,8 +179,8 @@ public class ExtentionController extends Handler{
} }
@RequestMapping(value = "/ivr") @RequestMapping(value = "/ivr")
@Menu(type = "callcenter" , subtype = "ivr" , access = false) @Menu(type = "callcenter", subtype = "ivr")
public ModelAndView ivr(ModelMap map , HttpServletRequest request , HttpServletResponse response ,@Valid String hostid) { public ModelAndView ivr(ModelMap map, HttpServletRequest request, @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

@ -24,8 +24,11 @@ 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);
// PbxHost findById(String id);
List<PbxHost> findByOrgi(String orgi); List<PbxHost> findByOrgi(String orgi);
List<PbxHost> findByHostnameOrIpaddr(String hostname, String ip); List<PbxHost> findByHostnameOrIpaddr(String hostname, String ip);
int countByHostnameAndOrgi(String hostname, String orgi); int countByHostnameAndOrgi(String hostname, String orgi);