ROLEMapper.xml
3.2 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
<?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.tianbo.warehouse.dao.ROLEMapper" >
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.ROLE" >
<id column="ROLE_ID" property="roleId" jdbcType="DECIMAL" />
<result column="ROLE_NAME" property="roleName" jdbcType="VARCHAR" />
<result column="ROLE_SIGN" property="roleSign" jdbcType="VARCHAR" />
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
ROLE_ID, ROLE_NAME, ROLE_SIGN, DESCRIPTION
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.math.BigDecimal" >
select
<include refid="Base_Column_List" />
from ROLE
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
</select>
<select id="findRolesByUserId" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
SELECT
R.*
FROM
USERS U
LEFT JOIN USER_ROLE UR ON U .USER_ID = UR.USER_ID
LEFT JOIN ROLE R ON R.ROLE_ID= UR.ROLE_ID
where U.USER_ID = #{userId,jdbcType=DECIMAL}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal" >
delete from ROLE
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
</delete>
<insert id="insert" parameterType="com.tianbo.warehouse.model.ROLE" >
insert into ROLE (ROLE_ID, ROLE_NAME, ROLE_SIGN,
DESCRIPTION)
values (#{roleId,jdbcType=DECIMAL}, #{roleName,jdbcType=VARCHAR}, #{roleSign,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.ROLE" >
insert into ROLE
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="roleId != null" >
ROLE_ID,
</if>
<if test="roleName != null" >
ROLE_NAME,
</if>
<if test="roleSign != null" >
ROLE_SIGN,
</if>
<if test="description != null" >
DESCRIPTION,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="roleId != null" >
#{roleId,jdbcType=DECIMAL},
</if>
<if test="roleName != null" >
#{roleName,jdbcType=VARCHAR},
</if>
<if test="roleSign != null" >
#{roleSign,jdbcType=VARCHAR},
</if>
<if test="description != null" >
#{description,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.ROLE" >
update ROLE
<set >
<if test="roleName != null" >
ROLE_NAME = #{roleName,jdbcType=VARCHAR},
</if>
<if test="roleSign != null" >
ROLE_SIGN = #{roleSign,jdbcType=VARCHAR},
</if>
<if test="description != null" >
DESCRIPTION = #{description,jdbcType=VARCHAR},
</if>
</set>
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
</update>
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.ROLE" >
update ROLE
set ROLE_NAME = #{roleName,jdbcType=VARCHAR},
ROLE_SIGN = #{roleSign,jdbcType=VARCHAR},
DESCRIPTION = #{description,jdbcType=VARCHAR}
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
</update>
</mapper>