<?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.ruoyi.web.modules.industryservice.mapper.BizYakPhysioSeriesMapper">

    <resultMap type="com.ruoyi.web.modules.industryservice.domain.BizYakPhysioSeries" id="BizYakPhysioSeriesResult">
        <id     property="id"           column="id"/>
        <result property="yakAssetId"   column="yak_asset_id"/>
        <result property="collectTime"  column="collect_time"/>
        <result property="bodyTemp"     column="body_temp"/>
        <result property="steps"        column="steps"/>
        <result property="envTemp"      column="env_temp"/>
    </resultMap>

    <select id="selectByYakAssetId" resultMap="BizYakPhysioSeriesResult">
        select id, yak_asset_id, collect_time, body_temp, steps, env_temp
        from biz_yak_physio_series
        where yak_asset_id = #{yakAssetId}
        order by collect_time desc
    </select>

    <select id="selectChartByYakAssetId" resultMap="BizYakPhysioSeriesResult">
        select id, yak_asset_id, collect_time, body_temp, steps, env_temp
        from biz_yak_physio_series
        where yak_asset_id = #{yakAssetId}
          and collect_time &gt;= date_sub(now(), interval #{days} day)
        order by collect_time asc
    </select>

    <delete id="deleteByYakAssetId">
        delete from biz_yak_physio_series where yak_asset_id = #{yakAssetId}
    </delete>

    <insert id="batchInsert">
        insert into biz_yak_physio_series (yak_asset_id, collect_time, body_temp, steps, env_temp)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.yakAssetId}, #{item.collectTime}, #{item.bodyTemp}, #{item.steps}, #{item.envTemp})
        </foreach>
    </insert>
</mapper>
