From ca45754a14606973f06b56b4003fc891831f06e8 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期六, 29 二月 2020 16:29:54 +0800
Subject: [PATCH] 优化审核功能
---
CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java | 41 ++++++++++++++++++++++++++++++++++++-----
1 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java b/CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java
index 838f775..d8a907f 100644
--- a/CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java
+++ b/CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java
@@ -1,14 +1,17 @@
package com.java110.common.smo.impl;
import com.java110.common.dao.IFileServiceDao;
+import com.java110.config.properties.code.Java110Properties;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.core.smo.file.IFileInnerServiceSMO;
import com.java110.dto.file.FileDto;
-import com.java110.utils.util.BeanConvertUtil;
+import com.java110.core.client.FtpUploadTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
+import sun.misc.BASE64Encoder;
+import java.util.ArrayList;
import java.util.List;
@RestController
@@ -17,17 +20,45 @@
@Autowired
private IFileServiceDao fileServiceDaoImpl;
+ @Autowired
+ private Java110Properties java110Properties;
+
+ @Autowired
+ private FtpUploadTemplate ftpUploadTemplate;
+
+
@Override
- public int saveFile(@RequestBody FileDto fileDto) {
+ public String saveFile(@RequestBody FileDto fileDto) {
- int saveFileFlag = fileServiceDaoImpl.saveFile(BeanConvertUtil.beanCovertMap(fileDto));
+ //int saveFileFlag = fileServiceDaoImpl.saveFile(BeanConvertUtil.beanCovertMap(fileDto));
- return saveFileFlag;
+
+ String fileName = ftpUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(),
+ java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
+ java110Properties.getFtpUserPassword(), java110Properties.getFtpPath());
+
+ return fileName;
}
@Override
public List<FileDto> queryFiles(@RequestBody FileDto fileDto) {
- return BeanConvertUtil.covertBeanList(fileServiceDaoImpl.getFiles(BeanConvertUtil.beanCovertMap(fileDto)), FileDto.class);
+ //return BeanConvertUtil.covertBeanList(fileServiceDaoImpl.getFiles(BeanConvertUtil.beanCovertMap(fileDto)), FileDto.class);
+ List<FileDto> fileDtos = new ArrayList<>();
+ String fileName = fileDto.getFileSaveName();
+ String ftpPath = java110Properties.getFtpPath();
+ if (fileName.contains("/")) {
+ ftpPath += fileName.substring(0, fileName.lastIndexOf("/")+1);
+ fileName = fileName.substring(fileName.lastIndexOf("/")+1, fileName.length());
+ }
+ byte[] fileImg = ftpUploadTemplate.downFileByte(ftpPath, fileName, java110Properties.getFtpServer(),
+ java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
+ java110Properties.getFtpUserPassword());
+
+ String context = new BASE64Encoder().encode(fileImg);
+
+ fileDto.setContext(context);
+ fileDtos.add(fileDto);
+ return fileDtos;
}
public IFileServiceDao getFileServiceDaoImpl() {
--
Gitblit v1.8.0