liuxiaolong
2019-05-06 f99bc8c6a1d10610373738edd7d0aa0181c81d99
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
102
103
104
105
106
107
108
109
110
111
<?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.cloud.user.dao.SysRoleDao">
 
    <select id="count" resultType="int">
        select count(*) from sys_role t WHERE  t.delFlag = '0'
        <if test="name != null and name != ''">
            and t.name like concat('%', #{name}, '%')
        </if>
        <if test="orgId != null and orgId != ''">
            and orgId = #{orgId}
        </if>
    </select>
 
    <select id="findData" resultType="com.cloud.model.sys.SysRole" parameterType="map">
        select * from sys_role t
        WHERE  t.delFlag = '0'
        <if test="name != null and name != ''">
            and t.name like concat('%', #{name}, '%')
        </if>
        <if test="orgId != null and orgId != ''">
            and orgId = #{orgId}
        </if>
        <if test="start != null and length != null">
            limit ${start},${length}
        </if>
    </select>
 
    <!--验证角色名称-->
    <select id="findByName" parameterType="map" resultType="com.cloud.model.sys.SysRole">
        select * from sys_role t
        WHERE t.delFlag = '0'
        and t.name = #{name}
        <if test="orgId != null and orgId != ''">
            and orgId = #{orgId}
        </if>
    </select>
 
    <select id="findByIdParams" resultType="com.cloud.model.sys.SysRole">
        select * from sys_role t where delFlag = '0'  and t.id = #{id}
        <if test="orgId != null">
            and orgId = #{orgId}
        </if>
    </select>
 
    <update id="delete" >
        UPDATE sys_role SET
        delFlag = '1' WHERE id = #{id}
        <if test="orgId != null">
            and orgId = #{orgId}
        </if>
    </update>
 
    <!--角色下拉列表查询-->
    <select id="findRoleList" parameterType="map" resultType="map">
        select id,name from sys_role where delFlag = '0'
        <if test="orgId != null and orgId != ''">
            and orgId = #{orgId}
        </if>
    </select>
 
    <!--角色修改-->
    <update id="updateByPrimaryKeySelective" parameterType="com.cloud.model.sys.SysRole">
        update sys_role
        <set>
            <if test="orgId != null">
                orgId = #{orgId,jdbcType=INTEGER},
            </if>
            <if test="name != null">
                name = #{name,jdbcType=VARCHAR},
            </if>
            <if test="code != null">
                code = #{code,jdbcType=VARCHAR},
            </if>
            <if test="roleType != null">
                roleType = #{roleType,jdbcType=VARCHAR},
            </if>
            <if test="dataScope != null">
                dataScope = #{dataScope,jdbcType=VARCHAR},
            </if>
            <if test="isSys != null">
                isSys = #{isSys,jdbcType=INTEGER},
            </if>
            <if test="enabled != null">
                enabled = #{enabled,jdbcType=VARCHAR},
            </if>
            <if test="delFlag != null">
                delFlag = #{delFlag,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                createTime = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                updateTime = #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
 
    <!--更新前删除角色相关的权限-->
    <delete id="deleteRoleMenus" parameterType="map">
        DELETE FROM sys_role_menu WHERE roleId = #{id} and orgId = #{orgId}
    </delete>
 
    <!--更新角色权限-->
    <insert id="saveRoleMenus" parameterType="map">
        INSERT sys_role_menu values(#{id},#{menuId},#{orgId})
    </insert>
 
</mapper>