UserMapper.xml
3.37 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?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.monitor.mysql.mapper.UserMapper" >
<resultMap id="BaseResultMap" type="com.model.User" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="pwd" property="pwd" jdbcType="VARCHAR" />
<result column="level" property="level" jdbcType="INTEGER" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="mobile" property="mobile" jdbcType="VARCHAR" />
<result column="c_name" property="cname" jdbcType="VARCHAR" />
<result column="role" property="role" jdbcType="VARCHAR" />
<result column="modules" property="modules" jdbcType="VARCHAR" />
<result column="module_groups" property="moduleGroups" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, name, pwd, level, email, mobile,c_name,role,modules,module_groups
</sql>
<select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from user
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByName" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from user
where name = #{name,jdbcType=VARCHAR}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user
</select>
<select id="selectUsers" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user
order by id desc
limit #{startIndex},#{pageSize}
</select>
<select id="selectUsersByRole" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user
where role = #{role}
</select>
<delete id="deleteById" parameterType="java.lang.Integer" >
delete from user
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByName" parameterType="java.lang.String" >
delete from user
where name = #{name,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.model.User" >
insert into user
(name,pwd,level,email,mobile,c_name,role,modules,module_groups, create_time, update_time)
values
(#{name,jdbcType=VARCHAR},#{pwd,jdbcType=VARCHAR},#{level,jdbcType=INTEGER},
#{email,jdbcType=VARCHAR},#{mobile,jdbcType=VARCHAR},#{cname,jdbcType=VARCHAR},#{role,jdbcType=VARCHAR},
#{modules,jdbcType=VARCHAR},#{moduleGroups,jdbcType=VARCHAR},
now(),now())
</insert>
<update id="update" parameterType="com.model.User" >
update user
set level = #{level,jdbcType=INTEGER},
email = #{email,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR},
role= #{role,jdbcType=VARCHAR},
c_name= #{cname,jdbcType=VARCHAR},
modules= #{modules,jdbcType=VARCHAR},
module_groups= #{moduleGroups,jdbcType=VARCHAR},
update_time = now()
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updatePwd" parameterType="com.model.User" >
update user
set pwd = #{pwd,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCount" resultType="java.lang.Integer">
select
count(1)
from user
</select>
</mapper>