<?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.gyee.frame.mapper.auto.GyeepermissionMapper">
  <resultMap id="BaseResultMap" type="com.gyee.frame.model.auto.Gyeepermission">
    <result column="id" jdbcType="VARCHAR" property="id" />
    <result column="permisssionlevel" jdbcType="VARCHAR" property="permisssionlevel" />
    <result column="permisssionname" jdbcType="VARCHAR" property="permisssionname" />
    <result column="describes" jdbcType="VARCHAR" property="describes" />
    <result column="remark1" jdbcType="VARCHAR" property="remark1" />
    <result column="remark2" jdbcType="VARCHAR" property="remark2" />
    <result column="parent" jdbcType="VARCHAR" property="parent" />
    <result column="isable" jdbcType="VARCHAR" property="isable" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
<sql id="Base_Column_List">
	  	  	      	id,
       	  	      	permisssionlevel,
       	  	      	permisssionname,
       	  	      	describes,
       	  	      	remark1,
       	  	      	remark2,
       	  	      	parent,
       	  	    	  	isable
       	</sql>
  <select id="selectByExample" parameterType="com.gyee.frame.model.auto.GyeepermissionExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from gyeepermission
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from gyeepermission
    where id = #{id,jdbcType=VARCHAR}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from gyeepermission
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.GyeepermissionExample">
    delete from gyeepermission
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  
  <insert id="insert" parameterType="com.gyee.frame.model.auto.Gyeepermission">
    insert into gyeepermission (
      	  	       id,
       	  	       permisssionlevel,
       	  	       permisssionname,
       	  	       describes,
       	  	       remark1,
       	  	       remark2,
       	  	       parent,
       	  	    	  isable
       	    )
    values (
	  	  	      	#{id,jdbcType=VARCHAR},
       	  	      	#{permisssionlevel,jdbcType=VARCHAR},
       	  	      	#{permisssionname,jdbcType=VARCHAR},
       	  	      	#{describes,jdbcType=VARCHAR},
       	  	      	#{remark1,jdbcType=VARCHAR},
       	  	      	#{remark2,jdbcType=VARCHAR},
       	  	      	#{parent,jdbcType=VARCHAR},
       	  	    	  #{isable,jdbcType=VARCHAR}
       	    )
  </insert>
  
  <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.Gyeepermission">
    insert into gyeepermission
    <trim prefix="(" suffix=")" suffixOverrides=",">
          
      <if test="id != null">
        id,
      </if>
      
         
      <if test="permisssionlevel != null">
        permisssionlevel,
      </if>
      
         
      <if test="permisssionname != null">
        permisssionname,
      </if>
      
         
      <if test="describes != null">
        describes,
      </if>
      
         
      <if test="remark1 != null">
        remark1,
      </if>
      
         
      <if test="remark2 != null">
        remark2,
      </if>
      
         
      <if test="parent != null">
        parent,
      </if>
      
         
      <if test="isable != null">
        isable,
      </if>
      
         </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
          <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
          <if test="permisssionlevel != null">
        #{permisssionlevel,jdbcType=VARCHAR},
      </if>
          <if test="permisssionname != null">
        #{permisssionname,jdbcType=VARCHAR},
      </if>
          <if test="describes != null">
        #{describes,jdbcType=VARCHAR},
      </if>
          <if test="remark1 != null">
        #{remark1,jdbcType=VARCHAR},
      </if>
          <if test="remark2 != null">
        #{remark2,jdbcType=VARCHAR},
      </if>
          <if test="parent != null">
        #{parent,jdbcType=VARCHAR},
      </if>
          <if test="isable != null">
        #{isable,jdbcType=VARCHAR},
      </if>
        </trim>
  </insert>
  
  <select id="countByExample" parameterType="com.gyee.frame.model.auto.GyeepermissionExample" resultType="java.lang.Long">
    select count(*) from gyeepermission
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  
  <update id="updateByExampleSelective" parameterType="map">
    update gyeepermission
    <set>
          <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
          <if test="record.permisssionlevel != null">
        permisssionlevel = #{record.permisssionlevel,jdbcType=VARCHAR},
      </if>
          <if test="record.permisssionname != null">
        permisssionname = #{record.permisssionname,jdbcType=VARCHAR},
      </if>
          <if test="record.describes != null">
        describes = #{record.describes,jdbcType=VARCHAR},
      </if>
          <if test="record.remark1 != null">
        remark1 = #{record.remark1,jdbcType=VARCHAR},
      </if>
          <if test="record.remark2 != null">
        remark2 = #{record.remark2,jdbcType=VARCHAR},
      </if>
          <if test="record.parent != null">
        parent = #{record.parent,jdbcType=VARCHAR},
      </if>
          <if test="record.isable != null">
        isable = #{record.isable,jdbcType=VARCHAR},
      </if>
         
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  
  
  <update id="updateByExample" parameterType="map">
    update gyeepermission
    set
            	     	 id = #{record.id,jdbcType=VARCHAR},
    	         	     	 permisssionlevel = #{record.permisssionlevel,jdbcType=VARCHAR},
    	         	     	 permisssionname = #{record.permisssionname,jdbcType=VARCHAR},
    	         	     	 describes = #{record.describes,jdbcType=VARCHAR},
    	         	     	 remark1 = #{record.remark1,jdbcType=VARCHAR},
    	         	     	 remark2 = #{record.remark2,jdbcType=VARCHAR},
    	         	     	 parent = #{record.parent,jdbcType=VARCHAR},
    	         	     	 isable = #{record.isable,jdbcType=VARCHAR}
    	         <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  
  
      <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.Gyeepermission">
    update gyeepermission
    <set>
                          <if test="permisssionlevel != null">
        permisssionlevel = #{permisssionlevel,jdbcType=VARCHAR},
      </if>
                      <if test="permisssionname != null">
        permisssionname = #{permisssionname,jdbcType=VARCHAR},
      </if>
                      <if test="describes != null">
        describes = #{describes,jdbcType=VARCHAR},
      </if>
                      <if test="remark1 != null">
        remark1 = #{remark1,jdbcType=VARCHAR},
      </if>
                      <if test="remark2 != null">
        remark2 = #{remark2,jdbcType=VARCHAR},
      </if>
                      <if test="parent != null">
        parent = #{parent,jdbcType=VARCHAR},
      </if>
                      <if test="isable != null">
        isable = #{isable,jdbcType=VARCHAR},
      </if>
              </set>
    where 
            id = #{id,jdbcType=VARCHAR}
                                                                  
  </update>

      	      	   	      	   	      	   	      	   	      	   	      	   	      	   	      	

  <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.Gyeepermission">
    update gyeepermission
    set 
             	        	    	 			permisssionlevel = #{permisssionlevel,jdbcType=VARCHAR},
		     	        	    	 			permisssionname = #{permisssionname,jdbcType=VARCHAR},
		     	        	    	 			describes = #{describes,jdbcType=VARCHAR},
		     	        	    	 			remark1 = #{remark1,jdbcType=VARCHAR},
		     	        	    	 			remark2 = #{remark2,jdbcType=VARCHAR},
		     	        	    	 			parent = #{parent,jdbcType=VARCHAR},
		     	        	    	 			isable = #{isable,jdbcType=VARCHAR}
		     	        where 
            id = #{id,jdbcType=VARCHAR}
                                                                    
  </update>
  
  <select id="queryPermissionByRoleId" parameterType="java.lang.String" resultType="com.gyee.frame.model.auto.Gyeepermission">
       select * from gyeepermission gp inner join gyeerolepermission grp on gp.id=grp.permisssionid inner join gyeeuserrole gur on grp.roleid=gur.roleid where gur.userid=#{userid,jdbcType=VARCHAR}
 </select>
  
                                            
</mapper>