|
@@ -1,14 +1,13 @@
|
|
|
package com.ruoyi.project.pssr.service.impl;
|
|
|
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
+import com.ruoyi.project.pssr.domain.TPssrFile;
|
|
|
+import com.ruoyi.project.pssr.mapper.TPssrFileMapper;
|
|
|
+import com.ruoyi.project.pssr.service.ITPssrFileService;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.ruoyi.project.pssr.mapper.TPssrFileMapper;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrFile;
|
|
|
-import com.ruoyi.project.pssr.service.ITPssrFileService;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* PSSR附件Service业务层处理
|
|
@@ -17,8 +16,7 @@ import com.ruoyi.project.pssr.service.ITPssrFileService;
|
|
|
* @date 2024-10-30
|
|
|
*/
|
|
|
@Service
|
|
|
-public class TPssrFileServiceImpl implements ITPssrFileService
|
|
|
-{
|
|
|
+public class TPssrFileServiceImpl implements ITPssrFileService {
|
|
|
@Autowired
|
|
|
private TPssrFileMapper tPssrFileMapper;
|
|
|
|
|
@@ -29,8 +27,7 @@ public class TPssrFileServiceImpl implements ITPssrFileService
|
|
|
* @return PSSR附件
|
|
|
*/
|
|
|
@Override
|
|
|
- public TPssrFile selectTPssrFileById(Long fileId)
|
|
|
- {
|
|
|
+ public TPssrFile selectTPssrFileById(Long fileId) {
|
|
|
return tPssrFileMapper.selectTPssrFileById(fileId);
|
|
|
}
|
|
|
|
|
@@ -41,8 +38,7 @@ public class TPssrFileServiceImpl implements ITPssrFileService
|
|
|
* @return PSSR附件
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<TPssrFile> selectTPssrFileList(TPssrFile tPssrFile)
|
|
|
- {
|
|
|
+ public List<TPssrFile> selectTPssrFileList(TPssrFile tPssrFile) {
|
|
|
return tPssrFileMapper.selectTPssrFileList(tPssrFile);
|
|
|
}
|
|
|
|
|
@@ -62,8 +58,7 @@ public class TPssrFileServiceImpl implements ITPssrFileService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertTPssrFile(TPssrFile tPssrFile)
|
|
|
- {
|
|
|
+ public int insertTPssrFile(TPssrFile tPssrFile) {
|
|
|
return tPssrFileMapper.insertTPssrFile(tPssrFile);
|
|
|
}
|
|
|
|
|
@@ -74,8 +69,7 @@ public class TPssrFileServiceImpl implements ITPssrFileService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateTPssrFile(TPssrFile tPssrFile)
|
|
|
- {
|
|
|
+ public int updateTPssrFile(TPssrFile tPssrFile) {
|
|
|
return tPssrFileMapper.updateTPssrFile(tPssrFile);
|
|
|
}
|
|
|
|
|
@@ -86,8 +80,7 @@ public class TPssrFileServiceImpl implements ITPssrFileService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteTPssrFileByIds(Long[] fileIds)
|
|
|
- {
|
|
|
+ public int deleteTPssrFileByIds(Long[] fileIds) {
|
|
|
return tPssrFileMapper.deleteTPssrFileByIds(fileIds);
|
|
|
}
|
|
|
|
|
@@ -98,16 +91,16 @@ public class TPssrFileServiceImpl implements ITPssrFileService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteTPssrFileById(Long fileId)
|
|
|
- {
|
|
|
+ public int deleteTPssrFileById(Long fileId) {
|
|
|
return tPssrFileMapper.deleteTPssrFileById(fileId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateFileRelevance(List<Long> fileIds, String forShort, Long itemId,Long subId) {
|
|
|
- if(!CollectionUtils.isNotEmpty(fileIds)){
|
|
|
+ public void updateFileRelevance(List<Long> fileIds, String forShort, Long itemId, Long subId) {
|
|
|
+ if (!CollectionUtils.isNotEmpty(fileIds)) {
|
|
|
return;
|
|
|
}
|
|
|
+ // 更新附件信息
|
|
|
for (Long fileId : fileIds) {
|
|
|
TPssrFile pssrFile = new TPssrFile();
|
|
|
pssrFile.setSubId(subId);
|
|
@@ -116,5 +109,15 @@ public class TPssrFileServiceImpl implements ITPssrFileService
|
|
|
pssrFile.setFileId(fileId);
|
|
|
tPssrFileMapper.updateTPssrFile(pssrFile);
|
|
|
}
|
|
|
+ // 如果已有附件不属于当前id集合中,删除
|
|
|
+ TPssrFile query = new TPssrFile();
|
|
|
+ query.setSubId(subId);
|
|
|
+ query.setItemId(itemId);
|
|
|
+ query.setForShort(forShort);
|
|
|
+ for (TPssrFile exist : tPssrFileMapper.selectTPssrFileList(query)) {
|
|
|
+ if (!fileIds.contains(exist.getFileId())){
|
|
|
+ tPssrFileMapper.deleteTPssrFileById(exist.getFileId());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|