Mybatis plus使用xml编写sql,需要添加条件时,使用map传值时,xml文件内怎么获取Map当中的属性值

​ Mapper层,添加 @Param("query") ,这个query用于后面xml的编写 

ClassroomStructureVO getScheduleByCycleAndClass(@Param("query") Map<String, Object> query);

 

 

xml文件,通过query.字段名,就能够得到Map内对应的Object数据

<select id="getScheduleByCycleAndClass" parameterType="map" resultMap="SelectResultMap">
      SELECT *
      FROM *
      <where>
        1 = 1
        <if test="query.cycleId != null">
          and FC.CYCLE_ID = #{query.cycleId}
        </if>
      </where>
    </select>

 

 



posted @ 2022-02-11 17:18  yu4hao4  阅读(495)  评论(0)    收藏  举报