| /** | 
|  * Copyright (c) 2019 人人开源 All rights reserved. | 
|  * | 
|  * https://www.renren.io | 
|  * | 
|  * 版权所有,侵权必究! | 
|  */ | 
| package com.zt.modules.message.service; | 
|   | 
| import java.util.Date; | 
| import java.util.List; | 
|   | 
| import org.springframework.stereotype.Service; | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
| import com.zt.common.constant.Constant; | 
| import com.zt.common.service.BaseService; | 
| import com.zt.modules.message.dao.SysNoticeUserDao; | 
| import com.zt.modules.message.enums.NoticeReadStatus; | 
| import com.zt.modules.message.model.SysNoticeUser; | 
|   | 
| /** | 
|  * 我的通知 | 
|  * | 
|  * @author hehz | 
|  */ | 
| @Service | 
| public class SysNoticeUserService extends BaseService<SysNoticeUserDao, SysNoticeUser> { | 
|   | 
|     /** | 
|      * 获取被通知的用户 | 
|      */ | 
|     public List<SysNoticeUser> getNoticeUserList(Long noticeId) { | 
|         return baseDao.getNoticeUserList(noticeId); | 
|     } | 
|   | 
|     /** | 
|      * 标记我的通知为已读 | 
|      * | 
|      * @param receiverId | 
|      *            接收者ID | 
|      * @param noticeId | 
|      *            通知ID | 
|      */ | 
|     public void updateReadStatus(Long receiverId, Long noticeId) { | 
|         SysNoticeUser entity = new SysNoticeUser().setReceiverId(receiverId).setNoticeId(noticeId) | 
|                 .setStatus(NoticeReadStatus.READ.value()).setReadDate(new Date()); | 
|   | 
|         // 标记为已读 | 
|         QueryWrapper<SysNoticeUser> query = new QueryWrapper<>(); | 
|         query.eq("receiver_id", receiverId); | 
|         query.eq("notice_id", noticeId); | 
|         baseDao.update(entity, query); | 
|     } | 
|   | 
|     /** | 
|      * 未读的通知数 | 
|      * | 
|      * @param receiverId | 
|      *            接收者ID | 
|      */ | 
|     public int getUnReadNoticeCount(Long receiverId) { | 
|         return baseDao.selectCount(new QueryWrapper<SysNoticeUser>().eq(Constant.TableColumn.IS_DELETE, Constant.Bool.NO) | 
|                 .lambda().eq(SysNoticeUser::getReceiverId, receiverId) | 
|                 .eq(SysNoticeUser::getStatus, NoticeReadStatus.UNREAD.value())); | 
|     } | 
| } |