diff --git a/share-api/src/main/java/com/xjy/ai/api/controller/sys/BusiAttachmentsController.java b/share-api/src/main/java/com/xjy/ai/api/controller/sys/BusiAttachmentsController.java index 68e4295..4955078 100644 --- a/share-api/src/main/java/com/xjy/ai/api/controller/sys/BusiAttachmentsController.java +++ b/share-api/src/main/java/com/xjy/ai/api/controller/sys/BusiAttachmentsController.java @@ -7,6 +7,8 @@ import com.xjy.ai.common.utils.FtpFileUtil; import com.xjy.ai.model.dao.sys.entity.BusiAttachments; import com.xjy.ai.model.service.sys.BusiAttachmentsService; import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -36,6 +38,8 @@ public class BusiAttachmentsController { @Autowired private BusiAttachmentsService busiAttachmentsService; + private static final Logger logger = LoggerFactory.getLogger(FtpFileUtil.class); + @ApiOperation("上传文件") @RequestMapping(value = "/upload", method = RequestMethod.POST) public ResponseData upload(MultipartFile file) throws IOException { @@ -50,6 +54,7 @@ public class BusiAttachmentsController { tempOS.write(file.getBytes()); Boolean result = ftpFileUtil.uploadFile(tempFile); if (!result) { + logger.info("附件上传失败"); return DataPacketUtil.errorJsonResult(Constants.UPLOAD_FILE + Constants.FAIL_MSG); } @@ -69,7 +74,8 @@ public class BusiAttachmentsController { } busiAttachment.setFileViewUrl(ftpFileUtil.getFileMap().get("url").toString()); - if (!result || busiAttachmentsService.insert(busiAttachment) < 1) { + if (busiAttachmentsService.insert(busiAttachment) < 1) { + logger.info("附件保存失败"); return DataPacketUtil.errorJsonResult(Constants.UPLOAD_FILE + Constants.FAIL_MSG); } @@ -77,7 +83,8 @@ public class BusiAttachmentsController { busiAttachmentsService.getLastBusiAttachement(), Constants.UPLOAD_FILE + Constants.SUCCESS_MSG ); } catch (Exception e){ - System.out.print(e); + logger.info(e.getMessage()); + e.printStackTrace(); return DataPacketUtil.errorJsonResult(Constants.UPLOAD_FILE + Constants.FAIL_MSG); } finally { tempFile.delete();