mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Closed #122 支持上传客服图标
This commit is contained in:
parent
0b272744a5
commit
77643c7ef8
@ -16,12 +16,11 @@
|
||||
*/
|
||||
package com.chatopera.cc.app.handler.admin.channel;
|
||||
|
||||
import com.chatopera.cc.app.basic.MainUtils;
|
||||
import com.chatopera.cc.app.cache.CacheHelper;
|
||||
import com.chatopera.cc.app.handler.Handler;
|
||||
import com.chatopera.cc.app.model.CousultInvite;
|
||||
import com.chatopera.cc.app.model.Organ;
|
||||
import com.chatopera.cc.app.model.OrgiSkillRel;
|
||||
import com.chatopera.cc.app.model.User;
|
||||
import com.chatopera.cc.app.model.*;
|
||||
import com.chatopera.cc.app.persistence.blob.JpaBlobHelper;
|
||||
import com.chatopera.cc.app.persistence.repository.*;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -70,6 +69,24 @@ public class WebIMController extends Handler {
|
||||
@Autowired
|
||||
private SNSAccountRepository snsAccountRes;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRes;
|
||||
|
||||
|
||||
private String saveImageFile(MultipartFile multipart) throws IOException {
|
||||
StreamingFile sf = new StreamingFile();
|
||||
final String fileid = MainUtils.getUUID();
|
||||
sf.setId(fileid);
|
||||
sf.setMime(multipart.getContentType());
|
||||
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||
sf.setName(multipart.getOriginalFilename());
|
||||
streamingFileRes.save(sf);
|
||||
return fileid;
|
||||
}
|
||||
|
||||
@RequestMapping("/index")
|
||||
@Menu(type = "app", subtype = "app", admin = true)
|
||||
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String snsid) {
|
||||
@ -106,23 +123,14 @@ public class WebIMController extends Handler {
|
||||
inviteData.setSnsaccountid(super.getUser(request).getId());
|
||||
}
|
||||
inviteData.setOrgi(super.getOrgi(request));
|
||||
// 网页品牌标识
|
||||
if (webimlogo != null && webimlogo.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
File logoDir = new File(path, "logo");
|
||||
if (!logoDir.exists()) {
|
||||
logoDir.mkdirs();
|
||||
}
|
||||
String fileName = "logo/" + inviteData.getId() + webimlogo.getOriginalFilename().substring(webimlogo.getOriginalFilename().lastIndexOf("."));
|
||||
FileCopyUtils.copy(webimlogo.getBytes(), new File(path, fileName));
|
||||
inviteData.setConsult_dialog_logo(fileName);
|
||||
inviteData.setConsult_dialog_logo(saveImageFile(webimlogo));
|
||||
}
|
||||
|
||||
// 网页坐席头像
|
||||
if (agentheadimg != null && agentheadimg.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||
File headimgDir = new File(path, "headimg");
|
||||
if (!headimgDir.exists()) {
|
||||
headimgDir.mkdirs();
|
||||
}
|
||||
String fileName = "headimg/" + inviteData.getId() + agentheadimg.getOriginalFilename().substring(agentheadimg.getOriginalFilename().lastIndexOf("."));
|
||||
FileCopyUtils.copy(agentheadimg.getBytes(), new File(path, fileName));
|
||||
inviteData.setConsult_dialog_headimg(fileName);
|
||||
inviteData.setConsult_dialog_headimg(saveImageFile(agentheadimg));
|
||||
}
|
||||
invite.save(inviteData);
|
||||
CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi());
|
||||
@ -200,13 +208,7 @@ public class WebIMController extends Handler {
|
||||
tempInviteData.setCtrlenter(inviteData.isCtrlenter());
|
||||
|
||||
if (dialogad != null && !StringUtils.isBlank(dialogad.getName()) && dialogad.getBytes() != null && dialogad.getBytes().length > 0) {
|
||||
String fileName = "ad/" + inviteData.getId() + dialogad.getOriginalFilename().substring(dialogad.getOriginalFilename().lastIndexOf("."));
|
||||
File file = new File(path, fileName);
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
FileCopyUtils.copy(dialogad.getBytes(), file);
|
||||
tempInviteData.setDialog_ad(fileName);
|
||||
tempInviteData.setDialog_ad(saveImageFile(dialogad));
|
||||
}
|
||||
invite.save(tempInviteData);
|
||||
inviteData = tempInviteData;
|
||||
@ -246,13 +248,7 @@ public class WebIMController extends Handler {
|
||||
tempInviteData.setConsult_invite_color(inviteData.getConsult_invite_color());
|
||||
|
||||
if (invotebg != null && !StringUtils.isBlank(invotebg.getName()) && invotebg.getBytes() != null && invotebg.getBytes().length > 0) {
|
||||
String fileName = "invote/" + inviteData.getId() + invotebg.getOriginalFilename().substring(invotebg.getOriginalFilename().lastIndexOf("."));
|
||||
File file = new File(path, fileName);
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
FileCopyUtils.copy(invotebg.getBytes(), file);
|
||||
tempInviteData.setConsult_invite_bg(fileName);
|
||||
tempInviteData.setConsult_invite_bg(saveImageFile(invotebg));
|
||||
}
|
||||
invite.save(tempInviteData);
|
||||
inviteData = tempInviteData;
|
||||
@ -291,7 +287,6 @@ public class WebIMController extends Handler {
|
||||
* 获取当前产品下人员信息
|
||||
*
|
||||
* @param request
|
||||
* @param q
|
||||
* @return
|
||||
*/
|
||||
private List<User> getUsers(HttpServletRequest request) {
|
||||
|
@ -58,7 +58,7 @@ public class MediaController extends Handler {
|
||||
private String path;
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRepository;
|
||||
private StreamingFileRepository streamingFileRes;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
@ -74,7 +74,7 @@ public class MediaController extends Handler {
|
||||
@Valid String id,
|
||||
@RequestParam(value = "original", required = false) boolean original,
|
||||
@RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException {
|
||||
StreamingFile sf = streamingFileRepository.findOne(id);
|
||||
StreamingFile sf = streamingFileRes.findOne(id);
|
||||
if (sf != null) {
|
||||
response.setHeader("Content-Type", sf.getMime());
|
||||
response.setContentType(sf.getMime());
|
||||
@ -84,6 +84,8 @@ public class MediaController extends Handler {
|
||||
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);
|
||||
}
|
||||
@ -132,7 +134,7 @@ public class MediaController extends Handler {
|
||||
sf.setName(multipart.getOriginalFilename());
|
||||
sf.setMime(multipart.getContentType());
|
||||
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||
streamingFileRepository.save(sf);
|
||||
streamingFileRes.save(sf);
|
||||
String fileURL = "/res/image.html?id=" + fileid;
|
||||
notify = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回
|
||||
} else {
|
||||
@ -148,12 +150,16 @@ public class MediaController extends Handler {
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request));
|
||||
if (attachmentFile != null && attachmentFile.getFileid() != null) {
|
||||
StreamingFile sf = streamingFileRepository.findOne(attachmentFile.getFileid());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,9 @@
|
||||
<label class="layui-form-label">笔记分类:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select id="notesCategory" name="notesCategory" lay-filter="category" required lay-verify="required" style="display: inline">
|
||||
<option value="webim">网页</option>
|
||||
<option value="callout">外呼</option>
|
||||
<option value="callin">呼入</option>
|
||||
<option value="webim">网页</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user