<?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.BizYakGrowthRecordMapper">

    <resultMap type="com.ruoyi.web.modules.industryservice.domain.BizYakGrowthRecord" id="BizYakGrowthRecordResult">
        <id     property="id"           column="id"/>
        <result property="yakAssetId"   column="yak_asset_id"/>
        <result property="dayAge"       column="day_age"/>
        <result property="weightKg"     column="weight_kg"/>
        <result property="heightCm"     column="height_cm"/>
        <result property="chestCm"      column="chest_cm"/>
        <result property="lengthCm"     column="length_cm"/>
        <result property="collectTime"  column="collect_time"/>
        <result property="dataKind"     column="data_kind"/>
    </resultMap>

    <select id="selectByYakAssetId" resultMap="BizYakGrowthRecordResult">
        select id, yak_asset_id, day_age, weight_kg, height_cm, chest_cm, length_cm, collect_time, data_kind
        from biz_yak_growth_record
        where yak_asset_id = #{yakAssetId}
        order by collect_time desc, id desc
    </select>

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

    <insert id="batchInsert">
        insert into biz_yak_growth_record (
            yak_asset_id, day_age, weight_kg, height_cm, chest_cm, length_cm, collect_time, data_kind
        ) values
        <foreach collection="list" item="item" separator=",">
            (#{item.yakAssetId}, #{item.dayAge}, #{item.weightKg}, #{item.heightCm},
             #{item.chestCm}, #{item.lengthCm}, #{item.collectTime}, #{item.dataKind})
        </foreach>
    </insert>
</mapper>
