| New file | 
|  |  |  | 
|---|
|  |  |  | <?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.BaRolePermissionsMapper"> | 
|---|
|  |  |  | <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaRolePermissions"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | <!--@Table ba_role_permissions--> | 
|---|
|  |  |  | <id column="id" jdbcType="BIGINT" property="id" /> | 
|---|
|  |  |  | <result column="roleId" jdbcType="BIGINT" property="roleid" /> | 
|---|
|  |  |  | <!--    <result column="permissions" jdbcType="VARCHAR" property="permissions" />--> | 
|---|
|  |  |  | <result column="permissions" property="permissions" jdbcType="JAVA_OBJECT" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" /> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  | <sql id="Base_Column_List"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | id, roleId, permissions | 
|---|
|  |  |  | </sql> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List" /> | 
|---|
|  |  |  | from ba_role_permissions | 
|---|
|  |  |  | where id = #{id,jdbcType=BIGINT} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | delete from ba_role_permissions | 
|---|
|  |  |  | where id = #{id,jdbcType=BIGINT} | 
|---|
|  |  |  | </delete> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--依据角色编号删除角色授权--> | 
|---|
|  |  |  | <delete id="delPermissionsByRoleId" parameterType="java.lang.Long"> | 
|---|
|  |  |  | delete from ba_role_permissions where roleId = ${roleId} | 
|---|
|  |  |  | </delete> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRolePermissions"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | insert into ba_role_permissions (id, roleId, permissions | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | values (#{id,jdbcType=BIGINT}, #{roleid,jdbcType=BIGINT}, #{permissions,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | </insert> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRolePermissions"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | insert into ba_role_permissions | 
|---|
|  |  |  | <trim prefix="(" suffix=")" suffixOverrides=","> | 
|---|
|  |  |  | <if test="id != null"> | 
|---|
|  |  |  | id, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="roleid != null"> | 
|---|
|  |  |  | roleId, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="permissions != null"> | 
|---|
|  |  |  | permissions, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | <trim prefix="values (" suffix=")" suffixOverrides=","> | 
|---|
|  |  |  | <if test="id != null"> | 
|---|
|  |  |  | #{id,jdbcType=BIGINT}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="roleid != null"> | 
|---|
|  |  |  | #{roleid,jdbcType=BIGINT}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="permissions != null"> | 
|---|
|  |  |  | #{permissions,jdbcType=JAVA_OBJECT,typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </insert> | 
|---|
|  |  |  | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRolePermissions"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | update ba_role_permissions | 
|---|
|  |  |  | <set> | 
|---|
|  |  |  | <if test="roleid != null"> | 
|---|
|  |  |  | roleId = #{roleid,jdbcType=BIGINT}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="permissions != null"> | 
|---|
|  |  |  | permissions = #{permissions,jdbcType=JAVA_OBJECT,typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </set> | 
|---|
|  |  |  | where id = #{id,jdbcType=BIGINT} | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRolePermissions"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | update ba_role_permissions | 
|---|
|  |  |  | set roleId = #{roleid,jdbcType=BIGINT}, | 
|---|
|  |  |  | permissions = #{permissions,jdbcType=JAVA_OBJECT,typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler} | 
|---|
|  |  |  | where id = #{id,jdbcType=BIGINT} | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--根据指定条件获取角色记录数--> | 
|---|
|  |  |  | <select id="getRecordCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM ba_role role | 
|---|
|  |  |  | LEFT JOIN ba_role_permissions per ON per.roleId = role.id | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | AND role.deleted = 0 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <if test = "roleId != null and roleId > 0"> | 
|---|
|  |  |  | AND role.id = ${roleId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <if test = "roleName != null and roleName !=''"> | 
|---|
|  |  |  | AND role.name LIKE CONCAT('%',#{roleName},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--根据指定条件获取角色记录--> | 
|---|
|  |  |  | <select id="getRoles" resultType="com.dy.pipIrrGlobal.voBa.VoRole"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CAST(role.id AS char) AS roleId, | 
|---|
|  |  |  | role.name AS roleName, | 
|---|
|  |  |  | per.id AS perId, | 
|---|
|  |  |  | (SELECT `name` FROM ba_user WHERE id =  role.operator) AS operator, | 
|---|
|  |  |  | role.operate_dt AS operateDt | 
|---|
|  |  |  | FROM ba_role role | 
|---|
|  |  |  | LEFT JOIN ba_role_permissions per ON per.roleId = role.id | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | AND role.deleted = 0 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <if test = "roleId != null and roleId > 0"> | 
|---|
|  |  |  | AND role.id = ${roleId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <if test = "roleName != null and roleName !=''"> | 
|---|
|  |  |  | AND role.name LIKE CONCAT('%',#{roleName},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | ORDER BY role.operate_dt DESC | 
|---|
|  |  |  | <trim prefix="limit " > | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|