The backend is passed into the list (put it in the map), when sql is in judgment, the operation is as follows
[Method 1] Use foreach in Mybits
<select id="*" parameterType="map" resultType="map">
SELECT * WHERE 条件1
<if test="传进的List名.size()>0">
AND 要查询的变量 IN
<foreach collection="传进的List名" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
FROM 表名
</select>
The foreach attributes mainly include item, index, collection, open, separator, and close.
1. The alias of the element when the item loops,
2. Index is equivalent to int i in the for loop,
3. What does open start with,
4. Separator separator,
5. What does close end with,
6. Collection attribute, key in map
[Method 2] String splicing, (not tested)
String a = "("+list.get(0);
for (int i = 1 ;i<list.size();i++){
a=a+","+list.get(i);
}
a=a+")";