<?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.ruoyi.cc.mapper.CcExtPowerMapper">
    
    <resultMap type="CcExtPower" id="CcExtPowerResult">
        <result property="powerId"    column="power_id"    />
        <result property="extNum"    column="ext_num"    />
        <result property="groupId"    column="group_id"    />
    </resultMap>

    <sql id="selectCcExtPowerVo">
        select power_id, ext_num, group_id from cc_ext_power
    </sql>

    <select id="selectCcExtPowerList" parameterType="CcExtPower" resultMap="CcExtPowerResult">
        <include refid="selectCcExtPowerVo"/>
        <where>  
            <if test="extNum != null  and extNum != ''"> and ext_num = #{extNum}</if>
            <if test="groupId != null  and groupId != ''"> and group_id = #{groupId}</if>
        </where>
    </select>
    
    <select id="selectCcExtPowerByPowerId" parameterType="Long" resultMap="CcExtPowerResult">
        <include refid="selectCcExtPowerVo"/>
        where power_id = #{powerId}
    </select>

    <insert id="insertCcExtPower" parameterType="CcExtPower" useGeneratedKeys="true" keyProperty="powerId">
        insert into cc_ext_power
        <trim prefix="(" suffix=")" suffixOverrides=",">
            ext_num,
            group_id,
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{extNum},
            #{groupId},
         </trim>
    </insert>

    <update id="updateCcExtPower" parameterType="CcExtPower">
        update cc_ext_power
        <trim prefix="SET" suffixOverrides=",">
            group_id = #{groupId},
        </trim>
        where power_id = #{powerId}
    </update>

    <delete id="deleteCcExtPowerByPowerId" parameterType="Long">
        delete from cc_ext_power where power_id = #{powerId}
    </delete>

    <delete id="deleteCcExtPowerByPowerIds" parameterType="String">
        delete from cc_ext_power where power_id in 
        <foreach item="powerId" collection="array" open="(" separator="," close=")">
            #{powerId}
        </foreach>
    </delete>

</mapper>