AddressBookimpl实现类更改如下:

AddressBookMapper.xml更改如下:
<update id="update" parameterType="addressBook">
update address_book
<set>
<if test="consignee != null">
consignee = #{consignee},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="phone != null">
phone = #{phone},
</if>
<if test="provinceCode != null">
province_code = #{provinceCode},
</if>
<if test="provinceName != null">
province_name = #{provinceName},
</if>
<if test="cityCode != null">
city_code = #{cityCode},
</if>
<if test="cityName != null">
city_name = #{cityName},
</if>
<if test="districtCode != null">
district_code = #{districtCode},
</if>
<if test="districtName != null">
district_name = #{districtName},
</if>
<if test="detail != null">
detail = #{detail},
</if>
<if test="label != null">
label = #{label},
</if>
<if test="isDefault != null">
is_default = #{isDefault},
</if>
</set>
where id = #{id}
</update>
这样即可实现实时更改地址簿信息
文章讲述了如何在AddressBookimpl实现类中通过修改AddressBookMapper.xml文件的SQL语句,使用iftest条件判断来实现地址簿信息的实时更新,关注点在于数据库操作和条件逻辑的运用。
2万+

被折叠的 条评论
为什么被折叠?



