有一个表,根据id任意更改字段,可以单独只改其中一个字段,也可以全部一起改。这里可以单独改密码,单独改角色名,或者两个一起改。
<update id="updateUserByAccount" parameterType="com.ozq.house_rental.pojo.User">
UPDATE user SET
<choose>
<when test="password!=null and password !=''">password=#{password}</when>
<when test="roleName!=null and roleName !=''">role_name = #{roleName}</when>
<otherwise>
password=#{password},
role_name = #{roleName}
</otherwise>
</choose>
WHERE account=#{account}
</update>