<?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="vip.xiaonuo.modular.ai.taskInspection.mapper.TaskInspectionMapper">

    <select id="page" resultType="vip.xiaonuo.modular.ai.taskInspection.entity.vo.TaskInspectionPageVo">
        SELECT
            t.id,
            c.config_name AS 'warningType',
            p.full_name AS 'unitName',
            w.warning_content,
            t.create_time,
            t.status
        FROM
            `task_inspection` t
            LEFT JOIN `warning_info` w ON t.warning_id = w.id
            LEFT JOIN `base_config` c ON w.warning_type_id = c.id
            LEFT JOIN `base_pigpen` p ON w.unit_id = p.id
        WHERE
            t.notifier_id = #{userId}
             <if test="status != null">
                AND t.status = #{status}
            </if>
        ORDER BY
            t.create_time DESC
    </select>
    <select id="detail" resultType="vip.xiaonuo.modular.ai.taskInspection.entity.vo.TaskInspectionPageVo"
            parameterType="java.lang.String">
        SELECT
        t.id,
        c.config_name AS 'warningType',
        p.full_name AS 'unitName',
        w.warning_content,
        t.create_time,
        t.status,
        t.inspect_time,
        u.NAME AS 'userName',
        t.description,
        t.img_url
        FROM
        `task_inspection` t
        LEFT JOIN `warning_info` w ON t.warning_id = w.id
        LEFT JOIN `base_config` c ON w.warning_type_id = c.id
        LEFT JOIN `base_pigpen` p ON w.unit_id = p.id
        LEFT JOIN `SYS_USER` u ON t.inspect_person_id = u.id
        WHERE
        t.id = #{id}
    </select>
</mapper>