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:
parent
4f4616ccba
commit
540a480cd1
@ -1,106 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.controller.admin.callcenter;
|
||||
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
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 org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/callcenter")
|
||||
public class CallCenterBlackController extends Handler{
|
||||
|
||||
@Autowired
|
||||
private BlackListRepository blackRes ;
|
||||
|
||||
@RequestMapping(value = "/black")
|
||||
@Menu(type = "callcenter" , subtype = "callcenterblack" , access = false , 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/add")
|
||||
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
|
||||
public ModelAndView blackadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
|
||||
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/add"));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/black/save")
|
||||
@Menu(type = "callcenter" , subtype = "black" , access = false , 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/edit")
|
||||
@Menu(type = "callcenter" , subtype = "black" , access = false , 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" , access = false , 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/delete")
|
||||
@Menu(type = "callcenter" , subtype = "black" , access = false , 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"));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.controller.admin.callcenter;
|
||||
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
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 org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/callcenter")
|
||||
public class CallCenterBlackController extends Handler{
|
||||
|
||||
@Autowired
|
||||
private 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/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/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/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/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"));
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public class CallCenterMediaController extends Handler {
|
||||
}
|
||||
|
||||
@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) {
|
||||
map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/play"));
|
||||
|
@ -58,31 +58,30 @@ public class TemplateController extends Handler {
|
||||
private final Cache cache;
|
||||
|
||||
@RequestMapping("/index")
|
||||
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
||||
@Menu(type = "admin", subtype = "template", admin = true)
|
||||
public ModelAndView index(ModelMap map) {
|
||||
map.addAttribute("sysDicList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_DIC));
|
||||
return request(super.createAdminTempletResponse("/admin/system/template/index"));
|
||||
}
|
||||
|
||||
@RequestMapping("/expall")
|
||||
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
@Menu(type = "admin", subtype = "template", admin = true)
|
||||
public void expall(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
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.getOutputStream().write(MainUtils.toBytes(templateList));
|
||||
return;
|
||||
}
|
||||
|
||||
@RequestMapping("/imp")
|
||||
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||
public ModelAndView imp(ModelMap map, HttpServletRequest request) {
|
||||
@Menu(type = "admin", subtype = "template", admin = true)
|
||||
public ModelAndView imp() {
|
||||
return request(super.createRequestPageTempletResponse("/admin/system/template/imp"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping("/impsave")
|
||||
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||
public ModelAndView impsave(ModelMap map, HttpServletRequest request, @RequestParam(value = "dataFile", required = false) MultipartFile dataFile) throws Exception {
|
||||
@Menu(type = "admin", subtype = "template", admin = true)
|
||||
public ModelAndView impsave(@RequestParam(value = "dataFile", required = false) MultipartFile dataFile) throws Exception {
|
||||
if (dataFile != null && dataFile.getSize() > 0) {
|
||||
List<Template> templateList = (List<Template>) MainUtils.toObject(dataFile.getBytes());
|
||||
if (templateList != null && templateList.size() > 0) {
|
||||
@ -96,7 +95,7 @@ public class TemplateController extends Handler {
|
||||
}
|
||||
|
||||
@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) {
|
||||
map.addAttribute("sysDic", dicRes.findById(type));
|
||||
map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(type, super.getOrgi(request)));
|
||||
@ -104,14 +103,14 @@ public class TemplateController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
@Menu(type = "admin", subtype = "template", access = false, admin = true)
|
||||
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String type) {
|
||||
@Menu(type = "admin", subtype = "template", admin = true)
|
||||
public ModelAndView add(ModelMap map, @Valid String type) {
|
||||
map.addAttribute("sysDic", dicRes.findById(type));
|
||||
return request(super.createRequestPageTempletResponse("/admin/system/template/add"));
|
||||
}
|
||||
|
||||
@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) {
|
||||
template.setOrgi(super.getOrgi(request));
|
||||
template.setCreatetime(new Date());
|
||||
@ -127,7 +126,7 @@ public class TemplateController extends Handler {
|
||||
}
|
||||
|
||||
@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) {
|
||||
map.addAttribute("sysDic", dicRes.findById(type));
|
||||
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||
@ -135,7 +134,7 @@ public class TemplateController extends Handler {
|
||||
}
|
||||
|
||||
@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) {
|
||||
Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request));
|
||||
if (oldTemplate != null) {
|
||||
@ -157,7 +156,7 @@ public class TemplateController extends Handler {
|
||||
}
|
||||
|
||||
@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) {
|
||||
map.addAttribute("sysDic", dicRes.findById(type));
|
||||
map.addAttribute("template", templateRes.findByIdAndOrgi(id, super.getOrgi(request)));
|
||||
@ -165,7 +164,7 @@ public class TemplateController extends Handler {
|
||||
}
|
||||
|
||||
@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) {
|
||||
Template oldTemplate = templateRes.findByIdAndOrgi(template.getId(), super.getOrgi(request));
|
||||
if (oldTemplate != null) {
|
||||
@ -179,7 +178,7 @@ public class TemplateController extends Handler {
|
||||
}
|
||||
|
||||
@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) {
|
||||
templateRes.delete(template);
|
||||
cache.deleteSystembyIdAndOrgi(template.getId(), super.getOrgi(request));
|
||||
|
@ -1,131 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.chatopera.cc.controller.apps;
|
||||
|
||||
import com.chatopera.cc.acd.ACDPolicyService;
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.cache.Cache;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.Quality;
|
||||
import com.chatopera.cc.model.QualityRequest;
|
||||
import com.chatopera.cc.model.SessionConfig;
|
||||
import com.chatopera.cc.model.Tag;
|
||||
import com.chatopera.cc.persistence.repository.QualityRepository;
|
||||
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
|
||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/apps/quality")
|
||||
public class AgentQualityController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private ACDPolicyService acdPolicyService;
|
||||
|
||||
@Autowired
|
||||
private QualityRepository qualityRes;
|
||||
|
||||
@Autowired
|
||||
private SessionConfigRepository sessionConfigRes;
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@RequestMapping(value = "/index")
|
||||
@Menu(type = "agent", subtype = "quality", access = false)
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
||||
map.addAttribute("sessionConfig", acdPolicyService.initSessionConfig(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()));
|
||||
return request(super.createAppsTempletResponse("/apps/quality/index"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/save")
|
||||
@Menu(type = "agent", subtype = "quality", access = false)
|
||||
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid QualityRequest qualityArray) {
|
||||
String orgi = super.getOrgi(request);
|
||||
|
||||
if (qualityArray != null && qualityArray.getTitle() != null) {
|
||||
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
|
||||
qualityRes.delete(qualityList);
|
||||
List<Quality> tempList = new ArrayList<Quality>();
|
||||
for (int i = 0; i < qualityArray.getTitle().length; i++) {
|
||||
Quality temp = new Quality();
|
||||
temp.setName(qualityArray.getTitle()[i]);
|
||||
if (qualityArray.getDescription().length == qualityArray.getTitle().length) {
|
||||
temp.setDescription(qualityArray.getDescription()[i]);
|
||||
}
|
||||
if (qualityArray.getScore().length == qualityArray.getTitle().length) {
|
||||
temp.setScore(qualityArray.getScore()[i]);
|
||||
}
|
||||
temp.setOrgi(super.getOrgi(request));
|
||||
temp.setQualitytype(MainContext.QualityType.CHAT.toString());
|
||||
tempList.add(temp);
|
||||
}
|
||||
if (tempList.size() > 0) {
|
||||
qualityRes.save(tempList);
|
||||
}
|
||||
SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
|
||||
if (config != null) {
|
||||
if ("points".equals(request.getParameter("qualityscore"))) {
|
||||
config.setQualityscore("points");
|
||||
} else {
|
||||
config.setQualityscore("score");
|
||||
}
|
||||
|
||||
sessionConfigRes.save(config);
|
||||
cache.putSessionConfigByOrgi(config, orgi);
|
||||
cache.deleteSessionConfigListByOrgi(orgi);
|
||||
}
|
||||
if (qualityArray != null && qualityArray.getTag() != null && qualityArray.getTag().length > 0) {
|
||||
List<Tag> tagList = tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString());
|
||||
if (tagList.size() > 0) {
|
||||
tagRes.delete(tagList);
|
||||
}
|
||||
List<Tag> tagTempList = new ArrayList<Tag>();
|
||||
for (String tag : qualityArray.getTag()) {
|
||||
Tag temp = new Tag();
|
||||
temp.setOrgi(super.getOrgi(request));
|
||||
temp.setCreater(super.getUser(request).getId());
|
||||
temp.setTag(tag);
|
||||
temp.setCreater(super.getOrgi(request));
|
||||
temp.setTagtype(MainContext.TagType.QUALITY.toString());
|
||||
tagTempList.add(temp);
|
||||
}
|
||||
if (tagTempList.size() > 0) {
|
||||
tagRes.save(tagTempList);
|
||||
}
|
||||
}
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/quality/index.html"));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.chatopera.cc.controller.apps;
|
||||
|
||||
import com.chatopera.cc.acd.ACDPolicyService;
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.cache.Cache;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.Quality;
|
||||
import com.chatopera.cc.model.QualityRequest;
|
||||
import com.chatopera.cc.model.SessionConfig;
|
||||
import com.chatopera.cc.model.Tag;
|
||||
import com.chatopera.cc.persistence.repository.QualityRepository;
|
||||
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
|
||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/apps/quality")
|
||||
public class AgentQualityController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private ACDPolicyService acdPolicyService;
|
||||
|
||||
@Autowired
|
||||
private QualityRepository qualityRes;
|
||||
|
||||
@Autowired
|
||||
private SessionConfigRepository sessionConfigRes;
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@RequestMapping(value = "/index")
|
||||
@Menu(type = "agent", subtype = "quality")
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
||||
map.addAttribute("sessionConfig", acdPolicyService.initSessionConfig(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()));
|
||||
return request(super.createAppsTempletResponse("/apps/quality/index"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/save")
|
||||
@Menu(type = "agent", subtype = "quality")
|
||||
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid QualityRequest qualityArray) {
|
||||
String orgi = super.getOrgi(request);
|
||||
|
||||
if (qualityArray != null && qualityArray.getTitle() != null) {
|
||||
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
|
||||
qualityRes.delete(qualityList);
|
||||
List<Quality> tempList = new ArrayList<Quality>();
|
||||
for (int i = 0; i < qualityArray.getTitle().length; i++) {
|
||||
Quality temp = new Quality();
|
||||
temp.setName(qualityArray.getTitle()[i]);
|
||||
if (qualityArray.getDescription().length == qualityArray.getTitle().length) {
|
||||
temp.setDescription(qualityArray.getDescription()[i]);
|
||||
}
|
||||
if (qualityArray.getScore().length == qualityArray.getTitle().length) {
|
||||
temp.setScore(qualityArray.getScore()[i]);
|
||||
}
|
||||
temp.setOrgi(super.getOrgi(request));
|
||||
temp.setQualitytype(MainContext.QualityType.CHAT.toString());
|
||||
tempList.add(temp);
|
||||
}
|
||||
if (tempList.size() > 0) {
|
||||
qualityRes.save(tempList);
|
||||
}
|
||||
SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
|
||||
if (config != null) {
|
||||
if ("points".equals(request.getParameter("qualityscore"))) {
|
||||
config.setQualityscore("points");
|
||||
} else {
|
||||
config.setQualityscore("score");
|
||||
}
|
||||
|
||||
sessionConfigRes.save(config);
|
||||
cache.putSessionConfigByOrgi(config, orgi);
|
||||
cache.deleteSessionConfigListByOrgi(orgi);
|
||||
}
|
||||
if (qualityArray != null && qualityArray.getTag() != null && qualityArray.getTag().length > 0) {
|
||||
List<Tag> tagList = tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString());
|
||||
if (tagList.size() > 0) {
|
||||
tagRes.delete(tagList);
|
||||
}
|
||||
List<Tag> tagTempList = new ArrayList<Tag>();
|
||||
for (String tag : qualityArray.getTag()) {
|
||||
Tag temp = new Tag();
|
||||
temp.setOrgi(super.getOrgi(request));
|
||||
temp.setCreater(super.getUser(request).getId());
|
||||
temp.setTag(tag);
|
||||
temp.setCreater(super.getOrgi(request));
|
||||
temp.setTagtype(MainContext.TagType.QUALITY.toString());
|
||||
tagTempList.add(temp);
|
||||
}
|
||||
if (tagTempList.size() > 0) {
|
||||
tagRes.save(tagTempList);
|
||||
}
|
||||
}
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/quality/index.html"));
|
||||
}
|
||||
}
|
||||
|
@ -1,182 +1,178 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.chatopera.cc.controller.apps;
|
||||
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.AttachmentFile;
|
||||
import com.chatopera.cc.model.KbsTopic;
|
||||
import com.chatopera.cc.model.KbsType;
|
||||
import com.chatopera.cc.persistence.es.KbsTopicRepository;
|
||||
import com.chatopera.cc.persistence.repository.AttachmentRepository;
|
||||
import com.chatopera.cc.persistence.repository.KbsTypeRepository;
|
||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
@Controller
|
||||
@RequestMapping({"/apps/kbs"})
|
||||
public class KbsController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes ;
|
||||
|
||||
@Autowired
|
||||
private KbsTypeRepository kbsTypeRes ;
|
||||
|
||||
@Autowired
|
||||
private KbsTopicRepository kbsTopicRes ;
|
||||
|
||||
@Autowired
|
||||
private AttachmentRepository attachementRes;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@RequestMapping({"/index"})
|
||||
@Menu(type="apps", subtype="kbs")
|
||||
public ModelAndView index(ModelMap map , HttpServletRequest request){
|
||||
return request(super.createAppsTempletResponse("/apps/business/kbs/index"));
|
||||
}
|
||||
|
||||
@RequestMapping({"/list"})
|
||||
@Menu(type="apps", subtype="kbs")
|
||||
public ModelAndView list(ModelMap map , HttpServletRequest request){
|
||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request))) ;
|
||||
return request(super.createAppsTempletResponse("/apps/business/kbs/list"));
|
||||
}
|
||||
|
||||
@RequestMapping({"/list/type"})
|
||||
@Menu(type="apps", subtype="kbs")
|
||||
public ModelAndView listtype(ModelMap map , HttpServletRequest request,@Valid String typeid){
|
||||
if(!StringUtils.isBlank(typeid) && !typeid.equals("0")){
|
||||
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/typelist"));
|
||||
}
|
||||
|
||||
@RequestMapping({"/addtype"})
|
||||
@Menu(type="apps", subtype="kbs")
|
||||
public ModelAndView addtype(ModelMap map , HttpServletRequest request ){
|
||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request))) ;
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/addtype"));
|
||||
}
|
||||
|
||||
@RequestMapping("/type/save")
|
||||
@Menu(type = "apps" , subtype = "kbs")
|
||||
public ModelAndView typesave(HttpServletRequest request ,@Valid KbsType kbsType) {
|
||||
int count = kbsTypeRes.countByOrgiAndNameAndParentid(super.getOrgi(request), kbsType.getName(), kbsType.getParentid()) ;
|
||||
if(count == 0){
|
||||
kbsType.setOrgi(super.getOrgi(request));
|
||||
kbsType.setCreater(super.getUser(request).getId());
|
||||
kbsType.setCreatetime(new Date());
|
||||
kbsTypeRes.save(kbsType) ;
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/kbs/list.html"));
|
||||
}
|
||||
|
||||
@RequestMapping({"/add"})
|
||||
@Menu(type="apps", subtype="kbs")
|
||||
public ModelAndView add(ModelMap map , HttpServletRequest request ,@Valid String typeid){
|
||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request))) ;
|
||||
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.KBS.toString())) ;
|
||||
if(!StringUtils.isBlank(typeid) && !typeid.equals("0")){
|
||||
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ;
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/add"));
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@Menu(type = "topic" , subtype = "save" , access = false)
|
||||
public ModelAndView save(HttpServletRequest request ,
|
||||
final @Valid KbsTopic topic ,
|
||||
@RequestParam(value = "files", required = false) MultipartFile[] files) throws IOException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/apps/kbs/index.html"));
|
||||
topic.setOrgi(super.getOrgi(request));
|
||||
topic.setCreater(super.getUser(request).getId());
|
||||
topic.setUsername(super.getUser(request).getUsername());
|
||||
|
||||
processAttachmentFile(files, topic, request, topic.getId(), topic.getId());
|
||||
|
||||
KbsType workOrderType = kbsTypeRes.findByIdAndOrgi(topic.getTptype(), super.getOrgi(request)) ;
|
||||
// 知识处理流程,如果知识分类需要审批,则触发知识流程
|
||||
if(workOrderType.isApproval()){
|
||||
topic.setApproval(false);
|
||||
}else{
|
||||
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(""); //序列化 附件文件,方便显示,避免多一次查询 附件的操作
|
||||
//保存附件
|
||||
for(MultipartFile file : files){
|
||||
if(file.getSize() > 0){ //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制
|
||||
String fileid = MainUtils.md5(file.getBytes()) ; //使用 文件的 MD5作为 ID,避免重复上传大文件
|
||||
if(!StringUtils.isBlank(fileid)){
|
||||
AttachmentFile attachmentFile = new AttachmentFile() ;
|
||||
attachmentFile.setCreater(super.getUser(request).getId());
|
||||
attachmentFile.setOrgi(super.getOrgi(request));
|
||||
attachmentFile.setDataid(dataid);
|
||||
attachmentFile.setModelid(modelid);
|
||||
attachmentFile.setModel(MainContext.ModelType.WORKORDERS.toString());
|
||||
attachmentFile.setFilelength((int) file.getSize());
|
||||
if(file.getContentType()!=null && file.getContentType().length() > 255){
|
||||
attachmentFile.setFiletype(file.getContentType().substring(0 , 255));
|
||||
}else{
|
||||
attachmentFile.setFiletype(file.getContentType());
|
||||
}
|
||||
if(file.getOriginalFilename()!=null && file.getOriginalFilename().length() > 255){
|
||||
attachmentFile.setTitle(file.getOriginalFilename().substring(0 , 255));
|
||||
}else{
|
||||
attachmentFile.setTitle(file.getOriginalFilename());
|
||||
}
|
||||
if(!StringUtils.isBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0){
|
||||
attachmentFile.setImage(true);
|
||||
}
|
||||
attachmentFile.setFileid(fileid);
|
||||
attachementRes.save(attachmentFile) ;
|
||||
FileUtils.writeByteArrayToFile(new File(path , "app/kbs/"+fileid), file.getBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.chatopera.cc.controller.apps;
|
||||
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.AttachmentFile;
|
||||
import com.chatopera.cc.model.KbsTopic;
|
||||
import com.chatopera.cc.model.KbsType;
|
||||
import com.chatopera.cc.persistence.es.KbsTopicRepository;
|
||||
import com.chatopera.cc.persistence.repository.AttachmentRepository;
|
||||
import com.chatopera.cc.persistence.repository.KbsTypeRepository;
|
||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
@Controller
|
||||
@RequestMapping({"/apps/kbs"})
|
||||
public class KbsController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes;
|
||||
|
||||
@Autowired
|
||||
private KbsTypeRepository kbsTypeRes;
|
||||
|
||||
@Autowired
|
||||
private KbsTopicRepository kbsTopicRes;
|
||||
|
||||
@Autowired
|
||||
private AttachmentRepository attachementRes;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@RequestMapping({"/index"})
|
||||
@Menu(type = "apps", subtype = "kbs")
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
||||
return request(super.createAppsTempletResponse("/apps/business/kbs/index"));
|
||||
}
|
||||
|
||||
@RequestMapping({"/list"})
|
||||
@Menu(type = "apps", subtype = "kbs")
|
||||
public ModelAndView list(ModelMap map, HttpServletRequest request) {
|
||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
||||
return request(super.createAppsTempletResponse("/apps/business/kbs/list"));
|
||||
}
|
||||
|
||||
@RequestMapping({"/list/type"})
|
||||
@Menu(type = "apps", subtype = "kbs")
|
||||
public ModelAndView listtype(ModelMap map, HttpServletRequest request, @Valid String typeid) {
|
||||
if (!StringUtils.isBlank(typeid) && !typeid.equals("0")) {
|
||||
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/typelist"));
|
||||
}
|
||||
|
||||
@RequestMapping({"/addtype"})
|
||||
@Menu(type = "apps", subtype = "kbs")
|
||||
public ModelAndView addtype(ModelMap map, HttpServletRequest request) {
|
||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/addtype"));
|
||||
}
|
||||
|
||||
@RequestMapping("/type/save")
|
||||
@Menu(type = "apps", subtype = "kbs")
|
||||
public ModelAndView typesave(HttpServletRequest request, @Valid KbsType kbsType) {
|
||||
int count = kbsTypeRes.countByOrgiAndNameAndParentid(super.getOrgi(request), kbsType.getName(), kbsType.getParentid());
|
||||
if (count == 0) {
|
||||
kbsType.setOrgi(super.getOrgi(request));
|
||||
kbsType.setCreater(super.getUser(request).getId());
|
||||
kbsType.setCreatetime(new Date());
|
||||
kbsTypeRes.save(kbsType);
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("redirect:/apps/kbs/list.html"));
|
||||
}
|
||||
|
||||
@RequestMapping({"/add"})
|
||||
@Menu(type = "apps", subtype = "kbs")
|
||||
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String typeid) {
|
||||
map.addAttribute("kbsTypeResList", kbsTypeRes.findByOrgi(super.getOrgi(request)));
|
||||
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.KBS.toString()));
|
||||
if (!StringUtils.isBlank(typeid) && !typeid.equals("0")) {
|
||||
map.addAttribute("kbsType", kbsTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
||||
}
|
||||
return request(super.createRequestPageTempletResponse("/apps/business/kbs/add"));
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@Menu(type = "topic", subtype = "save")
|
||||
public ModelAndView save(HttpServletRequest request,
|
||||
final @Valid KbsTopic topic,
|
||||
@RequestParam(value = "files", required = false) MultipartFile[] files) throws IOException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/apps/kbs/index.html"));
|
||||
topic.setOrgi(super.getOrgi(request));
|
||||
topic.setCreater(super.getUser(request).getId());
|
||||
topic.setUsername(super.getUser(request).getUsername());
|
||||
|
||||
processAttachmentFile(files, topic, request, topic.getId(), topic.getId());
|
||||
|
||||
KbsType workOrderType = kbsTypeRes.findByIdAndOrgi(topic.getTptype(), super.getOrgi(request));
|
||||
// 知识处理流程,如果知识分类需要审批,则触发知识流程
|
||||
topic.setApproval(!workOrderType.isApproval());
|
||||
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(""); //序列化 附件文件,方便显示,避免多一次查询 附件的操作
|
||||
//保存附件
|
||||
for (MultipartFile file : files) {
|
||||
if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制
|
||||
String fileid = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件
|
||||
if (!StringUtils.isBlank(fileid)) {
|
||||
AttachmentFile attachmentFile = new AttachmentFile();
|
||||
attachmentFile.setCreater(super.getUser(request).getId());
|
||||
attachmentFile.setOrgi(super.getOrgi(request));
|
||||
attachmentFile.setDataid(dataid);
|
||||
attachmentFile.setModelid(modelid);
|
||||
attachmentFile.setModel(MainContext.ModelType.WORKORDERS.toString());
|
||||
attachmentFile.setFilelength((int) file.getSize());
|
||||
if (file.getContentType() != null && file.getContentType().length() > 255) {
|
||||
attachmentFile.setFiletype(file.getContentType().substring(0, 255));
|
||||
} else {
|
||||
attachmentFile.setFiletype(file.getContentType());
|
||||
}
|
||||
if (file.getOriginalFilename() != null && file.getOriginalFilename().length() > 255) {
|
||||
attachmentFile.setTitle(file.getOriginalFilename().substring(0, 255));
|
||||
} else {
|
||||
attachmentFile.setTitle(file.getOriginalFilename());
|
||||
}
|
||||
if (!StringUtils.isBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) {
|
||||
attachmentFile.setImage(true);
|
||||
}
|
||||
attachmentFile.setFileid(fileid);
|
||||
attachementRes.save(attachmentFile);
|
||||
FileUtils.writeByteArrayToFile(new File(path, "app/kbs/" + fileid), file.getBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class AgentSummaryController extends Handler {
|
||||
* 按条件查询
|
||||
*/
|
||||
@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) {
|
||||
final String orgi = super.getOrgi(request);
|
||||
Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> {
|
||||
@ -105,7 +105,7 @@ public class AgentSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@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) {
|
||||
AgentServiceSummary summary = serviceSummaryRes.findByIdAndOrgi(id, super.getOrgi(request));
|
||||
map.addAttribute("summary", summary);
|
||||
@ -123,7 +123,7 @@ public class AgentSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save")
|
||||
@Menu(type = "agent", subtype = "agentsummary", access = false)
|
||||
@Menu(type = "agent", subtype = "agentsummary")
|
||||
public ModelAndView save(HttpServletRequest request, @Valid final AgentServiceSummary summary) {
|
||||
AgentServiceSummary oldSummary = serviceSummaryRes.findByIdAndOrgi(summary.getId(), super.getOrgi(request));
|
||||
if (oldSummary != null) {
|
||||
@ -138,7 +138,7 @@ public class AgentSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/expids")
|
||||
@Menu(type = "agent", subtype = "agentsummary", access = false)
|
||||
@Menu(type = "agent", subtype = "agentsummary")
|
||||
public void expids(HttpServletResponse response, @Valid String[] ids) throws IOException {
|
||||
if (ids != null && ids.length > 0) {
|
||||
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAllById(Arrays.asList(ids));
|
||||
@ -156,7 +156,7 @@ public class AgentSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/expall")
|
||||
@Menu(type = "agent", subtype = "agentsummary", access = false)
|
||||
@Menu(type = "agent", subtype = "agentsummary")
|
||||
public void expall(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgi(
|
||||
MainContext.ChannelType.PHONE.toString(), super.getOrgi(request), PageRequest.of(0, 10000));
|
||||
@ -174,7 +174,7 @@ public class AgentSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final String orgi = super.getOrgi(request);
|
||||
Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> {
|
||||
|
@ -73,7 +73,7 @@ public class ProcessedSummaryController extends Handler {
|
||||
* 按条件查询
|
||||
*/
|
||||
@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) {
|
||||
final String orgi = super.getOrgi(request);
|
||||
Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> {
|
||||
@ -113,7 +113,7 @@ public class ProcessedSummaryController extends Handler {
|
||||
|
||||
|
||||
@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) {
|
||||
AgentServiceSummary summary = serviceSummaryRes.findByIdAndOrgi(id, super.getOrgi(request));
|
||||
map.addAttribute("summary", summary);
|
||||
@ -131,7 +131,7 @@ public class ProcessedSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save")
|
||||
@Menu(type = "agent", subtype = "processed", access = false)
|
||||
@Menu(type = "agent", subtype = "processed")
|
||||
public ModelAndView save(HttpServletRequest request, @Valid final AgentServiceSummary summary) {
|
||||
AgentServiceSummary oldSummary = serviceSummaryRes.findByIdAndOrgi(summary.getId(), super.getOrgi(request));
|
||||
if (oldSummary != null) {
|
||||
@ -146,7 +146,7 @@ public class ProcessedSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/expids")
|
||||
@Menu(type = "agent", subtype = "processed", access = false)
|
||||
@Menu(type = "agent", subtype = "processed")
|
||||
public void expids(HttpServletResponse response, @Valid String[] ids) throws IOException {
|
||||
if (ids != null && ids.length > 0) {
|
||||
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAllById(Arrays.asList(ids));
|
||||
@ -165,7 +165,7 @@ public class ProcessedSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/expall")
|
||||
@Menu(type = "agent", subtype = "processed", access = false)
|
||||
@Menu(type = "agent", subtype = "processed")
|
||||
public void expall(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgi(
|
||||
MainContext.ChannelType.PHONE.toString(), super.getOrgi(request), PageRequest.of(0, 10000));
|
||||
@ -183,7 +183,7 @@ public class ProcessedSummaryController extends Handler {
|
||||
}
|
||||
|
||||
@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 {
|
||||
final String orgi = super.getOrgi(request);
|
||||
Page<AgentServiceSummary> page = serviceSummaryRes.findAll((Specification<AgentServiceSummary>) (root, query, cb) -> {
|
||||
|
@ -1,186 +1,186 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.controller.resource;
|
||||
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.AttachmentFile;
|
||||
import com.chatopera.cc.model.StreamingFile;
|
||||
import com.chatopera.cc.model.UploadStatus;
|
||||
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
|
||||
import com.chatopera.cc.persistence.repository.AttachmentRepository;
|
||||
import com.chatopera.cc.persistence.repository.StreamingFileRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/res")
|
||||
public class MediaController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRes;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
|
||||
private String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/";
|
||||
|
||||
@Autowired
|
||||
private AttachmentRepository attachementRes;
|
||||
|
||||
@RequestMapping("/image")
|
||||
@Menu(type = "resouce", subtype = "image", access = true)
|
||||
public void index(HttpServletResponse response,
|
||||
@Valid String id,
|
||||
@RequestParam(value = "original", required = false) boolean original,
|
||||
@RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException {
|
||||
StreamingFile sf = streamingFileRes.findOne(id);
|
||||
if (sf != null) {
|
||||
response.setHeader("Content-Type", sf.getMime());
|
||||
response.setContentType(sf.getMime());
|
||||
if (cooperation && (sf.getCooperation() != null)) { // 协作文件
|
||||
IOUtils.copy(sf.getCooperation().getBinaryStream(), response.getOutputStream());
|
||||
} else if (original && sf.getData() != null) { // 源文件
|
||||
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
|
||||
} else if (sf.getThumbnail() != null) { // 缩略图
|
||||
IOUtils.copy(sf.getThumbnail().getBinaryStream(), response.getOutputStream());
|
||||
} else if (sf.getData() != null) {
|
||||
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
|
||||
} else {
|
||||
logger.warn("[index] can not get streaming file id {}, original {}, cooperation {}", id, original, cooperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/voice")
|
||||
@Menu(type = "resouce", subtype = "voice", access = true)
|
||||
public void voice(HttpServletResponse response, @Valid String id) throws IOException {
|
||||
File file = new File(path, id);
|
||||
if (file.exists() && file.isFile()) {
|
||||
response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, id)));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/url")
|
||||
@Menu(type = "resouce", subtype = "image", access = true)
|
||||
public void url(HttpServletResponse response, @Valid String url) throws IOException {
|
||||
byte[] data = new byte[1024];
|
||||
int length = 0;
|
||||
OutputStream out = response.getOutputStream();
|
||||
if (StringUtils.isNotBlank(url)) {
|
||||
InputStream input = new URL(url).openStream();
|
||||
while ((length = input.read(data)) > 0) {
|
||||
out.write(data, 0, length);
|
||||
}
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/image/upload")
|
||||
@Menu(type = "resouce", subtype = "imageupload", access = false)
|
||||
public ModelAndView upload(ModelMap map,
|
||||
HttpServletRequest request,
|
||||
@RequestParam(value = "imgFile", required = false) MultipartFile multipart) throws IOException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload"));
|
||||
UploadStatus notify = null;
|
||||
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
File uploadDir = new File(path, "upload");
|
||||
if (!uploadDir.exists()) {
|
||||
uploadDir.mkdirs();
|
||||
}
|
||||
String fileid = MainUtils.getUUID();
|
||||
StreamingFile sf = new StreamingFile();
|
||||
sf.setId(fileid);
|
||||
sf.setName(multipart.getOriginalFilename());
|
||||
sf.setMime(multipart.getContentType());
|
||||
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||
streamingFileRes.save(sf);
|
||||
String fileURL = "/res/image.html?id=" + fileid;
|
||||
notify = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回
|
||||
} else {
|
||||
notify = new UploadStatus("请选择图片文件");
|
||||
}
|
||||
map.addAttribute("upload", notify);
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping("/file")
|
||||
@Menu(type = "resouce", subtype = "file", access = false)
|
||||
public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException, SQLException {
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request));
|
||||
if (attachmentFile != null && attachmentFile.getFileid() != null) {
|
||||
StreamingFile sf = streamingFileRes.findOne(attachmentFile.getFileid());
|
||||
if (sf != null) {
|
||||
response.setContentType(attachmentFile.getFiletype());
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8"));
|
||||
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
|
||||
} else {
|
||||
logger.warn("[streaming file] can not get file id {}", attachmentFile.getFileid());
|
||||
}
|
||||
} else {
|
||||
logger.warn("[attachment file] can not find attachment file id {}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/template")
|
||||
@Menu(type = "resouce", subtype = "template", access = false)
|
||||
public void template(HttpServletResponse response, HttpServletRequest request, @Valid String filename) throws IOException {
|
||||
if (StringUtils.isNotBlank(filename)) {
|
||||
InputStream is = MediaController.class.getClassLoader().getResourceAsStream(TEMPLATE_DATA_PATH + filename);
|
||||
if (is != null) {
|
||||
response.setContentType("text/plain");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(filename, "UTF-8"));
|
||||
int length;
|
||||
byte[] data = new byte[1024];
|
||||
while ((length = is.read(data)) > 0) {
|
||||
response.getOutputStream().write(data, 0, length);
|
||||
}
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.controller.resource;
|
||||
|
||||
import com.chatopera.cc.basic.MainUtils;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.AttachmentFile;
|
||||
import com.chatopera.cc.model.StreamingFile;
|
||||
import com.chatopera.cc.model.UploadStatus;
|
||||
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
|
||||
import com.chatopera.cc.persistence.repository.AttachmentRepository;
|
||||
import com.chatopera.cc.persistence.repository.StreamingFileRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/res")
|
||||
public class MediaController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRes;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
|
||||
private final String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/";
|
||||
|
||||
@Autowired
|
||||
private AttachmentRepository attachementRes;
|
||||
|
||||
@RequestMapping("/image")
|
||||
@Menu(type = "resouce", subtype = "image", access = true)
|
||||
public void index(HttpServletResponse response,
|
||||
@Valid String id,
|
||||
@RequestParam(value = "original", required = false) boolean original,
|
||||
@RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException {
|
||||
StreamingFile sf = streamingFileRes.findOne(id);
|
||||
if (sf != null) {
|
||||
response.setHeader("Content-Type", sf.getMime());
|
||||
response.setContentType(sf.getMime());
|
||||
if (cooperation && (sf.getCooperation() != null)) { // 协作文件
|
||||
IOUtils.copy(sf.getCooperation().getBinaryStream(), response.getOutputStream());
|
||||
} else if (original && sf.getData() != null) { // 源文件
|
||||
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
|
||||
} else if (sf.getThumbnail() != null) { // 缩略图
|
||||
IOUtils.copy(sf.getThumbnail().getBinaryStream(), response.getOutputStream());
|
||||
} else if (sf.getData() != null) {
|
||||
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
|
||||
} else {
|
||||
logger.warn("[index] can not get streaming file id {}, original {}, cooperation {}", id, original, cooperation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/voice")
|
||||
@Menu(type = "resouce", subtype = "voice", access = true)
|
||||
public void voice(HttpServletResponse response, @Valid String id) throws IOException {
|
||||
File file = new File(path, id);
|
||||
if (file.exists() && file.isFile()) {
|
||||
response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, id)));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/url")
|
||||
@Menu(type = "resouce", subtype = "image", access = true)
|
||||
public void url(HttpServletResponse response, @Valid String url) throws IOException {
|
||||
byte[] data = new byte[1024];
|
||||
int length = 0;
|
||||
OutputStream out = response.getOutputStream();
|
||||
if (StringUtils.isNotBlank(url)) {
|
||||
InputStream input = new URL(url).openStream();
|
||||
while ((length = input.read(data)) > 0) {
|
||||
out.write(data, 0, length);
|
||||
}
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/image/upload")
|
||||
@Menu(type = "resouce", subtype = "imageupload")
|
||||
public ModelAndView upload(ModelMap map,
|
||||
HttpServletRequest request,
|
||||
@RequestParam(value = "imgFile", required = false) MultipartFile multipart) throws IOException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload"));
|
||||
UploadStatus notify = null;
|
||||
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
File uploadDir = new File(path, "upload");
|
||||
if (!uploadDir.exists()) {
|
||||
uploadDir.mkdirs();
|
||||
}
|
||||
String fileid = MainUtils.getUUID();
|
||||
StreamingFile sf = new StreamingFile();
|
||||
sf.setId(fileid);
|
||||
sf.setName(multipart.getOriginalFilename());
|
||||
sf.setMime(multipart.getContentType());
|
||||
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||
streamingFileRes.save(sf);
|
||||
String fileURL = "/res/image.html?id=" + fileid;
|
||||
notify = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回
|
||||
} else {
|
||||
notify = new UploadStatus("请选择图片文件");
|
||||
}
|
||||
map.addAttribute("upload", notify);
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping("/file")
|
||||
@Menu(type = "resouce", subtype = "file")
|
||||
public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException, SQLException {
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request));
|
||||
if (attachmentFile != null && attachmentFile.getFileid() != null) {
|
||||
StreamingFile sf = streamingFileRes.findOne(attachmentFile.getFileid());
|
||||
if (sf != null) {
|
||||
response.setContentType(attachmentFile.getFiletype());
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8"));
|
||||
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
|
||||
} else {
|
||||
logger.warn("[streaming file] can not get file id {}", attachmentFile.getFileid());
|
||||
}
|
||||
} else {
|
||||
logger.warn("[attachment file] can not find attachment file id {}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/template")
|
||||
@Menu(type = "resouce", subtype = "template")
|
||||
public void template(HttpServletResponse response, HttpServletRequest request, @Valid String filename) throws IOException {
|
||||
if (StringUtils.isNotBlank(filename)) {
|
||||
InputStream is = MediaController.class.getClassLoader().getResourceAsStream(TEMPLATE_DATA_PATH + filename);
|
||||
if (is != null) {
|
||||
response.setContentType("text/plain");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(filename, "UTF-8"));
|
||||
int length;
|
||||
byte[] data = new byte[1024];
|
||||
while ((length = is.read(data)) > 0) {
|
||||
response.getOutputStream().write(data, 0, length);
|
||||
}
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user