Commit ab9c06a7 authored by yff's avatar yff

附件修改

parent 61045403
package com.gavel.kwell.controller;
import java.io.FileInputStream;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
......@@ -278,7 +277,6 @@ public class GpfkController extends BaseController {
FileInputStream fileInputStream = attachmentService.download(file.getId());
doAttachmentPreview(file.getId(), response, fileInputStream);
}
}
@RequestMapping(value = "/jgfk", method = RequestMethod.POST)
......
package com.gavel.kwell.service;
import org.springframework.web.multipart.MultipartFile;
import com.gavel.common.attachment.persistent.Attachment;
import com.gavel.common.base.service.BaseEditService;
......@@ -9,4 +11,5 @@ public interface GpfkfjService extends BaseEditService {
public Attachment queryBzgxFj(String bzgxid,String type);
public void checkGxfjIfFitRule(MultipartFile multipartFile, String folderorpath,String groupid);
}
......@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import com.gavel.common.Constants;
import com.gavel.common.attachment.persistent.Attachment;
......@@ -1967,5 +1968,6 @@ public class GpfkServiceImpl extends BaseEditServiceImpl implements GpfkService
}
/************ -------------------科威尔反馈升级--END--------- ******/
}
......@@ -6,8 +6,11 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import com.gavel.common.attachment.persistent.Attachment;
import com.gavel.common.attachment.persistent.Folder;
import com.gavel.common.attachment.service.AttachmentFolderService;
import com.gavel.common.attachment.service.AttachmentService;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.gygl.dao.BzgxDao;
......@@ -18,7 +21,8 @@ import com.gavel.kwell.service.GpfkfjService;
@Service("gpfkfjService")
@Transactional
public class GpfkfjServiceImpl extends BaseEditServiceImpl implements GpfkfjService {
@Autowired
private AttachmentFolderService attachmentFolderService;
@Autowired
private AttachmentService attachmentService;
......@@ -26,7 +30,7 @@ public class GpfkfjServiceImpl extends BaseEditServiceImpl implements GpfkfjServ
@Autowired
private BzgxDao bzgxDao;
private static final String ZDS1_FLODER="bzgx\\gyzyzdso";
private static final String ZDS1_FLODER="gylx";
private static final String ZDS2_FLODER="bzgx\\gyzyzdss";
......@@ -34,7 +38,6 @@ public class GpfkfjServiceImpl extends BaseEditServiceImpl implements GpfkfjServ
private static final String ZDS1_BZ="O";
private static final String ZDS2_BZ="T";
private static final String SP_BZ="M";
@Override
public void initService() {
......@@ -68,9 +71,42 @@ public class GpfkfjServiceImpl extends BaseEditServiceImpl implements GpfkfjServ
}
@Override
public void checkGxfjIfFitRule(MultipartFile multipartFile, String folderorpath, String groupid) {
Folder folder = attachmentFolderService.getFolder(folderorpath,true);
if(folder!=null&&StringUtils.isNotEmpty(folder.getPath())) {
String suffix = getFileSuffix(multipartFile);
if(folder.getPath().equals(ZDS1_FLODER)) {
if(!suffix.toUpperCase().endsWith(".PDF")) {
throwReturnMessage("上传文件得为PDF格式!,请重新检查!");
}
}
else if(folder.getPath().equals(ZDS2_FLODER)) {
if(!suffix.toUpperCase().endsWith(".PDF")) {
throwReturnMessage("上传文件得为PDF格式!,请重新检查!");
}
}
else if(folder.getPath().equals(SP_FLODER)) {
if(!suffix.toUpperCase().endsWith(".MP4")) {
throwReturnMessage("上传文件得为MP4视频格式!,请重新检查!");
}
}
else {
}
}
}
public static String getFileSuffix(MultipartFile multipartFile) {
//获取文件全名
String filename =multipartFile.getOriginalFilename();
//对文文件的全名进行截取然后在后缀名进行删选。
int begin = filename.indexOf(".");
int last = filename.length();
//获得文件后缀名
return filename.substring(begin, last);
}
}
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