<?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.management.dao.LairageRecordDao">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.huimv.management.entity.LairageRecordEntity" id="lairageRecordMap">
        <result property="id" column="id"/>
        <result property="eartag" column="eartag"/>
        <result property="dayAge" column="day_age"/>
        <result property="weight" column="weight"/>
        <result property="fosterStatus" column="foster_status"/>
        <result property="healthStatus" column="health_status"/>
        <result property="whereDidYouGo" column="where_did_you_go"/>
        <result property="breed" column="breed"/>
        <result property="sex" column="sex"/>
        <result property="birthday" column="birthday"/>
        <result property="originPlace" column="origin_place"/>
        <result property="farmId" column="farm_id"/>
        <result property="pigstyId" column="pigsty_id"/>
        <result property="unitId" column="unit_id"/>
        <result property="periodId" column="period_id"/>
        <result property="inFenceTime" column="in_fence_time"/>
        <result property="outFenceTime" column="out_fence_time"/>
        <result property="outFenceStatus" column="out_fence_status"/>
        <result property="motherEartag" column="mother_eartag"/>
        <result property="fatherEartag" column="father_eartag"/>
        <result property="deleted" column="deleted"/>
        <result property="gmtCreate" column="gmt_create"/>
        <result property="gmtModified" column="gmt_modified"/>
    </resultMap>

    <select id="list" resultType="com.huimv.management.entity.vo.PigBaseVo">
        SELECT
          base.id,
          base.eartag,
          base.day_age,
          unit.number unit_name,
          unit.id unit_id,
          base.weight,
          base.foster_status,
          base.health_status,
          base.where_did_you_go,
          base.breed,
          base.sex,
          base.birthday,
          base.origin_place,
          pigsty.number pigsty_name,
          pigsty.id pigsty_id,
          period.number period_name,
          period.id period_id,
          base.in_fence_time,
          base.out_fence_time,
          base.out_fence_status,
          base.mother_eartag,
          base.father_eartag,
          farm.name farm_name

        from mgt_lairage_record base
        LEFT JOIN mgt_period period on period.id = base.period_id
        JOIN mgt_pigsty pigsty on pigsty.id = base.pigsty_id
        JOIN mgt_unit unit on unit.id = base.unit_id
        JOIN mgt_farm farm on farm.id = base.farm_id
        ${ew.customSqlSegment}

    </select>

</mapper>