Repository navigation
Expand file tree
/
Copy pathUser.xml
More file actions
54 lines (46 loc) · 1.86 KB
/
Copy pathUser.xml
File metadata and controls
54 lines (46 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.springboot.mapper.UserMapper">
<insert id="save">
insert into user(name, username, age, sex, phone, address, account)
values(#{name}, #{username}, #{age}, #{sex}, #{phone}, #{address}, #{account})
</insert>
<update id="updateById">
update user set name = #{name}, age = #{age}, sex = #{sex}, phone = #{phone}, address = #{address},
updatetime = #{updatetime}, account = #{account}, status = #{status} where id = #{id}
</update>
<update id="updateByUserNo">
update user set account = account + #{score}, where username = #{userNo}
<set>
<if test="status != null">
status = #{status}
</if>
</set>
</update>
<delete id="deleteById">
delete from user where id = #{id}
</delete>
<select id="list" resultType="com.example.springboot.entity.User">
select * from user
</select>
<select id="listByCondition" resultType="com.example.springboot.entity.User">
select * from user
<where>
<if test="name != null and name != ''">
name like concat('%', #{ name }, '%')
</if>
<if test="phone != null and phone != ''">
and phone like concat('%', #{ phone }, '%')
</if>
</where>
order by id desc
</select>
<select id="getById" resultType="com.example.springboot.entity.User">
select * from user where id = #{id}
</select>
<select id="getByUsername" resultType="com.example.springboot.entity.User">
select * from user where username = #{username}
</select>
</mapper>