Jelajahi Sumber

文件异常处理

车车 7 bulan lalu
induk
melakukan
41f3091ff1

+ 9 - 0
ktg-admin/src/main/java/com/ktg/web/controller/system/SysUserCharacteristicController.java

@@ -118,6 +118,15 @@ public class SysUserCharacteristicController extends BaseController
         return CommonResult.success(sysUserCharacteristicService.deleteSysUserCharacteristicByRecordIds(recordIds));
     }
 
+    @ApiOperation("删除用户特征(指纹、面部)")
+    @PreAuthorize("@ss.hasPermi('iscs:characteristic:remove')")
+    @Log(title = "用户特征(指纹、面部)", businessType = BusinessType.DELETE)
+    @GetMapping("/removeSysUserCharacteristicByRecordIds")
+    public CommonResult<Boolean> removeSysUserCharacteristicByRecordIds(String recordIds)
+    {
+        return CommonResult.success(sysUserCharacteristicService.deleteSysUserCharacteristicByRecordIds(recordIds));
+    }
+
     @ApiOperation("新增人脸录入-人脸识别后裁剪存储")
     // @PreAuthorize("@ss.hasPermi('iscs:characteristic:add')")
     @Log(title = "新增人脸录入-人脸识别后裁剪存储", businessType = BusinessType.INSERT)

+ 11 - 7
ktg-system/src/main/java/com/ktg/system/service/impl/SysUserCharacteristicServiceImpl.java

@@ -182,13 +182,17 @@ public class SysUserCharacteristicServiceImpl extends ServiceImpl<SysUserCharact
         List<SysUserCharacteristic> sysUserCharacteristics = listByIds(list);
         for (SysUserCharacteristic sysUserCharacteristic : sysUserCharacteristics) {
             if (StringUtils.isNotBlank(sysUserCharacteristic.getContent())) {
-                File file = new File(sysUserCharacteristic.getContent());
-                if (!file.delete()) {
-                    log.error("DAT文件删除失败: " + sysUserCharacteristic.getContent());
-                }
-                File file1 = new File(sysUserCharacteristic.getImagePath());
-                if (!file1.delete()) {
-                    log.error("img文件删除失败: " + sysUserCharacteristic.getImagePath());
+                try {
+                    File file = new File(sysUserCharacteristic.getContent());
+                    if (!file.delete()) {
+                        log.error("DAT文件删除失败: " + sysUserCharacteristic.getContent());
+                    }
+                    File file1 = new File(sysUserCharacteristic.getImagePath());
+                    if (!file1.delete()) {
+                        log.error("img文件删除失败: " + sysUserCharacteristic.getImagePath());
+                    }
+                } catch (Exception e) {
+                    log.error("存在异常文件:{}", e);
                 }
             }
         }