mapper.xml
<insert id="insertSelectiveList" parameterType="java.util.Map" useGeneratedKeys="true" keyProperty="id">
<foreach collection="list" item="item" index="index" separator=";">
insert into buy_receive_addresses
<include refid="insertSelectNotNull" />
values (
<trim suffixOverrides=",">
<if test="item.id != null">
#{item.id,jdbcType=INTEGER},
</if>
<if test="item.isDefault != null">
#{item.isDefault,jdbcType=CHAR},
</if>
<if test="item.receivePersonalName != null">
#{item.receivePersonalName,jdbcType=VARCHAR},
</if>
<if test="item.area != null">
#{item.area,jdbcType=VARCHAR},
</if>
<if test="item.address != null">
#{item.address,jdbcType=VARCHAR},
</if>
<if test="item.mobile != null">
#{item.mobile,jdbcType=VARCHAR},
</if>
<if test="item.phone != null">
#{item.phone,jdbcType=VARCHAR},
</if>
<if test="item.email != null">
#{item.email,jdbcType=VARCHAR},
</if>
<if test="item.phoneUserId != null">
#{item.phoneUserId,jdbcType=INTEGER},
</if>
</trim>
)
</foreach>
</insert>
<sql id="insertSelectNotNull">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.id != null">
id,
</if>
<if test="item.isDefault != null">
is_default,
</if>
<if test="item.receivePersonalName != null">
receive_personal_name,
</if>
<if test="item.area != null">
area,
</if>
<if test="item.address != null">
address,
</if>
<if test="item.mobile != null">
mobile,
</if>
<if test="item.phone != null">
phone,
</if>
<if test="item.email != null">
email,
</if>
<if test="item.phoneUserId != null">
phone_user_id,
</if>
</trim>
</sql>
public int insertBuyReceiveAddressesList(List<?> returnDataList) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("list",(List<BuyReceiveAddresses>)returnDataList);
return buyReceiveAddressesMapperDao.insertSelectiveList(map);
}
int insertSelectiveList(Map map);