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

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.huimv.management.entity.UnitEntity" id="unitMap">
        <result property="id" column="id"/>
        <result property="number" column="number"/>
        <result property="pigstyId" column="pigsty_id"/>
        <result property="farmId" column="farm_id"/>
        <result property="currentPeriodId" column="current_period_id" />
        <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.UnitVo">
        SELECT
            unit.id,
            unit.number,
            unit.pigsty_id,
            unit.current_period_id periodId,
            unit.farm_id,

            pigsty.number pigstyName,
            period.number periodName
        FROM
            mgt_unit unit
        JOIN mgt_pigsty pigsty ON pigsty.id = unit.pigsty_id
         LEFT JOIN mgt_period period ON  period.id = unit.current_period_id
         ${ew.customSqlSegment}
    </select>


</mapper>