| <?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.pipIrrGlobal.daoBa.BaPrivilegeMapper"> | 
|   | 
|     <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaPrivilege"> | 
|         <!--@mbg.generated--> | 
|         <!--@Table ba_privilege--> | 
|         <result column="id" jdbcType="BIGINT" property="id" /> | 
|         <result column="num" jdbcType="INTEGER" property="num" /> | 
|         <result column="name" jdbcType="VARCHAR" property="name" /> | 
|         <result column="type" jdbcType="VARCHAR" property="type" /> | 
|     </resultMap> | 
|   | 
|     <sql id="Base_Column_List"> | 
|         <!--@mbg.generated--> | 
|         id, num, name, type | 
|     </sql> | 
|   | 
|     <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.privilegeId | 
|         inner join ba_user_role ur on rp.roleId = ur.roleId | 
|         inner join ba_role r on ur.roleId = r.id | 
|         where r.deleted != 1 | 
|         <if test="userId != null"> | 
|             and ur.userId = #{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.privilegeId | 
|         <if test="roleId != null"> | 
|             where rp.roleId = #{roleId, jdbcType=BIGINT} | 
|         </if> | 
|     </select> | 
|   | 
|     <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaPrivilege"> | 
|         <!--@mbg.generated--> | 
|         insert into ba_privilege (<include refid="Base_Column_List" />) | 
|         values (#{id,jdbcType=BIGINT}, | 
|         #{num,jdbcType=INTEGER}, | 
|         #{name,jdbcType=VARCHAR}, | 
|         #{type, jdbcType=VARCHAR} | 
|         ) | 
|     </insert> | 
|   | 
|     <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaPrivilege"> | 
|         <!--@mbg.generated--> | 
|         insert into ba_privilege | 
|         <trim prefix="(" suffix=")" suffixOverrides=","> | 
|             <if test="id != null"> | 
|                 id, | 
|             </if> | 
|             <if test="num != null"> | 
|                 id, | 
|             </if> | 
|             <if test="name != null"> | 
|                 name, | 
|             </if> | 
|             <if test="type != null"> | 
|                 type, | 
|             </if> | 
|         </trim> | 
|         <trim prefix="values (" suffix=")" suffixOverrides=","> | 
|             <if test="id != null"> | 
|                 #{id,jdbcType=BIGINT}, | 
|             </if> | 
|             <if test="num != null"> | 
|                 #{name,jdbcType=INTEGER}, | 
|             </if> | 
|             <if test="name != null"> | 
|                 #{name,jdbcType=VARCHAR}, | 
|             </if> | 
|             <if test="type != null"> | 
|                 #{type,jdbcType=VARCHAR}, | 
|             </if> | 
|         </trim> | 
|     </insert> | 
| </mapper> |