75 lines
2.3 KiB
Java
75 lines
2.3 KiB
Java
package com.gunshi.project.ss.mapper;
|
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
import com.gunshi.db.dto.MonthRangeSo;
|
|
import com.gunshi.project.ss.entity.vo.MentenceInfoCount12Vo;
|
|
import com.gunshi.project.ss.entity.vo.StatusCountVo;
|
|
import com.gunshi.project.ss.model.HiddenInfo;
|
|
import org.apache.ibatis.annotations.MapKey;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Select;
|
|
|
|
import java.util.List;
|
|
|
|
@Mapper
|
|
public interface HiddenInfoMapper extends BaseMapper<HiddenInfo> {
|
|
|
|
@Select("""
|
|
<script>
|
|
WITH month_series AS (
|
|
SELECT
|
|
TO_CHAR(generate_series(
|
|
DATE_TRUNC('month', #{dto.start}::timestamp),
|
|
DATE_TRUNC('month', #{dto.end}::timestamp) - INTERVAL '1 month',
|
|
'1 month'
|
|
), 'YYYY-MM') AS month
|
|
)
|
|
SELECT
|
|
ms.month,
|
|
COALESCE(COUNT(hi.found_time), 0) AS hidden_count
|
|
FROM month_series ms
|
|
LEFT JOIN hidden_info hi ON ms.month = TO_CHAR(hi.found_time, 'YYYY-MM')
|
|
AND hi.found_time >= DATE_TRUNC('month', #{dto.start}::timestamp)
|
|
AND hi.found_time < DATE_TRUNC('month', #{dto.end}::timestamp) + INTERVAL '1 month'
|
|
GROUP BY ms.month
|
|
ORDER BY ms.month;
|
|
</script>
|
|
""")
|
|
List<MentenceInfoCount12Vo> selectCount12(@Param("dto") MonthRangeSo monthRangeSo);
|
|
|
|
|
|
@Select("""
|
|
<script>
|
|
SELECT
|
|
status,
|
|
COUNT(*) AS count
|
|
FROM hidden_info
|
|
WHERE found_time >= DATE_TRUNC('month', #{dto.start}::timestamp)
|
|
AND found_time < DATE_TRUNC('month', #{dto.end}::timestamp) + INTERVAL '1 month'
|
|
GROUP BY status
|
|
ORDER BY status;
|
|
</script>
|
|
""")
|
|
@MapKey("status")
|
|
List<StatusCountVo> selectCountType(@Param("dto") MonthRangeSo monthRangeSo);
|
|
|
|
@Select("""
|
|
WITH all_status AS (
|
|
SELECT 0 AS status UNION
|
|
SELECT 1 AS status
|
|
)
|
|
SELECT
|
|
a.status,
|
|
COALESCE(COUNT(h.id), 0) AS count
|
|
FROM all_status a
|
|
LEFT JOIN hidden_info h
|
|
ON a.status = h.status
|
|
AND TO_CHAR(h.found_time, 'YYYY') = #{year}
|
|
GROUP BY a.status
|
|
ORDER BY a.status;
|
|
""")
|
|
@MapKey("status")
|
|
List<StatusCountVo> countYear(@Param("year") String year);
|
|
}
|