添加收件箱阅读状态相关

This commit is contained in:
wans 2022-04-29 15:09:32 +08:00
parent a261de6841
commit 060dbeb4cd
6 changed files with 125 additions and 37 deletions

View File

@ -31,6 +31,33 @@ public class MailAppController extends DefaultBaseController {
@Autowired @Autowired
private IMailService mailService; 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<String, Object> 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<String, Object> params = requestParams();
Integer unreadCounts = mailService.getAppUserUnreadMail(token, params);
return unreadCounts;
}
@ApiOperation(value = "批量发送内部邮件接口", notes = "批量发送内部邮件接口") @ApiOperation(value = "批量发送内部邮件接口", notes = "批量发送内部邮件接口")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header") @ApiImplicitParam(name = "token", value = "token", paramType = "header")
@ -51,7 +78,7 @@ public class MailAppController extends DefaultBaseController {
@ApiImplicitParam(name = "keywords", value = "标题|收件人姓名", paramType = "query", dataType = "String") @ApiImplicitParam(name = "keywords", value = "标题|收件人姓名", paramType = "query", dataType = "String")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-page-app=send-mail") @GetMapping("list-page-app-send-mail")
public SuccessResultList<List<MailSendDTO>> listPageAppSendMail(@RequestHeader("token") String token, ListPage page) { public SuccessResultList<List<MailSendDTO>> listPageAppSendMail(@RequestHeader("token") String token, ListPage page) {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
page.setParams(params); page.setParams(params);
@ -63,7 +90,7 @@ public class MailAppController extends DefaultBaseController {
@ApiImplicitParam(name = "token", value = "token", paramType = "header") @ApiImplicitParam(name = "token", value = "token", paramType = "header")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @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, public MailSendDTO getAppSendMail(@RequestHeader("token") String token,
@PathVariable("mailId") String mailId){ @PathVariable("mailId") String mailId){
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
@ -79,7 +106,7 @@ public class MailAppController extends DefaultBaseController {
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20") @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-page-app=inbox-mail") @GetMapping("list-page-app-inbox-mail")
public SuccessResultList<List<MailInboxDTO>> listPageAppInboxMail(@RequestHeader("token") String token, ListPage page) { public SuccessResultList<List<MailInboxDTO>> listPageAppInboxMail(@RequestHeader("token") String token, ListPage page) {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
page.setParams(params); page.setParams(params);
@ -92,7 +119,7 @@ public class MailAppController extends DefaultBaseController {
@ApiImplicitParam(name = "token", value = "token", paramType = "header") @ApiImplicitParam(name = "token", value = "token", paramType = "header")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @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, public MailInboxDTO getAppInboxMail(@RequestHeader("token") String token,
@PathVariable("id") String id){ @PathVariable("id") String id){
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
@ -123,7 +150,7 @@ public class MailAppController extends DefaultBaseController {
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20") @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-page-app=draft-mail") @GetMapping("list-page-app-draft-mail")
public SuccessResultList<List<MailSendDTO>> listPageAppDraftMail(@RequestHeader("token") String token, ListPage page) { public SuccessResultList<List<MailSendDTO>> listPageAppDraftMail(@RequestHeader("token") String token, ListPage page) {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
page.setParams(params); page.setParams(params);
@ -135,7 +162,7 @@ public class MailAppController extends DefaultBaseController {
@ApiImplicitParam(name = "token", value = "token", paramType = "header") @ApiImplicitParam(name = "token", value = "token", paramType = "header")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @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, public MailSendDTO getAppDraftMail(@RequestHeader("token") String token,
@PathVariable("mailId") String mailId){ @PathVariable("mailId") String mailId){
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
@ -179,7 +206,7 @@ public class MailAppController extends DefaultBaseController {
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20") @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list-page-app=del-mail") @GetMapping("list-page-app-del-mail")
public SuccessResultList<List<MailDelDTO>> listPageAppDelMail(@RequestHeader("token") String token, ListPage page) { public SuccessResultList<List<MailDelDTO>> listPageAppDelMail(@RequestHeader("token") String token, ListPage page) {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
page.setParams(params); page.setParams(params);
@ -192,7 +219,7 @@ public class MailAppController extends DefaultBaseController {
@ApiImplicitParam(name = "id", value = "Id值", paramType = "path") @ApiImplicitParam(name = "id", value = "Id值", paramType = "path")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @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, public MailDelDTO getAppDelMail(@RequestHeader("token") String token,
@PathVariable("id") String id){ @PathVariable("id") String id){
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();

View File

@ -51,4 +51,8 @@ public interface IMailDao {
void deleteDelMail(String ids); void deleteDelMail(String ids);
void deleteAppDelMailAll(Map<String, Object> query); void deleteAppDelMailAll(Map<String, Object> query);
void saveMailReadTag(Map<String, Object> saveMap);
Map<String, Object> getUserMailReadTag(Map<String, Object> params);
} }

View File

@ -2,6 +2,7 @@ package cn.com.tenlion.systemoa.pojo.dtos.mail;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@ -49,4 +50,9 @@ public class MailInboxDTO {
private String secretTypes; private String secretTypes;
@ApiModelProperty(name = "creatorNames", value = "发件人姓名") @ApiModelProperty(name = "creatorNames", value = "发件人姓名")
private String creatorNames; private String creatorNames;
@ApiModelProperty(name = "readTag", value = "阅读状态0未读1已读")
private Integer readTag;
@ApiModelProperty(name = "readTime", value = "阅读时间")
private String readTime;
} }

View File

@ -100,4 +100,8 @@ public interface IMailService {
void deleteAppDraftMail(String token, String ids); void deleteAppDraftMail(String token, String ids);
void deleteAppDelMailAll(String token); void deleteAppDelMailAll(String token);
Integer getAppUserUnreadMail(String token, Map<String, Object> params);
void saveAppMailReadTag(String token, Map<String, Object> params);
} }

View File

@ -43,6 +43,28 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService
@Autowired @Autowired
private IUserService userService; private IUserService userService;
@Override
public void saveAppMailReadTag(String token, Map<String, Object> params) {
AppTokenUser appTokenUser = getAppTokenUser(token);
String id = params.get("id").toString();
Map<String, Object> 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<String, Object> params) {
AppTokenUser appTokenUser = getAppTokenUser(token);
if(appTokenUser == null || "".equals(appTokenUser.getId())){
return 0;
}
params.clear();
params.put("userId", appTokenUser.getId());
List<MailInboxDTO> list = mailDao.listInboxMail(params);
return list == null ? 0 : list.size();
}
@Override @Override
public void saveSendMail(MailSendVO vo) { public void saveSendMail(MailSendVO vo) {
@ -146,18 +168,14 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService
params.put("userId", appTokenUser.getId()); params.put("userId", appTokenUser.getId());
PageHelper.startPage(page.getPage(), page.getRows()); PageHelper.startPage(page.getPage(), page.getRows());
List<MailInboxDTO> list = mailDao.listInboxMail(params); List<MailInboxDTO> list = mailDao.listInboxMail(params);
// 处理发件人
for (MailInboxDTO item : list){ for (MailInboxDTO item : list){
// 处理发件人
String creatorId = item.getCreator(); String creatorId = item.getCreator();
UserDTO userDTO = userService.get(creatorId); UserDTO userDTO = userService.get(creatorId);
String creatorNames = userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]"; String creatorNames = userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]";
item.setCreatorNames(creatorNames); item.setCreatorNames(creatorNames);
}
// 处理抄送情况 // 处理抄送情况
for(MailInboxDTO item : list){ if(item.getCopyForIds() != null && !"".equals(item.getCopyForIds())){
if(item.getCopyForIds() == null || "".equals(item.getCopyForIds())){
continue;
}
String[] copyForIds = item.getCopyForIds().split(","); String[] copyForIds = item.getCopyForIds().split(",");
for (String str : copyForIds){ for (String str : copyForIds){
if(str.equals(appTokenUser.getId())){ if(str.equals(appTokenUser.getId())){
@ -167,10 +185,7 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService
} }
} }
// 处理密送情况 // 处理密送情况
for(MailInboxDTO item : list){ if(item.getSecretIds() != null && !"".equals(item.getSecretIds())){
if(item.getSecretIds() == null || "".equals(item.getSecretIds())){
continue;
}
String[] secretIds = item.getSecretIds().split(","); String[] secretIds = item.getSecretIds().split(",");
for (String str : secretIds){ for (String str : secretIds){
String tempId = ""; String tempId = "";
@ -185,6 +200,15 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService
} }
} }
} }
// 处理阅读状态
params.put("id", item.getId());
Map<String, Object> readTagMap = mailDao.getUserMailReadTag(params);
item.setReadTag(0);
if(readTagMap != null){
item.setReadTag(1);
item.setReadTime(readTagMap.get("readTime").toString());
}
}
PageInfo<MailInboxDTO> pageInfo = new PageInfo<>(list); PageInfo<MailInboxDTO> pageInfo = new PageInfo<>(list);
return new SuccessResultList<>(list, pageInfo.getPageNum(), pageInfo.getTotal()); return new SuccessResultList<>(list, pageInfo.getPageNum(), pageInfo.getTotal());
} }

View File

@ -60,6 +60,29 @@
<result column="del_time" property="delTime"/> <result column="del_time" property="delTime"/>
</resultMap> </resultMap>
<!-- 添加已阅记录 -->
<insert id="saveMailReadTag" parameterType="map">
INSERT INTO oa_mail_read_tag (
id, user_id, read_time
) VALUES (
#{id}, #{userId}, #{readTime}
)
</insert>
<!-- 查询邮件是否已读 -->
<select id="getUserMailReadTag" parameterType="map" resultType="map">
SELECT
id,
user_id userId,
read_time readTime
FROM
oa_mail_read_tag
WHERE
id = # {id}
AND user_id = #{userId}
LIMIT 1
</select>
<!-- 发信 --> <!-- 发信 -->
<insert id="saveSendMail" parameterType="map"> <insert id="saveSendMail" parameterType="map">
INSERT INTO oa_mail_send( INSERT INTO oa_mail_send(