<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.base.dao.IconInfoDAO">
    <resultMap id="IconInfoMap" type="com.jpsoft.shinestar.modules.base.entity.IconInfo">
        <id property="id" column="id_"/>
        <result property="iconName" column="icon_name"/>
        <result property="iconRoute" column="icon_route"/>
        <result property="iconSubRoute" column="icon_sub_route"/>
        <result property="iconUrl" column="icon_url"/>
        <result property="useEnable" column="use_enable"/>
        <result property="iconPic" column="icon_pic"/>
        <result property="iconTypeId" column="icon_type_id"/>
        <result property="iconParam" column="icon_param"/>
        <result property="delFlag" column="del_flag"/>
        <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="remark" column="remark_"/>
        <result property="iconCommonPic" column="icon_common_pic"/>
        <result property="iconTypeName" column="icon_type_name"/>
        <result property="sortNo" column="sort_no"/>
    </resultMap>
    <insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.IconInfo">
        <!--
        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
            select sys_guid() from dual
        </selectKey>
        -->
        <![CDATA[
		insert into base_icon_info
	    (id_,icon_name,icon_route,icon_sub_route,icon_url,use_enable,icon_pic,icon_type_id,icon_param,del_flag,create_by,create_time,update_by,update_time,remark_,icon_common_pic,sort_no)
		values
		(
            #{id,jdbcType=VARCHAR}
            ,#{iconName,jdbcType=VARCHAR}
            ,#{iconRoute,jdbcType=VARCHAR}
            ,#{iconSubRoute,jdbcType=VARCHAR}
            ,#{iconUrl,jdbcType=VARCHAR}
            ,#{useEnable,jdbcType= NUMERIC }
            ,#{iconPic,jdbcType=VARCHAR}
            ,#{iconTypeId,jdbcType=VARCHAR}
            ,#{iconParam,jdbcType=VARCHAR}
            ,#{delFlag,jdbcType= NUMERIC }
            ,#{createBy,jdbcType=VARCHAR}
            ,#{createTime,jdbcType= TIMESTAMP }
            ,#{updateBy,jdbcType=VARCHAR}
            ,#{updateTime,jdbcType= TIMESTAMP }
            ,#{remark,jdbcType=VARCHAR}
            ,#{iconCommonPic,jdbcType=VARCHAR}
            ,#{sortNo,jdbcType=BIGINT}
		)
	]]>
    </insert>
    <delete id="delete" parameterType="string">
        delete from base_icon_info where id_=#{id,jdbcType=VARCHAR}
    </delete>
    <update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.IconInfo">
        update base_icon_info
        <set>
            <if test="iconName!=null">
                icon_name=#{iconName,jdbcType=VARCHAR},
            </if>
            <if test="iconRoute!=null">
                icon_route=#{iconRoute,jdbcType=VARCHAR},
            </if>
            <if test="iconSubRoute!=null">
                icon_sub_route=#{iconSubRoute,jdbcType=VARCHAR},
            </if>
            <if test="iconUrl!=null">
                icon_url=#{iconUrl,jdbcType=VARCHAR},
            </if>
            <if test="useEnable!=null">
                use_enable=#{useEnable,jdbcType= NUMERIC },
            </if>
            <if test="iconPic!=null">
                icon_pic=#{iconPic,jdbcType=VARCHAR},
            </if>
            <if test="iconTypeId!=null">
                icon_type_id=#{iconTypeId,jdbcType=VARCHAR},
            </if>
            <if test="iconParam!=null">
                icon_param=#{iconParam,jdbcType=VARCHAR},
            </if>
            <if test="delFlag!=null">
                del_flag=#{delFlag,jdbcType= NUMERIC },
            </if>
            <if test="createBy!=null">
                create_by=#{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime!=null">
                create_time=#{createTime,jdbcType= TIMESTAMP },
            </if>
            <if test="updateBy!=null">
                update_by=#{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime!=null">
                update_time=#{updateTime,jdbcType= TIMESTAMP },
            </if>
            <if test="remark!=null">
                remark_=#{remark,jdbcType=VARCHAR},
            </if>
            <if test="iconCommonPic!=null">
                icon_common_pic=#{iconCommonPic,jdbcType=VARCHAR},
            </if><if test="sortNo!=null">
            sort_no=#{sortNo,jdbcType=BIGINT},
        </if>
        </set>
        where id_=#{id}
    </update>
    <select id="get" parameterType="string" resultMap="IconInfoMap">
        select * from base_icon_info where id_=#{0} and del_flag = 0
    </select>
    <select id="exist" parameterType="string" resultType="int">
        select count(*) from base_icon_info where id_=#{0}
    </select>
    <select id="list" resultMap="IconInfoMap">
        select t1.*,t2.type_name as icon_type_name
        from base_icon_info t1
        inner join base_icon_type t2 on t1.icon_type_id = t2.id_
        where t1.del_flag=0
    </select>
    <select id="search" parameterType="hashmap" resultMap="IconInfoMap">
        <![CDATA[
			select * from base_icon_info
		]]>
        <where>
            del_flag=0
            <if test="searchParams.iconName != null">
                and icon_name like #{searchParams.iconName}
            </if>
            <if test="searchParams.remark != null">
                and remark_ like #{searchParams.remark}
            </if>
        </where>
        <foreach item="sort" collection="sortList" open="order by" separator=",">
            ${sort.name} ${sort.order}
        </foreach>
    </select>
</mapper>