<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>