浏览代码

修改删除文件的Bug

hyx 2 年之前
父节点
当前提交
c1e220f9a3

+ 3 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/YxnnServiceImpl.java

@@ -94,7 +94,9 @@ public class YxnnServiceImpl implements YxnnService {
         if (Blank.isNotEmpty(impressionNanan.getUrlAddress())) {
             File file = new File(path + "/" + impressionNanan.getUrlAddress());
             //删出对应的文件,以及对应的文件信息
-            file.delete();
+            if(file.exists()){
+                file.delete();
+            }
         }
         if (yxnnDao.deleteDocumentById(id) <= 0) {
             return SendUtil.send(false, ConstStr.DELETEUSER_FAILED, "");

+ 2 - 2
nngkxxdp/src/main/resources/mapper/YxnnDao.xml

@@ -54,7 +54,7 @@
         where id = #{id}
     </select>
 
-    <insert id="updateDocumentById" parameterType="com.example.nngkxxdp.entity.ImpressionNanan">
+    <update id="updateDocumentById" parameterType="com.example.nngkxxdp.entity.ImpressionNanan">
         UPDATE impression_nanan
         SET uploader_phone=#{uploaderPhone},
             upload_time=#{uploadTime},
@@ -64,7 +64,7 @@
             examine_state=#{examineState},
             picture_description=#{pictureDescription}
         WHERE id = #{id}
-    </insert>
+    </update>
 
     <delete id="deleteDocumentById">
         DELETE