package cn.lihongjie.coal.noticeStatus.repository;

import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.noticeStatus.dto.MyNoticeStatusDto;
import cn.lihongjie.coal.noticeStatus.entity.NoticeStatusEntity;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface NoticeStatusRepository extends BaseRepository<NoticeStatusEntity> {
    @Query("""
    select count(1) as allCount, 
        sum(case when t.read then 1 else 0 end) as readCount,
        sum(case when t.read then 0 else 1 end) as unReadCount,
        sum(case when t.delete then 1 else 0 end) as deleteCount
      from NoticeStatusEntity t where t.user.id = ?1
""")
    MyNoticeStatusDto userNoticeCount(String userId);
}
