添加日志

Former-commit-id: 2989c4a1ef6d87cfdc08dbc650bf734eda9d2321
This commit is contained in:
zengwei 2021-03-31 09:32:20 +08:00
parent 5fe5389a65
commit 53f2ff7ff7
1 changed files with 9 additions and 2 deletions

View File

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