|
|
@@ -0,0 +1,77 @@
|
|
|
+package com.storlead.mail.controller.mkt;
|
|
|
+
|
|
|
+import com.storlead.framework.common.result.Result;
|
|
|
+import com.storlead.mail.webclient.client.MktMailFileRemoteClient;
|
|
|
+import com.storlead.mail.webclient.support.MailRemoteResponseWriter;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 营销邮件附件(路径前缀 /mkt/email/file,能力对齐 CRM {@code MaiAttachmentApiController})。
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mkt/email/file")
|
|
|
+@Api(tags = "营销邮件: 附件")
|
|
|
+@Log4j2
|
|
|
+public class MktAttachmentApiController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MktMailFileRemoteClient mktMailFileRemoteClient;
|
|
|
+
|
|
|
+ @PostMapping("/cache_mail_file")
|
|
|
+ @ApiOperation("缓存营销邮件临时附件(scene=MKT)")
|
|
|
+ public Result<?> cacheMailFile(@RequestParam("files") List<MultipartFile> files,
|
|
|
+ @RequestParam("accountId") Long accountId) {
|
|
|
+ return mktMailFileRemoteClient.cacheMailFile(files, accountId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/cache_image_file")
|
|
|
+ @ApiOperation("缓存营销邮件正文图片")
|
|
|
+ public Map<String, Object> cacheImageFile(@RequestParam("upload") MultipartFile file,
|
|
|
+ @RequestParam(value = "accountId", required = false) Long accountId) {
|
|
|
+ return mktMailFileRemoteClient.cacheImageFile(file, accountId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/download_mail_file")
|
|
|
+ @ApiOperation("下载营销临时附件")
|
|
|
+ public void downLoadMailFile(Long fileId, HttpServletResponse response) {
|
|
|
+ MailRemoteResponseWriter.write(response, mktMailFileRemoteClient.downloadTempFile(fileId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/images/{imageName}")
|
|
|
+ public ResponseEntity<byte[]> getImage(@PathVariable String imageName) {
|
|
|
+ return MailRemoteResponseWriter.image(mktMailFileRemoteClient.getImage(imageName));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ @ApiOperation("按邮件查询正式附件(mkt_mail_attachment)")
|
|
|
+ public Result<?> listAttachments(@RequestParam Long mailId) {
|
|
|
+ return mktMailFileRemoteClient.listAttachments(mailId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/download")
|
|
|
+ @ApiOperation("下载营销正式附件")
|
|
|
+ public void downloadFormalFile(@RequestParam Long fileId, HttpServletResponse response) {
|
|
|
+ MailRemoteResponseWriter.write(response, mktMailFileRemoteClient.downloadFormalFile(fileId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/download_temp")
|
|
|
+ @ApiOperation("下载营销临时附件")
|
|
|
+ public void downloadTempFile(@RequestParam Long fileId, HttpServletResponse response) {
|
|
|
+ MailRemoteResponseWriter.write(response, mktMailFileRemoteClient.downloadTempFile(fileId));
|
|
|
+ }
|
|
|
+}
|