添加收件箱阅读状态相关
This commit is contained in:
parent
a261de6841
commit
060dbeb4cd
@ -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<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 = "批量发送内部邮件接口")
|
||||
@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<List<MailSendDTO>> listPageAppSendMail(@RequestHeader("token") String token, ListPage page) {
|
||||
Map<String, Object> 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<String, Object> 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<List<MailInboxDTO>> listPageAppInboxMail(@RequestHeader("token") String token, ListPage page) {
|
||||
Map<String, Object> 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<String, Object> 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<List<MailSendDTO>> listPageAppDraftMail(@RequestHeader("token") String token, ListPage page) {
|
||||
Map<String, Object> 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<String, Object> 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<List<MailDelDTO>> listPageAppDelMail(@RequestHeader("token") String token, ListPage page) {
|
||||
Map<String, Object> 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<String, Object> params = requestParams();
|
||||
|
@ -51,4 +51,8 @@ public interface IMailDao {
|
||||
void deleteDelMail(String ids);
|
||||
|
||||
void deleteAppDelMailAll(Map<String, Object> query);
|
||||
|
||||
void saveMailReadTag(Map<String, Object> saveMap);
|
||||
|
||||
Map<String, Object> getUserMailReadTag(Map<String, Object> params);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -100,4 +100,8 @@ public interface IMailService {
|
||||
void deleteAppDraftMail(String token, String ids);
|
||||
|
||||
void deleteAppDelMailAll(String token);
|
||||
|
||||
Integer getAppUserUnreadMail(String token, Map<String, Object> params);
|
||||
|
||||
void saveAppMailReadTag(String token, Map<String, Object> params);
|
||||
}
|
||||
|
@ -43,6 +43,28 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService
|
||||
@Autowired
|
||||
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
|
||||
public void saveSendMail(MailSendVO vo) {
|
||||
@ -146,18 +168,14 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService
|
||||
params.put("userId", appTokenUser.getId());
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<MailInboxDTO> 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;
|
||||
}
|
||||
if(item.getCopyForIds() != null && !"".equals(item.getCopyForIds())){
|
||||
String[] copyForIds = item.getCopyForIds().split(",");
|
||||
for (String str : copyForIds){
|
||||
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())){
|
||||
continue;
|
||||
}
|
||||
if(item.getSecretIds() != null && !"".equals(item.getSecretIds())){
|
||||
String[] secretIds = item.getSecretIds().split(",");
|
||||
for (String str : secretIds){
|
||||
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);
|
||||
return new SuccessResultList<>(list, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
@ -60,6 +60,29 @@
|
||||
<result column="del_time" property="delTime"/>
|
||||
</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 INTO oa_mail_send(
|
||||
|
Loading…
Reference in New Issue
Block a user