|
@@ -135,20 +135,12 @@ public class AttachmentCenterController {
|
|
|
public HttpRespMsg rename(Integer id,String name){
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
AttachmentCenter attachmentCenter = attachmentCenterMapper.selectById(id);
|
|
|
- File file = new File(uploadPath+ attachmentCenter.getAttachmentName());
|
|
|
+ File file = new File(attachmentCenter.getServerName());
|
|
|
if(file.exists()){
|
|
|
- File newFile = new File(uploadPath + name);
|
|
|
- boolean b = file.renameTo(newFile);
|
|
|
- if(b){
|
|
|
- attachmentCenter.setAttachmentName(name);
|
|
|
- attachmentCenter.setServerName(uploadPath+name);
|
|
|
- String pathPrefix = "/upload/";
|
|
|
- attachmentCenter.setUrl(pathPrefix + name);
|
|
|
- attachmentCenterMapper.updateById(attachmentCenter);
|
|
|
- msg.setError("文件重命名成功");
|
|
|
- }else {
|
|
|
- msg.setError("文件重命名失败");
|
|
|
- }
|
|
|
+ attachmentCenter.setAttachmentName(name);
|
|
|
+ String pathPrefix = "/upload/";
|
|
|
+ attachmentCenterMapper.updateById(attachmentCenter);
|
|
|
+ msg.setMsg("文件重命名成功");
|
|
|
}else {
|
|
|
msg.setError("文件不存在");
|
|
|
}
|
|
@@ -159,12 +151,12 @@ public class AttachmentCenterController {
|
|
|
public HttpRespMsg delete(Integer id){
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
AttachmentCenter attachmentCenter = attachmentCenterMapper.selectById(id);
|
|
|
- File file = new File(uploadPath+ attachmentCenter.getAttachmentName());
|
|
|
+ File file = new File(attachmentCenter.getServerName());
|
|
|
if(file.exists()){
|
|
|
boolean delete = file.delete();
|
|
|
if(delete){
|
|
|
attachmentCenterMapper.deleteById(id);
|
|
|
- msg.setError("文件删除成功");
|
|
|
+ msg.setMsg("文件删除成功");
|
|
|
}else {
|
|
|
msg.setError("文件删除失败");
|
|
|
}
|