zbj//1.修改资源 2.删除资源
This commit is contained in:
@@ -67,4 +67,9 @@ public class ResourceData {
|
|||||||
@TableField(value = "type")
|
@TableField(value = "type")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名称
|
||||||
|
*/
|
||||||
|
@TableField(value = "file_name")
|
||||||
|
private String fileName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class ResourceController extends BaseController {
|
|||||||
log.info(e.getMessage());
|
log.info(e.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("文件路劲有误");
|
throw new RuntimeException("文件路径有误");
|
||||||
}
|
}
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -206,38 +206,26 @@ public class ResourceController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static long getFileSize(InputStream inputStream) throws IOException {
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int len;
|
|
||||||
long size = 0;
|
|
||||||
while ((len = inputStream.read(buffer)) != -1) {
|
|
||||||
size += len;
|
|
||||||
}
|
|
||||||
inputStream.close();
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改资源
|
* 修改资源
|
||||||
*//*
|
*/
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/updateFile")
|
@PostMapping("/updateFile")
|
||||||
@ApiOperation("修改资源")
|
@ApiOperation("修改资源")
|
||||||
public HttpResult<Boolean> updateFile(@ApiParam(value = "文件", required = false) MultipartFile multipartFile,
|
public HttpResult<Boolean> updateFile(@ApiParam(value = "id", required = true) String id,
|
||||||
@ApiParam(value = "id", required = true) String id,
|
@ApiParam(value = "文件", required = false) MultipartFile multipartFile,
|
||||||
@ApiParam(value = "资源名称", required = true) String name,
|
@ApiParam(value = "文件", required = false) MultipartFile picture,
|
||||||
@ApiParam(value = "资源类型", required = true) String type,
|
@ApiParam(value = "资源名称", required = false) String name,
|
||||||
@ApiParam(value = "资源描述", required = true) String description,
|
@ApiParam(value = "资源状态", required = false) Integer state,
|
||||||
@ApiParam(value = "系统类型Guid", required = false) String systemType) {
|
@ApiParam(value = "资源类型", required = false) Integer type) {
|
||||||
String methodDescribe = getMethodDescribe("updateFile");
|
String methodDescribe = getMethodDescribe("updateFile");
|
||||||
Boolean flag = iResourceAdministrationService.updateFile(multipartFile, id, name, type, description, systemType);
|
Boolean flag = iResourceAdministrationService.updateFile(id, multipartFile, picture, name,state, type);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
*//**
|
/**
|
||||||
* 删除资源
|
* 删除资源
|
||||||
*//*
|
*/
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@GetMapping("/deleteFile")
|
@GetMapping("/deleteFile")
|
||||||
@ApiOperation("删除资源")
|
@ApiOperation("删除资源")
|
||||||
@@ -248,7 +236,7 @@ public class ResourceController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出数据
|
* 导出数据
|
||||||
|
|||||||
@@ -26,12 +26,10 @@ public interface ResourceService extends IService<ResourceData> {
|
|||||||
|
|
||||||
void previewFile(String id, HttpServletRequest request, HttpServletResponse response) throws IOException;
|
void previewFile(String id, HttpServletRequest request, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
/*
|
Boolean updateFile(String id, MultipartFile multipartFile, MultipartFile picture, String name, Integer state,Integer type);
|
||||||
Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String description, String systemType);
|
|
||||||
|
|
||||||
Boolean deleteFile(String id);
|
Boolean deleteFile(String id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
void exportData();*/
|
void exportData();*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, ResourceDat
|
|||||||
resourceData.setUploadTime(LocalDateTime.now());
|
resourceData.setUploadTime(LocalDateTime.now());
|
||||||
resourceData.setState(1);
|
resourceData.setState(1);
|
||||||
resourceData.setType(type);
|
resourceData.setType(type);
|
||||||
|
resourceData.setFileName(multipartFile.getOriginalFilename());
|
||||||
return this.save(resourceData);
|
return this.save(resourceData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ResourceData> queryData() {
|
public List<ResourceData> queryData() {
|
||||||
List<ResourceData> list = this.list();
|
List<ResourceData> list = this.list();
|
||||||
@@ -190,46 +190,58 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, ResourceDat
|
|||||||
//return resourceData;
|
//return resourceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String description, String systemType) {
|
public Boolean updateFile(String id, MultipartFile multipartFile, MultipartFile picture, String name, Integer state, Integer type) {
|
||||||
Resinformation resinformation = resourceAdministrationMapper.selectById(id);
|
ResourceData resourceData = resourceMapper.selectById(id);
|
||||||
|
//文件
|
||||||
if (null != multipartFile && !multipartFile.isEmpty()) {
|
if (null != multipartFile && !multipartFile.isEmpty()) {
|
||||||
//删除文件
|
//删除文件
|
||||||
fileStorageUtil.deleteFile(resinformation.getUrl());
|
fileStorageUtil.deleteFile(resourceData.getResUrl());
|
||||||
//获取路径
|
//获取路径
|
||||||
String url = fileStorageUtil.uploadMultipart(multipartFile, OssPath.RESOURCEADMINISTRATION);
|
String resUrl = fileStorageUtil.uploadMultipart(multipartFile, OssPath.RESOURCEDATA);
|
||||||
resinformation.setUrl(url);
|
resourceData.setResUrl(resUrl);
|
||||||
resinformation.setFileName(multipartFile.getOriginalFilename());
|
resourceData.setFileName(multipartFile.getOriginalFilename());
|
||||||
}
|
}
|
||||||
resinformation.setName(name);
|
//图片
|
||||||
resinformation.setDescription(description);
|
if (null != picture && !picture.isEmpty()) {
|
||||||
//获取用户id
|
if (StringUtils.isNotBlank(resourceData.getPicUrl())) {
|
||||||
String userIndex = RequestUtil.getUserIndex();
|
//删除图片
|
||||||
//String userIndex = "123456";
|
fileStorageUtil.deleteFile(resourceData.getResUrl());
|
||||||
resinformation.setUpdateUser(userIndex);
|
|
||||||
resinformation.setUpdateTime(LocalDateTime.now());
|
|
||||||
resinformation.setState(1);
|
|
||||||
if (StringUtils.isNotBlank(systemType)) {
|
|
||||||
resinformation.setSystemType(systemType);
|
|
||||||
}
|
}
|
||||||
resinformation.setType(type);
|
//获取路径
|
||||||
int i = resourceAdministrationMapper.updateById(resinformation);
|
String picUrl = fileStorageUtil.uploadMultipart(picture, OssPath.RESOURCEDATA);
|
||||||
|
resourceData.setPicUrl(picUrl);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(name)) {
|
||||||
|
resourceData.setResourceName(name);
|
||||||
|
}
|
||||||
|
if (null != state) {
|
||||||
|
resourceData.setState(state);
|
||||||
|
}
|
||||||
|
if (null != type) {
|
||||||
|
resourceData.setType(type);
|
||||||
|
}
|
||||||
|
resourceData.setUpdateTime(LocalDateTime.now());
|
||||||
|
int i = resourceMapper.updateById(resourceData);
|
||||||
return i > 0;
|
return i > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteFile(String id) {
|
public Boolean deleteFile(String id) {
|
||||||
Resinformation resinformation = resourceAdministrationMapper.selectById(id);
|
ResourceData resourceData = resourceMapper.selectById(id);
|
||||||
//删除文件
|
//删除文件
|
||||||
fileStorageUtil.deleteFile(resinformation.getUrl());
|
fileStorageUtil.deleteFile(resourceData.getResUrl());
|
||||||
|
//存在图片删除图片
|
||||||
|
if (StringUtils.isNotBlank(resourceData.getPicUrl())){
|
||||||
|
fileStorageUtil.deleteFile(resourceData.getPicUrl());
|
||||||
|
}
|
||||||
//删除数据
|
//删除数据
|
||||||
int i = resourceAdministrationMapper.deleteById(id);
|
int i = resourceMapper.deleteById(id);
|
||||||
return i > 0;
|
return i > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public void exportData() {
|
public void exportData() {
|
||||||
String fileName = "资源列表.csv";
|
String fileName = "资源列表.csv";
|
||||||
|
|||||||
Reference in New Issue
Block a user