|
|
@@ -2,12 +2,14 @@ package com.goafanti.standard.service.impl;
|
|
|
|
|
|
import com.goafanti.common.dao.StandardDocumentMapper;
|
|
|
import com.goafanti.common.model.StandardDocument;
|
|
|
+import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
import com.goafanti.standard.bo.InputStandardList;
|
|
|
import com.goafanti.standard.bo.OutStandardDocument;
|
|
|
import com.goafanti.standard.service.StandardService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
@@ -17,6 +19,9 @@ import java.util.Map;
|
|
|
public class StandardServiceImpl extends BaseMybatisDao<StandardDocumentMapper> implements StandardService {
|
|
|
@Autowired
|
|
|
private StandardDocumentMapper standardDocumentMapper;
|
|
|
+ @Value("${upload.path}")
|
|
|
+ private String uploadPath;
|
|
|
+
|
|
|
@Override
|
|
|
public Object add(StandardDocument in) {
|
|
|
return standardDocumentMapper.insertSelective(in);
|
|
|
@@ -24,11 +29,23 @@ public class StandardServiceImpl extends BaseMybatisDao<StandardDocumentMapper>
|
|
|
|
|
|
@Override
|
|
|
public Object delete(StandardDocument in) {
|
|
|
- return standardDocumentMapper.deleteByPrimaryKey(Long.valueOf(in.getId()));
|
|
|
+ Long id = Long.valueOf(in.getId());
|
|
|
+ StandardDocument use = standardDocumentMapper.selectByPrimaryKey(id);
|
|
|
+ if (StringUtils.isNotEmpty(in.getUrl())){
|
|
|
+ String filePath = uploadPath + "/" + use.getUrl();
|
|
|
+ com.goafanti.common.utils.excel.FileUtils.deleteFile(filePath);
|
|
|
+ }
|
|
|
+ return standardDocumentMapper.deleteByPrimaryKey(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object update(StandardDocument in) {
|
|
|
+ Long id = Long.valueOf(in.getId());
|
|
|
+ StandardDocument use = standardDocumentMapper.selectByPrimaryKey(id);
|
|
|
+ if (in.getUrl().equals(use.getUrl())&& StringUtils.isNotEmpty(in.getUrl())){
|
|
|
+ String filePath = uploadPath + "/" + use.getUrl();
|
|
|
+ com.goafanti.common.utils.excel.FileUtils.deleteFile(filePath);
|
|
|
+ }
|
|
|
return standardDocumentMapper.updateByPrimaryKeySelective(in);
|
|
|
}
|
|
|
|