mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Fix BlackListRepository related class
This commit is contained in:
parent
7d882fdd82
commit
33a12a8be9
@ -20,30 +20,30 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.chatopera.cc.basic.Constants;
|
||||
import com.chatopera.cc.cache.Cache;
|
||||
import com.chatopera.cc.persistence.repository.BlackListRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.annotation.JmsListener;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 访客黑名单
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class BlackListEventSubscription {
|
||||
private final static Logger logger = LoggerFactory.getLogger(BlackListEventSubscription.class);
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
@NonNull
|
||||
private final Cache cache;
|
||||
|
||||
@Autowired
|
||||
private BlackListRepository blackListRes;
|
||||
@NonNull
|
||||
private final BlackListRepository blackListRes;
|
||||
|
||||
/**
|
||||
* 拉黑访客到达拉黑时间后,从黑名单中移除
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
@JmsListener(destination = Constants.WEBIM_SOCKETIO_ONLINE_USER_BLACKLIST, containerFactory = "jmsListenerContainerQueue")
|
||||
public void onMessage(final String payload) {
|
||||
|
@ -32,6 +32,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -40,7 +41,7 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
|
||||
private static final Logger logger = LoggerFactory.getLogger(AppCtxRefreshEventListener.class);
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
public void onApplicationEvent(@NonNull ContextRefreshedEvent event) {
|
||||
if (MainContext.getContext() == null) {
|
||||
logger.info("[onApplicationEvent] set main context and initialize the Cache System.");
|
||||
MainContext.setApplicationContext(event.getApplicationContext());
|
||||
@ -52,10 +53,10 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
|
||||
|
||||
if (!StringUtils.equalsIgnoreCase(cacheSetupStrategy, Constants.cache_setup_strategy_skip)) {
|
||||
|
||||
/**************************
|
||||
* 加载系统到缓存
|
||||
* 加载系统词典大约只需要5s左右
|
||||
**************************/
|
||||
//**************************
|
||||
//* 加载系统到缓存
|
||||
//* 加载系统词典大约只需要5s左右
|
||||
//**************************
|
||||
|
||||
// 首先将之前缓存清空,此处使用系统的默认租户信息
|
||||
cache.eraseSysDicByOrgi(MainContext.SYSTEM_ORGI);
|
||||
@ -79,7 +80,7 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
|
||||
parents.contains(dic.getDicid())) {
|
||||
// 不是根词典,并且包含在一个根词典内
|
||||
if (!rootDictItems.containsKey(dic.getDicid())) {
|
||||
rootDictItems.put(dic.getDicid(), new ArrayList<SysDic>());
|
||||
rootDictItems.put(dic.getDicid(), new ArrayList<>());
|
||||
}
|
||||
rootDictItems.get(dic.getDicid()).add(dic);
|
||||
}
|
||||
|
@ -21,8 +21,9 @@ import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.BlackEntity;
|
||||
import com.chatopera.cc.persistence.repository.BlackListRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -33,74 +34,75 @@ import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/callcenter")
|
||||
public class CallCenterBlackController extends Handler{
|
||||
@RequiredArgsConstructor
|
||||
public class CallCenterBlackController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private BlackListRepository blackRes ;
|
||||
@NonNull
|
||||
private final BlackListRepository blackRes;
|
||||
|
||||
@RequestMapping(value = "/black")
|
||||
@Menu(type = "callcenter", subtype = "callcenterblack", admin = true)
|
||||
public ModelAndView black(ModelMap map , HttpServletRequest request , @Valid String hostid) {
|
||||
map.addAttribute("blackList" , blackRes.findByOrgi(super.getOrgi(request)));
|
||||
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/index"));
|
||||
@RequestMapping(value = "/black")
|
||||
@Menu(type = "callcenter", subtype = "callcenterblack", admin = true)
|
||||
public ModelAndView black(ModelMap map, HttpServletRequest request) {
|
||||
map.addAttribute("blackList", blackRes.findByOrgi(super.getOrgi(request)));
|
||||
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/index"));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/black/add")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView blackadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
|
||||
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/add"));
|
||||
@RequestMapping(value = "/black/add")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView blackadd() {
|
||||
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/add"));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/black/save")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView blacksave(ModelMap map , HttpServletRequest request , @Valid String phones) {
|
||||
if(!StringUtils.isBlank(phones)){
|
||||
String[] ps = phones.split("[ ,,\t\n]") ;
|
||||
for(String ph : ps){
|
||||
if(ph.length() >= 3){
|
||||
int count = blackRes.countByPhoneAndOrgi(ph.trim(), super.getOrgi(request)) ;
|
||||
if(count == 0){
|
||||
BlackEntity be = new BlackEntity();
|
||||
be.setPhone(ph.trim());
|
||||
be.setChannel(MainContext.ChannelType.PHONE.toString());
|
||||
be.setOrgi(super.getOrgi(request));
|
||||
be.setCreater(super.getUser(request).getId());
|
||||
blackRes.save(be) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
|
||||
@RequestMapping(value = "/black/save")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView blacksave(HttpServletRequest request, @Valid String phones) {
|
||||
if (!StringUtils.isBlank(phones)) {
|
||||
String[] ps = phones.split("[ ,,\t\n]");
|
||||
for (String ph : ps) {
|
||||
if (ph.length() >= 3) {
|
||||
int count = blackRes.countByPhoneAndOrgi(ph.trim(), super.getOrgi(request));
|
||||
if (count == 0) {
|
||||
BlackEntity be = new BlackEntity();
|
||||
be.setPhone(ph.trim());
|
||||
be.setChannel(MainContext.ChannelType.PHONE.toString());
|
||||
be.setOrgi(super.getOrgi(request));
|
||||
be.setCreater(super.getUser(request).getId());
|
||||
blackRes.save(be);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/black/edit")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView blackedit(ModelMap map , HttpServletRequest request , @Valid String id) {
|
||||
map.addAttribute("black" , blackRes.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/edit"));
|
||||
@RequestMapping(value = "/black/edit")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView blackedit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||
map.addAttribute("black", blackRes.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/edit"));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/black/update")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid BlackEntity black) {
|
||||
if(!StringUtils.isBlank(black.getId())){
|
||||
BlackEntity oldBlack = blackRes.findByIdAndOrgi(black.getId(), super.getOrgi(request)) ;
|
||||
if(oldBlack!=null){
|
||||
oldBlack.setPhone(black.getPhone());
|
||||
oldBlack.setChannel(MainContext.ChannelType.PHONE.toString());
|
||||
oldBlack.setOrgi(super.getOrgi(request));
|
||||
blackRes.save(oldBlack);
|
||||
}
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
|
||||
@RequestMapping(value = "/black/update")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView pbxhostupdate(HttpServletRequest request, @Valid BlackEntity black) {
|
||||
if (!StringUtils.isBlank(black.getId())) {
|
||||
BlackEntity oldBlack = blackRes.findByIdAndOrgi(black.getId(), super.getOrgi(request));
|
||||
if (oldBlack != null) {
|
||||
oldBlack.setPhone(black.getPhone());
|
||||
oldBlack.setChannel(MainContext.ChannelType.PHONE.toString());
|
||||
oldBlack.setOrgi(super.getOrgi(request));
|
||||
blackRes.save(oldBlack);
|
||||
}
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/black/delete")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView blackdelete(ModelMap map , HttpServletRequest request , @Valid String id) {
|
||||
if(!StringUtils.isBlank(id)){
|
||||
blackRes.delete(id);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
|
||||
@RequestMapping(value = "/black/delete")
|
||||
@Menu(type = "callcenter", subtype = "black", admin = true)
|
||||
public ModelAndView blackdelete(@Valid String id) {
|
||||
if (!StringUtils.isBlank(id)) {
|
||||
blackRes.deleteById(id);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.*;
|
||||
import com.chatopera.cc.persistence.repository.*;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -45,31 +45,29 @@ import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/setting")
|
||||
@RequiredArgsConstructor
|
||||
public class AgentSettingsController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private ACDPolicyService acdPolicyService;
|
||||
@NonNull
|
||||
private final ACDPolicyService acdPolicyService;
|
||||
|
||||
@Autowired
|
||||
private SessionConfigRepository sessionConfigRes;
|
||||
@NonNull
|
||||
private final SessionConfigRepository sessionConfigRes;
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes;
|
||||
@NonNull
|
||||
private final TagRepository tagRes;
|
||||
|
||||
@Autowired
|
||||
private BlackListRepository blackListRes;
|
||||
@NonNull
|
||||
private final BlackListRepository blackListRes;
|
||||
|
||||
@Autowired
|
||||
private AdTypeRepository adTypeRes;
|
||||
@NonNull
|
||||
private final AdTypeRepository adTypeRes;
|
||||
|
||||
@Autowired
|
||||
private TemplateRepository templateRes;
|
||||
@NonNull
|
||||
private final TemplateRepository templateRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
@NonNull
|
||||
private final Cache cache;
|
||||
|
||||
@RequestMapping("/agent/index")
|
||||
@Menu(type = "setting", subtype = "sessionconfig", admin = false)
|
||||
@ -136,7 +134,7 @@ public class AgentSettingsController extends Handler {
|
||||
|
||||
@RequestMapping("/blacklist/delete")
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView blacklistdelete(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||
public ModelAndView blacklistdelete(HttpServletRequest request, @Valid String id) {
|
||||
if (!StringUtils.isBlank(id)) {
|
||||
BlackEntity tempBlackEntity = blackListRes.findByIdAndOrgi(id, super.getOrgi(request));
|
||||
if (tempBlackEntity != null) {
|
||||
@ -174,22 +172,22 @@ public class AgentSettingsController extends Handler {
|
||||
|
||||
@RequestMapping("/tag/add")
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagadd(ModelMap map, HttpServletRequest request, @Valid String tagtype) {
|
||||
public ModelAndView tagadd(ModelMap map, @Valid String tagtype) {
|
||||
map.addAttribute("tagtype", tagtype);
|
||||
return request(super.createRequestPageTempletResponse("/apps/setting/agent/tagadd"));
|
||||
}
|
||||
|
||||
@RequestMapping("/tag/edit")
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) {
|
||||
map.put("tag", tagRes.findOne(id));
|
||||
public ModelAndView tagedit(ModelMap map, @Valid String id, @Valid String tagtype) {
|
||||
map.put("tag", tagRes.findById(id).orElse(null));
|
||||
map.addAttribute("tagtype", tagtype);
|
||||
return request(super.createRequestPageTempletResponse("/apps/setting/agent/tagedit"));
|
||||
}
|
||||
|
||||
@RequestMapping("/tag/update")
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagupdate(ModelMap map, HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) {
|
||||
public ModelAndView tagupdate(HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) {
|
||||
Tag temptag = tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag());
|
||||
if (temptag == null || tag.getId().equals(temptag.getId())) {
|
||||
tag.setOrgi(super.getOrgi(request));
|
||||
@ -201,7 +199,7 @@ public class AgentSettingsController extends Handler {
|
||||
|
||||
@RequestMapping("/tag/save")
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagsave(ModelMap map, HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) {
|
||||
public ModelAndView tagsave(HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) {
|
||||
if (tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()) == null) {
|
||||
tag.setOrgi(super.getOrgi(request));
|
||||
tag.setCreater(super.getUser(request).getId());
|
||||
@ -212,15 +210,15 @@ public class AgentSettingsController extends Handler {
|
||||
|
||||
@RequestMapping("/tag/delete")
|
||||
@Menu(type = "setting", subtype = "tag", admin = false)
|
||||
public ModelAndView tagdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) {
|
||||
tagRes.delete(id);
|
||||
public ModelAndView tagdelete(@Valid String id, @Valid String tagtype) {
|
||||
tagRes.deleteById(id);
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/acd")
|
||||
@Menu(type = "setting", subtype = "acd", admin = false)
|
||||
public ModelAndView acd(ModelMap map, HttpServletRequest request) {
|
||||
public ModelAndView acd(ModelMap map) {
|
||||
map.put("tagTypeList", Dict.getInstance().getDic("com.dic.tag.type"));
|
||||
return request(super.createAppsTempletResponse("/apps/setting/agent/acd"));
|
||||
}
|
||||
@ -256,14 +254,14 @@ public class AgentSettingsController extends Handler {
|
||||
|
||||
@RequestMapping("/adv/add")
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advadd(ModelMap map, HttpServletRequest request, @Valid String adpos) {
|
||||
public ModelAndView advadd(ModelMap map, @Valid String adpos) {
|
||||
map.addAttribute("adpos", adpos);
|
||||
return request(super.createRequestPageTempletResponse("/apps/setting/agent/adadd"));
|
||||
}
|
||||
|
||||
@RequestMapping("/adv/save")
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advsave(ModelMap map, HttpServletRequest request, @Valid AdType adv, @Valid String advtype, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
|
||||
public ModelAndView advsave(HttpServletRequest request, @Valid AdType adv, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
|
||||
adv.setOrgi(super.getOrgi(request));
|
||||
adv.setCreater(super.getUser(request).getId());
|
||||
if (StringUtils.isNotBlank(adv.getContent())) {
|
||||
@ -290,7 +288,7 @@ public class AgentSettingsController extends Handler {
|
||||
|
||||
@RequestMapping("/adv/update")
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advupdate(ModelMap map, HttpServletRequest request, @Valid AdType ad, @Valid String adpos, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
|
||||
public ModelAndView advupdate(HttpServletRequest request, @Valid AdType ad, @Valid String adpos, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
|
||||
AdType tempad = adTypeRes.findByIdAndOrgi(ad.getId(), super.getOrgi(request));
|
||||
if (tempad != null) {
|
||||
ad.setOrgi(super.getOrgi(request));
|
||||
@ -312,8 +310,8 @@ public class AgentSettingsController extends Handler {
|
||||
|
||||
@RequestMapping("/adv/delete")
|
||||
@Menu(type = "setting", subtype = "adv", admin = false)
|
||||
public ModelAndView advdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String adpos) {
|
||||
adTypeRes.delete(id);
|
||||
public ModelAndView advdelete(HttpServletRequest request, @Valid String id, @Valid String adpos) {
|
||||
adTypeRes.deleteById(id);
|
||||
MainUtils.initAdv(super.getOrgi(request));
|
||||
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user