郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?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.gk.hotwork.Mapper.RoleInfoMapper" >
  <resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.RoleInfo" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="createdby" property="createdby" jdbcType="VARCHAR" />
    <result column="createddate" property="createddate" jdbcType="TIMESTAMP" />
    <result column="lastmodifiedby" property="lastmodifiedby" jdbcType="VARCHAR" />
    <result column="lastmodifieddate" property="lastmodifieddate" jdbcType="TIMESTAMP" />
    <result column="description" property="description" jdbcType="VARCHAR" />
    <result column="code" property="code" jdbcType="VARCHAR" />
    <result column="btnaccess" property="btnaccess" jdbcType="VARCHAR" />
    <result column="isdel" property="isdel" jdbcType="TINYINT" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--          -->
    id, name, createdby, createddate, lastmodifiedby, lastmodifieddate, description,
    code, btnaccess,isdel
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    <!--          -->
    select
    <include refid="Base_Column_List" />
    from role
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="selectRoleByUser" resultType="com.gk.hotwork.Domain.RoleInfo">
    SELECT
    role.id,
    role.`name`
    from role
    LEFT JOIN userroles on userroles.roleid = role.id
    where
    userroles.userid = #{id,jdbcType=BIGINT}
  </select>
  <select id="selectList" resultType="com.gk.hotwork.Domain.RoleInfo">
    select
    <include refid="Base_Column_List" />
    from role
    <where>
        1=1
        and isdel = 0
      <if test="name != null and name !=''">
       and name = #{name}
      </if>
    </where>
  </select>
  <select id="selectExistRole" resultType="com.gk.hotwork.Domain.RoleInfo">
    select
    <include refid="Base_Column_List" />
    from role
    <where>
      1=1
      <if test="name != null and name !=''">
        and name = #{name}
      </if>
      <if test="id != null">
        and id != #{id}
      </if>
    </where>
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    <!--          -->
    delete from role
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <update id="updateByPrimaryKeySelective" parameterType="com.gk.hotwork.Domain.RoleInfo" >
    <!--          -->
    update role
    <set >
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="createdby != null" >
        createdby = #{createdby,jdbcType=VARCHAR},
      </if>
      <if test="createddate != null" >
        createddate = #{createddate,jdbcType=TIMESTAMP},
      </if>
      <if test="lastmodifiedby != null" >
        lastmodifiedby = #{lastmodifiedby,jdbcType=VARCHAR},
      </if>
      <if test="lastmodifieddate != null" >
        lastmodifieddate = #{lastmodifieddate,jdbcType=TIMESTAMP},
      </if>
      <if test="description != null" >
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="code != null" >
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="btnaccess != null" >
        btnaccess = #{btnaccess,jdbcType=VARCHAR},
      </if>
      <if test="isdel != null">
        isdel = #{isdel,jdbcType=TINYINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gk.hotwork.Domain.RoleInfo" >
    <!--          -->
    update role
    set name = #{name,jdbcType=VARCHAR},
      createdby = #{createdby,jdbcType=VARCHAR},
      createddate = #{createddate,jdbcType=TIMESTAMP},
      lastmodifiedby = #{lastmodifiedby,jdbcType=VARCHAR},
      lastmodifieddate = #{lastmodifieddate,jdbcType=TIMESTAMP},
      description = #{description,jdbcType=VARCHAR},
      code = #{code,jdbcType=VARCHAR},
      btnaccess = #{btnaccess,jdbcType=VARCHAR},
      isdel = #{isdel,jdbcType=TINYINT},
    where id = #{id,jdbcType=BIGINT}
  </update>
  <select id="selectOauthRoleByUser" resultType="com.gk.hotwork.Config.Oauth2.OauthRole">
    SELECT
    ar.id,
    ar.NAME,
    ar.code,
    ar.btnaccess
    FROM
    userroles AS aur
    LEFT JOIN role AS ar ON ar.id = aur.roleid
    WHERE
    aur.userid = #{id,jdbcType=INTEGER}
  </select>
    <select id="selectRoleCount" resultType="java.lang.Integer">
      select
      count(0)
      from role
      where isdel = 0
      <if test="name != null and name != ''">
       and name like concat("%",#{name},"%")
      </if>
    </select>
  <select id="selectPageForRole" resultType="com.gk.hotwork.Domain.RoleInfo">
      select
      *
      from role
      where isdel = 0
    <if test="params.name != null and params.name != ''">
      and name like concat("%",#{params.name},"%")
    </if>
    order by createddate desc
    <if test="params.first != null and params.pageSize != null">
      limit #{params.first},#{params.pageSize}
    </if>
  </select>
</mapper>