<?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.izouma.awesomeadmin.dao.PowerInfoMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.PowerInfo">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="role_id" property="roleId" jdbcType="INTEGER"/>
        <result column="menu_id" property="menuId" jdbcType="INTEGER"/>
        <result column="can_add" property="canAdd" jdbcType="INTEGER"/>
        <result column="can_delete" property="canDelete" jdbcType="INTEGER"/>
        <result column="can_update" property="canUpdate" jdbcType="INTEGER"/>
        <result column="can_select" property="canSelect" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
		 id, role_id, menu_id, can_add, can_delete, can_update, can_select, del_flag
	</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from sys_power_info
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
		delete from sys_power_info
		where id = #{id,jdbcType=INTEGER}
	</delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.PowerInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into sys_power_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="roleId != null">
                role_id,
            </if>
            <if test="menuId != null">
                menu_id,
            </if>
            <if test="canAdd != null">
                can_add,
            </if>
            <if test="canDelete != null">
                can_delete,
            </if>
            <if test="canUpdate != null">
                can_update,
            </if>
            <if test="canSelect != null">
                can_select,
            </if>
            <if test="delFlag != null">
                del_flag,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="roleId != null">
                #{roleId,jdbcType=INTEGER},
            </if>
            <if test="menuId != null">
                #{menuId,jdbcType=INTEGER},
            </if>
            <if test="canAdd != null">
                #{canAdd,jdbcType=INTEGER},
            </if>
            <if test="canDelete != null">
                #{canDelete,jdbcType=INTEGER},
            </if>
            <if test="canUpdate != null">
                #{canUpdate,jdbcType=INTEGER},
            </if>
            <if test="canSelect != null">
                #{canSelect,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.PowerInfo">
        update sys_power_info
        <set>
            <if test="roleId != null">
                role_id = #{roleId,jdbcType=INTEGER},
            </if>
            <if test="menuId != null">
                menu_id = #{menuId,jdbcType=INTEGER},
            </if>
            <if test="canAdd != null">
                can_add = #{canAdd,jdbcType=INTEGER},
            </if>
            <if test="canDelete != null">
                can_delete = #{canDelete,jdbcType=INTEGER},
            </if>
            <if test="canUpdate != null">
                can_update = #{canUpdate,jdbcType=INTEGER},
            </if>
            <if test="canSelect != null">
                can_select = #{canSelect,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag,jdbcType=CHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryPowerInfosByPage" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.PowerInfo">
        select
        <include refid="Base_Column_List"/>
        from sys_power_info
        <where>
            and del_flag = 'N'
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.roleId != null and !&quot;&quot;.equals(record.roleId)">
                and role_id = #{record.roleId}
            </if>
            <if test="record.menuId != null and !&quot;&quot;.equals(record.menuId)">
                and menu_id = #{record.menuId}
            </if>
            <if test="record.canAdd != null and !&quot;&quot;.equals(record.canAdd)">
                and can_add = #{record.canAdd}
            </if>
            <if test="record.canDelete != null and !&quot;&quot;.equals(record.canDelete)">
                and can_delete = #{record.canDelete}
            </if>
            <if test="record.canUpdate != null and !&quot;&quot;.equals(record.canUpdate)">
                and can_update = #{record.canUpdate}
            </if>
            <if test="record.canSelect != null and !&quot;&quot;.equals(record.canSelect)">
                and can_select = #{record.canSelect}
            </if>
        </where>
        order by id desc
    </select>
    <select id="queryAllPowerInfo" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.PowerInfo">
        select
        <include refid="Base_Column_List"/>
        from sys_power_info
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="roleId != null and !&quot;&quot;.equals(roleId)">
                and role_id = #{roleId}
            </if>
            <if test="menuId != null and !&quot;&quot;.equals(menuId)">
                and menu_id = #{menuId}
            </if>
            <if test="canAdd != null and !&quot;&quot;.equals(canAdd)">
                and can_add = #{canAdd}
            </if>
            <if test="canDelete != null and !&quot;&quot;.equals(canDelete)">
                and can_delete = #{canDelete}
            </if>
            <if test="canUpdate != null and !&quot;&quot;.equals(canUpdate)">
                and can_update = #{canUpdate}
            </if>
            <if test="canSelect != null and !&quot;&quot;.equals(canSelect)">
                and can_select = #{canSelect}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="roleIdStr != null and !&quot;&quot;.equals(roleIdStr)">
                and role_id in (${roleIdStr})
            </if>
        </where>
        order by id desc
    </select>
    <select id="queryPowerInfo" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.PowerInfo">
        select
        <include refid="Base_Column_List"/>
        from sys_power_info
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="roleId != null and !&quot;&quot;.equals(roleId)">
                and role_id = #{roleId}
            </if>
            <if test="menuId != null and !&quot;&quot;.equals(menuId)">
                and menu_id = #{menuId}
            </if>
            <if test="canAdd != null and !&quot;&quot;.equals(canAdd)">
                and can_add = #{canAdd}
            </if>
            <if test="canDelete != null and !&quot;&quot;.equals(canDelete)">
                and can_delete = #{canDelete}
            </if>
            <if test="canUpdate != null and !&quot;&quot;.equals(canUpdate)">
                and can_update = #{canUpdate}
            </if>
            <if test="canSelect != null and !&quot;&quot;.equals(canSelect)">
                and can_select = #{canSelect}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE sys_power_info SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>

    <update id="deleteByRoleId">
        UPDATE sys_power_info SET del_flag = 'Y'
        <where>
            AND role_id = #{roleId}
        </where>
    </update>
</mapper>

