<?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.project.system.mapper.SysDictMoedataMapper">
    
    <resultMap type="SysDictMoedata" id="SysDictMoedataResult">
        <result property="id"    column="id"    />
        <result property="pid"    column="pid"    />
        <result property="ancestors"    column="ancestors"    />
        <result property="name"    column="name"    />
        <result property="ordersum"    column="ordersum"    />
        <result property="keyword"    column="keyword"    />
        <result property="status"    column="status"    />
        <result property="isdel"    column="isdel"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSysDictMoedataVo">
        select id, pid, ancestors, name, ordersum, keyword, status, isdel, create_time from sys_dict_moedata
    </sql>

    <select id="selectSysDictMoedataList" parameterType="SysDictMoedata" resultMap="SysDictMoedataResult">
        <include refid="selectSysDictMoedataVo"/>
        where isdel = '0'
            <if test="pid != null "> and pid = #{pid}</if>
            <if test="ancestors != null  and ancestors != ''"> and ancestors = #{ancestors}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="ordersum != null "> and ordersum = #{ordersum}</if>
            <if test="keyword != null  and keyword != ''"> and keyword = #{keyword}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>

        order by ordersum
    </select>
    
    <select id="selectSysDictMoedataById" parameterType="Long" resultMap="SysDictMoedataResult">
        <include refid="selectSysDictMoedataVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysDictMoedata" parameterType="SysDictMoedata">
        insert into sys_dict_moedata
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="pid != null ">pid,</if>
            <if test="ancestors != null  and ancestors != ''">ancestors,</if>
            <if test="name != null  and name != ''">name,</if>
            <if test="ordersum != null ">ordersum,</if>
            <if test="keyword != null  and keyword != ''">keyword,</if>
            <if test="status != null  and status != ''">status,</if>
            <if test="isdel != null  and isdel != ''">isdel,</if>
            <if test="createTime != null ">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="pid != null ">#{pid},</if>
            <if test="ancestors != null  and ancestors != ''">#{ancestors},</if>
            <if test="name != null  and name != ''">#{name},</if>
            <if test="ordersum != null ">#{ordersum},</if>
            <if test="keyword != null  and keyword != ''">#{keyword},</if>
            <if test="status != null  and status != ''">#{status},</if>
            <if test="isdel != null  and isdel != ''">#{isdel},</if>
            <if test="createTime != null ">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateSysDictMoedata" parameterType="SysDictMoedata">
        update sys_dict_moedata
        <trim prefix="SET" suffixOverrides=",">
            <if test="pid != null ">pid = #{pid},</if>
            <if test="ancestors != null  and ancestors != ''">ancestors = #{ancestors},</if>
            <if test="name != null  and name != ''">name = #{name},</if>
            <if test="ordersum != null ">ordersum = #{ordersum},</if>
            <if test="keyword != null  and keyword != ''">keyword = #{keyword},</if>
            <if test="status != null  and status != ''">status = #{status},</if>
            <if test="isdel != null  and isdel != ''">isdel = #{isdel},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysDictMoedataById" parameterType="Long">
        update sys_dict_moedata set isdel='1' where id = #{id}
    </delete>

    <delete id="deleteSysDictMoedataByIds" parameterType="String">
        update sys_dict_moedata set isdel='1' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>