|
@@ -1,12 +1,19 @@
|
|
package com.fjhx.service.impl;
|
|
package com.fjhx.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.fjhx.config.TaskPoolConfig;
|
|
|
|
+import com.fjhx.config.exception.ServiceException;
|
|
import com.fjhx.entity.EmailMessageAttachment;
|
|
import com.fjhx.entity.EmailMessageAttachment;
|
|
import com.fjhx.mapper.EmailMessageAttachmentMapper;
|
|
import com.fjhx.mapper.EmailMessageAttachmentMapper;
|
|
import com.fjhx.service.IEmailMessageAttachmentService;
|
|
import com.fjhx.service.IEmailMessageAttachmentService;
|
|
|
|
+import com.fjhx.utils.EmailEngineUtil;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.io.FileNotFoundException;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.concurrent.Executor;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -19,9 +26,28 @@ import java.util.List;
|
|
@Service
|
|
@Service
|
|
public class EmailMessageAttachmentServiceImpl extends ServiceImpl<EmailMessageAttachmentMapper, EmailMessageAttachment> implements IEmailMessageAttachmentService {
|
|
public class EmailMessageAttachmentServiceImpl extends ServiceImpl<EmailMessageAttachmentMapper, EmailMessageAttachment> implements IEmailMessageAttachmentService {
|
|
|
|
|
|
|
|
+ @Qualifier(TaskPoolConfig.EXECUTOR)
|
|
|
|
+ @Autowired
|
|
|
|
+ private Executor syncExecutor;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<EmailMessageAttachment> getAttachmentList(String messageId) {
|
|
public List<EmailMessageAttachment> getAttachmentList(String messageId) {
|
|
return list(q -> q.eq(EmailMessageAttachment::getMessageId, messageId));
|
|
return list(q -> q.eq(EmailMessageAttachment::getMessageId, messageId));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void downloadAttachment(String email, String attachmentId, String path) {
|
|
|
|
+ try {
|
|
|
|
+ EmailEngineUtil.downloadAttachment(email, attachmentId, path);
|
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
|
+ throw new ServiceException("下载附件失败");
|
|
|
|
+ }
|
|
|
|
+ syncExecutor.execute(() -> {
|
|
|
|
+ EmailMessageAttachment attachment = new EmailMessageAttachment();
|
|
|
|
+ attachment.setAttachmentId(attachmentId);
|
|
|
|
+ attachment.setIsDownload(true);
|
|
|
|
+ updateById(attachment);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|