123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <?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.fs.company.mapper.CompanyRoleMapper">
- <resultMap type="CompanyRole" id="CompanyRoleResult">
- <result property="roleId" column="role_id" />
- <result property="companyId" column="company_id" />
- <result property="roleName" column="role_name" />
- <result property="roleKey" column="role_key" />
- <result property="roleSort" column="role_sort" />
- <result property="dataScope" column="data_scope" />
- <result property="menuCheckStrictly" column="menu_check_strictly" />
- <result property="deptCheckStrictly" column="dept_check_strictly" />
- <result property="status" column="status" />
- <result property="delFlag" column="del_flag" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- </resultMap>
- <sql id="selectCompanyRoleVo">
- select role_id, company_id, role_name, role_key, role_sort, data_scope, menu_check_strictly, dept_check_strictly, status, del_flag, create_by, create_time, update_by, update_time, remark from company_role
- </sql>
- <select id="selectCompanyRoleList" parameterType="CompanyRole" resultMap="CompanyRoleResult">
- <include refid="selectCompanyRoleVo"/>
- <where>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="roleName != null and roleName != ''"> and role_name like concat('%', #{roleName}, '%')</if>
- <if test="roleKey != null and roleKey != ''"> and role_key = #{roleKey}</if>
- <if test="roleSort != null "> and role_sort = #{roleSort}</if>
- <if test="dataScope != null and dataScope != ''"> and data_scope = #{dataScope}</if>
- <if test="menuCheckStrictly != null "> and menu_check_strictly = #{menuCheckStrictly}</if>
- <if test="deptCheckStrictly != null "> and dept_check_strictly = #{deptCheckStrictly}</if>
- <if test="status != null and status != ''"> and status = #{status}</if>
- </where>
- </select>
- <select id="selectCompanyRoleById" parameterType="Long" resultMap="CompanyRoleResult">
- <include refid="selectCompanyRoleVo"/>
- where role_id = #{roleId}
- </select>
- <insert id="insertCompanyRole" parameterType="CompanyRole" useGeneratedKeys="true" keyProperty="roleId">
- insert into company_role
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="companyId != null">company_id,</if>
- <if test="roleName != null and roleName != ''">role_name,</if>
- <if test="roleKey != null and roleKey != ''">role_key,</if>
- <if test="roleSort != null">role_sort,</if>
- <if test="dataScope != null">data_scope,</if>
- <if test="menuCheckStrictly != null">menu_check_strictly,</if>
- <if test="deptCheckStrictly != null">dept_check_strictly,</if>
- <if test="status != null and status != ''">status,</if>
- <if test="delFlag != null">del_flag,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="companyId != null">#{companyId},</if>
- <if test="roleName != null and roleName != ''">#{roleName},</if>
- <if test="roleKey != null and roleKey != ''">#{roleKey},</if>
- <if test="roleSort != null">#{roleSort},</if>
- <if test="dataScope != null">#{dataScope},</if>
- <if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
- <if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
- <if test="status != null and status != ''">#{status},</if>
- <if test="delFlag != null">#{delFlag},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- </trim>
- </insert>
- <update id="updateCompanyRole" parameterType="CompanyRole">
- update company_role
- <trim prefix="SET" suffixOverrides=",">
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
- <if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
- <if test="roleSort != null">role_sort = #{roleSort},</if>
- <if test="dataScope != null">data_scope = #{dataScope},</if>
- <if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
- <if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
- <if test="status != null and status != ''">status = #{status},</if>
- <if test="delFlag != null">del_flag = #{delFlag},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- </trim>
- where role_id = #{roleId}
- </update>
- <delete id="deleteCompanyRoleById" parameterType="Long">
- delete from company_role where role_id = #{roleId}
- </delete>
- <delete id="deleteCompanyRoleByIds" parameterType="String">
- delete from company_role where role_id in
- <foreach item="roleId" collection="array" open="(" separator="," close=")">
- #{roleId}
- </foreach>
- </delete>
- <select id="selectRolePermissionByUserId" parameterType="Long" resultMap="CompanyRoleResult">
- <include refid="selectRoleVo"/>
- WHERE r.del_flag = '0' and ur.user_id = #{userId}
- </select>
- <sql id="selectRoleVo">
- select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
- r.status, r.del_flag, r.create_time, r.remark
- from company_role r
- left join company_user_role ur on ur.role_id = r.role_id
- left join company_user u on u.user_id = ur.user_id
- left join company_dept d on u.dept_id = d.dept_id
- </sql>
- <select id="selectRolesByUserName" parameterType="String" resultMap="CompanyRoleResult">
- <include refid="selectRoleVo"/>
- WHERE r.del_flag = '0' and u.user_name = #{userName}
- </select>
- <select id="checkRoleNameUnique" parameterType="String" resultMap="CompanyRoleResult">
- <include refid="selectRoleVo"/>
- <where>
- <if test="roleName != null">
- AND r.role_name=#{roleName}
- </if>
- <if test="companyId != null">
- AND r.company_id = #{companyId}
- </if>
- </where>
- limit 1
- </select>
- <select id="checkRoleKeyUnique" parameterType="String" resultMap="CompanyRoleResult">
- <include refid="selectRoleVo"/>
- <where>
- <if test="roleKey != null">
- AND r.role_key=#{roleKey}
- </if>
- <if test="companyId != null">
- AND r.company_id = #{companyId}
- </if>
- </where>
- limit 1
- </select>
- <select id="selectRoleListByUserId" parameterType="Long" resultType="Integer">
- select r.role_id
- from company_role r
- left join company_user_role ur on ur.role_id = r.role_id
- left join company_user u on u.user_id = ur.user_id
- where u.user_id = #{userId}
- </select>
- <select id="selectRoleListByIds" resultType="com.fs.company.domain.CompanyRole">
- select * from company_role
- where del_flag = '0' and status = '0'
- and role_id in
- <foreach collection="roleIds" item="roleId" separator="," open="(" close=")">
- #{roleId}
- </foreach>
- </select>
- <select id="selectCompanyRoleByRoleKey" resultType="com.fs.company.domain.CompanyRole">
- SELECT * FROM company_role WHERE del_flag=0 AND role_key = #{roleKey}
- </select>
- </mapper>
|