1+ <mapper namespace =" test" >
2+ <sql id =" columns_id" >id,username,password,createtime</sql >
3+
4+ <select id =" selectTestTable" >
5+ SELECT <include refid =" columns_id" > </include > FROM test_table
6+ <where >
7+ <if test =" {TestTable.id} != nil and {TestTable.id} != 0" >AND id = #{TestTable.id} </if >
8+ <if test =" {TestTable.username} != nil" >AND username = #{TestTable.username} </if >
9+ <if test =" {TestTable.password} != nil" >AND password = #{TestTable.password} </if >
10+ <if test =" {TestTable.createtime} != nil" >AND createtime = #{TestTable.createtime} </if >
11+ </where >
12+ </select >
13+
14+ <select id =" selectTestTableCount" >
15+ SELECT COUNT(*) FROM test_table
16+ <where >
17+ <if test =" {TestTable.id} != nil and {TestTable.id} != 0" >AND id = #{TestTable.id} </if >
18+ <if test =" {TestTable.username} != nil" >AND username = #{TestTable.username} </if >
19+ <if test =" {TestTable.password} != nil" >AND password = #{TestTable.password} </if >
20+ <if test =" {TestTable.createtime} != nil" >AND createtime = #{TestTable.createtime} </if >
21+ </where >
22+ </select >
23+
24+ <insert id =" insertTestTable" >
25+ INSERT INTO test_table (id,username,password,createtime)
26+ VALUES(
27+ #{TestTable.id},
28+ #{TestTable.username},
29+ #{TestTable.password},
30+ #{TestTable.createtime}
31+ )
32+ </insert >
33+
34+ <insert id =" insertBatchTestTable" >
35+ INSERT INTO test_table (id,username,password,createtime)
36+ VALUES
37+ <foreach item =" item" index =" index" collection =" {0}" open =" " separator =" ," close =" " >
38+ (#{item.TestTable.id},#{item.TestTable.username},#{item.TestTable.password},#{item.TestTable.createtime})
39+ </foreach >
40+ </insert >
41+
42+ <update id =" updateTestTable" >
43+ UPDATE test_table
44+ <set >
45+ <if test =" {TestTable.username} != nil" > username = #{TestTable.username} </if >
46+ <if test =" {TestTable.password} != nil" > password = #{TestTable.password} </if >
47+ <if test =" {TestTable.createtime} != nil" > createtime = #{TestTable.createtime} </if >
48+ </set >
49+ WHERE id = #{TestTable.id}
50+ </update >
51+
52+ <delete id =" deleteTestTable" >
53+ DELETE FROM test_table
54+ <where >
55+ <if test =" {TestTable.id} != nil and {TestTable.id} != 0" >AND id = #{TestTable.id} </if >
56+ <if test =" {TestTable.username} != nil" >AND username = #{TestTable.username} </if >
57+ <if test =" {TestTable.password} != nil" >AND password = #{TestTable.password} </if >
58+ <if test =" {TestTable.createtime} != nil" >AND createtime = #{TestTable.createtime} </if >
59+ </where >
60+ </delete >
61+ </mapper >
0 commit comments