1.根据ID进行修改操作
<update id="updateById" parameterType="com.example.entity.Admin">
update admin
<set>
<if test="username != null">
username =#{username},
</if>
<if test="password != null">
password =#{password},
</if>
<if test="name != null">
name =#{name},
</if>
<if test="phone != null">
phone =#{phone},
</if>
<if test="email != null">
email =#{email},
</if>
<if test="avatar != null">
avatar =#{avatar},
</if>
</set>
where id =#{id}
</update>
2.删除操作
删除操作比较简单,可以使用注解开发
一般情况,复杂 的sql使用xml,简易的sql使用注解开发
@Delete("delete from hotel where id =#{id}")
void deleteById(Integer id);
3.批量删除
适合小白的批量删除,一般推荐使用编写xml进行批量删除
public void deleteBatch(List<Integer> list){
for (Integer id : list) {
deleteById(id);
}
}