Browse Source

新增、修改、删除、列表、详情、上传标准文件接口新增

anderx 1 year ago
parent
commit
184bb4fbc2

+ 18 - 1
src/main/java/com/goafanti/standard/service/impl/StandardServiceImpl.java

@@ -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);
     }
 

+ 3 - 3
src/main/resources/props/config_local.properties

@@ -1,8 +1,8 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
 
-static.host=//static.jishutao.com/1.3.14
-#static.host=//172.16.1.187/1.3.14
+#static.host=//static.jishutao.com/1.3.14
+static.host=//172.16.1.187/1.3.14
 
 #jdbc.url=jdbc\:mysql://localhost:3306/aft20240430?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
@@ -56,7 +56,7 @@ yxjl_max=100
 amb.maxLvl=6
 
 
-avatar.host=//172.16.0.255:3000
+avatar.host=//172.16.1.199:3000
 #static.host=//172.16.0.255:3000/1.2.62
 #avatar.host=//static.jishutao.com
 rd.static.host=//static.jishutao.com/RD/1.0.03