<?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="com.tuoheng.miniprogram.dao.InspectionFileMapper">


    <select id="selectByInspectionId" resultType="com.tuoheng.miniprogram.vo.SeeQuestionVo">
        select
           tf.question_id as questionId,
           tf.question_name as questionName,
           tf.file_thumbnail as fileThumbnail,
           tf.file_original as fileOriginal,
           tf.file_image as fileImage,
           tfh.handler_image as handlerImage,
           tfh.handler_result as handlerResult,
           tfh.handler_time as handlerTime,
           tfh.handler_user as handlerUser
           from
           th_inspection_file as tf
           left join th_inspection_file_handle AS tfh on tf.id = tfh.inspection_file_id
           where tf.mark =1 and tfh.mark=1
           and tf.id=#{id}
    </select>


    <select id="getInspectionFileCount" resultType="java.lang.Integer">
        select count(id)
        from th_inspection_file
        where date_format(update_time, '%Y-%m-%d') = #{today}
        and mark = 1
        and update_user = #{userId}
    </select>
    <select id="getInspectionFileHandleCount" resultType="java.lang.Integer">
        select count(id)
        from th_inspection_file
        where date_format(update_time, '%Y-%m-%d') = #{today}
        and mark = 1
        and tenant_id = #{tenantId}
    </select>
</mapper>