mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
#116 store image and file into mysql
This commit is contained in:
parent
97ac1ce890
commit
892e85b033
@ -36,6 +36,7 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import javax.servlet.MultipartConfigElement;
|
import javax.servlet.MultipartConfigElement;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -44,6 +45,7 @@ import java.io.IOException;
|
|||||||
@EnableJpaRepositories("com.chatopera.cc.app.persistence.repository")
|
@EnableJpaRepositories("com.chatopera.cc.app.persistence.repository")
|
||||||
@EnableElasticsearchRepositories("com.chatopera.cc.app.persistence.es")
|
@EnableElasticsearchRepositories("com.chatopera.cc.app.persistence.es")
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
|
@EnableTransactionManagement
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
@Value("${web.upload-path}")
|
@Value("${web.upload-path}")
|
||||||
|
@ -766,14 +766,14 @@ public class MainUtils {
|
|||||||
return workintTime;
|
return workintTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File processImage(File destFile, File imageFile) throws FileNotFoundException, IOException {
|
public static File processImage(final File destFile, final File imageFile) throws FileNotFoundException, IOException {
|
||||||
if (imageFile != null && imageFile.exists()) {
|
if (imageFile != null && imageFile.exists()) {
|
||||||
Thumbnails.of(imageFile).width(460).keepAspectRatio(true).toFile(destFile);
|
Thumbnails.of(imageFile).width(460).keepAspectRatio(true).toFile(destFile);
|
||||||
}
|
}
|
||||||
return destFile;
|
return destFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File scaleImage(File destFile, File imageFile, float quality) throws FileNotFoundException, IOException {
|
public static File scaleImage(final File destFile, final File imageFile, float quality) throws FileNotFoundException, IOException {
|
||||||
if (imageFile != null && imageFile.exists()) {
|
if (imageFile != null && imageFile.exists()) {
|
||||||
Thumbnails.of(imageFile).scale(1f).outputQuality(quality).toFile(destFile);
|
Thumbnails.of(imageFile).scale(1f).outputQuality(quality).toFile(destFile);
|
||||||
}
|
}
|
||||||
@ -846,45 +846,6 @@ public class MainUtils {
|
|||||||
return execute;
|
return execute;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processAttachmentFile(MultipartFile[] files, AttachmentRepository attachementRes, String path, User user, String orgi, WorkOrders workOrders, HttpServletRequest request, String dataid, String modelid) throws IOException {
|
|
||||||
if (files != null && files.length > 0) {
|
|
||||||
workOrders.setAnonymous(true);//变更用途为是否有 附件
|
|
||||||
//保存附件
|
|
||||||
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(user.getId());
|
|
||||||
attachmentFile.setOrgi(orgi);
|
|
||||||
attachmentFile.setOrgan(user.getOrgan());
|
|
||||||
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, "upload/" + fileid), file.getBytes());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统配置
|
* 获取系统配置
|
||||||
*
|
*
|
||||||
|
@ -25,15 +25,13 @@ import com.chatopera.cc.app.im.client.NettyClients;
|
|||||||
import com.chatopera.cc.app.im.message.ChatMessage;
|
import com.chatopera.cc.app.im.message.ChatMessage;
|
||||||
import com.chatopera.cc.app.im.router.OutMessageRouter;
|
import com.chatopera.cc.app.im.router.OutMessageRouter;
|
||||||
import com.chatopera.cc.app.model.*;
|
import com.chatopera.cc.app.model.*;
|
||||||
|
import com.chatopera.cc.app.persistence.blob.JpaBlobHelper;
|
||||||
import com.chatopera.cc.app.persistence.es.ContactsRepository;
|
import com.chatopera.cc.app.persistence.es.ContactsRepository;
|
||||||
import com.chatopera.cc.app.persistence.es.QuickReplyRepository;
|
import com.chatopera.cc.app.persistence.es.QuickReplyRepository;
|
||||||
import com.chatopera.cc.app.persistence.repository.*;
|
import com.chatopera.cc.app.persistence.repository.*;
|
||||||
import com.chatopera.cc.exception.CSKefuException;
|
import com.chatopera.cc.exception.CSKefuException;
|
||||||
import com.chatopera.cc.exchange.DataExchangeInterface;
|
import com.chatopera.cc.exchange.DataExchangeInterface;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.*;
|
||||||
import com.chatopera.cc.util.OnlineUserUtils;
|
|
||||||
import com.chatopera.cc.util.PinYinTools;
|
|
||||||
import com.chatopera.cc.util.PropertiesEventUtils;
|
|
||||||
import com.chatopera.cc.util.mobile.MobileAddress;
|
import com.chatopera.cc.util.mobile.MobileAddress;
|
||||||
import com.chatopera.cc.util.mobile.MobileNumberUtils;
|
import com.chatopera.cc.util.mobile.MobileNumberUtils;
|
||||||
import freemarker.template.TemplateException;
|
import freemarker.template.TemplateException;
|
||||||
@ -149,6 +147,12 @@ public class AgentController extends Handler {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ConsultInviteRepository inviteRepository;
|
private ConsultInviteRepository inviteRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StreamingFileRepository streamingFileRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JpaBlobHelper jpaBlobHelper;
|
||||||
|
|
||||||
@Value("${web.upload-path}")
|
@Value("${web.upload-path}")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
@ -169,7 +173,7 @@ public class AgentController extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!StringUtils.isBlank(sort)) {
|
if (StringUtils.isNotBlank(sort)) {
|
||||||
List<Order> list = new ArrayList<Order>();
|
List<Order> list = new ArrayList<Order>();
|
||||||
if (sort.equals("lastmessage")) {
|
if (sort.equals("lastmessage")) {
|
||||||
list.add(new Order(Direction.DESC, "status"));
|
list.add(new Order(Direction.DESC, "status"));
|
||||||
@ -208,7 +212,7 @@ public class AgentController extends Handler {
|
|||||||
agentUser = (AgentUser) agentUserList.get(0);
|
agentUser = (AgentUser) agentUserList.get(0);
|
||||||
view.addObject("curagentuser", agentUser);
|
view.addObject("curagentuser", agentUser);
|
||||||
view.addObject("inviteData", OnlineUserUtils.cousult(agentUser.getAppid(), agentUser.getOrgi(), inviteRepository));
|
view.addObject("inviteData", OnlineUserUtils.cousult(agentUser.getAppid(), agentUser.getOrgi(), inviteRepository));
|
||||||
if (!StringUtils.isBlank(agentUser.getAgentserviceid())) {
|
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
|
||||||
List<AgentServiceSummary> summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request));
|
List<AgentServiceSummary> summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request));
|
||||||
if (summarizes.size() > 0) {
|
if (summarizes.size() > 0) {
|
||||||
view.addObject("summary", summarizes.get(0));
|
view.addObject("summary", summarizes.get(0));
|
||||||
@ -217,7 +221,7 @@ public class AgentController extends Handler {
|
|||||||
|
|
||||||
view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), super.getOrgi(request), new PageRequest(0, 20, Direction.DESC, "updatetime")));
|
view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), super.getOrgi(request), new PageRequest(0, 20, Direction.DESC, "updatetime")));
|
||||||
AgentService agentService = null;
|
AgentService agentService = null;
|
||||||
if (!StringUtils.isBlank(agentUser.getAgentserviceid())) {
|
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
|
||||||
agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid());
|
agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid());
|
||||||
view.addObject("curAgentService", agentService);
|
view.addObject("curAgentService", agentService);
|
||||||
|
|
||||||
@ -247,10 +251,10 @@ public class AgentController extends Handler {
|
|||||||
view.addObject("onlineUser", onlineUser);
|
view.addObject("onlineUser", onlineUser);
|
||||||
}
|
}
|
||||||
} else if (MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())) {
|
} else if (MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())) {
|
||||||
if (agentService != null && !StringUtils.isBlank(agentService.getOwner())) {
|
if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) {
|
||||||
StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner());
|
StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner());
|
||||||
if (statusEvent != null) {
|
if (statusEvent != null) {
|
||||||
if (!StringUtils.isBlank(statusEvent.getHostid())) {
|
if (StringUtils.isNotBlank(statusEvent.getHostid())) {
|
||||||
PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid());
|
PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid());
|
||||||
view.addObject("pbxHost", pbxHost);
|
view.addObject("pbxHost", pbxHost);
|
||||||
}
|
}
|
||||||
@ -302,19 +306,19 @@ public class AgentController extends Handler {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!StringUtils.isBlank(agentService.getAppid())) {
|
if (StringUtils.isNotBlank(agentService.getAppid())) {
|
||||||
map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(agentService.getAppid(), super.getOrgi(request)));
|
map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(agentService.getAppid(), super.getOrgi(request)));
|
||||||
}
|
}
|
||||||
List<AgentUserContacts> relaList = agentUserContactsRes.findByUseridAndOrgi(agentService.getUserid(), agentService.getOrgi());
|
List<AgentUserContacts> relaList = agentUserContactsRes.findByUseridAndOrgi(agentService.getUserid(), agentService.getOrgi());
|
||||||
if (relaList.size() > 0) {
|
if (relaList.size() > 0) {
|
||||||
AgentUserContacts agentUserContacts = relaList.get(0);
|
AgentUserContacts agentUserContacts = relaList.get(0);
|
||||||
if (MainContext.model.get("contacts") != null && !StringUtils.isBlank(agentUserContacts.getContactsid())) {
|
if (MainContext.model.get("contacts") != null && StringUtils.isNotBlank(agentUserContacts.getContactsid())) {
|
||||||
DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("contacts");
|
DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("contacts");
|
||||||
if (dataExchange != null) {
|
if (dataExchange != null) {
|
||||||
map.addAttribute("contacts", dataExchange.getDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getOrgi(request)));
|
map.addAttribute("contacts", dataExchange.getDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getOrgi(request)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MainContext.model.get("workorders") != null && !StringUtils.isBlank(agentUserContacts.getContactsid())) {
|
if (MainContext.model.get("workorders") != null && StringUtils.isNotBlank(agentUserContacts.getContactsid())) {
|
||||||
DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders");
|
DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders");
|
||||||
if (dataExchange != null) {
|
if (dataExchange != null) {
|
||||||
map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getUser(request).getId(), super.getOrgi(request)));
|
map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getUser(request).getId(), super.getOrgi(request)));
|
||||||
@ -346,7 +350,7 @@ public class AgentController extends Handler {
|
|||||||
agentUserTaskRes.save(agentUserTask);
|
agentUserTaskRes.save(agentUserTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StringUtils.isBlank(agentUser.getAgentserviceid())) {
|
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
|
||||||
List<AgentServiceSummary> summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request));
|
List<AgentServiceSummary> summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request));
|
||||||
if (summarizes.size() > 0) {
|
if (summarizes.size() > 0) {
|
||||||
view.addObject("summary", summarizes.get(0));
|
view.addObject("summary", summarizes.get(0));
|
||||||
@ -355,7 +359,7 @@ public class AgentController extends Handler {
|
|||||||
|
|
||||||
view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), super.getOrgi(request), new PageRequest(0, 20, Direction.DESC, "updatetime")));
|
view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), super.getOrgi(request), new PageRequest(0, 20, Direction.DESC, "updatetime")));
|
||||||
AgentService agentService = null;
|
AgentService agentService = null;
|
||||||
if (!StringUtils.isBlank(agentUser.getAgentserviceid())) {
|
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
|
||||||
agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid());
|
agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid());
|
||||||
view.addObject("curAgentService", agentService);
|
view.addObject("curAgentService", agentService);
|
||||||
if (agentService != null) {
|
if (agentService != null) {
|
||||||
@ -385,10 +389,10 @@ public class AgentController extends Handler {
|
|||||||
view.addObject("onlineUser", onlineUser);
|
view.addObject("onlineUser", onlineUser);
|
||||||
}
|
}
|
||||||
} else if (MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())) {
|
} else if (MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())) {
|
||||||
if (agentService != null && !StringUtils.isBlank(agentService.getOwner())) {
|
if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) {
|
||||||
StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner());
|
StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner());
|
||||||
if (statusEvent != null) {
|
if (statusEvent != null) {
|
||||||
if (!StringUtils.isBlank(statusEvent.getHostid())) {
|
if (StringUtils.isNotBlank(statusEvent.getHostid())) {
|
||||||
PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid());
|
PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid());
|
||||||
view.addObject("pbxHost", pbxHost);
|
view.addObject("pbxHost", pbxHost);
|
||||||
}
|
}
|
||||||
@ -455,7 +459,7 @@ public class AgentController extends Handler {
|
|||||||
@RequestMapping("/workorders/list")
|
@RequestMapping("/workorders/list")
|
||||||
@Menu(type = "apps", subtype = "workorderslist")
|
@Menu(type = "apps", subtype = "workorderslist")
|
||||||
public ModelAndView workorderslist(HttpServletRequest request, String contactsid, ModelMap map) {
|
public ModelAndView workorderslist(HttpServletRequest request, String contactsid, ModelMap map) {
|
||||||
if (MainContext.model.get("workorders") != null && !StringUtils.isBlank(contactsid)) {
|
if (MainContext.model.get("workorders") != null && StringUtils.isNotBlank(contactsid)) {
|
||||||
DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders");
|
DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders");
|
||||||
if (dataExchange != null) {
|
if (dataExchange != null) {
|
||||||
map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(contactsid, super.getUser(request).getId(), super.getOrgi(request)));
|
map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(contactsid, super.getUser(request).getId(), super.getOrgi(request)));
|
||||||
@ -481,7 +485,7 @@ public class AgentController extends Handler {
|
|||||||
agentStatus.setAgentno(user.getId());
|
agentStatus.setAgentno(user.getId());
|
||||||
agentStatus.setLogindate(new Date());
|
agentStatus.setLogindate(new Date());
|
||||||
|
|
||||||
if (!StringUtils.isBlank(user.getOrgan())) {
|
if (StringUtils.isNotBlank(user.getOrgan())) {
|
||||||
Organ organ = organRes.findByIdAndOrgi(user.getOrgan(), super.getOrgiByTenantshare(request));
|
Organ organ = organRes.findByIdAndOrgi(user.getOrgan(), super.getOrgiByTenantshare(request));
|
||||||
if (organ != null && organ.isSkill()) {
|
if (organ != null && organ.isSkill()) {
|
||||||
agentStatus.setSkill(organ.getId());
|
agentStatus.setSkill(organ.getId());
|
||||||
@ -589,7 +593,7 @@ public class AgentController extends Handler {
|
|||||||
AgentUser agentUser = agentUserRepository.findByIdAndOrgi(userid, super.getOrgi(request));
|
AgentUser agentUser = agentUserRepository.findByIdAndOrgi(userid, super.getOrgi(request));
|
||||||
if (agentUser != null && super.getUser(request).getId().equals(agentUser.getAgentno())) {
|
if (agentUser != null && super.getUser(request).getId().equals(agentUser.getAgentno())) {
|
||||||
AutomaticServiceDist.deleteAgentUser(agentUser, super.getOrgi(request));
|
AutomaticServiceDist.deleteAgentUser(agentUser, super.getOrgi(request));
|
||||||
if (!StringUtils.isBlank(agentUser.getAgentserviceid())) {
|
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
|
||||||
AgentService agentService = agentServiceRepository.findByIdAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request));
|
AgentService agentService = agentServiceRepository.findByIdAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request));
|
||||||
agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString());
|
agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString());
|
||||||
agentServiceRepository.save(agentService);
|
agentServiceRepository.save(agentService);
|
||||||
@ -655,7 +659,7 @@ public class AgentController extends Handler {
|
|||||||
blackListRes.save(tempBlackEntiry);
|
blackListRes.save(tempBlackEntiry);
|
||||||
blackEntity = tempBlackEntiry;
|
blackEntity = tempBlackEntiry;
|
||||||
}
|
}
|
||||||
if (!StringUtils.isBlank(userid)) {
|
if (StringUtils.isNotBlank(userid)) {
|
||||||
CacheHelper.getSystemCacheBean().put(userid, blackEntity, super.getOrgi(request));
|
CacheHelper.getSystemCacheBean().put(userid, blackEntity, super.getOrgi(request));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -681,58 +685,58 @@ public class AgentController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/image/upload")
|
@RequestMapping("/image/upload")
|
||||||
@Menu(type = "im", subtype = "image", access = false)
|
@Menu(type = "im", subtype = "image", access = false)
|
||||||
public ModelAndView upload(ModelMap map, HttpServletRequest request, @RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @Valid String id, @Valid String paste) throws IOException {
|
public ModelAndView upload(ModelMap map,
|
||||||
|
HttpServletRequest request,
|
||||||
|
@RequestParam(value = "imgFile", required = false) MultipartFile multipart,
|
||||||
|
@Valid String id,
|
||||||
|
@Valid String paste) throws IOException {
|
||||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/upload"));
|
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/upload"));
|
||||||
UploadStatus upload = null;
|
UploadStatus notify = null;
|
||||||
String fileName = null;
|
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||||
if (imgFile != null && imgFile.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.md5(imgFile.getBytes()), fileURL = null, targetFile = null;
|
String fileid = MainUtils.getUUID();
|
||||||
|
String fileURL = null;
|
||||||
ChatMessage data = new ChatMessage();
|
ChatMessage data = new ChatMessage();
|
||||||
if (imgFile.getContentType() != null && imgFile.getContentType().indexOf("image") >= 0) {
|
StreamingFile sf = new StreamingFile();
|
||||||
fileName = "upload/" + fileid + "_original";
|
|
||||||
File imageFile = new File(path, fileName);
|
|
||||||
FileCopyUtils.copy(imgFile.getBytes(), imageFile);
|
|
||||||
targetFile = "upload/" + fileid;
|
|
||||||
MainUtils.processImage(new File(path, targetFile), imageFile);
|
|
||||||
|
|
||||||
|
if (multipart.getContentType() != null && multipart.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) {
|
||||||
fileURL = "/res/image.html?id=" + targetFile;
|
// process thumbnail
|
||||||
if (request.getServerPort() == 80) {
|
File original = new File(path, "upload/" + fileid + "_original");
|
||||||
fileURL = "/res/image.html?id=" + targetFile;
|
File thumbnail = new File(path, "upload/" + fileid);
|
||||||
} else {
|
FileCopyUtils.copy(multipart.getBytes(), original);
|
||||||
fileURL = "/res/image.html?id=" + targetFile;
|
MainUtils.processImage(thumbnail, original);
|
||||||
}
|
sf.setThumbnail(jpaBlobHelper.createBlobWithFile(thumbnail));
|
||||||
upload = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回
|
fileURL = "/res/image.html?id=" + fileid;
|
||||||
data.setAttachmentid(fileid);
|
|
||||||
} else {
|
} else {
|
||||||
String attachid = processAttachmentFile(imgFile, request);
|
String attachid = processAttachmentFile(multipart, fileid, request);
|
||||||
|
|
||||||
upload = new UploadStatus("0", "/res/file.html?id=" + attachid);
|
|
||||||
fileURL = "/res/file.html?id=" + attachid;
|
fileURL = "/res/file.html?id=" + attachid;
|
||||||
if (request.getServerPort() == 80) {
|
|
||||||
fileURL = "/res/file.html?id=" + attachid;
|
|
||||||
} else {
|
|
||||||
fileURL = "/res/file.html?id=" + attachid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
data.setFilename(imgFile.getOriginalFilename());
|
|
||||||
data.setFilesize((int) imgFile.getSize());
|
|
||||||
|
|
||||||
OutMessageRouter router = null;
|
sf.setId(fileid);
|
||||||
|
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||||
|
sf.setName(multipart.getOriginalFilename());
|
||||||
|
sf.setMime(multipart.getContentType());
|
||||||
|
streamingFileRepository.save(sf);
|
||||||
|
|
||||||
|
data.setFilename(multipart.getOriginalFilename());
|
||||||
|
data.setFilesize((int) multipart.getSize());
|
||||||
|
data.setAttachmentid(fileid);
|
||||||
|
|
||||||
|
notify = new UploadStatus("0", fileURL);
|
||||||
|
|
||||||
AgentUser agentUser = agentUserRepository.findByIdAndOrgi(id, super.getOrgi(request));
|
AgentUser agentUser = agentUserRepository.findByIdAndOrgi(id, super.getOrgi(request));
|
||||||
|
|
||||||
if (agentUser != null && paste == null) {
|
if (agentUser != null && paste == null) { // 发送消息
|
||||||
router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel());
|
OutMessageRouter router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel());
|
||||||
MessageOutContent outMessage = new MessageOutContent();
|
MessageOutContent outMessage = new MessageOutContent();
|
||||||
if (router != null) {
|
if (router != null) { // 发送消息给访客
|
||||||
outMessage.setMessage(fileURL);
|
outMessage.setMessage(fileURL);
|
||||||
outMessage.setFilename(imgFile.getOriginalFilename());
|
outMessage.setFilename(multipart.getOriginalFilename());
|
||||||
outMessage.setFilesize((int) imgFile.getSize());
|
outMessage.setFilesize((int) multipart.getSize());
|
||||||
if (imgFile.getContentType() != null && imgFile.getContentType().indexOf("image") >= 0) {
|
if (multipart.getContentType() != null && multipart.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) {
|
||||||
outMessage.setMessageType(MainContext.MediaTypeEnum.IMAGE.toString());
|
outMessage.setMessageType(MainContext.MediaTypeEnum.IMAGE.toString());
|
||||||
data.setMsgtype(MainContext.MediaTypeEnum.IMAGE.toString());
|
data.setMsgtype(MainContext.MediaTypeEnum.IMAGE.toString());
|
||||||
} else {
|
} else {
|
||||||
@ -753,7 +757,7 @@ public class AgentController extends Handler {
|
|||||||
data.setAgentserviceid(agentUser.getAgentserviceid());
|
data.setAgentserviceid(agentUser.getAgentserviceid());
|
||||||
|
|
||||||
data.setCalltype(MainContext.CallTypeEnum.OUT.toString());
|
data.setCalltype(MainContext.CallTypeEnum.OUT.toString());
|
||||||
if (!StringUtils.isBlank(agentUser.getAgentno())) {
|
if (StringUtils.isNotBlank(agentUser.getAgentno())) {
|
||||||
data.setTouser(agentUser.getUserid());
|
data.setTouser(agentUser.getUserid());
|
||||||
}
|
}
|
||||||
data.setChannel(agentUser.getChannel());
|
data.setChannel(agentUser.getChannel());
|
||||||
@ -771,11 +775,10 @@ public class AgentController extends Handler {
|
|||||||
// 通知文件上传消息
|
// 通知文件上传消息
|
||||||
NettyClients.getInstance().publishAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data);
|
NettyClients.getInstance().publishAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
upload = new UploadStatus("请选择图片文件");
|
notify = new UploadStatus("请选择图片文件");
|
||||||
}
|
}
|
||||||
map.addAttribute("upload", upload);
|
map.addAttribute("upload", notify);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,7 +788,7 @@ public class AgentController extends Handler {
|
|||||||
ChatMessage message = chatMessageRepository.findById(id);
|
ChatMessage message = chatMessageRepository.findById(id);
|
||||||
map.addAttribute("chatMessage", message);
|
map.addAttribute("chatMessage", message);
|
||||||
map.addAttribute("agentUser", CacheHelper.getAgentUserCacheBean().getCacheObject(message.getUserid(), message.getOrgi()));
|
map.addAttribute("agentUser", CacheHelper.getAgentUserCacheBean().getCacheObject(message.getUserid(), message.getOrgi()));
|
||||||
/*if(!StringUtils.isBlank(t)){
|
/*if(StringUtils.isNotBlank(t)){
|
||||||
map.addAttribute("t", t) ;
|
map.addAttribute("t", t) ;
|
||||||
}*/
|
}*/
|
||||||
map.addAttribute("t", true);
|
map.addAttribute("t", true);
|
||||||
@ -794,22 +797,37 @@ public class AgentController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/message/image/upload")
|
@RequestMapping("/message/image/upload")
|
||||||
@Menu(type = "im", subtype = "image", access = false)
|
@Menu(type = "im", subtype = "image", access = false)
|
||||||
public ModelAndView messageimage(ModelMap map, HttpServletRequest request, @RequestParam(value = "image", required = false) MultipartFile image, @Valid String id, @Valid String userid, @Valid String fileid) throws IOException {
|
public ModelAndView messageimage(ModelMap map,
|
||||||
if (image != null && !StringUtils.isBlank(fileid)) {
|
HttpServletRequest request,
|
||||||
|
@RequestParam(value = "image", required = false) MultipartFile image,
|
||||||
|
@Valid String id,
|
||||||
|
@Valid String userid,
|
||||||
|
@Valid String fileid) throws IOException {
|
||||||
|
logger.info("messageimage id {}, fileid {}", id, fileid);
|
||||||
|
if (image != null && StringUtils.isNotBlank(fileid)) {
|
||||||
File tempFile = File.createTempFile(fileid, ".png");
|
File tempFile = File.createTempFile(fileid, ".png");
|
||||||
try {
|
try {
|
||||||
String fileName = "upload/" + fileid + "_cooperation";
|
// 创建临时图片文件
|
||||||
File imageFile = new File(path, fileName);
|
|
||||||
if (!tempFile.getParentFile().exists()) {
|
if (!tempFile.getParentFile().exists()) {
|
||||||
tempFile.getParentFile().mkdirs();
|
tempFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
// 写入临时文件
|
||||||
FileCopyUtils.copy(image.getBytes(), tempFile);
|
FileCopyUtils.copy(image.getBytes(), tempFile);
|
||||||
ChatMessage chatMessage = chatMessageRepository.findById(id);
|
ChatMessage chatMessage = chatMessageRepository.findById(id);
|
||||||
chatMessage.setCooperation(true);
|
chatMessage.setCooperation(true);
|
||||||
chatMessageRepository.save(chatMessage);
|
chatMessageRepository.save(chatMessage);
|
||||||
|
|
||||||
|
// 写入协作文件
|
||||||
|
String fileName = "upload/" + fileid + "_cooperation";
|
||||||
|
File imageFile = new File(path, fileName);
|
||||||
MainUtils.scaleImage(imageFile, tempFile, 0.1F);
|
MainUtils.scaleImage(imageFile, tempFile, 0.1F);
|
||||||
|
|
||||||
|
// 保存到数据库
|
||||||
|
StreamingFile sf = streamingFileRepository.findOne(fileid);
|
||||||
|
if (sf != null) {
|
||||||
|
sf.setCooperation(jpaBlobHelper.createBlobWithFile(imageFile));
|
||||||
|
streamingFileRepository.save(sf);
|
||||||
|
}
|
||||||
|
|
||||||
OutMessageRouter router = null;
|
OutMessageRouter router = null;
|
||||||
AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(chatMessage.getUserid(), chatMessage.getOrgi());
|
AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(chatMessage.getUserid(), chatMessage.getOrgi());
|
||||||
@ -818,7 +836,7 @@ public class AgentController extends Handler {
|
|||||||
router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel());
|
router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel());
|
||||||
MessageOutContent outMessage = new MessageOutContent();
|
MessageOutContent outMessage = new MessageOutContent();
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
outMessage.setMessage("/res/image.html?id=" + fileName);
|
outMessage.setMessage("/res/image.html?id=" + fileid + "&cooperation=true");
|
||||||
outMessage.setFilename(imageFile.getName());
|
outMessage.setFilename(imageFile.getName());
|
||||||
|
|
||||||
outMessage.setAttachmentid(chatMessage.getAttachmentid());
|
outMessage.setAttachmentid(chatMessage.getAttachmentid());
|
||||||
@ -841,36 +859,33 @@ public class AgentController extends Handler {
|
|||||||
return request(super.createRequestPageTempletResponse("/public/success"));
|
return request(super.createRequestPageTempletResponse("/public/success"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String processAttachmentFile(MultipartFile file, HttpServletRequest request) throws IOException {
|
private String processAttachmentFile(final MultipartFile multipart, final String fileid, HttpServletRequest request) throws IOException {
|
||||||
String id = null;
|
String id = null;
|
||||||
if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制
|
if (multipart.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制
|
||||||
String fileid = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件
|
AttachmentFile attachmentFile = new AttachmentFile();
|
||||||
if (StringUtils.isNotBlank(fileid)) {
|
attachmentFile.setCreater(super.getUser(request).getId());
|
||||||
AttachmentFile attachmentFile = new AttachmentFile();
|
attachmentFile.setOrgi(super.getOrgi(request));
|
||||||
attachmentFile.setCreater(super.getUser(request).getId());
|
attachmentFile.setOrgan(super.getUser(request).getOrgan());
|
||||||
attachmentFile.setOrgi(super.getOrgi(request));
|
attachmentFile.setModel(MainContext.ModelType.WEBIM.toString());
|
||||||
attachmentFile.setOrgan(super.getUser(request).getOrgan());
|
attachmentFile.setFilelength((int) multipart.getSize());
|
||||||
attachmentFile.setModel(MainContext.ModelType.WEBIM.toString());
|
if (multipart.getContentType() != null && multipart.getContentType().length() > 255) {
|
||||||
attachmentFile.setFilelength((int) file.getSize());
|
attachmentFile.setFiletype(multipart.getContentType().substring(0, 255));
|
||||||
if (file.getContentType() != null && file.getContentType().length() > 255) {
|
} else {
|
||||||
attachmentFile.setFiletype(file.getContentType().substring(0, 255));
|
attachmentFile.setFiletype(multipart.getContentType());
|
||||||
} else {
|
|
||||||
attachmentFile.setFiletype(file.getContentType());
|
|
||||||
}
|
|
||||||
File uploadFile = new File(file.getOriginalFilename());
|
|
||||||
if (uploadFile.getName() != null && uploadFile.getName().length() > 255) {
|
|
||||||
attachmentFile.setTitle(uploadFile.getName().substring(0, 255));
|
|
||||||
} else {
|
|
||||||
attachmentFile.setTitle(uploadFile.getName());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) {
|
|
||||||
attachmentFile.setImage(true);
|
|
||||||
}
|
|
||||||
attachmentFile.setFileid(fileid);
|
|
||||||
attachementRes.save(attachmentFile);
|
|
||||||
FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes());
|
|
||||||
id = attachmentFile.getId();
|
|
||||||
}
|
}
|
||||||
|
File uploadFile = new File(multipart.getOriginalFilename());
|
||||||
|
if (uploadFile.getName() != null && uploadFile.getName().length() > 255) {
|
||||||
|
attachmentFile.setTitle(uploadFile.getName().substring(0, 255));
|
||||||
|
} else {
|
||||||
|
attachmentFile.setTitle(uploadFile.getName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) {
|
||||||
|
attachmentFile.setImage(true);
|
||||||
|
}
|
||||||
|
attachmentFile.setFileid(fileid);
|
||||||
|
attachementRes.save(attachmentFile);
|
||||||
|
FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), multipart.getBytes());
|
||||||
|
id = attachmentFile.getId();
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -879,7 +894,7 @@ public class AgentController extends Handler {
|
|||||||
@RequestMapping(value = "/contacts")
|
@RequestMapping(value = "/contacts")
|
||||||
@Menu(type = "apps", subtype = "contacts")
|
@Menu(type = "apps", subtype = "contacts")
|
||||||
public ModelAndView contacts(ModelMap map, HttpServletRequest request, @Valid String contactsid, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid) {
|
public ModelAndView contacts(ModelMap map, HttpServletRequest request, @Valid String contactsid, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid) {
|
||||||
if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(contactsid)) {
|
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(contactsid)) {
|
||||||
List<OnlineUser> onlineUserList = this.onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request));
|
List<OnlineUser> onlineUserList = this.onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request));
|
||||||
if (onlineUserList.size() > 0) {
|
if (onlineUserList.size() > 0) {
|
||||||
OnlineUser onlineUser = onlineUserList.get(0);
|
OnlineUser onlineUser = onlineUserList.get(0);
|
||||||
@ -925,9 +940,9 @@ public class AgentController extends Handler {
|
|||||||
@Valid String agentserviceid,
|
@Valid String agentserviceid,
|
||||||
@Valid String agentuserid,
|
@Valid String agentuserid,
|
||||||
@Valid String channel) {
|
@Valid String channel) {
|
||||||
if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) {
|
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
|
||||||
AgentUser agentUser = this.agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request));
|
AgentUser agentUser = this.agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request));
|
||||||
if (agentUser != null && !StringUtils.isBlank(agentUser.getAgentserviceid())) {
|
if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
|
||||||
List<AgentServiceSummary> summaries = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request));
|
List<AgentServiceSummary> summaries = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request));
|
||||||
if (summaries.size() > 0) {
|
if (summaries.size() > 0) {
|
||||||
map.addAttribute("summary", summaries.get(0));
|
map.addAttribute("summary", summaries.get(0));
|
||||||
@ -955,7 +970,7 @@ public class AgentController extends Handler {
|
|||||||
@Valid String agentserviceid,
|
@Valid String agentserviceid,
|
||||||
@Valid String agentuserid,
|
@Valid String agentuserid,
|
||||||
@Valid String channel) {
|
@Valid String channel) {
|
||||||
if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) {
|
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
|
||||||
summary.setOrgi(super.getOrgi(request));
|
summary.setOrgi(super.getOrgi(request));
|
||||||
summary.setCreater(super.getUser(request).getId());
|
summary.setCreater(super.getUser(request).getId());
|
||||||
|
|
||||||
@ -981,7 +996,7 @@ public class AgentController extends Handler {
|
|||||||
@RequestMapping(value = "/transfer")
|
@RequestMapping(value = "/transfer")
|
||||||
@Menu(type = "apps", subtype = "transfer")
|
@Menu(type = "apps", subtype = "transfer")
|
||||||
public ModelAndView transfer(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid) {
|
public ModelAndView transfer(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid) {
|
||||||
if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) {
|
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
|
||||||
//map.addAttribute("organList", organRes.findByOrgiAndOrgid(super.getOrgi(request),super.getOrgid(request))) ;
|
//map.addAttribute("organList", organRes.findByOrgiAndOrgid(super.getOrgi(request),super.getOrgid(request))) ;
|
||||||
|
|
||||||
List<Organ> skillList = OnlineUserUtils.organ(super.getOrgi(request), true);
|
List<Organ> skillList = OnlineUserUtils.organ(super.getOrgi(request), true);
|
||||||
@ -1022,7 +1037,7 @@ public class AgentController extends Handler {
|
|||||||
@RequestMapping(value = "/transfer/agent")
|
@RequestMapping(value = "/transfer/agent")
|
||||||
@Menu(type = "apps", subtype = "transferagent")
|
@Menu(type = "apps", subtype = "transferagent")
|
||||||
public ModelAndView transferagent(ModelMap map, HttpServletRequest request, @Valid String organ) {
|
public ModelAndView transferagent(ModelMap map, HttpServletRequest request, @Valid String organ) {
|
||||||
if (!StringUtils.isBlank(organ)) {
|
if (StringUtils.isNotBlank(organ)) {
|
||||||
List<String> usersids = new ArrayList<String>();
|
List<String> usersids = new ArrayList<String>();
|
||||||
List<AgentStatus> agentStatusList = AutomaticServiceDist.getAgentStatus(organ, super.getOrgi(request));
|
List<AgentStatus> agentStatusList = AutomaticServiceDist.getAgentStatus(organ, super.getOrgi(request));
|
||||||
if (!agentStatusList.isEmpty()) {
|
if (!agentStatusList.isEmpty()) {
|
||||||
@ -1047,7 +1062,7 @@ public class AgentController extends Handler {
|
|||||||
@RequestMapping(value = "/transfer/save")
|
@RequestMapping(value = "/transfer/save")
|
||||||
@Menu(type = "apps", subtype = "transfersave")
|
@Menu(type = "apps", subtype = "transfersave")
|
||||||
public ModelAndView transfersave(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid, @Valid String agentno, @Valid String memo) {
|
public ModelAndView transfersave(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid, @Valid String agentno, @Valid String memo) {
|
||||||
if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid) && !StringUtils.isBlank(agentno)) {
|
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid) && StringUtils.isNotBlank(agentno)) {
|
||||||
AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(userid, super.getOrgi(request));
|
AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(userid, super.getOrgi(request));
|
||||||
AgentService agentService = this.agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request));
|
AgentService agentService = this.agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request));
|
||||||
if (agentUser != null) {
|
if (agentUser != null) {
|
||||||
@ -1081,7 +1096,7 @@ public class AgentController extends Handler {
|
|||||||
|
|
||||||
if (agentService != null) {
|
if (agentService != null) {
|
||||||
agentService.setAgentno(agentno);
|
agentService.setAgentno(agentno);
|
||||||
if (!StringUtils.isBlank(memo)) {
|
if (StringUtils.isNotBlank(memo)) {
|
||||||
agentService.setTransmemo(memo);
|
agentService.setTransmemo(memo);
|
||||||
}
|
}
|
||||||
agentService.setTrans(true);
|
agentService.setTrans(true);
|
||||||
@ -1103,7 +1118,7 @@ public class AgentController extends Handler {
|
|||||||
quickTypeList.addAll(priQuickTypeList);
|
quickTypeList.addAll(priQuickTypeList);
|
||||||
map.addAttribute("pubQuickTypeList", quickTypeList);
|
map.addAttribute("pubQuickTypeList", quickTypeList);
|
||||||
|
|
||||||
if (!StringUtils.isBlank(typeid)) {
|
if (StringUtils.isNotBlank(typeid)) {
|
||||||
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1114,7 +1129,7 @@ public class AgentController extends Handler {
|
|||||||
@RequestMapping("/quickreply/add")
|
@RequestMapping("/quickreply/add")
|
||||||
@Menu(type = "setting", subtype = "quickreplyadd", admin = true)
|
@Menu(type = "setting", subtype = "quickreplyadd", admin = true)
|
||||||
public ModelAndView quickreplyadd(ModelMap map, HttpServletRequest request, @Valid String parentid) {
|
public ModelAndView quickreplyadd(ModelMap map, HttpServletRequest request, @Valid String parentid) {
|
||||||
if (!StringUtils.isBlank(parentid)) {
|
if (StringUtils.isNotBlank(parentid)) {
|
||||||
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(parentid, super.getOrgi(request)));
|
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(parentid, super.getOrgi(request)));
|
||||||
}
|
}
|
||||||
map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()));
|
map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()));
|
||||||
@ -1124,7 +1139,7 @@ public class AgentController extends Handler {
|
|||||||
@RequestMapping("/quickreply/save")
|
@RequestMapping("/quickreply/save")
|
||||||
@Menu(type = "setting", subtype = "quickreply", admin = true)
|
@Menu(type = "setting", subtype = "quickreply", admin = true)
|
||||||
public ModelAndView quickreplysave(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) {
|
public ModelAndView quickreplysave(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) {
|
||||||
if (!StringUtils.isBlank(quickReply.getTitle()) && !StringUtils.isBlank(quickReply.getContent())) {
|
if (StringUtils.isNotBlank(quickReply.getTitle()) && StringUtils.isNotBlank(quickReply.getContent())) {
|
||||||
quickReply.setOrgi(super.getOrgi(request));
|
quickReply.setOrgi(super.getOrgi(request));
|
||||||
quickReply.setCreater(super.getUser(request).getId());
|
quickReply.setCreater(super.getUser(request).getId());
|
||||||
quickReply.setType(MainContext.QuickTypeEnum.PRI.toString());
|
quickReply.setType(MainContext.QuickTypeEnum.PRI.toString());
|
||||||
@ -1158,7 +1173,7 @@ public class AgentController extends Handler {
|
|||||||
@RequestMapping("/quickreply/update")
|
@RequestMapping("/quickreply/update")
|
||||||
@Menu(type = "setting", subtype = "quickreply", admin = true)
|
@Menu(type = "setting", subtype = "quickreply", admin = true)
|
||||||
public ModelAndView quickreplyupdate(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) {
|
public ModelAndView quickreplyupdate(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) {
|
||||||
if (!StringUtils.isBlank(quickReply.getId())) {
|
if (StringUtils.isNotBlank(quickReply.getId())) {
|
||||||
QuickReply temp = quickReplyRes.findOne(quickReply.getId());
|
QuickReply temp = quickReplyRes.findOne(quickReply.getId());
|
||||||
quickReply.setOrgi(super.getOrgi(request));
|
quickReply.setOrgi(super.getOrgi(request));
|
||||||
quickReply.setCreater(super.getUser(request).getId());
|
quickReply.setCreater(super.getUser(request).getId());
|
||||||
@ -1175,7 +1190,7 @@ public class AgentController extends Handler {
|
|||||||
@Menu(type = "apps", subtype = "kbs")
|
@Menu(type = "apps", subtype = "kbs")
|
||||||
public ModelAndView addtype(ModelMap map, HttpServletRequest request, @Valid String typeid) {
|
public ModelAndView addtype(ModelMap map, HttpServletRequest request, @Valid String typeid) {
|
||||||
map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()));
|
map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()));
|
||||||
if (!StringUtils.isBlank(typeid)) {
|
if (StringUtils.isNotBlank(typeid)) {
|
||||||
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request)));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/addtype"));
|
return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/addtype"));
|
||||||
|
@ -24,6 +24,7 @@ import com.chatopera.cc.app.cache.CacheHelper;
|
|||||||
import com.chatopera.cc.app.handler.Handler;
|
import com.chatopera.cc.app.handler.Handler;
|
||||||
import com.chatopera.cc.app.im.util.RichMediaUtils;
|
import com.chatopera.cc.app.im.util.RichMediaUtils;
|
||||||
import com.chatopera.cc.app.model.*;
|
import com.chatopera.cc.app.model.*;
|
||||||
|
import com.chatopera.cc.app.persistence.blob.JpaBlobHelper;
|
||||||
import com.chatopera.cc.app.persistence.es.ContactsRepository;
|
import com.chatopera.cc.app.persistence.es.ContactsRepository;
|
||||||
import com.chatopera.cc.app.persistence.repository.*;
|
import com.chatopera.cc.app.persistence.repository.*;
|
||||||
import com.chatopera.cc.util.*;
|
import com.chatopera.cc.util.*;
|
||||||
@ -78,6 +79,12 @@ public class IMController extends Handler {
|
|||||||
@Value("${web.upload-path}")
|
@Value("${web.upload-path}")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StreamingFileRepository streamingFileRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JpaBlobHelper jpaBlobHelper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConsultInviteRepository inviteRepository;
|
private ConsultInviteRepository inviteRepository;
|
||||||
|
|
||||||
@ -707,62 +714,76 @@ public class IMController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/image/upload")
|
@RequestMapping("/image/upload")
|
||||||
@Menu(type = "im", subtype = "image", access = true)
|
@Menu(type = "im", subtype = "image", access = true)
|
||||||
public ModelAndView upload(ModelMap map, HttpServletRequest request, @RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @Valid String channel, @Valid String userid, @Valid String username, @Valid String appid, @Valid String orgi, @Valid String paste) throws IOException {
|
public ModelAndView upload(ModelMap map, HttpServletRequest request,
|
||||||
|
@RequestParam(value = "imgFile", required = false) MultipartFile multipart,
|
||||||
|
@Valid String channel,
|
||||||
|
@Valid String userid,
|
||||||
|
@Valid String username,
|
||||||
|
@Valid String appid,
|
||||||
|
@Valid String orgi,
|
||||||
|
@Valid String paste) throws IOException {
|
||||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload"));
|
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload"));
|
||||||
UploadStatus upload = null;
|
UploadStatus upload = null;
|
||||||
String fileName = null;
|
String fileName = null;
|
||||||
if (imgFile != null
|
if (multipart != null
|
||||||
&& imgFile.getOriginalFilename().lastIndexOf(".") > 0
|
&& multipart.getOriginalFilename().lastIndexOf(".") > 0
|
||||||
&& StringUtils.isNotBlank(userid)) {
|
&& StringUtils.isNotBlank(userid)) {
|
||||||
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.md5(imgFile.getBytes());
|
|
||||||
if (imgFile.getContentType() != null
|
String fileid = MainUtils.getUUID();
|
||||||
&& imgFile.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) {
|
StreamingFile sf = new StreamingFile();
|
||||||
|
sf.setId(fileid);
|
||||||
|
sf.setName(multipart.getOriginalFilename());
|
||||||
|
sf.setMime(multipart.getContentType());
|
||||||
|
if (multipart.getContentType() != null
|
||||||
|
&& multipart.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) {
|
||||||
// 检查文件格式
|
// 检查文件格式
|
||||||
String invalid = AttachementFormatValidator.getInstance().validate(Constants.ATTACHMENT_TYPE_IMAGE, imgFile.getOriginalFilename());
|
String invalid = StreamingFileUtils.getInstance().validate(Constants.ATTACHMENT_TYPE_IMAGE, multipart.getOriginalFilename());
|
||||||
if (invalid == null) {
|
if (invalid == null) {
|
||||||
fileName = "upload/" + fileid + "_original";
|
fileName = "upload/" + fileid + "_original";
|
||||||
File imageFile = new File(path, fileName);
|
File imageFile = new File(path, fileName);
|
||||||
FileCopyUtils.copy(imgFile.getBytes(), imageFile);
|
FileCopyUtils.copy(multipart.getBytes(), imageFile);
|
||||||
String thumbnailsFileName = "upload/" + fileid;
|
String thumbnailsFileName = "upload/" + fileid;
|
||||||
MainUtils.processImage(new File(path, thumbnailsFileName), imageFile);
|
File thumbnail = new File(path, thumbnailsFileName);
|
||||||
|
MainUtils.processImage(thumbnail, imageFile);
|
||||||
|
|
||||||
|
// 存储数据库
|
||||||
|
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||||
|
sf.setThumbnail(jpaBlobHelper.createBlobWithFile(thumbnail));
|
||||||
|
streamingFileRepository.save(sf);
|
||||||
|
String fileUrl = "/res/image.html?id=" + fileid;
|
||||||
|
upload = new UploadStatus("0", fileUrl);
|
||||||
|
|
||||||
upload = new UploadStatus("0", "/res/image.html?id=" + thumbnailsFileName);
|
|
||||||
String image = "/res/image.html?id=" + thumbnailsFileName;
|
|
||||||
if (request.getServerPort() == 80) {
|
|
||||||
image = "/res/image.html?id=" + thumbnailsFileName;
|
|
||||||
} else {
|
|
||||||
image = "/res/image.html?id=" + thumbnailsFileName;
|
|
||||||
}
|
|
||||||
if (paste == null) {
|
if (paste == null) {
|
||||||
if (StringUtils.isNotBlank(channel)) {
|
if (StringUtils.isNotBlank(channel)) {
|
||||||
RichMediaUtils.uploadImageWithChannel(image, fileid, (int) imgFile.getSize(), imgFile.getName(), channel, userid, username, appid, orgi);
|
RichMediaUtils.uploadImageWithChannel(fileUrl, fileid, (int) multipart.getSize(), multipart.getName(), channel, userid, username, appid, orgi);
|
||||||
} else {
|
} else {
|
||||||
RichMediaUtils.uploadImage(image, fileid, (int) imgFile.getSize(), imgFile.getName(), userid);
|
RichMediaUtils.uploadImage(fileUrl, fileid, (int) multipart.getSize(), multipart.getName(), userid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
upload = new UploadStatus(invalid);
|
upload = new UploadStatus(invalid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String invalid = AttachementFormatValidator.getInstance().validate(Constants.ATTACHMENT_TYPE_FILE, imgFile.getOriginalFilename());
|
String invalid = StreamingFileUtils.getInstance().validate(Constants.ATTACHMENT_TYPE_FILE, multipart.getOriginalFilename());
|
||||||
if (invalid == null) {
|
if (invalid == null) {
|
||||||
String id = processAttachmentFile(imgFile, request);
|
// 存储数据库
|
||||||
|
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||||
|
streamingFileRepository.save(sf);
|
||||||
|
|
||||||
|
// 存储到本地硬盘
|
||||||
|
String id = processAttachmentFile(multipart, fileid, request);
|
||||||
upload = new UploadStatus("0", "/res/file.html?id=" + id);
|
upload = new UploadStatus("0", "/res/file.html?id=" + id);
|
||||||
String file = "/res/file.html?id=" + id;
|
String file = "/res/file.html?id=" + id;
|
||||||
if (request.getServerPort() == 80) {
|
|
||||||
file = "/res/file.html?id=" + id;
|
File tempFile = new File(multipart.getOriginalFilename());
|
||||||
} else {
|
|
||||||
file = "/res/file.html?id=" + id;
|
|
||||||
}
|
|
||||||
File tempFile = new File(imgFile.getOriginalFilename());
|
|
||||||
if (StringUtils.isNotBlank(channel)) {
|
if (StringUtils.isNotBlank(channel)) {
|
||||||
RichMediaUtils.uploadFileWithChannel(file, (int) imgFile.getSize(), tempFile.getName(), channel, userid, username, appid, orgi, id);
|
RichMediaUtils.uploadFileWithChannel(file, (int) multipart.getSize(), tempFile.getName(), channel, userid, username, appid, orgi, id);
|
||||||
} else {
|
} else {
|
||||||
RichMediaUtils.uploadFile(file, (int) imgFile.getSize(), tempFile.getName(), userid, id);
|
RichMediaUtils.uploadFile(file, (int) multipart.getSize(), tempFile.getName(), userid, id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
upload = new UploadStatus(invalid);
|
upload = new UploadStatus(invalid);
|
||||||
@ -775,36 +796,33 @@ public class IMController extends Handler {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String processAttachmentFile(MultipartFile file, HttpServletRequest request) throws IOException {
|
private String processAttachmentFile(final MultipartFile file, final String fileid, HttpServletRequest request) throws IOException {
|
||||||
String id = null;
|
String id = null;
|
||||||
if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制
|
if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制
|
||||||
String fileid = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件
|
AttachmentFile attachmentFile = new AttachmentFile();
|
||||||
if (StringUtils.isNotBlank(fileid)) {
|
attachmentFile.setCreater(super.getUser(request).getId());
|
||||||
AttachmentFile attachmentFile = new AttachmentFile();
|
attachmentFile.setOrgi(super.getOrgi(request));
|
||||||
attachmentFile.setCreater(super.getUser(request).getId());
|
attachmentFile.setOrgan(super.getUser(request).getOrgan());
|
||||||
attachmentFile.setOrgi(super.getOrgi(request));
|
attachmentFile.setModel(MainContext.ModelType.WEBIM.toString());
|
||||||
attachmentFile.setOrgan(super.getUser(request).getOrgan());
|
attachmentFile.setFilelength((int) file.getSize());
|
||||||
attachmentFile.setModel(MainContext.ModelType.WEBIM.toString());
|
if (file.getContentType() != null && file.getContentType().length() > 255) {
|
||||||
attachmentFile.setFilelength((int) file.getSize());
|
attachmentFile.setFiletype(file.getContentType().substring(0, 255));
|
||||||
if (file.getContentType() != null && file.getContentType().length() > 255) {
|
} else {
|
||||||
attachmentFile.setFiletype(file.getContentType().substring(0, 255));
|
attachmentFile.setFiletype(file.getContentType());
|
||||||
} else {
|
|
||||||
attachmentFile.setFiletype(file.getContentType());
|
|
||||||
}
|
|
||||||
File uploadFile = new File(file.getOriginalFilename());
|
|
||||||
if (uploadFile.getName() != null && uploadFile.getName().length() > 255) {
|
|
||||||
attachmentFile.setTitle(uploadFile.getName().substring(0, 255));
|
|
||||||
} else {
|
|
||||||
attachmentFile.setTitle(uploadFile.getName());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) {
|
|
||||||
attachmentFile.setImage(true);
|
|
||||||
}
|
|
||||||
attachmentFile.setFileid(fileid);
|
|
||||||
attachementRes.save(attachmentFile);
|
|
||||||
FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes());
|
|
||||||
id = attachmentFile.getId();
|
|
||||||
}
|
}
|
||||||
|
File uploadFile = new File(file.getOriginalFilename());
|
||||||
|
if (uploadFile.getName() != null && uploadFile.getName().length() > 255) {
|
||||||
|
attachmentFile.setTitle(uploadFile.getName().substring(0, 255));
|
||||||
|
} else {
|
||||||
|
attachmentFile.setTitle(uploadFile.getName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) {
|
||||||
|
attachmentFile.setImage(true);
|
||||||
|
}
|
||||||
|
attachmentFile.setFileid(fileid);
|
||||||
|
attachementRes.save(attachmentFile);
|
||||||
|
FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes());
|
||||||
|
id = attachmentFile.getId();
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -16,42 +16,53 @@
|
|||||||
*/
|
*/
|
||||||
package com.chatopera.cc.app.handler.resource;
|
package com.chatopera.cc.app.handler.resource;
|
||||||
|
|
||||||
import java.io.File;
|
import com.chatopera.cc.app.basic.MainUtils;
|
||||||
import java.io.IOException;
|
import com.chatopera.cc.app.handler.Handler;
|
||||||
import java.io.InputStream;
|
import com.chatopera.cc.app.model.AttachmentFile;
|
||||||
import java.io.OutputStream;
|
import com.chatopera.cc.app.model.StreamingFile;
|
||||||
import java.net.URL;
|
import com.chatopera.cc.app.model.UploadStatus;
|
||||||
|
import com.chatopera.cc.app.persistence.blob.JpaBlobHelper;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.chatopera.cc.app.persistence.repository.AttachmentRepository;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import com.chatopera.cc.app.persistence.repository.StreamingFileRepository;
|
||||||
import javax.validation.Valid;
|
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.slf4j.Logger;
|
||||||
|
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.util.FileCopyUtils;
|
|
||||||
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 com.chatopera.cc.util.Menu;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.chatopera.cc.app.basic.MainUtils;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import com.chatopera.cc.app.persistence.repository.AttachmentRepository;
|
import javax.validation.Valid;
|
||||||
import com.chatopera.cc.app.handler.Handler;
|
import java.io.File;
|
||||||
import com.chatopera.cc.app.model.AttachmentFile;
|
import java.io.IOException;
|
||||||
import com.chatopera.cc.app.model.UploadStatus;
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
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);
|
||||||
|
|
||||||
@Value("${web.upload-path}")
|
@Value("${web.upload-path}")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StreamingFileRepository streamingFileRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JpaBlobHelper jpaBlobHelper;
|
||||||
|
|
||||||
private String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/";
|
private String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -59,32 +70,25 @@ public class MediaController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/image")
|
@RequestMapping("/image")
|
||||||
@Menu(type = "resouce", subtype = "image", access = true)
|
@Menu(type = "resouce", subtype = "image", access = true)
|
||||||
public void index(HttpServletResponse response, @Valid String id) throws IOException {
|
public void index(HttpServletResponse response,
|
||||||
File file = new File(path, id);
|
@Valid String id,
|
||||||
if (!StringUtils.isBlank(id) && !(id.endsWith(".png") || id.endsWith(".jpg"))) {
|
@RequestParam(value = "original", required = false) boolean original,
|
||||||
if (id.endsWith("_original") && !file.exists()) {
|
@RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException {
|
||||||
File orgFile = new File(path, id.substring(0, id.indexOf("_original")));
|
logger.info("index id {}, original {}, cooperation {}", id, original, cooperation);
|
||||||
if (orgFile.exists()) {
|
StreamingFile sf = streamingFileRepository.findOne(id);
|
||||||
MainUtils.processImage(file = new File(path, id), orgFile);
|
if (sf != null) {
|
||||||
}
|
response.setHeader("Content-Type", sf.getMime());
|
||||||
} else if (!StringUtils.isBlank(id) && file.exists() && !id.endsWith("_original")) {
|
response.setContentType(sf.getMime());
|
||||||
File originalFile = new File(path, id + "_original");
|
if (cooperation && (sf.getCooperation() != null)) { // 协作文件
|
||||||
if (!originalFile.exists()) {
|
IOUtils.copy(sf.getCooperation().getBinaryStream(), response.getOutputStream());
|
||||||
MainUtils.processImage(new File(path, id + "_original"), file);
|
} else if (original && sf.getData() != null) { // 源文件
|
||||||
}
|
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
|
||||||
} else if (!StringUtils.isBlank(id) && !file.exists() && !id.endsWith("_original")) {
|
} else if (sf.getThumbnail() != null) { // 缩略图
|
||||||
File destFile = new File(path, id + "_original");
|
IOUtils.copy(sf.getThumbnail().getBinaryStream(), response.getOutputStream());
|
||||||
if (destFile.exists()) {
|
} else {
|
||||||
MainUtils.processImage(new File(path + id), destFile);
|
logger.warn("[index] can not get streaming file id {}, original {}, cooperation {}", id, original, cooperation);
|
||||||
}
|
|
||||||
file = new File(path, id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file.exists() && file.isFile()) {
|
|
||||||
response.setHeader("Content-Type", "image/png");
|
|
||||||
response.setContentType("image/png");
|
|
||||||
response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, id)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/voice")
|
@RequestMapping("/voice")
|
||||||
@ -102,7 +106,7 @@ public class MediaController extends Handler {
|
|||||||
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.isBlank(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);
|
||||||
@ -113,44 +117,43 @@ public class MediaController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/image/upload")
|
@RequestMapping("/image/upload")
|
||||||
@Menu(type = "resouce", subtype = "imageupload", access = false)
|
@Menu(type = "resouce", subtype = "imageupload", access = false)
|
||||||
public ModelAndView upload(ModelMap map, HttpServletRequest request, @RequestParam(value = "imgFile", required = false) MultipartFile imgFile) throws IOException {
|
public ModelAndView upload(ModelMap map,
|
||||||
|
HttpServletRequest request,
|
||||||
|
@RequestParam(value = "imgFile", required = false) MultipartFile multipart) throws IOException {
|
||||||
ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload"));
|
ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload"));
|
||||||
UploadStatus upload = null;
|
UploadStatus notify = null;
|
||||||
String fileName = null;
|
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) {
|
||||||
if (imgFile != null && imgFile.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();
|
||||||
}
|
}
|
||||||
fileName = "upload/" + MainUtils.md5(imgFile.getBytes()) + imgFile.getOriginalFilename().substring(imgFile.getOriginalFilename().lastIndexOf(".")).toLowerCase();
|
String fileid = MainUtils.getUUID();
|
||||||
FileCopyUtils.copy(imgFile.getBytes(), new File(path, fileName));
|
StreamingFile sf = new StreamingFile();
|
||||||
|
sf.setId(fileid);
|
||||||
String fileURL = request.getScheme() + "://" + request.getServerName() + "/res/image.html?id=" + fileName;
|
sf.setName(multipart.getOriginalFilename());
|
||||||
if (request.getServerPort() == 80) {
|
sf.setMime(multipart.getContentType());
|
||||||
fileURL = request.getScheme() + "://" + request.getServerName() + "/res/image.html?id=" + fileName;
|
sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize()));
|
||||||
} else {
|
streamingFileRepository.save(sf);
|
||||||
fileURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/res/image.html?id=" + fileName;
|
String fileURL = "/res/image.html?id=" + fileid;
|
||||||
}
|
notify = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回
|
||||||
upload = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回
|
|
||||||
} else {
|
} else {
|
||||||
upload = new UploadStatus("请选择图片文件");
|
notify = new UploadStatus("请选择图片文件");
|
||||||
}
|
}
|
||||||
map.addAttribute("upload", upload);
|
map.addAttribute("upload", notify);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/file")
|
@RequestMapping("/file")
|
||||||
@Menu(type = "resouce", subtype = "file", access = false)
|
@Menu(type = "resouce", subtype = "file", access = false)
|
||||||
public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException {
|
public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException, SQLException {
|
||||||
if (!StringUtils.isBlank(id)) {
|
if (StringUtils.isNotBlank(id)) {
|
||||||
AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request));
|
AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request));
|
||||||
if (attachmentFile != null) {
|
if (attachmentFile != null && attachmentFile.getFileid() != null) {
|
||||||
response.setContentType(attachmentFile.getFiletype());
|
StreamingFile sf = streamingFileRepository.findOne(attachmentFile.getFileid());
|
||||||
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8"));
|
if (sf != null) {
|
||||||
if (StringUtils.isNotBlank(attachmentFile.getModel()) && attachmentFile.getModel().equals("app")) {
|
response.setContentType(attachmentFile.getFiletype());
|
||||||
response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, "app/" + attachmentFile.getFileid())));
|
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8"));
|
||||||
} else {
|
IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream());
|
||||||
response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, "upload/" + attachmentFile.getFileid())));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,7 +162,7 @@ public class MediaController extends Handler {
|
|||||||
@RequestMapping("/template")
|
@RequestMapping("/template")
|
||||||
@Menu(type = "resouce", subtype = "template", access = false)
|
@Menu(type = "resouce", subtype = "template", access = false)
|
||||||
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.isBlank(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");
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.app.model;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
import org.hibernate.annotations.Proxy;
|
||||||
|
|
||||||
|
import java.sql.Blob;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "cs_stream_file")
|
||||||
|
@Proxy(lazy = false)
|
||||||
|
public class StreamingFile implements java.io.Serializable {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String mime; // Media Type over HTTP
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Blob data;
|
||||||
|
|
||||||
|
private Blob thumbnail; // 图片缩略图
|
||||||
|
|
||||||
|
private Blob cooperation; // 图片协作图
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(length = 32)
|
||||||
|
@GeneratedValue(generator = "system-uuid")
|
||||||
|
@GenericGenerator(name = "system-uuid", strategy = "assigned")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(@NotNull String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Blob getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(@NotNull Blob data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blob getThumbnail() {
|
||||||
|
return thumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThumbnail(Blob thumbnail) {
|
||||||
|
this.thumbnail = thumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMime() {
|
||||||
|
return mime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMime(String mime) {
|
||||||
|
this.mime = mime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blob getCooperation() {
|
||||||
|
return cooperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCooperation(Blob cooperation) {
|
||||||
|
this.cooperation = cooperation;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.app.persistence.blob;
|
||||||
|
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.sql.Blob;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Transactional
|
||||||
|
public class JpaBlobHelper {
|
||||||
|
|
||||||
|
private final SessionFactory sessionFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public JpaBlobHelper(EntityManagerFactory factory) {
|
||||||
|
if (factory.unwrap(SessionFactory.class) == null) {
|
||||||
|
throw new NullPointerException("factory is not a hibernate factory");
|
||||||
|
}
|
||||||
|
this.sessionFactory = factory.unwrap(SessionFactory.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Blob createBlob(InputStream content, long size) {
|
||||||
|
return sessionFactory.getCurrentSession().getLobHelper().createBlob(content, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blob createBlobWithFile(final File file) throws FileNotFoundException {
|
||||||
|
return createBlob(new FileInputStream(file), file.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.app.persistence.repository;
|
||||||
|
|
||||||
|
import com.chatopera.cc.app.model.StreamingFile;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface StreamingFileRepository extends JpaRepository<StreamingFile, String> {
|
||||||
|
}
|
@ -19,20 +19,20 @@ package com.chatopera.cc.util;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class AttachementFormatValidator {
|
public class StreamingFileUtils {
|
||||||
|
|
||||||
private static AttachementFormatValidator singleton = new AttachementFormatValidator();
|
private static StreamingFileUtils singleton = new StreamingFileUtils();
|
||||||
|
|
||||||
private final HashMap<String, String> extMap = new HashMap<String, String>();
|
private final HashMap<String, String> extMap = new HashMap<String, String>();
|
||||||
|
|
||||||
private AttachementFormatValidator() {
|
private StreamingFileUtils() {
|
||||||
extMap.put(Constants.ATTACHMENT_TYPE_IMAGE, "gif,jpg,jpeg,png,bmp");
|
extMap.put(Constants.ATTACHMENT_TYPE_IMAGE, "gif,jpg,jpeg,png,bmp");
|
||||||
extMap.put(Constants.ATTACHMENT_TYPE_FILE, "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,c66");
|
extMap.put(Constants.ATTACHMENT_TYPE_FILE, "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,c66");
|
||||||
extMap.put("flash", "swf,flv");
|
extMap.put("flash", "swf,flv");
|
||||||
extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb");
|
extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AttachementFormatValidator getInstance() {
|
public static StreamingFileUtils getInstance() {
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,4 +49,5 @@ public class AttachementFormatValidator {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -31,11 +31,6 @@ server.log.path=../logs
|
|||||||
server.log.level=INFO
|
server.log.level=INFO
|
||||||
web.upload-path=../data
|
web.upload-path=../data
|
||||||
|
|
||||||
# multi part
|
|
||||||
spring.servlet.multipart.enabled=true
|
|
||||||
spring.servlet.multipart.max-file-size=20MB
|
|
||||||
spring.servlet.multipart.max-request-size=50MB
|
|
||||||
|
|
||||||
# IM Server
|
# IM Server
|
||||||
uk.im.server.port=8036
|
uk.im.server.port=8036
|
||||||
uk.im.server.host=localhost
|
uk.im.server.host=localhost
|
||||||
@ -153,4 +148,12 @@ cskefu.callout.watch.interval=60000
|
|||||||
##############################################
|
##############################################
|
||||||
storage.minio.url=http://192.168.2.217:9000
|
storage.minio.url=http://192.168.2.217:9000
|
||||||
storage.minio.access_key=M19Q8YJ8FzLyQtST7r0
|
storage.minio.access_key=M19Q8YJ8FzLyQtST7r0
|
||||||
storage.minio.secret_key=KHv6qjddHD4HfR1m7fjY7HglSO1WOSzIeTERRUUc
|
storage.minio.secret_key=KHv6qjddHD4HfR1m7fjY7HglSO1WOSzIeTERRUUc
|
||||||
|
|
||||||
|
# multi part
|
||||||
|
spring.servlet.multipart.enabled=true
|
||||||
|
spring.servlet.multipart.max-file-size=15MB
|
||||||
|
spring.servlet.multipart.max-request-size=15MB
|
||||||
|
|
||||||
|
# MySQL Blob
|
||||||
|
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
//创建新的图片对象
|
//创建新的图片对象
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
//指定图片的URL
|
//指定图片的URL
|
||||||
img.src = "/res/image.html?id=upload/${chatMessage.attachmentid!''}_cooperation";
|
img.src = "/res/image.html?id=${chatMessage.attachmentid!''}&cooperation=true&original=true";
|
||||||
//浏览器加载图片完毕后再绘制图片
|
//浏览器加载图片完毕后再绘制图片
|
||||||
img.onload = function(){
|
img.onload = function(){
|
||||||
//以Canvas画布上的坐标(10,10)为起始点,绘制图像
|
//以Canvas画布上的坐标(10,10)为起始点,绘制图像
|
||||||
@ -49,7 +49,7 @@
|
|||||||
<div class='ukefu-preview-image scrawl-main' id="scrawl-main">
|
<div class='ukefu-preview-image scrawl-main' id="scrawl-main">
|
||||||
<div class='ukefu-image-content hot'>
|
<div class='ukefu-image-content hot'>
|
||||||
<div class='ukefu-image-canvas' id='ukefu-image-content'>
|
<div class='ukefu-image-canvas' id='ukefu-image-content'>
|
||||||
<img id="ukefu_img_ctx" src='${chatMessage.message!''}_original'>
|
<img id="ukefu_img_ctx" src='${chatMessage.message!''}&original=true'>
|
||||||
</div>
|
</div>
|
||||||
<div class='drawBoard'>
|
<div class='drawBoard'>
|
||||||
<canvas id="canvas-borad" class="brushBorad">你的浏览器不支持 canvas 绘图</canvas>
|
<canvas id="canvas-borad" class="brushBorad">你的浏览器不支持 canvas 绘图</canvas>
|
||||||
|
@ -493,7 +493,7 @@
|
|||||||
var chat=document.getElementsByClassName('chatting-left').innerText;
|
var chat=document.getElementsByClassName('chatting-left').innerText;
|
||||||
chat = data.message;
|
chat = data.message;
|
||||||
if(data.messageType == "image"){
|
if(data.messageType == "image"){
|
||||||
chat = "<a href='"+data.message+"_original' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
chat = "<a href='"+data.message+"&original=true' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
||||||
}else if(data.messageType == "file"){
|
}else if(data.messageType == "file"){
|
||||||
chat = "<div class='ukefu-message-file'><div class='ukefu-file-icon'><img src='/im/img/file.png'></div><div class='ukefu-file-desc'><a href='"+data.message+"' target='_blank'><div>"+data.filename+"</div><div>"+(data.filesize/1024).toFixed(3)+"Kb</div></a></div></div>" ;
|
chat = "<div class='ukefu-message-file'><div class='ukefu-file-icon'><img src='/im/img/file.png'></div><div class='ukefu-file-desc'><a href='"+data.message+"' target='_blank'><div>"+data.filename+"</div><div>"+(data.filesize/1024).toFixed(3)+"Kb</div></a></div></div>" ;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@
|
|||||||
var chat=document.getElementsByClassName('chatting-left').innerText;
|
var chat=document.getElementsByClassName('chatting-left').innerText;
|
||||||
chat = data.message;
|
chat = data.message;
|
||||||
if(data.messageType == "image"){
|
if(data.messageType == "image"){
|
||||||
chat = "<a href='"+data.message+"_original' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
chat = "<a href='"+data.message+"&original=true' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
||||||
}else if(data.messageType == "cooperation"){
|
}else if(data.messageType == "cooperation"){
|
||||||
chat = "<a href='javascript:void(0)' onclick='acceptInvite(\""+data.message+"\", \""+data.attachmentid+"\")'>您收到一个协作邀请,点击进入协作</a>" ;
|
chat = "<a href='javascript:void(0)' onclick='acceptInvite(\""+data.message+"\", \""+data.attachmentid+"\")'>您收到一个协作邀请,点击进入协作</a>" ;
|
||||||
}else if(data.messageType == "action"){
|
}else if(data.messageType == "action"){
|
||||||
@ -324,7 +324,7 @@
|
|||||||
}
|
}
|
||||||
function acceptInvite(msgid,fileid){
|
function acceptInvite(msgid,fileid){
|
||||||
document.getElementById("cooperation").style.display = "block" ;
|
document.getElementById("cooperation").style.display = "block" ;
|
||||||
document.getElementById("ukefu_img_ctx").src = "/res/image.html?id=upload/"+fileid ;
|
document.getElementById("ukefu_img_ctx").src = "/res/image.html?id="+fileid + "&cooperation=true&original=true";
|
||||||
|
|
||||||
$("#ukefu_img_ctx").load(function() {
|
$("#ukefu_img_ctx").load(function() {
|
||||||
var height = document.getElementById("ukefu-image-content").offsetHeight;
|
var height = document.getElementById("ukefu-image-content").offsetHeight;
|
||||||
@ -348,7 +348,7 @@
|
|||||||
//创建新的图片对象
|
//创建新的图片对象
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
//指定图片的URL
|
//指定图片的URL
|
||||||
img.src = "/res/image.html?id=upload/" + fileid + "_cooperation";
|
img.src = "/res/image.html?id=" + fileid + "&cooperation=true&original=true";
|
||||||
//浏览器加载图片完毕后再绘制图片
|
//浏览器加载图片完毕后再绘制图片
|
||||||
img.onload = function() {
|
img.onload = function() {
|
||||||
ctx.clearRect(0,0,canvas.width,canvas.height);
|
ctx.clearRect(0,0,canvas.width,canvas.height);
|
||||||
|
@ -491,7 +491,7 @@
|
|||||||
var chat=document.getElementsByClassName('chatting-left').innerText;
|
var chat=document.getElementsByClassName('chatting-left').innerText;
|
||||||
chat = data.message;
|
chat = data.message;
|
||||||
if(data.messageType == "image"){
|
if(data.messageType == "image"){
|
||||||
chat = "<a href='"+data.message+"_original' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
chat = "<a href='"+data.message+"&original=true' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
||||||
}else if(data.messageType == "file"){
|
}else if(data.messageType == "file"){
|
||||||
chat = "<div class='ukefu-message-file'><div class='ukefu-file-icon'><img src='/im/img/file.png'></div><div class='ukefu-file-desc'><a href='"+data.message+"' target='_blank'><div>"+data.filename+"</div><div>"+(data.filesize/1024).toFixed(3)+"Kb</div></a></div></div>" ;
|
chat = "<div class='ukefu-message-file'><div class='ukefu-file-icon'><img src='/im/img/file.png'></div><div class='ukefu-file-desc'><a href='"+data.message+"' target='_blank'><div>"+data.filename+"</div><div>"+(data.filesize/1024).toFixed(3)+"Kb</div></a></div></div>" ;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<#if chatMessage.msgtype?? && chatMessage.msgtype == "image">
|
<#if chatMessage.msgtype?? && chatMessage.msgtype == "image">
|
||||||
<a href="${(chatMessage.message!'')?no_esc}_original" target="_blank"><img src="${(chatMessage.message!'')?no_esc}" class="ukefu-media-image"></a>
|
<a href="${(chatMessage.message!'')?no_esc}&original=true" target="_blank"><img src="${(chatMessage.message!'')?no_esc}" class="ukefu-media-image"></a>
|
||||||
<#elseif chatMessage.msgtype?? && chatMessage.msgtype == "cooperation">
|
<#elseif chatMessage.msgtype?? && chatMessage.msgtype == "cooperation">
|
||||||
<a href='javascript:void(0)' onclick='acceptInvite("${chatMessage.message!''}" , "${chatMessage.attachmentid!''}")'>您收到一个协作邀请,点击进入协作</a>
|
<a href='javascript:void(0)' onclick='acceptInvite("${chatMessage.message!''}" , "${chatMessage.attachmentid!''}")'>您收到一个协作邀请,点击进入协作</a>
|
||||||
<#elseif chatMessage.msgtype?? && chatMessage.msgtype == "file">
|
<#elseif chatMessage.msgtype?? && chatMessage.msgtype == "file">
|
||||||
|
@ -300,7 +300,7 @@
|
|||||||
var chat=document.getElementsByClassName('chatting-left').innerText;
|
var chat=document.getElementsByClassName('chatting-left').innerText;
|
||||||
chat = data.message;
|
chat = data.message;
|
||||||
if(data.messageType == "image"){
|
if(data.messageType == "image"){
|
||||||
chat = "<a href='"+data.message+"_original' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
chat = "<a href='"+data.message+"&original=true' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
||||||
}else if(data.messageType == "cooperation"){
|
}else if(data.messageType == "cooperation"){
|
||||||
chat = "<a href='javascript:void(0)' onclick='acceptInvite(\""+data.message+"\", \""+data.attachmentid+"\")'>您收到一个协作邀请,点击进入协作</a>" ;
|
chat = "<a href='javascript:void(0)' onclick='acceptInvite(\""+data.message+"\", \""+data.attachmentid+"\")'>您收到一个协作邀请,点击进入协作</a>" ;
|
||||||
}else if(data.messageType == "action"){
|
}else if(data.messageType == "action"){
|
||||||
@ -322,7 +322,7 @@
|
|||||||
}
|
}
|
||||||
function acceptInvite(msgid,fileid){
|
function acceptInvite(msgid,fileid){
|
||||||
document.getElementById("cooperation").style.display = "block" ;
|
document.getElementById("cooperation").style.display = "block" ;
|
||||||
document.getElementById("ukefu_img_ctx").src = "/res/image.html?id=upload/"+fileid ;
|
document.getElementById("ukefu_img_ctx").src = "/res/image.html?id="+fileid + "&cooperation=true&original=true";
|
||||||
|
|
||||||
$("#ukefu_img_ctx").load(function() {
|
$("#ukefu_img_ctx").load(function() {
|
||||||
var height = document.getElementById("ukefu-image-content").offsetHeight;
|
var height = document.getElementById("ukefu-image-content").offsetHeight;
|
||||||
@ -346,7 +346,7 @@
|
|||||||
//创建新的图片对象
|
//创建新的图片对象
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
//指定图片的URL
|
//指定图片的URL
|
||||||
img.src = "/res/image.html?id=upload/" + fileid + "_cooperation";
|
img.src = "/res/image.html?id=" + fileid + "&cooperation=true&original=true";
|
||||||
//浏览器加载图片完毕后再绘制图片
|
//浏览器加载图片完毕后再绘制图片
|
||||||
img.onload = function() {
|
img.onload = function() {
|
||||||
ctx.clearRect(0,0,canvas.width,canvas.height);
|
ctx.clearRect(0,0,canvas.width,canvas.height);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user