|
@@ -6,10 +6,7 @@ import com.fjhx.email.config.base.R;
|
|
|
import com.fjhx.email.config.exception.ServiceException;
|
|
|
import com.fjhx.email.entity.EnterpriseMailbox;
|
|
|
import com.fjhx.email.entity.PersonalMailbox;
|
|
|
-import com.fjhx.email.entity.dto.GetMessagePageDto;
|
|
|
-import com.fjhx.email.entity.dto.MailSyncInfo;
|
|
|
-import com.fjhx.email.entity.dto.MailboxInfo;
|
|
|
-import com.fjhx.email.entity.dto.SendDto;
|
|
|
+import com.fjhx.email.entity.dto.*;
|
|
|
import com.fjhx.email.entity.vo.MessageDetailVo;
|
|
|
import com.fjhx.email.entity.vo.MessageVo;
|
|
|
import com.fjhx.email.service.IEnterpriseMailboxService;
|
|
@@ -23,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.mail.MessagingException;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -49,7 +47,7 @@ public class MailController {
|
|
|
try {
|
|
|
synchronized (this) {
|
|
|
List<Long> onlineUserIdList = HxHttpUtil.getOnlineUserIdList();
|
|
|
- MailSyncInfo.mailboxInfoList = mailService.getMailboxInfoListByUserId(onlineUserIdList);
|
|
|
+ MailSyncInfo.mailboxInfoList = mailService.getMailboxInfoListByUserId(onlineUserIdList, MailSyncInfo.mailType);
|
|
|
}
|
|
|
} catch (IORuntimeException e) {
|
|
|
log.error("获取主服务在线用户超时");
|
|
@@ -70,7 +68,7 @@ public class MailController {
|
|
|
try {
|
|
|
synchronized (this) {
|
|
|
|
|
|
- List<MailboxInfo> mailboxInfoList = mailService.getMailboxInfoListByUserId(Collections.singletonList(userId));
|
|
|
+ List<MailboxInfo> mailboxInfoList = mailService.getMailboxInfoListByUserId(Collections.singletonList(userId), MailSyncInfo.mailType);
|
|
|
|
|
|
if (mailboxInfoList.size() == 0) {
|
|
|
return R.ok();
|
|
@@ -98,7 +96,7 @@ public class MailController {
|
|
|
*/
|
|
|
@GetMapping("/getUserEmailList/{userId}")
|
|
|
public R getUserEmailList(@PathVariable("userId") Long userId) {
|
|
|
- List<MailboxInfo> mailboxInfoList = mailService.getMailboxInfoListByUserId(Collections.singletonList(userId));
|
|
|
+ List<MailboxInfo> mailboxInfoList = mailService.getMailboxInfoListByUserId(Collections.singletonList(userId), null);
|
|
|
|
|
|
// 赋值文件夹未读邮件数量
|
|
|
mailService.setUnreadMessageCount(mailboxInfoList);
|
|
@@ -134,7 +132,7 @@ public class MailController {
|
|
|
SmtpUtil.sendMail(host, user, password, sendDto);
|
|
|
} catch (Exception e) {
|
|
|
log.error("发送邮件失败:", e);
|
|
|
- throw new ServiceException("发送邮件失败");
|
|
|
+ throw new ServiceException("发送邮件失败:{}", e.getMessage());
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -142,7 +140,7 @@ public class MailController {
|
|
|
/**
|
|
|
* 添加企业邮箱
|
|
|
*/
|
|
|
- @PostMapping("addEnterpriseMailbox")
|
|
|
+ @PostMapping("/addEnterpriseMailbox")
|
|
|
public R addEnterpriseMailbox(@RequestBody EnterpriseMailbox enterpriseMailbox) {
|
|
|
enterpriseMailboxService.add(enterpriseMailbox);
|
|
|
userLogin(enterpriseMailbox.getUserId());
|
|
@@ -152,11 +150,23 @@ public class MailController {
|
|
|
/**
|
|
|
* 添加个人邮箱
|
|
|
*/
|
|
|
- @PostMapping("addPersonalMailbox")
|
|
|
+ @PostMapping("/addPersonalMailbox")
|
|
|
public R addPersonalMailbox(@RequestBody PersonalMailbox personalMailbox) {
|
|
|
personalMailboxService.add(personalMailbox);
|
|
|
userLogin(personalMailbox.getUserId());
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/setSeen/{host}/{user}/{password}")
|
|
|
+ public R setSeen(@PathVariable("host") String host, @PathVariable("user") String user,
|
|
|
+ @PathVariable("password") String password, @RequestBody SetSeenDto dto) {
|
|
|
+ try {
|
|
|
+ mailService.setSeen(host, user, password, dto);
|
|
|
+ } catch (MessagingException e) {
|
|
|
+ log.error("设置已读失败:", e);
|
|
|
+ throw new ServiceException("设置已读失败:{}", e.getMessage());
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
}
|