Mybatis中查询条件为map中嵌套list

来源:互联网 发布:蓝月传奇官印升级数据 编辑:程序博客网 时间:2024/06/05 18:23

1、问题,map接受参数为HashMap<String,Object>;怎么根据他查询呢

sql语句:select result as orderRsult,IFNULL(sum(amount),0) as orderAmount,count(1) as orderCount from user_order WHERE app_id IN ( ? ) group by result


对应的mapper:

public List<Map<String,Object>> merOrderView(Map<String,Object>parametersMap);
其中map的结构:
{app_ids=[4110,4111], begaindate=2017-07-08, enddate=2017-07-09}
mapper.xml为
  <resultMap id="merOrderViewResult"   type="HashMap">                 <result column="orderRsult" property="orderRsult"/>                 <result column="orderAmount" property="orderAmount" />               <result column="orderCount" property="orderCount" />          </resultMap>       <select id="merOrderView"  parameterType="map"  resultMap="merOrderViewResult">            select result  as orderRsult,IFNULL(sum(amount),0) as orderAmount,count(1) as orderCount  from user_order            <where>                    <!--  <if test="null != app_id and '' != app_id">                     and  app_id=#{app_id}                   </if>-->                 <if test="app_ids !=null">                     AND app_id IN                     <foreach collection="app_ids" item="appid"  open="(" separator="," close=")">                         #{appid}                     </foreach>                 </if>                   <if test="null != begaindate">                     and  insert_date >=#{begaindate}                   </if>                   <if test="null != enddate">                     and  insert_date <=#{enddate}                   </if>                 </where>                 group by result       </select>




原创粉丝点击