|
@@ -8,11 +8,15 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.tofly.common.core.entity.ResultRespone;
|
|
|
import com.tofly.common.log.annotation.ToFlyAppLog;
|
|
|
+import com.tofly.fees.common.Ftp.FtpConfig;
|
|
|
+import com.tofly.fees.common.Ftp.FtpService;
|
|
|
import com.tofly.fees.wechatofficalacctmgt.entity.WxGhsq;
|
|
|
import com.tofly.fees.wechatofficalacctmgt.service.WxGhsqService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.net.ftp.FTP;
|
|
|
import org.apache.commons.net.ftp.FTPClient;
|
|
|
+import org.apache.commons.net.ftp.FTPReply;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -25,6 +29,9 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
* 微信-更名过户申请
|
|
@@ -33,13 +40,26 @@ import java.util.Arrays;
|
|
|
* @date Thu Jul 06 00:00:00 CST 2023
|
|
|
*/
|
|
|
@RestController
|
|
|
-@AllArgsConstructor
|
|
|
+
|
|
|
@RequestMapping("/api/wechatofficalacctmgt/wxghsq")
|
|
|
@Api(tags="微信-更名过户申请接口")
|
|
|
public class WxGhsqController {
|
|
|
|
|
|
- private final WxGhsqService wxGhsqService;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+@Autowired
|
|
|
+private WxGhsqService wxGhsqService;
|
|
|
+
|
|
|
+
|
|
|
+ @Value("${ftp.server}")
|
|
|
+ private String server;
|
|
|
+ @Value("${ftp.port}")
|
|
|
+ private int port;
|
|
|
+ @Value("${ftp.userName}")
|
|
|
+ private String userName;
|
|
|
+ @Value("${ftp.password}")
|
|
|
+ private String password;
|
|
|
|
|
|
* 分页查询
|
|
|
* @param page 分页对象
|
|
@@ -54,6 +74,45 @@ public class WxGhsqController {
|
|
|
|
|
|
|
|
|
|
|
|
+ @PostMapping("/upload")
|
|
|
+ @ApiOperation(value = "附件上传")
|
|
|
+ public ResultRespone uploadFile(@RequestParam("file") MultipartFile file) {
|
|
|
+ FTPClient ftpClient = new FTPClient();
|
|
|
+ try {
|
|
|
+ ftpClient.setControlEncoding("UTF-8");
|
|
|
+
|
|
|
+ FtpConfig ftp=new FtpConfig();
|
|
|
+
|
|
|
+ ftpClient.connect("192.168.2.233", 21);
|
|
|
+ ftpClient.login("ftpuser", "ftpuser");
|
|
|
+
|
|
|
+
|
|
|
+ int replyCode = ftpClient.getReplyCode();
|
|
|
+ if (!FTPReply.isPositiveCompletion(replyCode)) {
|
|
|
+ return ResultRespone.failed("FTP连接失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String remoteFilePath = "/ftppath";
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ String remoteFileName = remoteFilePath + "/" + fileName;
|
|
|
+
|
|
|
+ InputStream inputStream = file.getInputStream();
|
|
|
+ ftpClient.storeFile(remoteFileName, inputStream);
|
|
|
+ inputStream.close();
|
|
|
+
|
|
|
+ ftpClient.logout();
|
|
|
+ ftpClient.disconnect();
|
|
|
+ return ResultRespone.success("上传成功");
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return ResultRespone.failed("上传失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
* 通过id查询微信-更名过户申请
|
|
|
* @param id id
|