Commit c26037bc by giaogiao

统计未读消息数量

parent 831d6451
...@@ -42,4 +42,12 @@ public interface ImInboxMapper extends BaseMapper<ImInbox> { ...@@ -42,4 +42,12 @@ public interface ImInboxMapper extends BaseMapper<ImInbox> {
Long updateImMsgReceivedByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds); Long updateImMsgReceivedByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds);
Long updateImMsgReadByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds); Long updateImMsgReadByIds(@Param("clientId") Long clientId, @Param("msgIds") List<Long> msgIds);
/**
* 统计未读消息数量
*
* @param clientId
* @return
*/
Integer countMyNotReadCount(@Param("clientId") Long clientId);
} }
...@@ -70,6 +70,14 @@ public interface ImInboxService extends BaseService<ImInbox> { ...@@ -70,6 +70,14 @@ public interface ImInboxService extends BaseService<ImInbox> {
ApiResult<Boolean> updateImMsgReceived(ImMsgReceivedStatusUpdate imMsgReceivedUpdate); ApiResult<Boolean> updateImMsgReceived(ImMsgReceivedStatusUpdate imMsgReceivedUpdate);
/** /**
* 统计未读消息数量
*
* @param clientId
* @return
*/
Integer countMyNotReadCount(Long clientId);
/**
* 消息修改为已读状态 * 消息修改为已读状态
* *
* @return * @return
......
...@@ -116,6 +116,19 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox> ...@@ -116,6 +116,19 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
return ApiResult.ok(); return ApiResult.ok();
} }
/**
* 统计未读消息数量
*
* @param clientId
* @return
*/
@Override
public Integer countMyNotReadCount(Long clientId) {
return null;
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ApiResult<Boolean> updateImMsgRead(ImMsgReadStatusUpdate imMsgReadStatusUpdate) { public ApiResult<Boolean> updateImMsgRead(ImMsgReadStatusUpdate imMsgReadStatusUpdate) {
......
...@@ -7,6 +7,7 @@ import com.wecloud.im.entity.ImApplication; ...@@ -7,6 +7,7 @@ import com.wecloud.im.entity.ImApplication;
import com.wecloud.im.entity.ImClient; import com.wecloud.im.entity.ImClient;
import com.wecloud.im.entity.ImIosApns; import com.wecloud.im.entity.ImIosApns;
import com.wecloud.im.push.PushUtils; import com.wecloud.im.push.PushUtils;
import com.wecloud.im.service.ImInboxService;
import com.wecloud.im.service.ImIosApnsService; import com.wecloud.im.service.ImIosApnsService;
import com.wecloud.im.ws.model.request.PushModel; import com.wecloud.im.ws.model.request.PushModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -35,6 +36,10 @@ public class PushTask { ...@@ -35,6 +36,10 @@ public class PushTask {
@Autowired @Autowired
private ImIosApnsService imIosApnsService; private ImIosApnsService imIosApnsService;
@Autowired
private ImInboxService imInboxService;
/** /**
* 谷歌推送地址 * 谷歌推送地址
*/ */
...@@ -207,7 +212,8 @@ public class PushTask { ...@@ -207,7 +212,8 @@ public class PushTask {
String deviceToken = imClientReceiver.getDeviceToken(); String deviceToken = imClientReceiver.getDeviceToken();
String alertTitle = pushModel.getTitle(); String alertTitle = pushModel.getTitle();
String alertBody = pushModel.getSubTitle(); String alertBody = pushModel.getSubTitle();
int badge = 1; // 统计未读消息数量
int badge = imInboxService.countMyNotReadCount(imClientReceiver.getId());
String topicBundleId = apns.getBundleId(); String topicBundleId = apns.getBundleId();
String certificatePassword = apns.getPwd(); String certificatePassword = apns.getPwd();
boolean contentAvailable = false; boolean contentAvailable = false;
......
...@@ -46,5 +46,11 @@ ...@@ -46,5 +46,11 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from im_Inbox from im_Inbox
</select> </select>
<select id="countMyNotReadCount" resultType="java.lang.Integer">
SELECT COUNT(id)
FROM im_inbox
WHERE receiver = #{clientId}
AND read_msg_status = 0
</select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment