<?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.dailyInspection.mapper.DailyInspectionMapper">

    <select id="page" resultType="vip.xiaonuo.modular.ai.dailyInspection.entity.vo.DailyInspectionPageVo">
        SELECT
        d.id,
        p.full_name AS 'unitName',
        d.create_time,
        d.status
        FROM
        `daily_inspection` d
        LEFT JOIN `base_pigpen` p ON d.unit_id = p.id
        WHERE
        d.notifier_id = #{userId}
        <if test="status != null">
            AND d.status = #{status}
        </if>
        ORDER BY
        d.create_time DESC
    </select>
    <select id="detail" resultType="vip.xiaonuo.modular.ai.dailyInspection.entity.vo.DailyInspectionPageVo"
            parameterType="java.lang.String">
        SELECT
        d.id,
        p.full_name AS 'unitName',
        d.create_time,
        d.inspect_time,
        u.NAME AS 'userName',
        d.description,
        d.img_url,
        d.status
        FROM
        `daily_inspection` d
        LEFT JOIN `base_pigpen` p ON d.unit_id = p.id
        LEFT JOIN `SYS_USER` u ON d.inspect_person_id = u.id
        WHERE
        d.id = #{id}

    </select>
</mapper>