<?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.ems.mapper.ElecPriceTypeMapper">
    
    <resultMap type="com.ruoyi.ems.domain.ElecPriceType" id="ElecPriceTypeResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
    </resultMap>

    <sql id="selectElecPriceTypeVo">
        select id, code, name from dim_ems_elecprice_type
    </sql>

    <select id="selectElecPriceTypeList" parameterType="com.ruoyi.ems.domain.ElecPriceType" resultMap="ElecPriceTypeResult">
        <include refid="selectElecPriceTypeVo"/>
        <where>  
            <if test="code != null "> and code = #{code}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
        </where>
    </select>
    
    <select id="selectElecPriceTypeById" parameterType="Long" resultMap="ElecPriceTypeResult">
        <include refid="selectElecPriceTypeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertElecPriceType" parameterType="com.ruoyi.ems.domain.ElecPriceType" useGeneratedKeys="true" keyProperty="id">
        insert into dim_ems_elecprice_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="name != null and name != ''">name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="name != null and name != ''">#{name},</if>
         </trim>
    </insert>

    <update id="updateElecPriceType" parameterType="com.ruoyi.ems.domain.ElecPriceType">
        update dim_ems_elecprice_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="name != null and name != ''">name = #{name},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteElecPriceTypeById" parameterType="Long">
        delete from dim_ems_elecprice_type where id = #{id}
    </delete>

    <delete id="deleteElecPriceTypeByIds" parameterType="String">
        delete from dim_ems_elecprice_type where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>