| <?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.dy.pmsGlobal.daoBa.BaPrivilegeMapper"> | 
|   <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoBa.BaPrivilege"> | 
|     <!--@mbg.generated--> | 
|     <!--@Table ba_privilege--> | 
|     <id column="id" property="id" /> | 
|     <result column="num" property="num" /> | 
|     <result column="name" property="name" /> | 
|     <result column="type" property="type" /> | 
|   </resultMap> | 
|   <sql id="Base_Column_List"> | 
|     <!--@mbg.generated--> | 
|     id, num, `name`, `type` | 
|   </sql> | 
|   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | 
|     <!--@mbg.generated--> | 
|     select  | 
|     <include refid="Base_Column_List" /> | 
|     from ba_privilege | 
|     where id = #{id} | 
|   </select> | 
|   | 
|   <select id="selectCount" resultType="java.lang.Long"> | 
|     select | 
|       count(*) | 
|     from ba_privilege | 
|   </select> | 
|   | 
|   <select id="selectAll" resultMap="BaseResultMap"> | 
|     select | 
|     <include refid="Base_Column_List" /> | 
|     from ba_privilege | 
|   </select> | 
|   | 
|   <select id="selectPrivilegeByUserId" resultType="Integer"> | 
|     select p.num | 
|     from ba_privilege p | 
|     inner join ba_role_privilege rp on p.id = rp.privilege_id | 
|     inner join ba_user_role ur on rp.role_id = ur.role_id | 
|     inner join ba_role r on ur.role_id = r.id | 
|     where r.deleted != 1 | 
|     <if test="userId != null"> | 
|       and ur.user_id = #{userId, jdbcType=BIGINT} | 
|     </if> | 
|   </select> | 
|   | 
|   <select id="selectPrivilegeByRoleId" resultType="Integer"> | 
|     select p.num | 
|     from ba_privilege p | 
|     inner join ba_role_privilege rp on p.id = rp.privilege_id | 
|     <if test="roleId != null"> | 
|       where rp.role_id = #{roleId, jdbcType=BIGINT} | 
|     </if> | 
|   </select> | 
|   | 
| <!--  <select id="selectByRole" resultType="com.dy.pmsGlobal.pojoBa.BaPrivilege">--> | 
| <!--    select p.id,p.num,p.name,p.type--> | 
| <!--    from ba_privilege p--> | 
| <!--    inner join ba_role_privilege rp on p.id = rp.privilege_id--> | 
| <!--    <if test="roleId != null">--> | 
| <!--      where rp.role_id = #{roleId, jdbcType=BIGINT}--> | 
| <!--    </if>--> | 
| <!--  </select>--> | 
|   | 
|   | 
|   | 
|   <insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege"> | 
|     <!--@mbg.generated--> | 
|     insert into ba_privilege (id, num, `name`, `type`) | 
|     values (#{id}, #{num}, #{name}, #{type}) | 
|   </insert> | 
|   <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege"> | 
|     <!--@mbg.generated--> | 
|     insert into ba_privilege | 
|     <trim prefix="(" suffix=")" suffixOverrides=","> | 
|       <if test="id != null"> | 
|         id, | 
|       </if> | 
|       <if test="num != null"> | 
|         num, | 
|       </if> | 
|       <if test="name != null"> | 
|         `name`, | 
|       </if> | 
|       <if test="type != null"> | 
|         `type`, | 
|       </if> | 
|     </trim> | 
|     <trim prefix="values (" suffix=")" suffixOverrides=","> | 
|       <if test="id != null"> | 
|         #{id}, | 
|       </if> | 
|       <if test="num != null"> | 
|         #{num}, | 
|       </if> | 
|       <if test="name != null"> | 
|         #{name}, | 
|       </if> | 
|       <if test="type != null"> | 
|         #{type}, | 
|       </if> | 
|     </trim> | 
|   </insert> | 
|   <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege"> | 
|     <!--@mbg.generated--> | 
|     update ba_privilege | 
|     <set> | 
|       <if test="num != null"> | 
|         num = #{num}, | 
|       </if> | 
|       <if test="name != null"> | 
|         `name` = #{name}, | 
|       </if> | 
|       <if test="type != null"> | 
|         `type` = #{type}, | 
|       </if> | 
|     </set> | 
|     where id = #{id} | 
|   </update> | 
|   <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege"> | 
|     <!--@mbg.generated--> | 
|     update ba_privilege | 
|     set num = #{num}, | 
|       `name` = #{name}, | 
|       `type` = #{type} | 
|     where id = #{id} | 
|   </update> | 
|   | 
|   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> | 
|     <!--@mbg.generated--> | 
|     delete from ba_privilege | 
|     where id = #{id} | 
|   </delete> | 
|   | 
|   <select id="selectByIds" parameterType="arraylist" resultMap="BaseResultMap"> | 
|     select | 
|     <include refid="Base_Column_List" /> | 
|     from ba_privilege where id in | 
|     <foreach item="id" collection="ids" open="(" separator="," close=")"> | 
|       #{id} | 
|     </foreach> | 
|   </select> | 
| </mapper> |