以前都是所有参数丢hashmap传递,突然分成两个参数:
public List<HashMap<String, Object>> getDataByDataSource( @Param("sql") String dataSource, @Param("map") HashMap<String,Object> param);
<select id="getDataByDataSource" resultType="hashmap" flushCache="true" useCache="false"> ${sql} WHERE <choose> <when test="map.ids!=null and map.ids.size() >0"> sv.demandID in <foreach item="id" index="index" collection="map.ids" open="(" separator="," close=")"> #{id} </foreach> </when> <otherwise> sv.isDelete != 1 AND sv.companyID = #{companyID,jdbcType=INTEGER} </otherwise> </choose> </select>
其中for循环的collection应该写map.ids,而具体到拼接的时候就直接写hashmap对应的key就可以了,其他也是类似的写法,百度了一圈好像都没有这种奇葩的写法,就记录一下