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

Remove access = false

This commit is contained in:
dengchao@xgtl 2020-04-16 16:45:41 +08:00
parent 4f4616ccba
commit 540a480cd1
8 changed files with 631 additions and 636 deletions

View File

@ -1,106 +1,106 @@
/* /*
* 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.MainContext; import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler; import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.BlackEntity; import com.chatopera.cc.model.BlackEntity;
import com.chatopera.cc.persistence.repository.BlackListRepository; import com.chatopera.cc.persistence.repository.BlackListRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
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.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;
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;
@Controller @Controller
@RequestMapping("/admin/callcenter") @RequestMapping("/admin/callcenter")
public class CallCenterBlackController extends Handler{ public class CallCenterBlackController extends Handler{
@Autowired @Autowired
private BlackListRepository blackRes ; private BlackListRepository blackRes ;
@RequestMapping(value = "/black") @RequestMapping(value = "/black")
@Menu(type = "callcenter" , subtype = "callcenterblack" , access = false , admin = true) @Menu(type = "callcenter", subtype = "callcenterblack", admin = true)
public ModelAndView black(ModelMap map , HttpServletRequest request , @Valid String hostid) { public ModelAndView black(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.addAttribute("blackList" , blackRes.findByOrgi(super.getOrgi(request))); map.addAttribute("blackList" , blackRes.findByOrgi(super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/index")); return request(super.createRequestPageTempletResponse("/admin/callcenter/black/index"));
} }
@RequestMapping(value = "/black/add") @RequestMapping(value = "/black/add")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true) @Menu(type = "callcenter", subtype = "black", admin = true)
public ModelAndView blackadd(ModelMap map , HttpServletRequest request , @Valid String hostid) { public ModelAndView blackadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/add")); return request(super.createRequestPageTempletResponse("/admin/callcenter/black/add"));
} }
@RequestMapping(value = "/black/save") @RequestMapping(value = "/black/save")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true) @Menu(type = "callcenter", subtype = "black", admin = true)
public ModelAndView blacksave(ModelMap map , HttpServletRequest request , @Valid String phones) { public ModelAndView blacksave(ModelMap map , HttpServletRequest request , @Valid String phones) {
if(!StringUtils.isBlank(phones)){ if(!StringUtils.isBlank(phones)){
String[] ps = phones.split("[ ,\t\n]") ; String[] ps = phones.split("[ ,\t\n]") ;
for(String ph : ps){ for(String ph : ps){
if(ph.length() >= 3){ if(ph.length() >= 3){
int count = blackRes.countByPhoneAndOrgi(ph.trim(), super.getOrgi(request)) ; int count = blackRes.countByPhoneAndOrgi(ph.trim(), super.getOrgi(request)) ;
if(count == 0){ if(count == 0){
BlackEntity be = new BlackEntity(); BlackEntity be = new BlackEntity();
be.setPhone(ph.trim()); be.setPhone(ph.trim());
be.setChannel(MainContext.ChannelType.PHONE.toString()); be.setChannel(MainContext.ChannelType.PHONE.toString());
be.setOrgi(super.getOrgi(request)); be.setOrgi(super.getOrgi(request));
be.setCreater(super.getUser(request).getId()); be.setCreater(super.getUser(request).getId());
blackRes.save(be) ; blackRes.save(be) ;
} }
} }
} }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html")); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
} }
@RequestMapping(value = "/black/edit") @RequestMapping(value = "/black/edit")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true) @Menu(type = "callcenter", subtype = "black", admin = true)
public ModelAndView blackedit(ModelMap map , HttpServletRequest request , @Valid String id) { public ModelAndView blackedit(ModelMap map , HttpServletRequest request , @Valid String id) {
map.addAttribute("black" , blackRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("black" , blackRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/edit")); return request(super.createRequestPageTempletResponse("/admin/callcenter/black/edit"));
} }
@RequestMapping(value = "/black/update") @RequestMapping(value = "/black/update")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true) @Menu(type = "callcenter", subtype = "black", admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid BlackEntity black) { public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid BlackEntity black) {
if(!StringUtils.isBlank(black.getId())){ if(!StringUtils.isBlank(black.getId())){
BlackEntity oldBlack = blackRes.findByIdAndOrgi(black.getId(), super.getOrgi(request)) ; BlackEntity oldBlack = blackRes.findByIdAndOrgi(black.getId(), super.getOrgi(request)) ;
if(oldBlack!=null){ if(oldBlack!=null){
oldBlack.setPhone(black.getPhone()); oldBlack.setPhone(black.getPhone());
oldBlack.setChannel(MainContext.ChannelType.PHONE.toString()); oldBlack.setChannel(MainContext.ChannelType.PHONE.toString());
oldBlack.setOrgi(super.getOrgi(request)); oldBlack.setOrgi(super.getOrgi(request));
blackRes.save(oldBlack); blackRes.save(oldBlack);
} }
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html")); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
} }
@RequestMapping(value = "/black/delete") @RequestMapping(value = "/black/delete")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true) @Menu(type = "callcenter", subtype = "black", admin = true)
public ModelAndView blackdelete(ModelMap map , HttpServletRequest request , @Valid String id) { public ModelAndView blackdelete(ModelMap map , HttpServletRequest request , @Valid String id) {
if(!StringUtils.isBlank(id)){ if(!StringUtils.isBlank(id)){
blackRes.delete(id); blackRes.delete(id);
} }
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html")); return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
} }
} }

View File

@ -158,7 +158,7 @@ public class CallCenterMediaController extends Handler {
} }
@RequestMapping(value = "/play") @RequestMapping(value = "/play")
@Menu(type = "callcenter", subtype = "play", access = false) @Menu(type = "callcenter", subtype = "play")
public ModelAndView play(ModelMap map, HttpServletRequest request, @Valid final String id) { 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

@ -58,31 +58,30 @@ public class TemplateController extends Handler {
private final Cache cache; private final Cache cache;
@RequestMapping("/index") @RequestMapping("/index")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request) { public ModelAndView index(ModelMap map) {
map.addAttribute("sysDicList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC)); map.addAttribute("sysDicList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC));
return request(super.createAdminTempletResponse("/admin/system/template/index")); return request(super.createAdminTempletResponse("/admin/system/template/index"));
} }
@RequestMapping("/expall") @RequestMapping("/expall")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws Exception { public void expall(HttpServletRequest request, HttpServletResponse response) throws Exception {
List<Template> templateList = templateRes.findByOrgi(super.getOrgi(request)); List<Template> templateList = templateRes.findByOrgi(super.getOrgi(request));
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Template-Export-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".data"); response.setHeader("content-disposition", "attachment;filename=UCKeFu-Template-Export-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".data");
response.getOutputStream().write(MainUtils.toBytes(templateList)); response.getOutputStream().write(MainUtils.toBytes(templateList));
return;
} }
@RequestMapping("/imp") @RequestMapping("/imp")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView imp(ModelMap map, HttpServletRequest request) { public ModelAndView imp() {
return request(super.createRequestPageTempletResponse("/admin/system/template/imp")); return request(super.createRequestPageTempletResponse("/admin/system/template/imp"));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@RequestMapping("/impsave") @RequestMapping("/impsave")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView impsave(ModelMap map, HttpServletRequest request, @RequestParam(value = "dataFile", required = false) MultipartFile dataFile) throws Exception { public ModelAndView impsave(@RequestParam(value = "dataFile", required = false) MultipartFile dataFile) throws Exception {
if (dataFile != null && dataFile.getSize() > 0) { if (dataFile != null && dataFile.getSize() > 0) {
List<Template> templateList = (List<Template>) MainUtils.toObject(dataFile.getBytes()); List<Template> templateList = (List<Template>) MainUtils.toObject(dataFile.getBytes());
if (templateList != null && templateList.size() > 0) { if (templateList != null && templateList.size() > 0) {
@ -96,7 +95,7 @@ public class TemplateController extends Handler {
} }
@RequestMapping("/list") @RequestMapping("/list")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView list(ModelMap map, HttpServletRequest request, @Valid String type) { public ModelAndView list(ModelMap map, HttpServletRequest request, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type)); map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(type, super.getOrgi(request))); map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(type, super.getOrgi(request)));
@ -104,14 +103,14 @@ public class TemplateController extends Handler {
} }
@RequestMapping("/add") @RequestMapping("/add")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String type) { public ModelAndView add(ModelMap map, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type)); map.addAttribute("sysDic", dicRes.findById(type));
return request(super.createRequestPageTempletResponse("/admin/system/template/add")); return request(super.createRequestPageTempletResponse("/admin/system/template/add"));
} }
@RequestMapping("/save") @RequestMapping("/save")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView save(HttpServletRequest request, @Valid Template template) { public ModelAndView save(HttpServletRequest request, @Valid Template template) {
template.setOrgi(super.getOrgi(request)); template.setOrgi(super.getOrgi(request));
template.setCreatetime(new Date()); template.setCreatetime(new Date());
@ -127,7 +126,7 @@ public class TemplateController extends Handler {
} }
@RequestMapping("/edit") @RequestMapping("/edit")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String type) { public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type)); map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request)));
@ -135,7 +134,7 @@ public class TemplateController extends Handler {
} }
@RequestMapping("/update") @RequestMapping("/update")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView update(HttpServletRequest request, @Valid Template template) { public ModelAndView update(HttpServletRequest request, @Valid Template template) {
Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request)); Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request));
if (oldTemplate != null) { if (oldTemplate != null) {
@ -157,7 +156,7 @@ public class TemplateController extends Handler {
} }
@RequestMapping("/code") @RequestMapping("/code")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView code(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String type) { public ModelAndView code(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String type) {
map.addAttribute("sysDic", dicRes.findById(type)); map.addAttribute("sysDic", dicRes.findById(type));
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request))); map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request)));
@ -165,7 +164,7 @@ public class TemplateController extends Handler {
} }
@RequestMapping("/codesave") @RequestMapping("/codesave")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView codesave(HttpServletRequest request, @Valid Template template) { public ModelAndView codesave(HttpServletRequest request, @Valid Template template) {
Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request)); Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request));
if (oldTemplate != null) { if (oldTemplate != null) {
@ -179,7 +178,7 @@ public class TemplateController extends Handler {
} }
@RequestMapping("/delete") @RequestMapping("/delete")
@Menu(type = "admin", subtype = "template", access = false, admin = true) @Menu(type = "admin", subtype = "template", admin = true)
public ModelAndView delete(HttpServletRequest request, @Valid Template template) { public ModelAndView delete(HttpServletRequest request, @Valid Template template) {
templateRes.delete(template); templateRes.delete(template);
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request)); cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));

View File

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

View File

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

View File

@ -74,7 +74,7 @@ public class AgentSummaryController extends Handler {
* 按条件查询 * 按条件查询
*/ */
@RequestMapping(value = "/index") @RequestMapping(value = "/index")
@Menu(type = "agent", subtype = "agentsummary", access = false) @Menu(type = "agent", subtype = "agentsummary")
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid final String begin, @Valid final String end) { public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid final String begin, @Valid final String end) {
final String orgi = super.getOrgi(request); final String orgi = super.getOrgi(request);
Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> { Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> {
@ -105,7 +105,7 @@ public class AgentSummaryController extends Handler {
} }
@RequestMapping(value = "/process") @RequestMapping(value = "/process")
@Menu(type = "agent", subtype = "agentsummary", access = false) @Menu(type = "agent", subtype = "agentsummary")
public ModelAndView process(ModelMap map, HttpServletRequest request, @Valid final String id) { public ModelAndView process(ModelMap map, HttpServletRequest request, @Valid final String id) {
AgentServiceSummary summary = serviceSummaryRes.findByIdAndOrgi(id, super.getOrgi(request)); AgentServiceSummary summary = serviceSummaryRes.findByIdAndOrgi(id, super.getOrgi(request));
map.addAttribute("summary", summary); map.addAttribute("summary", summary);
@ -123,7 +123,7 @@ public class AgentSummaryController extends Handler {
} }
@RequestMapping(value = "/save") @RequestMapping(value = "/save")
@Menu(type = "agent", subtype = "agentsummary", access = false) @Menu(type = "agent", subtype = "agentsummary")
public ModelAndView save(HttpServletRequest request, @Valid final AgentServiceSummary summary) { public ModelAndView save(HttpServletRequest request, @Valid final AgentServiceSummary summary) {
AgentServiceSummary oldSummary = serviceSummaryRes.findByIdAndOrgi(summary.getId(), super.getOrgi(request)); AgentServiceSummary oldSummary = serviceSummaryRes.findByIdAndOrgi(summary.getId(), super.getOrgi(request));
if (oldSummary != null) { if (oldSummary != null) {
@ -138,7 +138,7 @@ public class AgentSummaryController extends Handler {
} }
@RequestMapping("/expids") @RequestMapping("/expids")
@Menu(type = "agent", subtype = "agentsummary", access = false) @Menu(type = "agent", subtype = "agentsummary")
public void expids(HttpServletResponse response, @Valid String[] ids) throws IOException { public void expids(HttpServletResponse response, @Valid String[] ids) throws IOException {
if (ids != null && ids.length > 0) { if (ids != null && ids.length > 0) {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAllById(Arrays.asList(ids)); Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAllById(Arrays.asList(ids));
@ -156,7 +156,7 @@ public class AgentSummaryController extends Handler {
} }
@RequestMapping("/expall") @RequestMapping("/expall")
@Menu(type = "agent", subtype = "agentsummary", access = false) @Menu(type = "agent", subtype = "agentsummary")
public void expall(HttpServletRequest request, HttpServletResponse response) throws IOException { public void expall(HttpServletRequest request, HttpServletResponse response) throws IOException {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgi( Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgi(
MainContext.ChannelType.PHONE.toString(), super.getOrgi(request), PageRequest.of(0, 10000)); MainContext.ChannelType.PHONE.toString(), super.getOrgi(request), PageRequest.of(0, 10000));
@ -174,7 +174,7 @@ public class AgentSummaryController extends Handler {
} }
@RequestMapping("/expsearch") @RequestMapping("/expsearch")
@Menu(type = "agent", subtype = "agentsummary", access = false) @Menu(type = "agent", subtype = "agentsummary")
public void expall(HttpServletRequest request, HttpServletResponse response, @Valid final String begin, @Valid final String end) throws IOException { public void expall(HttpServletRequest request, HttpServletResponse response, @Valid final String begin, @Valid final String end) throws IOException {
final String orgi = super.getOrgi(request); final String orgi = super.getOrgi(request);
Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> { Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> {

View File

@ -73,7 +73,7 @@ public class ProcessedSummaryController extends Handler {
* 按条件查询 * 按条件查询
*/ */
@RequestMapping(value = "/index") @RequestMapping(value = "/index")
@Menu(type = "agent", subtype = "processed", access = false) @Menu(type = "agent", subtype = "processed")
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid final String ani, @Valid final String called, @Valid final String begin, @Valid final String end) { public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid final String ani, @Valid final String called, @Valid final String begin, @Valid final String end) {
final String orgi = super.getOrgi(request); final String orgi = super.getOrgi(request);
Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> { Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> {
@ -113,7 +113,7 @@ public class ProcessedSummaryController extends Handler {
@RequestMapping(value = "/process") @RequestMapping(value = "/process")
@Menu(type = "agent", subtype = "processed", access = false) @Menu(type = "agent", subtype = "processed")
public ModelAndView process(ModelMap map, HttpServletRequest request, @Valid final String id) { public ModelAndView process(ModelMap map, HttpServletRequest request, @Valid final String id) {
AgentServiceSummary summary = serviceSummaryRes.findByIdAndOrgi(id, super.getOrgi(request)); AgentServiceSummary summary = serviceSummaryRes.findByIdAndOrgi(id, super.getOrgi(request));
map.addAttribute("summary", summary); map.addAttribute("summary", summary);
@ -131,7 +131,7 @@ public class ProcessedSummaryController extends Handler {
} }
@RequestMapping(value = "/save") @RequestMapping(value = "/save")
@Menu(type = "agent", subtype = "processed", access = false) @Menu(type = "agent", subtype = "processed")
public ModelAndView save(HttpServletRequest request, @Valid final AgentServiceSummary summary) { public ModelAndView save(HttpServletRequest request, @Valid final AgentServiceSummary summary) {
AgentServiceSummary oldSummary = serviceSummaryRes.findByIdAndOrgi(summary.getId(), super.getOrgi(request)); AgentServiceSummary oldSummary = serviceSummaryRes.findByIdAndOrgi(summary.getId(), super.getOrgi(request));
if (oldSummary != null) { if (oldSummary != null) {
@ -146,7 +146,7 @@ public class ProcessedSummaryController extends Handler {
} }
@RequestMapping("/expids") @RequestMapping("/expids")
@Menu(type = "agent", subtype = "processed", access = false) @Menu(type = "agent", subtype = "processed")
public void expids(HttpServletResponse response, @Valid String[] ids) throws IOException { public void expids(HttpServletResponse response, @Valid String[] ids) throws IOException {
if (ids != null && ids.length > 0) { if (ids != null && ids.length > 0) {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAllById(Arrays.asList(ids)); Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAllById(Arrays.asList(ids));
@ -165,7 +165,7 @@ public class ProcessedSummaryController extends Handler {
} }
@RequestMapping("/expall") @RequestMapping("/expall")
@Menu(type = "agent", subtype = "processed", access = false) @Menu(type = "agent", subtype = "processed")
public void expall(HttpServletRequest request, HttpServletResponse response) throws IOException { public void expall(HttpServletRequest request, HttpServletResponse response) throws IOException {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgi( Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgi(
MainContext.ChannelType.PHONE.toString(), super.getOrgi(request), PageRequest.of(0, 10000)); MainContext.ChannelType.PHONE.toString(), super.getOrgi(request), PageRequest.of(0, 10000));
@ -183,7 +183,7 @@ public class ProcessedSummaryController extends Handler {
} }
@RequestMapping("/expsearch") @RequestMapping("/expsearch")
@Menu(type = "agent", subtype = "processed", access = false) @Menu(type = "agent", subtype = "processed")
public void expall(HttpServletRequest request, HttpServletResponse response, @Valid final String ani, @Valid final String called, @Valid final String begin, @Valid final String end) throws IOException { public void expall(HttpServletRequest request, HttpServletResponse response, @Valid final String ani, @Valid final String called, @Valid final String begin, @Valid final String end) throws IOException {
final String orgi = super.getOrgi(request); final String orgi = super.getOrgi(request);
Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> { Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> {

View File

@ -1,186 +1,186 @@
/* /*
* 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.resource; package com.chatopera.cc.controller.resource;
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.AttachmentFile; import com.chatopera.cc.model.AttachmentFile;
import com.chatopera.cc.model.StreamingFile; import com.chatopera.cc.model.StreamingFile;
import com.chatopera.cc.model.UploadStatus; import com.chatopera.cc.model.UploadStatus;
import com.chatopera.cc.persistence.blob.JpaBlobHelper; import com.chatopera.cc.persistence.blob.JpaBlobHelper;
import com.chatopera.cc.persistence.repository.AttachmentRepository; import com.chatopera.cc.persistence.repository.AttachmentRepository;
import com.chatopera.cc.persistence.repository.StreamingFileRepository; import com.chatopera.cc.persistence.repository.StreamingFileRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils; import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
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.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
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.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URL; import java.net.URL;
import java.sql.SQLException; import java.sql.SQLException;
@Controller @Controller
@RequestMapping("/res") @RequestMapping("/res")
public class MediaController extends Handler { public class MediaController extends Handler {
private final static Logger logger = LoggerFactory.getLogger(MediaController.class); private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
@Value("${web.upload-path}") @Value("${web.upload-path}")
private String path; private String path;
@Autowired @Autowired
private StreamingFileRepository streamingFileRes; private StreamingFileRepository streamingFileRes;
@Autowired @Autowired
private JpaBlobHelper jpaBlobHelper; private JpaBlobHelper jpaBlobHelper;
private String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/"; private final String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/";
@Autowired @Autowired
private AttachmentRepository attachementRes; private AttachmentRepository attachementRes;
@RequestMapping("/image") @RequestMapping("/image")
@Menu(type = "resouce", subtype = "image", access = true) @Menu(type = "resouce", subtype = "image", access = true)
public void index(HttpServletResponse response, public void index(HttpServletResponse response,
@Valid String id, @Valid String id,
@RequestParam(value = "original", required = false) boolean original, @RequestParam(value = "original", required = false) boolean original,
@RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException { @RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException {
StreamingFile sf = streamingFileRes.findOne(id); StreamingFile sf = streamingFileRes.findOne(id);
if (sf != null) { if (sf != null) {
response.setHeader("Content-Type", sf.getMime()); response.setHeader("Content-Type", sf.getMime());
response.setContentType(sf.getMime()); response.setContentType(sf.getMime());
if (cooperation && (sf.getCooperation() != null)) { // 协作文件 if (cooperation && (sf.getCooperation() != null)) { // 协作文件
IOUtils.copy(sf.getCooperation().getBinaryStream(), response.getOutputStream()); IOUtils.copy(sf.getCooperation().getBinaryStream(), response.getOutputStream());
} else if (original && sf.getData() != null) { // 源文件 } else if (original && sf.getData() != null) { // 源文件
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream()); IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
} else if (sf.getThumbnail() != null) { // 缩略图 } else if (sf.getThumbnail() != null) { // 缩略图
IOUtils.copy(sf.getThumbnail().getBinaryStream(), response.getOutputStream()); IOUtils.copy(sf.getThumbnail().getBinaryStream(), response.getOutputStream());
} else if (sf.getData() != null) { } else if (sf.getData() != null) {
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream()); IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
} else { } else {
logger.warn("[index] can not get streaming file id {}, original {}, cooperation {}", id, original, cooperation); logger.warn("[index] can not get streaming file id {}, original {}, cooperation {}", id, original, cooperation);
} }
} }
} }
@RequestMapping("/voice") @RequestMapping("/voice")
@Menu(type = "resouce", subtype = "voice", access = true) @Menu(type = "resouce", subtype = "voice", access = true)
public void voice(HttpServletResponse response, @Valid String id) throws IOException { public void voice(HttpServletResponse response, @Valid String id) throws IOException {
File file = new File(path, id); File file = new File(path, id);
if (file.exists() && file.isFile()) { if (file.exists() && file.isFile()) {
response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, id))); response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, id)));
} }
} }
@RequestMapping("/url") @RequestMapping("/url")
@Menu(type = "resouce", subtype = "image", access = true) @Menu(type = "resouce", subtype = "image", access = true)
public void url(HttpServletResponse response, @Valid String url) throws IOException { public void url(HttpServletResponse response, @Valid String url) throws IOException {
byte[] data = new byte[1024]; byte[] data = new byte[1024];
int length = 0; int length = 0;
OutputStream out = response.getOutputStream(); OutputStream out = response.getOutputStream();
if (StringUtils.isNotBlank(url)) { if (StringUtils.isNotBlank(url)) {
InputStream input = new URL(url).openStream(); InputStream input = new URL(url).openStream();
while ((length = input.read(data)) > 0) { while ((length = input.read(data)) > 0) {
out.write(data, 0, length); out.write(data, 0, length);
} }
input.close(); input.close();
} }
} }
@RequestMapping("/image/upload") @RequestMapping("/image/upload")
@Menu(type = "resouce", subtype = "imageupload", access = false) @Menu(type = "resouce", subtype = "imageupload")
public ModelAndView upload(ModelMap map, public ModelAndView upload(ModelMap map,
HttpServletRequest request, HttpServletRequest request,
@RequestParam(value = "imgFile", required = false) MultipartFile multipart) throws IOException { @RequestParam(value = "imgFile", required = false) MultipartFile multipart) throws IOException {
ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload")); ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload"));
UploadStatus notify = null; UploadStatus notify = null;
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) { if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) {
File uploadDir = new File(path, "upload"); File uploadDir = new File(path, "upload");
if (!uploadDir.exists()) { if (!uploadDir.exists()) {
uploadDir.mkdirs(); uploadDir.mkdirs();
} }
String fileid = MainUtils.getUUID(); String fileid = MainUtils.getUUID();
StreamingFile sf = new StreamingFile(); StreamingFile sf = new StreamingFile();
sf.setId(fileid); sf.setId(fileid);
sf.setName(multipart.getOriginalFilename()); sf.setName(multipart.getOriginalFilename());
sf.setMime(multipart.getContentType()); sf.setMime(multipart.getContentType());
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
streamingFileRes.save(sf); streamingFileRes.save(sf);
String fileURL = "/res/image.html?id=" + fileid; String fileURL = "/res/image.html?id=" + fileid;
notify = new UploadStatus("0", fileURL); //图片直接发送给 客户不用返回 notify = new UploadStatus("0", fileURL); //图片直接发送给 客户不用返回
} else { } else {
notify = new UploadStatus("请选择图片文件"); notify = new UploadStatus("请选择图片文件");
} }
map.addAttribute("upload", notify); map.addAttribute("upload", notify);
return view; return view;
} }
@RequestMapping("/file") @RequestMapping("/file")
@Menu(type = "resouce", subtype = "file", access = false) @Menu(type = "resouce", subtype = "file")
public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException, SQLException { public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException, SQLException {
if (StringUtils.isNotBlank(id)) { if (StringUtils.isNotBlank(id)) {
AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request)); AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request));
if (attachmentFile != null && attachmentFile.getFileid() != null) { if (attachmentFile != null && attachmentFile.getFileid() != null) {
StreamingFile sf = streamingFileRes.findOne(attachmentFile.getFileid()); StreamingFile sf = streamingFileRes.findOne(attachmentFile.getFileid());
if (sf != null) { if (sf != null) {
response.setContentType(attachmentFile.getFiletype()); response.setContentType(attachmentFile.getFiletype());
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8"));
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream()); IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
} else { } else {
logger.warn("[streaming file] can not get file id {}", attachmentFile.getFileid()); logger.warn("[streaming file] can not get file id {}", attachmentFile.getFileid());
} }
} else { } else {
logger.warn("[attachment file] can not find attachment file id {}", id); logger.warn("[attachment file] can not find attachment file id {}", id);
} }
} }
} }
@RequestMapping("/template") @RequestMapping("/template")
@Menu(type = "resouce", subtype = "template", access = false) @Menu(type = "resouce", subtype = "template")
public void template(HttpServletResponse response, HttpServletRequest request, @Valid String filename) throws IOException { public void template(HttpServletResponse response, HttpServletRequest request, @Valid String filename) throws IOException {
if (StringUtils.isNotBlank(filename)) { if (StringUtils.isNotBlank(filename)) {
InputStream is = MediaController.class.getClassLoader().getResourceAsStream(TEMPLATE_DATA_PATH + filename); InputStream is = MediaController.class.getClassLoader().getResourceAsStream(TEMPLATE_DATA_PATH + filename);
if (is != null) { if (is != null) {
response.setContentType("text/plain"); response.setContentType("text/plain");
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(filename, "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(filename, "UTF-8"));
int length; int length;
byte[] data = new byte[1024]; byte[] data = new byte[1024];
while ((length = is.read(data)) > 0) { while ((length = is.read(data)) > 0) {
response.getOutputStream().write(data, 0, length); response.getOutputStream().write(data, 0, length);
} }
is.close(); is.close();
} }
} }
return; return;
} }
} }