|
@@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.hssx.pcbms.entity.TaskFile;
|
|
|
import com.hssx.pcbms.mapper.TaskFileMapper;
|
|
|
+import com.hssx.pcbms.mapper.UserMapper;
|
|
|
import com.hssx.pcbms.service.TaskFileService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.hssx.pcbms.util.HttpRespMsg;
|
|
@@ -32,8 +33,10 @@ public class TaskFileServiceImpl extends ServiceImpl<TaskFileMapper, TaskFile> i
|
|
|
private TaskFileMapper taskFileMapper;
|
|
|
@Value("${upload.path}")
|
|
|
private String path;
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
@Override
|
|
|
- public HttpRespMsg updateFile(MultipartFile file, String taskId) {
|
|
|
+ public HttpRespMsg updateFile(MultipartFile file,TaskFile taskFile) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String filePath = "";
|
|
|
if (file != null) {
|
|
@@ -43,10 +46,10 @@ public class TaskFileServiceImpl extends ServiceImpl<TaskFileMapper, TaskFile> i
|
|
|
msg.setError("上传图片失败了");
|
|
|
return msg;
|
|
|
}
|
|
|
- TaskFile taskFile = new TaskFile();
|
|
|
+ taskFile.setUploader(userMapper.selectById(taskFile.getUploaderId()).getName());
|
|
|
taskFile.setName(file.getOriginalFilename());
|
|
|
taskFile.setUrl(filePath);
|
|
|
- taskFile.setTaskId(taskId);
|
|
|
+ taskFile.setTaskId(taskFile.getTaskId());
|
|
|
taskFileMapper.insert(taskFile);
|
|
|
msg.data = filePath;
|
|
|
return msg;
|
|
@@ -61,4 +64,16 @@ public class TaskFileServiceImpl extends ServiceImpl<TaskFileMapper, TaskFile> i
|
|
|
msg.data = info;
|
|
|
return msg;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg delById(TaskFile taskFile) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ TaskFile oldtaskFile = taskFileMapper.selectById(taskFile.getId());
|
|
|
+ if(taskFile.getUploaderId().equals(oldtaskFile.getUploaderId())){
|
|
|
+ taskFileMapper.deleteById(oldtaskFile.getId());
|
|
|
+ }else{
|
|
|
+ msg.setError("您不具备删除该文件的");
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}
|