Commit 7c43fd99 by yao.xiao

解决冲突

parents a781a4e0 001bb210
package com.yd.api.agms; package com.yd.api.agms;
import com.alibaba.fastjson.JSON;
import com.yd.api.agms.service.*; import com.yd.api.agms.service.*;
import com.yd.api.agms.service.AgmsDashboardService; import com.yd.api.agms.service.AgmsDashboardService;
import com.yd.api.agms.service.AgmsFortuneService; import com.yd.api.agms.service.AgmsFortuneService;
...@@ -294,8 +295,11 @@ public class AgmsController { ...@@ -294,8 +295,11 @@ public class AgmsController {
} }
@RequestMapping(value="/controller") @RequestMapping(value="/controller")
public Object controller(@RequestParam String action,@RequestParam(value = "upfile",required = false) MultipartFile upfile) { public Object controller(@RequestParam String action, @RequestParam(required = false) String callback, @RequestParam(value = "upfile",required = false) MultipartFile upfile) {
ControllerResponseVO responseVO = agmsSharingService.controller(action, upfile); ControllerResponseVO responseVO = agmsSharingService.controller(action, upfile);
if ("config".equals(action)) {
return callback +"(" + JSON.toJSONString(responseVO) + ")";
}
return responseVO; return responseVO;
} }
/** /**
......
...@@ -8,6 +8,7 @@ import com.yd.rmi.ali.oss.service.OssService; ...@@ -8,6 +8,7 @@ import com.yd.rmi.ali.oss.service.OssService;
import com.yd.rmi.ali.oss.vo.OssOperateTypeEnum; import com.yd.rmi.ali.oss.vo.OssOperateTypeEnum;
import com.yd.rmi.ali.oss.vo.OssRequestVO; import com.yd.rmi.ali.oss.vo.OssRequestVO;
import com.yd.rmi.ali.oss.vo.OssResponseVO; import com.yd.rmi.ali.oss.vo.OssResponseVO;
import com.yd.rmi.ali.ossinterf.service.AliOssInterfService;
import com.yd.rmi.cache.SystemConfigService; import com.yd.rmi.cache.SystemConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -33,7 +34,6 @@ public class AgmsSharingServiceImpl implements AgmsSharingService { ...@@ -33,7 +34,6 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
@Override @Override
public ControllerResponseVO controller(String action, MultipartFile upfile) { public ControllerResponseVO controller(String action, MultipartFile upfile) {
ControllerResponseVO responseVO = new ControllerResponseVO(); ControllerResponseVO responseVO = new ControllerResponseVO();
String aliOssBucketName = systemConfigService.getSingleConfigValue("ALI_OSS_BUCKET_NAME");
String[] imageAllowFiles = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"}; String[] imageAllowFiles = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"};
String[] videoAllowFiles = new String[]{".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", String[] videoAllowFiles = new String[]{".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"}; ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"};
...@@ -43,6 +43,7 @@ public class AgmsSharingServiceImpl implements AgmsSharingService { ...@@ -43,6 +43,7 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso", ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"}; ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"};
if ("config".equals(action)) { if ("config".equals(action)) {
String aliOssBucketName = systemConfigService.getSingleConfigValue("ALI_OSS_BUCKET_NAME");
responseVO.setImageActionName("uploadimage"); responseVO.setImageActionName("uploadimage");
responseVO.setImageFieldName("upfile"); responseVO.setImageFieldName("upfile");
responseVO.setImageMaxSize(2048000); responseVO.setImageMaxSize(2048000);
...@@ -51,46 +52,46 @@ public class AgmsSharingServiceImpl implements AgmsSharingService { ...@@ -51,46 +52,46 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
responseVO.setImageCompressBorder(1600); responseVO.setImageCompressBorder(1600);
responseVO.setImageInsertAlign("none"); responseVO.setImageInsertAlign("none");
responseVO.setImageUrlPrefix(aliOssBucketName); responseVO.setImageUrlPrefix(aliOssBucketName);
responseVO.setImagePathFormat("/sharing/image/{time}{rand:6}"); responseVO.setImagePathFormat("/image/{time}{rand:6}");
responseVO.setScrawlActionName("uploadscrawl"); responseVO.setScrawlActionName("uploadscrawl");
responseVO.setScrawlFieldName("upfile"); responseVO.setScrawlFieldName("upfile");
responseVO.setScrawlPathFormat("/sharing/image/{time}{rand:6}"); responseVO.setScrawlPathFormat("/image/{time}{rand:6}");
responseVO.setScrawlMaxSize(2048000); responseVO.setScrawlMaxSize(2048000);
responseVO.setScrawlUrlPrefix(aliOssBucketName); responseVO.setScrawlUrlPrefix(aliOssBucketName);
responseVO.setScrawlInsertAlign("none"); responseVO.setScrawlInsertAlign("none");
responseVO.setSnapscreenActionName("uploadimage"); responseVO.setSnapscreenActionName("uploadimage");
responseVO.setSnapscreenPathFormat("/sharing/image/{time}{rand:6}"); responseVO.setSnapscreenPathFormat("/image/{time}{rand:6}");
responseVO.setSnapscreenUrlPrefix(aliOssBucketName); responseVO.setSnapscreenUrlPrefix(aliOssBucketName);
responseVO.setSnapscreenInsertAlign("none"); responseVO.setSnapscreenInsertAlign("none");
String[] catcherLocalDomain = new String[]{"127.0.0.1", "localhost", "img.baidu.com"}; String[] catcherLocalDomain = new String[]{"127.0.0.1", "localhost", "img.baidu.com"};
responseVO.setCatcherLocalDomain(Arrays.asList(catcherLocalDomain)); responseVO.setCatcherLocalDomain(Arrays.asList(catcherLocalDomain));
responseVO.setCatcherActionName("catchimage"); responseVO.setCatcherActionName("catchimage");
responseVO.setCatcherFieldName("source"); responseVO.setCatcherFieldName("source");
responseVO.setCatcherPathFormat("/sharing/image/{time}{rand:6}"); responseVO.setCatcherPathFormat("/image/{time}{rand:6}");
responseVO.setCatcherUrlPrefix(aliOssBucketName); responseVO.setCatcherUrlPrefix(aliOssBucketName);
responseVO.setCatcherMaxSize(2048000); responseVO.setCatcherMaxSize(2048000);
responseVO.setCatcherAllowFiles(Arrays.asList(imageAllowFiles)); responseVO.setCatcherAllowFiles(Arrays.asList(imageAllowFiles));
responseVO.setVideoActionName("uploadvideo"); responseVO.setVideoActionName("uploadvideo");
responseVO.setVideoFieldName("upfile"); responseVO.setVideoFieldName("upfile");
responseVO.setVideoPathFormat("/sharing/video/{time}{rand:6}"); responseVO.setVideoPathFormat("/video/{time}{rand:6}");
responseVO.setVideoUrlPrefix(aliOssBucketName); responseVO.setVideoUrlPrefix(aliOssBucketName);
responseVO.setVideoMaxSize(102400000); responseVO.setVideoMaxSize(102400000);
responseVO.setVideoAllowFiles(Arrays.asList(videoAllowFiles)); responseVO.setVideoAllowFiles(Arrays.asList(videoAllowFiles));
responseVO.setFileActionName("uploadfile"); responseVO.setFileActionName("uploadfile");
responseVO.setFileFieldName("upfile"); responseVO.setFileFieldName("upfile");
responseVO.setFilePathFormat("/sharing/file/{time}{rand:6}"); responseVO.setFilePathFormat("/file/{time}{rand:6}");
responseVO.setFileUrlPrefix(aliOssBucketName); responseVO.setFileUrlPrefix(aliOssBucketName);
responseVO.setFileMaxSize(51200000); responseVO.setFileMaxSize(51200000);
responseVO.setFileAllowFiles(Arrays.asList(fileAllowFiles)); responseVO.setFileAllowFiles(Arrays.asList(fileAllowFiles));
responseVO.setImageManagerActionName("listimage"); responseVO.setImageManagerActionName("listimage");
responseVO.setImageManagerListPath("/sharing/image/"); responseVO.setImageManagerListPath("/image/");
responseVO.setImageManagerListSize(20); responseVO.setImageManagerListSize(20);
responseVO.setImageManagerUrlPrefix(aliOssBucketName); responseVO.setImageManagerUrlPrefix(aliOssBucketName);
responseVO.setImageManagerInsertAlign("none"); responseVO.setImageManagerInsertAlign("none");
String[] imageManagerAllowFiles = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"}; String[] imageManagerAllowFiles = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"};
responseVO.setImageManagerAllowFiles(Arrays.asList(imageManagerAllowFiles)); responseVO.setImageManagerAllowFiles(Arrays.asList(imageManagerAllowFiles));
responseVO.setFileManagerActionName("listfile"); responseVO.setFileManagerActionName("listfile");
responseVO.setFileManagerListPath("/sharing/file/"); responseVO.setFileManagerListPath("/file/");
responseVO.setFileManagerUrlPrefix(aliOssBucketName); responseVO.setFileManagerUrlPrefix(aliOssBucketName);
responseVO.setFileManagerListSize(20); responseVO.setFileManagerListSize(20);
responseVO.setFileManagerAllowFiles(Arrays.asList(fileAllowFiles)); responseVO.setFileManagerAllowFiles(Arrays.asList(fileAllowFiles));
...@@ -99,22 +100,22 @@ public class AgmsSharingServiceImpl implements AgmsSharingService { ...@@ -99,22 +100,22 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
String type = upfile.getOriginalFilename().substring(upfile.getOriginalFilename().indexOf(".") + 1); String type = upfile.getOriginalFilename().substring(upfile.getOriginalFilename().indexOf(".") + 1);
byte[] bytes = upfile.getBytes(); byte[] bytes = upfile.getBytes();
InputStream in = new ByteArrayInputStream(bytes); InputStream in = new ByteArrayInputStream(bytes);
StringBuilder key = new StringBuilder("/sharing/"); StringBuilder key = new StringBuilder("sharing/");
String title; String title;
Date date = new Date(); Date date = new Date();
SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmmssSSS"); SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String nowTime = sd.format(date); String nowTime = sd.format(date);
if (Arrays.asList(imageAllowFiles).contains(type)){ if (Arrays.asList(imageAllowFiles).contains("." + type)){
title = nowTime + (int)(Math.random()*1000000); title = nowTime + (int)(Math.random()*1000000);
key.append("image/").append(title); key.append("image/").append(title);
}else if (Arrays.asList(videoAllowFiles).contains(type)){ }else if (Arrays.asList(videoAllowFiles).contains("." + type)){
title = nowTime + (int)(Math.random()*1000000); title = nowTime + (int)(Math.random()*1000000);
key.append("video/").append(title); key.append("video/").append(title);
}else { }else {
title = nowTime + (int)(Math.random()*1000000); title = nowTime + (int)(Math.random()*1000000);
key.append("file/").append(title); key.append("file/").append(title);
} }
String putFileToOss = ossService.putFileToOss(null, key.toString(), in); String putFileToOss = ossService.putFileToOss(null, key.toString() + "." + type, in);
responseVO.setState("SUCCESS"); responseVO.setState("SUCCESS");
responseVO.setUrl(putFileToOss); responseVO.setUrl(putFileToOss);
responseVO.setTitle(title); responseVO.setTitle(title);
......
...@@ -273,7 +273,8 @@ public class AliOssInterfServiceImpl implements AliOssInterfService { ...@@ -273,7 +273,8 @@ public class AliOssInterfServiceImpl implements AliOssInterfService {
* @param key 对象名 * @param key 对象名
* @return * @return
*/ */
public String generateUrl(String bucketName,String key){ @Override
public String generateUrl(String bucketName, String key){
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret); OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
String url = null; String url = null;
try{ try{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment