<?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.BizYakFeedingRecordMapper">
    <resultMap type="com.ruoyi.web.modules.industryservice.domain.BizYakFeedingRecord" id="BizYakFeedingRecordResult">
        <id property="id" column="id"/>
        <result property="yakAssetId" column="yak_asset_id"/>
        <result property="feedTarget" column="feed_target"/>
        <result property="startDayAge" column="start_day_age"/>
        <result property="endDayAge" column="end_day_age"/>
        <result property="feedType" column="feed_type"/>
        <result property="totalSupplementKg" column="total_supplement_kg"/>
        <result property="dailySupplementKg" column="daily_supplement_kg"/>
    </resultMap>
    <select id="selectByYakAssetId" resultMap="BizYakFeedingRecordResult">
        select id, yak_asset_id, feed_target, start_day_age, end_day_age, feed_type, total_supplement_kg, daily_supplement_kg
        from biz_yak_feeding_record where yak_asset_id = #{yakAssetId} order by start_day_age desc, id desc
    </select>
    <delete id="deleteByYakAssetId">delete from biz_yak_feeding_record where yak_asset_id = #{yakAssetId}</delete>
    <insert id="batchInsert">
        insert into biz_yak_feeding_record (yak_asset_id, feed_target, start_day_age, end_day_age, feed_type, total_supplement_kg, daily_supplement_kg) values
        <foreach collection="list" item="item" separator=",">
            (#{item.yakAssetId}, #{item.feedTarget}, #{item.startDayAge}, #{item.endDayAge}, #{item.feedType}, #{item.totalSupplementKg}, #{item.dailySupplementKg})
        </foreach>
    </insert>
</mapper>
