<delete id="deletetest">
    DELETE FROM user where id in
    <foreach item="ids" collection="list" open="(" separator="," close=")">
        #{ids}
    </foreach>
    and age = #{age}
</delete>

collection="list"  对应map中key值

item="ids"    ids可以随意起名   注意跟#{ids} 保持一致即可

List<String> list = new ArrayList<>();
list.add("21");
list.add("22");
TestVO testVO = new TestVO();
testVO.setAge(22);
testVO.setIds(list);
Map<String, Object> map = new HashMap<>();
map.put("list",list); //数据库字段1
map.put("age",22);    //数据库字段2
userMapper.deletetest(map);
return Result.success(true);

<foreach collection="map.staffIdList" item="visit_id"
         open="("  separator="," close=")">
    ${visit_id}   // #{}   可能会 报下表越界异常  原因未知
</foreach>





<if test="map.staffIdList != null and map.staffIdList.size > 0 ">
    AND a.visit_id IN
    <foreach collection="map.staffIdList" item="visit_id"
             open="("  separator="," close=")">
        ${visit_id}
    </foreach>
</if>
<if test="map.customerSearch != null and map.customerSearch != ''">
    AND (b.staff_name LIKE '%${map.customerSearch}%'
    OR a.member_id LIKE '%${map.customerSearch}%'
    OR a.member_name LIKE '%${map.customerSearch}%')
</if>
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐