<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.zjk.mapper.ZjkExpertLogMapper">

    <select id="getApplicationResults" resultType="java.util.Map">
        SELECT
        TO_CHAR( DATE ( application_time ), 'YYYY-MM-DD' ) AS application_date,-- 格式化日期为 yyyy-MM-dd
        COUNT( CASE WHEN entry_result = 1 THEN 1 END ) AS successCount,
        COUNT( CASE WHEN entry_result = 2 THEN 1 END ) AS errorCount
        FROM
        zjk_expert_log
        WHERE
        application_time IS NOT NULL and  application_time BETWEEN #{startTime} and  #{endTime}
        GROUP BY
        TO_CHAR( DATE ( application_time ), 'YYYY-MM-DD' ) -- 确保 GROUP BY 的字段与 SELECT 中一致
        ORDER BY
        application_date ASC;-- 按格式化后的日期排序
    </select>
</mapper>
