diff --git a/src/main/java/cn/com/tenlion/systemoa/controller/app/api/mail/MailAppController.java b/src/main/java/cn/com/tenlion/systemoa/controller/app/api/mail/MailAppController.java index 5a83fd4..2b9022b 100644 --- a/src/main/java/cn/com/tenlion/systemoa/controller/app/api/mail/MailAppController.java +++ b/src/main/java/cn/com/tenlion/systemoa/controller/app/api/mail/MailAppController.java @@ -31,6 +31,33 @@ public class MailAppController extends DefaultBaseController { @Autowired private IMailService mailService; + @ApiOperation(value = "保存邮件已读状态", notes = "保存邮件已读状态") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header"), + @ApiImplicitParam(name = "id", value = "邮件ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("save-app-mail-read-tag/{id}") + public SuccessResult saveAppMailReadTag(@RequestHeader("token") String token, + @PathVariable("id") String id){ + Map params = requestParams(); + params.put("id", id); + mailService.saveAppMailReadTag(token, params); + return new SuccessResult(); + } + + @ApiOperation(value = "用户未读邮件数量", notes = "用户未读邮件数量") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("get-app-user-unread-mail") + public Integer getAppUserUnreadMail(@RequestHeader("token") String token){ + Map params = requestParams(); + Integer unreadCounts = mailService.getAppUserUnreadMail(token, params); + return unreadCounts; + } + @ApiOperation(value = "批量发送内部邮件接口", notes = "批量发送内部邮件接口") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", paramType = "header") @@ -51,7 +78,7 @@ public class MailAppController extends DefaultBaseController { @ApiImplicitParam(name = "keywords", value = "标题|收件人姓名", paramType = "query", dataType = "String") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("list-page-app=send-mail") + @GetMapping("list-page-app-send-mail") public SuccessResultList> listPageAppSendMail(@RequestHeader("token") String token, ListPage page) { Map params = requestParams(); page.setParams(params); @@ -63,7 +90,7 @@ public class MailAppController extends DefaultBaseController { @ApiImplicitParam(name = "token", value = "token", paramType = "header") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("get-app=send-mail/{mailId}") + @GetMapping("get-app-send-mail/{mailId}") public MailSendDTO getAppSendMail(@RequestHeader("token") String token, @PathVariable("mailId") String mailId){ Map params = requestParams(); @@ -79,7 +106,7 @@ public class MailAppController extends DefaultBaseController { @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("list-page-app=inbox-mail") + @GetMapping("list-page-app-inbox-mail") public SuccessResultList> listPageAppInboxMail(@RequestHeader("token") String token, ListPage page) { Map params = requestParams(); page.setParams(params); @@ -92,7 +119,7 @@ public class MailAppController extends DefaultBaseController { @ApiImplicitParam(name = "token", value = "token", paramType = "header") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("get-app=inbox-mail/{id}") + @GetMapping("get-app-inbox-mail/{id}") public MailInboxDTO getAppInboxMail(@RequestHeader("token") String token, @PathVariable("id") String id){ Map params = requestParams(); @@ -123,7 +150,7 @@ public class MailAppController extends DefaultBaseController { @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("list-page-app=draft-mail") + @GetMapping("list-page-app-draft-mail") public SuccessResultList> listPageAppDraftMail(@RequestHeader("token") String token, ListPage page) { Map params = requestParams(); page.setParams(params); @@ -135,7 +162,7 @@ public class MailAppController extends DefaultBaseController { @ApiImplicitParam(name = "token", value = "token", paramType = "header") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("get-app=draft-mail/{mailId}") + @GetMapping("get-app-draft-mail/{mailId}") public MailSendDTO getAppDraftMail(@RequestHeader("token") String token, @PathVariable("mailId") String mailId){ Map params = requestParams(); @@ -179,7 +206,7 @@ public class MailAppController extends DefaultBaseController { @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("list-page-app=del-mail") + @GetMapping("list-page-app-del-mail") public SuccessResultList> listPageAppDelMail(@RequestHeader("token") String token, ListPage page) { Map params = requestParams(); page.setParams(params); @@ -192,7 +219,7 @@ public class MailAppController extends DefaultBaseController { @ApiImplicitParam(name = "id", value = "Id值", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("get-app=del-mail/{id}") + @GetMapping("get-app-del-mail/{id}") public MailDelDTO getAppDelMail(@RequestHeader("token") String token, @PathVariable("id") String id){ Map params = requestParams(); diff --git a/src/main/java/cn/com/tenlion/systemoa/dao/mail/IMailDao.java b/src/main/java/cn/com/tenlion/systemoa/dao/mail/IMailDao.java index 4c4d834..7ad271b 100644 --- a/src/main/java/cn/com/tenlion/systemoa/dao/mail/IMailDao.java +++ b/src/main/java/cn/com/tenlion/systemoa/dao/mail/IMailDao.java @@ -51,4 +51,8 @@ public interface IMailDao { void deleteDelMail(String ids); void deleteAppDelMailAll(Map query); + + void saveMailReadTag(Map saveMap); + + Map getUserMailReadTag(Map params); } diff --git a/src/main/java/cn/com/tenlion/systemoa/pojo/dtos/mail/MailInboxDTO.java b/src/main/java/cn/com/tenlion/systemoa/pojo/dtos/mail/MailInboxDTO.java index f627510..9763b8c 100644 --- a/src/main/java/cn/com/tenlion/systemoa/pojo/dtos/mail/MailInboxDTO.java +++ b/src/main/java/cn/com/tenlion/systemoa/pojo/dtos/mail/MailInboxDTO.java @@ -2,6 +2,7 @@ package cn.com.tenlion.systemoa.pojo.dtos.mail; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; import lombok.Data; import lombok.ToString; @@ -49,4 +50,9 @@ public class MailInboxDTO { private String secretTypes; @ApiModelProperty(name = "creatorNames", value = "发件人姓名") private String creatorNames; + @ApiModelProperty(name = "readTag", value = "阅读状态0未读1已读") + private Integer readTag; + @ApiModelProperty(name = "readTime", value = "阅读时间") + private String readTime; + } diff --git a/src/main/java/cn/com/tenlion/systemoa/service/mail/IMailService.java b/src/main/java/cn/com/tenlion/systemoa/service/mail/IMailService.java index 041f2fb..a67d079 100644 --- a/src/main/java/cn/com/tenlion/systemoa/service/mail/IMailService.java +++ b/src/main/java/cn/com/tenlion/systemoa/service/mail/IMailService.java @@ -100,4 +100,8 @@ public interface IMailService { void deleteAppDraftMail(String token, String ids); void deleteAppDelMailAll(String token); + + Integer getAppUserUnreadMail(String token, Map params); + + void saveAppMailReadTag(String token, Map params); } diff --git a/src/main/java/cn/com/tenlion/systemoa/service/mail/impl/MailServiceImpl.java b/src/main/java/cn/com/tenlion/systemoa/service/mail/impl/MailServiceImpl.java index d3869fc..a020a90 100644 --- a/src/main/java/cn/com/tenlion/systemoa/service/mail/impl/MailServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemoa/service/mail/impl/MailServiceImpl.java @@ -43,6 +43,28 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService @Autowired private IUserService userService; + @Override + public void saveAppMailReadTag(String token, Map params) { + AppTokenUser appTokenUser = getAppTokenUser(token); + String id = params.get("id").toString(); + Map saveMap = new HashMap<>(8); + saveMap.put("id", id); + saveMap.put("userId", appTokenUser.getId()); + saveMap.put("readTime", DateUtil.getTime()); + mailDao.saveMailReadTag(saveMap); + } + + @Override + public Integer getAppUserUnreadMail(String token, Map params) { + AppTokenUser appTokenUser = getAppTokenUser(token); + if(appTokenUser == null || "".equals(appTokenUser.getId())){ + return 0; + } + params.clear(); + params.put("userId", appTokenUser.getId()); + List list = mailDao.listInboxMail(params); + return list == null ? 0 : list.size(); + } @Override public void saveSendMail(MailSendVO vo) { @@ -146,44 +168,46 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService params.put("userId", appTokenUser.getId()); PageHelper.startPage(page.getPage(), page.getRows()); List list = mailDao.listInboxMail(params); - // 处理发件人 for (MailInboxDTO item : list){ + // 处理发件人 String creatorId = item.getCreator(); UserDTO userDTO = userService.get(creatorId); String creatorNames = userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]"; item.setCreatorNames(creatorNames); - } - // 处理抄送情况 - for(MailInboxDTO item : list){ - if(item.getCopyForIds() == null || "".equals(item.getCopyForIds())){ - continue; - } - String[] copyForIds = item.getCopyForIds().split(","); - for (String str : copyForIds){ - if(str.equals(appTokenUser.getId())){ - item.setCopyForTypes("1"); - continue; + // 处理抄送情况 + if(item.getCopyForIds() != null && !"".equals(item.getCopyForIds())){ + String[] copyForIds = item.getCopyForIds().split(","); + for (String str : copyForIds){ + if(str.equals(appTokenUser.getId())){ + item.setCopyForTypes("1"); + continue; + } } } - } - // 处理密送情况 - for(MailInboxDTO item : list){ - if(item.getSecretIds() == null || "".equals(item.getSecretIds())){ - continue; - } - String[] secretIds = item.getSecretIds().split(","); - for (String str : secretIds){ - String tempId = ""; - String tempName = ""; - if(str.equals(appTokenUser.getId())){ - tempId = str; - tempName = appTokenUser.getUsername() + "[" + appTokenUser.getName() + "]"; - item.setSecretIds(tempId); - item.setSecretNames(tempName); - item.setSecretTypes("1"); - continue; + // 处理密送情况 + if(item.getSecretIds() != null && !"".equals(item.getSecretIds())){ + String[] secretIds = item.getSecretIds().split(","); + for (String str : secretIds){ + String tempId = ""; + String tempName = ""; + if(str.equals(appTokenUser.getId())){ + tempId = str; + tempName = appTokenUser.getUsername() + "[" + appTokenUser.getName() + "]"; + item.setSecretIds(tempId); + item.setSecretNames(tempName); + item.setSecretTypes("1"); + continue; + } } } + // 处理阅读状态 + params.put("id", item.getId()); + Map readTagMap = mailDao.getUserMailReadTag(params); + item.setReadTag(0); + if(readTagMap != null){ + item.setReadTag(1); + item.setReadTime(readTagMap.get("readTime").toString()); + } } PageInfo pageInfo = new PageInfo<>(list); return new SuccessResultList<>(list, pageInfo.getPageNum(), pageInfo.getTotal()); diff --git a/src/main/resources/mybatis/mapper/mail/mail-mapper.xml b/src/main/resources/mybatis/mapper/mail/mail-mapper.xml index aa6c0b8..fb14d41 100644 --- a/src/main/resources/mybatis/mapper/mail/mail-mapper.xml +++ b/src/main/resources/mybatis/mapper/mail/mail-mapper.xml @@ -60,6 +60,29 @@ + + + INSERT INTO oa_mail_read_tag ( + id, user_id, read_time + ) VALUES ( + #{id}, #{userId}, #{readTime} + ) + + + + + INSERT INTO oa_mail_send(