<?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.huimv.apiservice.dao.IndoorEnvironmentDao">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.huimv.apiservice.entity.IndoorEnvironmentEntity" id="indoorEnvironmentMap">
        <result property="id" column="id"/>
        <result property="pigstyId" column="pigsty_id"/>
        <result property="temperature" column="temperature"/>
        <result property="humidity" column="humidity"/>
        <result property="airQuality" column="gas"/>
        <result property="date" column="date"/>
        <result property="collectTime" column="collect_time"/>
        <result property="deleted" column="deleted"/>
        <result property="gmtCreate" column="gmt_create"/>
        <result property="gmtModified" column="gmt_modified"/>
    </resultMap>

    <insert id="batchInsertData" >
        insert into mgt_indoor_environment(pigsty_id,date,temperature,humidity,air_quality,collect_time)
        values
        <foreach collection="list" item="item"  separator="," >
            #{item.date},
            #{item.farmId},
            (#{item.pigstyId},
            #{item.temperature},
            #{item.humidity},
            #{item.airQuality},
            #{item.collectTime})
        </foreach>
    </insert>

    <select id="select" resultType="com.huimv.apiservice.entity.vo.IndoorEnvVo">
        SELECT
          collect_time,
          temperature,
          humidity,
          air_quality
        FROM mgt_indoor_environment
        ${ew.customSqlSegment}
    </select>
</mapper>