代码演示

图:delete、from cstcu 的流程。

图:delete、from cstcu 的流程。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<delete id="deleteByIds" parameterType="CustomerVo">
delete
from cst_customer

<!-- foreach标签,进行遍历 -->
<!-- collection:遍历的集合,这里是QueryVo的ids属性 -->
<!-- item:遍历的项目,可以随便写,,但是和后面的#{}里面要一致 -->
<!-- open:在前面添加的sql片段 -->
<!-- close:在结尾处添加的sql片段 -->
<!-- separator:指定遍历的元素之间使用的分隔符 -->

<where>
<if test="ids !=null" >
<foreach collection="ids" item="id"
open="cust_id in (" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
</delete>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<update id="updateUserStatus" parameterType="user">
update tuser
<set>
<choose>
<when test="role.roleId==1">
status=1
</when>
<otherwise>
status=0
</otherwise>
</choose>
</set>
<where>
<!-- 这里用不用where都一样 -->
roleId=#{role.roleId}
</where>
</update>