|
@@ -13,14 +13,12 @@ import org.springframework.stereotype.Service;
|
|
|
import shop.alien.entity.result.R;
|
|
import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.LawyerUserViolation;
|
|
import shop.alien.entity.store.LawyerUserViolation;
|
|
|
import shop.alien.entity.store.LifeNotice;
|
|
import shop.alien.entity.store.LifeNotice;
|
|
|
-import shop.alien.entity.store.LifeUserViolation;
|
|
|
|
|
import shop.alien.entity.store.vo.LifeMessageVo;
|
|
import shop.alien.entity.store.vo.LifeMessageVo;
|
|
|
import shop.alien.entity.store.vo.LifeNoticeVo;
|
|
import shop.alien.entity.store.vo.LifeNoticeVo;
|
|
|
import shop.alien.lawyer.service.LawyerNoticeService;
|
|
import shop.alien.lawyer.service.LawyerNoticeService;
|
|
|
import shop.alien.mapper.LawyerUserViolationMapper;
|
|
import shop.alien.mapper.LawyerUserViolationMapper;
|
|
|
import shop.alien.mapper.LifeMessageMapper;
|
|
import shop.alien.mapper.LifeMessageMapper;
|
|
|
import shop.alien.mapper.LifeNoticeMapper;
|
|
import shop.alien.mapper.LifeNoticeMapper;
|
|
|
-import shop.alien.mapper.LifeUserViolationMapper;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -56,6 +54,11 @@ public class LawyerNoticeServiceImpl extends ServiceImpl<LifeNoticeMapper, LifeN
|
|
|
private static final Integer DELETE_FLAG_NOT_DELETED = 0;
|
|
private static final Integer DELETE_FLAG_NOT_DELETED = 0;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 未读标识:0-未读
|
|
|
|
|
+ */
|
|
|
|
|
+ private static final Integer IS_READ_UNREAD = 0;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 发送者ID分隔符
|
|
* 发送者ID分隔符
|
|
|
*/
|
|
*/
|
|
|
private static final String SENDER_ID_SEPARATOR = "_";
|
|
private static final String SENDER_ID_SEPARATOR = "_";
|
|
@@ -319,4 +322,29 @@ public class LawyerNoticeServiceImpl extends ServiceImpl<LifeNoticeMapper, LifeN
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R<Boolean> hasUnreadNotice(String receiverId) {
|
|
|
|
|
+ log.info("LawyerNoticeServiceImpl.hasUnreadNotice, receiverId={}", receiverId);
|
|
|
|
|
+
|
|
|
|
|
+ // 参数校验
|
|
|
|
|
+ if (StringUtils.isBlank(receiverId)) {
|
|
|
|
|
+ log.warn("接收人ID为空");
|
|
|
|
|
+ return R.fail("接收人ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 构建查询条件:查询未读且未删除的通知,使用LIMIT 1优化性能
|
|
|
|
|
+ LambdaQueryWrapper<LifeNotice> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(LifeNotice::getReceiverId, receiverId)
|
|
|
|
|
+ .eq(LifeNotice::getIsRead, IS_READ_UNREAD)
|
|
|
|
|
+ .eq(LifeNotice::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
|
|
|
|
|
+ .last("LIMIT 1");
|
|
|
|
|
+
|
|
|
|
|
+ // 使用selectOne判断是否存在,数据库找到一条记录即返回,比selectCount更高效
|
|
|
|
|
+ LifeNotice notice = lifeNoticeMapper.selectOne(queryWrapper);
|
|
|
|
|
+ boolean hasUnread = notice != null;
|
|
|
|
|
+
|
|
|
|
|
+ log.debug("LawyerNoticeServiceImpl.hasUnreadNotice, receiverId={}, hasUnread={}", receiverId, hasUnread);
|
|
|
|
|
+ return R.data(hasUnread);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|