PERMISSIONMapper.xml 6.5 KB
<?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.tianbo.warehouse.dao.PERMISSIONMapper" >
  <resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.PERMISSION" >
    <id column="permission_id" property="permissionId" jdbcType="INTEGER" />
    <result column="permission_name" property="permissionName" jdbcType="VARCHAR" />
    <result column="permission_sign" property="permissionSign" jdbcType="VARCHAR" />
    <result column="description" property="description" jdbcType="VARCHAR" />
    <result column="group_name" property="groupName" jdbcType="VARCHAR" />
    <result column="parent_id" property="parentId" jdbcType="INTEGER" />
    <result column="path" property="path" jdbcType="VARCHAR" />
    <result column="url" property="url" jdbcType="VARCHAR" />
    <result column="ext1" property="ext1" jdbcType="VARCHAR" />
    <result column="ext2" property="ext2" jdbcType="VARCHAR" />
    <result column="ext3" property="ext3" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    permission_id, permission_name, permission_sign, description, group_name, parent_id, 
    path, url, ext1, ext2, ext3
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from permission
    where permission_id = #{permissionId,jdbcType=INTEGER}
  </select>
  <select id="findAll" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from permission
  </select>
  <select id="findByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    SELECT
    P .*
    FROM
    permission P
    WHERE
    P .PERMISSION_ID IN (
    SELECT
    RP.permission_id
    FROM
    ROLE_PERMISSION RP
    WHERE
    RP.role_id IN (
    SELECT
    R.ROLE_ID
    FROM
    role R
    WHERE
    R.ROLE_ID IN (
    SELECT
    UR.ROLE_ID
    FROM
    USER_ROLE UR
    WHERE
    UR.USER_ID = #{userId,jdbcType=INTEGER}
    )
    )
    )
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from permission
    where permission_id = #{permissionId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.tianbo.warehouse.model.PERMISSION" >
    insert into permission (permission_id, permission_name, permission_sign, 
      description, group_name, parent_id, 
      path, url, ext1, ext2, 
      ext3)
    values (#{permissionId,jdbcType=INTEGER}, #{permissionName,jdbcType=VARCHAR}, #{permissionSign,jdbcType=VARCHAR}, 
      #{description,jdbcType=VARCHAR}, #{groupName,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, 
      #{path,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, 
      #{ext3,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.tianbo.warehouse.model.PERMISSION" >
    insert into permission
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="permissionId != null" >
        permission_id,
      </if>
      <if test="permissionName != null" >
        permission_name,
      </if>
      <if test="permissionSign != null" >
        permission_sign,
      </if>
      <if test="description != null" >
        description,
      </if>
      <if test="groupName != null" >
        group_name,
      </if>
      <if test="parentId != null" >
        parent_id,
      </if>
      <if test="path != null" >
        path,
      </if>
      <if test="url != null" >
        url,
      </if>
      <if test="ext1 != null" >
        ext1,
      </if>
      <if test="ext2 != null" >
        ext2,
      </if>
      <if test="ext3 != null" >
        ext3,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="permissionId != null" >
        #{permissionId,jdbcType=INTEGER},
      </if>
      <if test="permissionName != null" >
        #{permissionName,jdbcType=VARCHAR},
      </if>
      <if test="permissionSign != null" >
        #{permissionSign,jdbcType=VARCHAR},
      </if>
      <if test="description != null" >
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="groupName != null" >
        #{groupName,jdbcType=VARCHAR},
      </if>
      <if test="parentId != null" >
        #{parentId,jdbcType=INTEGER},
      </if>
      <if test="path != null" >
        #{path,jdbcType=VARCHAR},
      </if>
      <if test="url != null" >
        #{url,jdbcType=VARCHAR},
      </if>
      <if test="ext1 != null" >
        #{ext1,jdbcType=VARCHAR},
      </if>
      <if test="ext2 != null" >
        #{ext2,jdbcType=VARCHAR},
      </if>
      <if test="ext3 != null" >
        #{ext3,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.PERMISSION" >
    update permission
    <set >
      <if test="permissionName != null" >
        permission_name = #{permissionName,jdbcType=VARCHAR},
      </if>
      <if test="permissionSign != null" >
        permission_sign = #{permissionSign,jdbcType=VARCHAR},
      </if>
      <if test="description != null" >
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="groupName != null" >
        group_name = #{groupName,jdbcType=VARCHAR},
      </if>
      <if test="parentId != null" >
        parent_id = #{parentId,jdbcType=INTEGER},
      </if>
      <if test="path != null" >
        path = #{path,jdbcType=VARCHAR},
      </if>
      <if test="url != null" >
        url = #{url,jdbcType=VARCHAR},
      </if>
      <if test="ext1 != null" >
        ext1 = #{ext1,jdbcType=VARCHAR},
      </if>
      <if test="ext2 != null" >
        ext2 = #{ext2,jdbcType=VARCHAR},
      </if>
      <if test="ext3 != null" >
        ext3 = #{ext3,jdbcType=VARCHAR},
      </if>
    </set>
    where permission_id = #{permissionId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.PERMISSION" >
    update permission
    set permission_name = #{permissionName,jdbcType=VARCHAR},
      permission_sign = #{permissionSign,jdbcType=VARCHAR},
      description = #{description,jdbcType=VARCHAR},
      group_name = #{groupName,jdbcType=VARCHAR},
      parent_id = #{parentId,jdbcType=INTEGER},
      path = #{path,jdbcType=VARCHAR},
      url = #{url,jdbcType=VARCHAR},
      ext1 = #{ext1,jdbcType=VARCHAR},
      ext2 = #{ext2,jdbcType=VARCHAR},
      ext3 = #{ext3,jdbcType=VARCHAR}
    where permission_id = #{permissionId,jdbcType=INTEGER}
  </update>
</mapper>