dyh-service/dyh-sys/src/main/java/cn/huge/module/file/controller/web/FileInfoWebController.java
@@ -100,7 +100,7 @@ FileInfoBaseDTO fileInfoBaseDTO = new FileInfoBaseDTO(); BeanUtils.copyProperties(fileInfo, fileInfoBaseDTO); // 如果是身份证,就采用ocr失败 // 如果是身份证,就调用ocr识别 if (FileOwnerTypeBaseEnum.OWNER_TYPE_202.getIndex().equals(ownerType)){ fileInfoBaseDTO.setIdcardOcrResult(BaiduOcrUtils.ocrIdcard(file.getBytes())); } @@ -220,5 +220,21 @@ } } /** * 删除附件 * @url {ctx}/api/web/fileInfo/deleteFileById?id= * @param id 附件编号 * @return Object */ @GetMapping("/deleteFileById") public Object deleteFileById(@RequestParam(value = "id") String id) { try { service.deleteFileById(id); return ReturnSucUtils.getRepInfo(); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } } dyh-service/dyh-sys/src/main/java/cn/huge/module/file/controller/wechat/FileInfoWechatController.java
@@ -18,6 +18,7 @@ import cn.huge.module.sys.constant.FileBaseConsts; import cn.huge.module.sys.constant.FileOwnerTypeBaseEnum; import cn.huge.module.sys.dto.FileInfoBaseDTO; import cn.huge.module.utils.BaiduOcrUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -96,6 +97,12 @@ FileInfo fileInfo = service.wechatUploadFile(file, mainId, ownerId, ownerType, fileCount, uploaderDTO); FileInfoBaseDTO fileInfoBaseDTO = new FileInfoBaseDTO(); BeanUtils.copyProperties(fileInfo, fileInfoBaseDTO); // 如果是身份证,就调用ocr识别 if (FileOwnerTypeBaseEnum.OWNER_TYPE_202.getIndex().equals(ownerType)){ fileInfoBaseDTO.setIdcardOcrResult(BaiduOcrUtils.ocrIdcard(file.getBytes())); } files.add(fileInfoBaseDTO); fileCount++; } else { @@ -175,6 +182,22 @@ } } /** * 删除附件 * @url {ctx}/api/wechat/fileInfo/deleteFileById?id= * @param id 附件编号 * @return Object */ @GetMapping("/deleteFileById") public Object deleteFileById(@RequestParam(value = "id") String id) { try { service.deleteFileById(id); return ReturnSucUtils.getRepInfo(); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } dyh-service/dyh-sys/src/main/java/cn/huge/module/file/service/FileInfoService.java
@@ -11,9 +11,11 @@ import cn.huge.module.file.domain.dto.FileForCatListDTO; import cn.huge.module.file.domain.dto.UploaderDTO; import cn.huge.module.file.domain.po.FileInfo; import cn.huge.module.file.domain.po.FileRelate; import cn.huge.module.file.utils.FtpUtils; import cn.huge.module.file.utils.FtpMultipartFileWrapper; import cn.huge.module.sys.constant.FileOwnerTypeBaseEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -252,4 +254,23 @@ return fileForCatListDTOList; } /** * 根据编号删除附件 * @param id 附件编号 */ public void deleteFileById(String id) { try{ // 删除关系表 QueryWrapper<FileRelate> fileRelateQueryWrapper = new QueryWrapper<>(); fileRelateQueryWrapper.eq("file_id", id); fileRelateService.remove(fileRelateQueryWrapper); // 删除附件信息表 mapper.deleteById(id); // 删除ftp文件 }catch (Exception e){ log.error("service方法[FileInfoService.deleteFileById]调用失败,异常信息:"+e, e); throw new ServiceException("FileInfoService.deleteFileById", e); } } }