| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <?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.izouma.awesomeadmin.dao.SysRoleMapper" >
- <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.SysRole" >
- <id column="id" property="id" jdbcType="INTEGER" />
- <result column="office_id" property="officeId" jdbcType="VARCHAR" />
- <result column="name" property="name" jdbcType="VARCHAR" />
- <result column="enname" property="enname" jdbcType="VARCHAR" />
- <result column="role_type" property="roleType" jdbcType="VARCHAR" />
- <result column="is_sys" property="isSys" jdbcType="VARCHAR" />
- <result column="useable" property="useable" jdbcType="VARCHAR" />
- <result column="create_by" property="createBy" jdbcType="VARCHAR" />
- <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
- <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
- <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
- <result column="remarks" property="remarks" jdbcType="VARCHAR" />
- <result column="del_flag" property="delFlag" jdbcType="CHAR" />
- <result column="menu_ids" property="menuIds" jdbcType="VARCHAR" />
- <result column="permission" property="permission" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="Base_Column_List" >
- id, office_id, name, enname, role_type, is_sys, useable, create_by, create_date, update_by, update_date, remarks, del_flag,menu_ids,permission
- </sql>
- <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
- select
- <include refid="Base_Column_List" />
- from sys_role
- where id = #{id,jdbcType=INTEGER}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
- delete from sys_role
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.SysRole" useGeneratedKeys="true" keyProperty="id">
- insert into sys_role
- <trim prefix="(" suffix=")" suffixOverrides="," >
- <if test="id != null" >
- id,
- </if>
- <if test="officeId != null" >
- office_id,
- </if>
- <if test="name != null" >
- name,
- </if>
- <if test="enname != null" >
- enname,
- </if>
- <if test="roleType != null" >
- role_type,
- </if>
- <if test="isSys != null" >
- is_sys,
- </if>
- <if test="useable != null" >
- useable,
- </if>
- <if test="createBy != null" >
- create_by,
- </if>
- <if test="createDate != null" >
- create_date,
- </if>
- <if test="updateBy != null" >
- update_by,
- </if>
- <if test="updateDate != null" >
- update_date,
- </if>
- <if test="remarks != null" >
- remarks,
- </if>
- <if test="menuIds != null" >
- menu_ids,
- </if>
- <if test="permission != null" >
- permission,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides="," >
- <if test="id != null" >
- #{id,jdbcType=INTEGER},
- </if>
- <if test="officeId != null" >
- #{officeId,jdbcType=VARCHAR},
- </if>
- <if test="name != null" >
- #{name,jdbcType=VARCHAR},
- </if>
- <if test="enname != null" >
- #{enname,jdbcType=VARCHAR},
- </if>
- <if test="roleType != null" >
- #{roleType,jdbcType=VARCHAR},
- </if>
- <if test="isSys != null" >
- #{isSys,jdbcType=VARCHAR},
- </if>
- <if test="useable != null" >
- #{useable,jdbcType=VARCHAR},
- </if>
- <if test="createBy != null" >
- #{createBy,jdbcType=VARCHAR},
- </if>
- <if test="createDate != null" >
- #{createDate,jdbcType=TIMESTAMP},
- </if>
- <if test="updateBy != null" >
- #{updateBy,jdbcType=VARCHAR},
- </if>
- <if test="updateDate != null" >
- #{updateDate,jdbcType=TIMESTAMP},
- </if>
- <if test="remarks != null" >
- #{remarks,jdbcType=VARCHAR},
- </if>
- <if test="menuIds != null" >
- #{menuIds,jdbcType=VARCHAR},
- </if>
- <if test="permission != null" >
- #{permission,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.SysRole" >
- update sys_role
- <set >
- <if test="officeId != null" >
- office_id = #{officeId,jdbcType=VARCHAR},
- </if>
- <if test="name != null" >
- name = #{name,jdbcType=VARCHAR},
- </if>
- <if test="enname != null" >
- enname = #{enname,jdbcType=VARCHAR},
- </if>
- <if test="roleType != null" >
- role_type = #{roleType,jdbcType=VARCHAR},
- </if>
- <if test="isSys != null" >
- is_sys = #{isSys,jdbcType=VARCHAR},
- </if>
- <if test="useable != null" >
- useable = #{useable,jdbcType=VARCHAR},
- </if>
- <if test="createBy != null" >
- create_by = #{createBy,jdbcType=VARCHAR},
- </if>
- <if test="createDate != null" >
- create_date = #{createDate,jdbcType=TIMESTAMP},
- </if>
- <if test="updateBy != null" >
- update_by = #{updateBy,jdbcType=VARCHAR},
- </if>
- <if test="updateDate != null" >
- update_date = #{updateDate,jdbcType=TIMESTAMP},
- </if>
- <if test="remarks != null" >
- remarks = #{remarks,jdbcType=VARCHAR},
- </if>
- <if test="delFlag != null" >
- del_flag = #{delFlag,jdbcType=CHAR},
- </if>
- <if test="menuIds != null" >
- menu_ids = #{menuIds,jdbcType=VARCHAR},
- </if>
- <if test="permission != null" >
- permission = #{permission,jdbcType=VARCHAR},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <select id="querySysRolesByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SysRole">
- select <include refid="Base_Column_List"/> from sys_role
- <where>
- and del_flag = 'N'
- <if test="record.id != null and !"".equals(record.id)">
- and id = #{record.id}
- </if>
- <if test="record.officeId != null and !"".equals(record.officeId)">
- and office_id = #{record.officeId}
- </if>
- <if test="record.name != null and !"".equals(record.name)">
- and name = #{record.name}
- </if>
- <if test="record.enname != null and !"".equals(record.enname)">
- and enname = #{record.enname}
- </if>
- <if test="record.roleType != null and !"".equals(record.roleType)">
- and role_type = #{record.roleType}
- </if>
- <if test="record.isSys != null and !"".equals(record.isSys)">
- and is_sys = #{record.isSys}
- </if>
- <if test="record.useable != null and !"".equals(record.useable)">
- and useable = #{record.useable}
- </if>
- <if test="record.createBy != null and !"".equals(record.createBy)">
- and create_by = #{record.createBy}
- </if>
- <if test="record.createDate != null and !"".equals(record.createDate)">
- and create_date = #{record.createDate}
- </if>
- <if test="record.updateBy != null and !"".equals(record.updateBy)">
- and update_by = #{record.updateBy}
- </if>
- <if test="record.updateDate != null and !"".equals(record.updateDate)">
- and update_date = #{record.updateDate}
- </if>
- <if test="record.remarks != null and !"".equals(record.remarks)">
- and remarks = #{record.remarks}
- </if>
- <if test="record.delFlag != null and !"".equals(record.delFlag)">
- and del_flag = #{record.delFlag}
- </if>
- <if test="record.menuIds != null and !"".equals(record.menuIds)">
- and menu_ids = #{record.menuIds}
- </if>
- <if test="record.permission != null and !"".equals(record.permission)">
- and permission = #{record.permission}
- </if>
- </where>
- order by id desc
- </select>
- <select id="queryAllSysRole" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SysRole">
- select <include refid="Base_Column_List"/> from sys_role
- <where>
- and del_flag = 'N'
- <if test="id != null and !"".equals(id)">
- and id = #{id}
- </if>
- <if test="officeId != null and !"".equals(officeId)">
- and office_id = #{officeId}
- </if>
- <if test="name != null and !"".equals(name)">
- and name = #{name}
- </if>
- <if test="enname != null and !"".equals(enname)">
- and enname = #{enname}
- </if>
- <if test="roleType != null and !"".equals(roleType)">
- and role_type = #{roleType}
- </if>
- <if test="isSys != null and !"".equals(isSys)">
- and is_sys = #{isSys}
- </if>
- <if test="useable != null and !"".equals(useable)">
- and useable = #{useable}
- </if>
- <if test="createBy != null and !"".equals(createBy)">
- and create_by = #{createBy}
- </if>
- <if test="createDate != null and !"".equals(createDate)">
- and create_date = #{createDate}
- </if>
- <if test="updateBy != null and !"".equals(updateBy)">
- and update_by = #{updateBy}
- </if>
- <if test="updateDate != null and !"".equals(updateDate)">
- and update_date = #{updateDate}
- </if>
- <if test="remarks != null and !"".equals(remarks)">
- and remarks = #{remarks}
- </if>
- <if test="delFlag != null and !"".equals(delFlag)">
- and del_flag = #{delFlag}
- </if>
- <if test="idStr != null and !"".equals(idStr)">
- and id in (${idStr})
- </if>
- <if test="menuIds != null and !"".equals(menuIds)">
- and menu_ids = #{menuIds}
- </if>
- <if test="permission != null and !"".equals(permission)">
- and permission = #{permission}
- </if>
- </where>
- order by id desc
- </select>
- <select id="querySysRole" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SysRole">
- select <include refid="Base_Column_List"/> from sys_role
- <where>
- and del_flag = 'N'
- <if test="id != null and !"".equals(id)">
- and id = #{id}
- </if>
- <if test="officeId != null and !"".equals(officeId)">
- and office_id = #{officeId}
- </if>
- <if test="name != null and !"".equals(name)">
- and name = #{name}
- </if>
- <if test="enname != null and !"".equals(enname)">
- and enname = #{enname}
- </if>
- <if test="roleType != null and !"".equals(roleType)">
- and role_type = #{roleType}
- </if>
- <if test="isSys != null and !"".equals(isSys)">
- and is_sys = #{isSys}
- </if>
- <if test="useable != null and !"".equals(useable)">
- and useable = #{useable}
- </if>
- <if test="createBy != null and !"".equals(createBy)">
- and create_by = #{createBy}
- </if>
- <if test="createDate != null and !"".equals(createDate)">
- and create_date = #{createDate}
- </if>
- <if test="updateBy != null and !"".equals(updateBy)">
- and update_by = #{updateBy}
- </if>
- <if test="updateDate != null and !"".equals(updateDate)">
- and update_date = #{updateDate}
- </if>
- <if test="remarks != null and !"".equals(remarks)">
- and remarks = #{remarks}
- </if>
- <if test="delFlag != null and !"".equals(delFlag)">
- and del_flag = #{delFlag}
- </if>
- <if test="menuIds != null and !"".equals(menuIds)">
- and menu_ids = #{menuIds}
- </if>
- <if test="permission != null and !"".equals(permission)">
- and permission = #{permission}
- </if>
- </where>
- LIMIT 1
- </select>
- <select id="selectByPrimaryKeys" resultType="com.izouma.awesomeadmin.model.SysRole">
- select
- <include refid="Base_Column_List" />
- from sys_role
- where id in (${ids})
- and del_flag = 'N'
- </select>
- <select id="getUserRoles" resultType="com.izouma.awesomeadmin.model.SysRole">
- select
- <include refid="Base_Column_List" />
- from sys_role
- where id in (select role_id from sys_user_role where user_id = #{userId})
- and del_flag = 'N'
- </select>
- <update id="delete">
- UPDATE sys_role SET del_flag = 'Y'
- <where>
- AND id = #{id}
- </where>
- </update>
- <insert id="setUserRoles">
- insert into sys_user_role (user_id, role_id)
- values
- <foreach collection="roles" item="roleId" separator=",">
- (#{userId}, #{roleId})
- </foreach>
- </insert>
- <delete id="clearUserRoles">
- delete from sys_user_role where user_id = #{userId}
- </delete>
- <insert id="addUserRole">
- insert into sys_user_role (user_id, role_id) values (#{userId}, #{roleId})
- </insert>
- <delete id="removeUserRole">
- delete from sys_user_role when user_id = #{userId} and role_id = #{roleId}
- </delete>
- <select id="getUserRoleId" resultType="java.lang.String">
- SELECT group_concat(role_id) FROM sys_user_role WHERE user_id = #{id}
- </select>
- </mapper>
|