SysDictMapper.xml 11.1 KB
<?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.pashanhoo.dictionary.dao.SysDictMapper">
    <resultMap id="BaseResultMap" type="com.pashanhoo.dictionary.model.dto.SysDict">
        <!--@mbg.generated-->
        <!--@Table SYS_DICT-->
        <id column="DICTID" jdbcType="VARCHAR" property="dictId"/>
        <result column="PARENTID" jdbcType="VARCHAR" property="parentId"/>
        <result column="DCODE" jdbcType="VARCHAR" property="dcode"/>
        <result column="DNAME" jdbcType="VARCHAR" property="dname"/>
        <result column="SORT" jdbcType="DECIMAL" property="sort"/>
        <result column="ISTREE" jdbcType="CHAR" property="isTree"/>
        <result column="TYPEID" jdbcType="VARCHAR" property="typeId"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        DICTID, PARENTID, DCODE, DNAME, SORT, ISTREE, TYPEID
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from SYS_DICT
        where DICTID = #{dictid,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        <!--@mbg.generated-->
        delete
        from SYS_DICT
        where DICTID = #{dictid,jdbcType=VARCHAR}
    </delete>
    <insert id="insert" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
        <!--@mbg.generated-->
        insert into SYS_DICT (DICTID, PARENTID, DCODE,
        DNAME, SORT, ISTREE, TYPEID)
        values (#{dictId,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{dcode,jdbcType=VARCHAR},
        #{dname,jdbcType=VARCHAR}, #{sort,jdbcType=DECIMAL}, #{isTree,jdbcType=CHAR},
        #{typeId,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
        <!--@mbg.generated-->
        insert into SYS_DICT
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dictId != null">
                DICTID,
            </if>
            <if test="parentId != null">
                PARENTID,
            </if>
            <if test="dcode != null">
                DCODE,
            </if>
            <if test="dname != null">
                DNAME,
            </if>
            <if test="sort != null">
                SORT,
            </if>
            <if test="isTree != null">
                ISTREE,
            </if>
            <if test="typeId != null">
                TYPEID,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dictId != null">
                #{dictId,jdbcType=VARCHAR},
            </if>
            <if test="parentId != null">
                #{parentId,jdbcType=VARCHAR},
            </if>
            <if test="dcode != null">
                #{dcode,jdbcType=VARCHAR},
            </if>
            <if test="dname != null">
                #{dname,jdbcType=VARCHAR},
            </if>
            <if test="sort != null">
                #{sort,jdbcType=DECIMAL},
            </if>
            <if test="isTree != null">
                #{isTree,jdbcType=CHAR},
            </if>
            <if test="typeId != null">
                #{typeId,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
        <!--@mbg.generated-->
        update SYS_DICT
        <set>
            <if test="parentId != null">
                PARENTID = #{parentId,jdbcType=VARCHAR},
            </if>
            <if test="dcode != null">
                DCODE = #{dcode,jdbcType=VARCHAR},
            </if>
            <if test="dname != null">
                DNAME = #{dname,jdbcType=VARCHAR},
            </if>
            <if test="sort != null">
                SORT = #{sort,jdbcType=DECIMAL},
            </if>
            <if test="isTree != null">
                ISTREE = #{isTree,jdbcType=CHAR},
            </if>
            <if test="typeId != null">
                TYPEID = #{typeId,jdbcType=VARCHAR},
            </if>
        </set>
        where DICTID = #{dictId,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.pashanhoo.dictionary.model.dto.SysDict">
        <!--@mbg.generated-->
        update SYS_DICT
        set PARENTID = #{parentId,jdbcType=VARCHAR},
        DCODE    = #{dcode,jdbcType=VARCHAR},
        DNAME    = #{dname,jdbcType=VARCHAR},
        SORT     = #{sort,jdbcType=DECIMAL},
        ISTREE   = #{isTree,jdbcType=CHAR},
        TYPEID   = #{typeId,jdbcType=VARCHAR}
        where DICTID = #{dictId,jdbcType=VARCHAR}
    </update>
    <update id="updateBatch" parameterType="java.util.List">
        <!--@mbg.generated-->
        update SYS_DICT
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="PARENTID = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.parentId,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="DCODE = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dcode,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="DNAME = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dname,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="SORT = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.sort,jdbcType=DECIMAL}
                </foreach>
            </trim>
            <trim prefix="ISTREE = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.isTree,jdbcType=CHAR}
                </foreach>
            </trim>
            <trim prefix="TYPEID = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.typeId,jdbcType=VARCHAR}
                </foreach>
            </trim>
        </trim>
        where DICTID in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.dictId,jdbcType=VARCHAR}
        </foreach>
    </update>
    <update id="updateBatchSelective" parameterType="java.util.List">
        <!--@mbg.generated-->
        update SYS_DICT
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="PARENTID = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.parentId != null">
                        when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.parentId,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="DCODE = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.dcode != null">
                        when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dcode,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="DNAME = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.dname != null">
                        when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.dname,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="SORT = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.sort != null">
                        when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.sort,jdbcType=DECIMAL}
                    </if>
                </foreach>
            </trim>
            <trim prefix="ISTREE = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.isTree != null">
                        when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.isTree,jdbcType=CHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="TYPEID = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.typeId != null">
                        when DICTID = #{item.dictId,jdbcType=VARCHAR} then #{item.typeId,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
        </trim>
        where DICTID in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.dictId,jdbcType=VARCHAR}
        </foreach>
    </update>
    <insert id="batchInsert" parameterType="map">
        <!--@mbg.generated-->
        insert into SYS_DICT
        (DICTID, PARENTID, DCODE, DNAME, SORT, ISTREE, TYPEID)

        <foreach collection="list" item="item" index="index" separator="union all">
            (select #{item.dictId,jdbcType=VARCHAR},
            #{item.parentId,jdbcType=VARCHAR},
            #{item.dcode,jdbcType=VARCHAR},
            #{item.dname,jdbcType=VARCHAR},
            #{item.sort,jdbcType=DECIMAL},
            #{item.isTree,jdbcType=CHAR},
            #{item.typeId,jdbcType=VARCHAR}
            from dual)
        </foreach>
    </insert>

    <select id="getSysDictParent" resultType="com.pashanhoo.dictionary.model.vo.GetSysDictParentVo">
        select rownum,SD.*
        from SYS_DICT SD
        <where>
            PARENTID is null
            <if test="request.dcode != null and request.dcode != ''">
                and DCODE like '%'||#{request.dcode,jdbcType=VARCHAR}||'%'
            </if>
            <if test="request.dname != null and request.dname != ''">
                and DNAME like '%'||#{request.dname,jdbcType=VARCHAR}||'%'
            </if>
        </where>
    </select>

    <select id="getSysDictByTypeId" resultMap="BaseResultMap">
        select *
        from SYS_DICT
        where TYPEID = #{typeId,jdbcType=VARCHAR}
        and PARENTID is not null
    </select>

    <delete id="deleteListByPrimaryKey">
        delete
        from SYS_DICT
        where
        DICTID in
        <foreach collection="dictWithoutParent" index="index" item="item" open="(" close=")" separator=",">
            #{item.dictId,jdbcType=VARCHAR}
        </foreach>
    </delete>

    <select id="selectAll" resultMap="BaseResultMap">
        select *
        from SYS_DICT
    </select>

    <delete id="deleteByTypeId">
        delete  from SYS_DICT where TYPEID = #{typeid,jdbcType=VARCHAR} and PARENTID is not null
    </delete>
</mapper>