<?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.frequency.level.mapper.LevelMapper">
    
    <resultMap type="com.ruoyi.frequency.level.entity.Level" id="LevelResult">
        <result property="id"    column="id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="name"    column="name"    />
        <result property="icon"    column="icon"    />
        <result property="compliance"    column="compliance"    />
        <result property="sort"    column="sort"    />
        <result property="type"    column="type"    />
        <result property="edgePipingType"    column="edge_piping_type"    />
        <result property="illustrate"    column="illustrate"    />
    </resultMap>

    <sql id="selectLevelVo">
        select id, create_by, create_time, update_by, update_time, del_flag, name, icon, compliance, sort, type, edge_piping_type,illustrate from t_level
    </sql>

    <select id="selectLevelList" parameterType="com.ruoyi.frequency.level.entity.Level" resultMap="LevelResult">
        <include refid="selectLevelVo"/>
        <where>
             and del_flag != 2
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="icon != null  and icon != ''"> and icon = #{icon}</if>
            <if test="compliance != null  and compliance != ''"> and compliance = #{compliance}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="edgePipingType != null "> and edge_piping_type = #{edgePipingType}</if>
        </where>
        order by compliance asc
    </select>
    
    <select id="selectLevelById" parameterType="Long" resultMap="LevelResult">
        <include refid="selectLevelVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertLevel" parameterType="com.ruoyi.frequency.level.entity.Level">
        insert into t_level
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="name != null">name,</if>
            <if test="icon != null">icon,</if>
            <if test="compliance != null">compliance,</if>
            <if test="sort != null">sort,</if>
            <if test="type != null">type,</if>
            <if test="edgePipingType != null">edge_piping_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="name != null">#{name},</if>
            <if test="icon != null">#{icon},</if>
            <if test="compliance != null">#{compliance},</if>
            <if test="sort != null">#{sort},</if>
            <if test="type != null">#{type},</if>
            <if test="edgePipingType != null">#{edgePipingType},</if>
         </trim>
    </insert>

    <update id="updateLevel" parameterType="com.ruoyi.frequency.level.entity.Level">
        update t_level
        <trim prefix="SET" suffixOverrides=",">
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="name != null">name = #{name},</if>
            <if test="icon != null">icon = #{icon},</if>
            <if test="compliance != null">compliance = #{compliance},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="type != null">type = #{type},</if>
            <if test="edgePipingType != null">edge_piping_type = #{edgePipingType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLevelById" parameterType="Long">
        delete from t_level where id = #{id}
    </delete>

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