<?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.ssm.manage.mapper.RlPowerMapper">

    <resultMap id="BaseResultMap" type="com.ssm.manage.entity.RlPower">
        <result property="powerId" column="power_id"/>
        <result property="powerName" column="power_name"/>
    </resultMap>

    <sql id="Base_Column_List">
        power_id
        , power_name
    </sql>
    <insert id="insertPower" parameterType="com.ssm.manage.dto.RlPowerDto">
        insert into rl_power(power_id, power_name) values(#{powerId}, #{powerName})
        <selectKey keyProperty="powerId" resultType="java.lang.Integer" order="AFTER">
            select last_insert_id()
        </selectKey>
    </insert>

    <select id="queryAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from rl_power
        <where>
            <if test="powerId != null">
                and power_id = #{powerId}
            </if>
            <if test="powerName != null and powerName != ''">
                and power_name = #{powerName}
            </if>
        </where>
    </select>


</mapper>
