|
|
|
@ -21,9 +21,9 @@ import com.huoran.iasf.vo.req.FileParameters; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler; |
|
|
|
@ -33,11 +33,14 @@ import javax.servlet.ServletException; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
import java.net.URLDecoder; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.nio.file.Files; |
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
import java.nio.file.Paths; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -86,11 +89,17 @@ public class SysFilesController { |
|
|
|
|
uEditorResult.setState("error"); |
|
|
|
|
return uEditorResult; |
|
|
|
|
} |
|
|
|
|
String[] allowedExtension = new String[]{"jpg", "png", "gif", "doc", "xls", "xlsx", "docx", "pdf", "mov","mp4","MP3"}; |
|
|
|
|
fileUploadUtils.assertAllowed(file,allowedExtension); |
|
|
|
|
|
|
|
|
|
String pattern = ".*\\.(mp4|MP3|MP4|jpg|png|gif|doc|xls|xlsx|docx|pdf|mp3)$"; |
|
|
|
|
boolean hasExtension = Pattern.matches(pattern, file.getOriginalFilename()); |
|
|
|
|
if (!hasExtension){ |
|
|
|
|
String[] allowedExtension = new String[]{"jpg", "png", "gif", "doc", "xls", "xlsx", "docx", "pdf", "mov","mp4","MP3"}; |
|
|
|
|
fileUploadUtils.assertAllowed(file,allowedExtension); |
|
|
|
|
} |
|
|
|
|
return sysFilesService.saveFile(file,fileParameters); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "更新文件信息") |
|
|
|
|
@PostMapping("/update") |
|
|
|
|
public R update(@RequestBody FileParameters fileParameters) { |
|
|
|
@ -128,7 +137,27 @@ public class SysFilesController { |
|
|
|
|
@ApiOperation(value = "查询分页数据",response = SysFilesEntity.class) |
|
|
|
|
@PostMapping("/listByPage") |
|
|
|
|
@RequiresPermissions("sysFiles:list") |
|
|
|
|
public R findListByPage(@RequestBody SysFilesEntity sysFiles) { |
|
|
|
|
public R findListByPage(@RequestBody SysFilesEntity sysFiles) throws UnsupportedEncodingException { |
|
|
|
|
if (!StringUtils.isEmpty(sysFiles.getQuote())) { |
|
|
|
|
//中文转码
|
|
|
|
|
String title = URLDecoder.decode(sysFiles.getQuote(), StandardCharsets.UTF_8.toString()); |
|
|
|
|
sysFiles.setQuote(title); |
|
|
|
|
} |
|
|
|
|
if (!StringUtils.isEmpty(sysFiles.getFileName())) { |
|
|
|
|
//中文转码
|
|
|
|
|
String title = URLDecoder.decode(sysFiles.getFileName(), StandardCharsets.UTF_8.toString()); |
|
|
|
|
sysFiles.setFileName(title); |
|
|
|
|
} |
|
|
|
|
if (!StringUtils.isEmpty(sysFiles.getUploader())) { |
|
|
|
|
//中文转码
|
|
|
|
|
String title = URLDecoder.decode(sysFiles.getUploader(), StandardCharsets.UTF_8.toString()); |
|
|
|
|
sysFiles.setUploader(title); |
|
|
|
|
} |
|
|
|
|
if (!StringUtils.isEmpty(sysFiles.getType())) { |
|
|
|
|
//中文转码
|
|
|
|
|
String title = URLDecoder.decode(sysFiles.getType(), StandardCharsets.UTF_8.toString()); |
|
|
|
|
sysFiles.setType(title); |
|
|
|
|
} |
|
|
|
|
return sysFilesService.getPage(sysFiles); |
|
|
|
|
|
|
|
|
|
/*LambdaQueryWrapper<SysFilesEntity> queryWrapper = Wrappers.lambdaQuery(); |
|
|
|
|