mybaits在新增</insert>
里加入 ON DUPLICATE KEY UPDATE
实例
<insert id="insert">
INSERT INTO ws_product_fun(
id,
pro_sum_id,
fun_title,
fun_desc,
fun_photo,
fun_sort,
isdel,
create_user,
create_time
)
VALUES (
#{id},
#{proSumId},
#{funTitle},
#{funDesc},
#{funPhoto},
#{funSort},
#{isdel},
#{createUser},
now()
)
ON DUPLICATE KEY UPDATE
<if test= "proSumId !=null and proSumId !=''" >
pro_sum_id = #{proSumId},
</if>
<if test= "funTitle !=null and funTitle !=''" >
fun_title = #{funTitle},
</if>
<if test= "funDesc !=null and funDesc !=''" >
fun_desc = #{funDesc},
</if>
<if test= "funPhoto !=null and funPhoto !=''" >
fun_photo = #{funPhoto},
</if>
<if test= "funSort !=null and funSort !=''" >
fun_sort = #{funSort},
</if>
<if test= "isdel !=null and isdel !=''" >
isdel = #{isdel},
</if>
<if test= "createUser !=null and createUser !=''" >
create_user = #{createUser},
</if>
<if test= "createTime !=null and createTime !=''" >
create_time = #{createTime},
</if>
<if test= "updateUser !=null and updateUser !=''" >
update_user = #{updateUser},
</if>
update_time = now()
</insert>
存在相同ID,修改,没有,新增