加@Param("")
dao
//根据区域id获取对应的 楼宇、楼层、房间数据范围
List<DbAread> findBuildingListByAreaId(@Param("dbAread")DbAread dbAread,@Param("type")Integer type);
xml
<!-- 根据区域id获取对应的 楼宇、楼层、房间数据范围 -->
<select id="findBuildingListByAreaId" resultType="DbAread" >
SELECT
<include refid="dbAreadColumns"/>
FROM db_aread a
<include refid="dbAreadJoins"/>
<where>
area_id =#{dbAread.dbArea.id}
</where>
GROUP BY
<choose>
<when test="type !=null and type == 1 ">
a.building_id
</when>
<when test="type !=null and type == 2 ">
a.storey_id
</when>
<when test="type !=null and type == 3 ">
a.room_id
</when>
<otherwise>
</otherwise>
</choose>
</select>
不加@Param("") 不用写 dbAread参数
//根据 楼宇楼层房间 获取区域明细 (找对应的区域)
List<DbAread> findDbAreadByBBR(DbAread dbAread);
<!-- 根据 楼宇楼层房间 获取区域明细 (找对应的区域) -->
<select id="findDbAreadByBBR" resultType="DbAread" >
SELECT
<include refid="dbAreadColumns"/>
FROM db_aread a
<include refid="dbAreadJoins"/>
<where> 1=1
<if test="dbBuilding !=null and dbBuilding.id !=null and dbBuilding.id != ''">
and a.building_id =#{dbBuilding.id}
</if>
<if test="dbBuildingStorey !=null and dbBuildingStorey.id !=null and dbBuildingStorey.id != '' ">
and a.storey_id =#{dbBuildingStorey.id}
</if>
<if test="dbBsRoom !=null and dbBsRoom.id !=null and dbBsRoom.id != '' ">
and a.room_id =#{dbBsRoom.id}
</if>
</where>
</select>