When traversing the array parameters and splicing sql, the last parameter does not require certain keywords, so it is necessary to determine whether it is the end of the loop
signal
<select id="count" parameterType="list" resultType="java.lang.Integer">
<if test="list!=null and list.size()>0">
<foreach item="item" collection="list" index="index">
SELECT
count(1)
FROM
t_user
WHERE
create_at >= #{item.startTime}
AND
create_at < #{item.endTime}
AND
<if test="index != (list.size() - 1)">
union all
</if>
</foreach>
</if>
</select>
The index is the subscript of the loop, list.size() - 1 is the meaning of the last subscript of the array, it is feasible to test