<?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.MobileBannerInfoDAO">
    <resultMap id="MobileBannerInfoMap" type="com.jpsoft.shinestar.modules.base.entity.MobileBannerInfo">
        <id property="id" column="id_"/>
        <result property="name" column="name_"/>
        <result property="classify" column="classify_"/>
        <result property="linkUrl" column="link_url"/>
        <result property="picUrl" column="pic_url"/>
        <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="enabled" column="enabled_"/>
        <result property="sortNo" column="sort_no"/>
        <result property="isTeachers" column="is_teachers"/>
        <result property="goodsType" column="goods_type"/>
    </resultMap>
    <insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.MobileBannerInfo">
        <!--
        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
            select sys_guid() from dual
        </selectKey>
        -->
        <![CDATA[
		insert into base_mobile_banner_info
	    (id_,name_,classify_,link_url,pic_url,create_by,create_time,update_by,update_time,del_flag,enabled_,sort_no,goods_type,is_teachers)
		values
		(
			#{id,jdbcType=VARCHAR}
			,#{name,jdbcType=VARCHAR}
			,#{classify,jdbcType= VARCHAR }
			,#{linkUrl,jdbcType=VARCHAR}
			,#{picUrl,jdbcType=VARCHAR}
			,#{createBy,jdbcType=VARCHAR}
			,#{createTime,jdbcType= TIMESTAMP }
			,#{updateBy,jdbcType=VARCHAR}
			,#{updateTime,jdbcType= TIMESTAMP }
			,#{delFlag,jdbcType= NUMERIC }
			,#{enabled,jdbcType=VARCHAR}
			,#{sortNo,jdbcType= NUMERIC }
			,#{goodsType,jdbcType=VARCHAR}
			,#{isTeachers,jdbcType= NUMERIC }
		)
	]]>
    </insert>
    <delete id="delete" parameterType="string">
        delete from base_mobile_banner_info where id_=#{id,jdbcType=VARCHAR}
    </delete>
    <update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.MobileBannerInfo">
        update base_mobile_banner_info
        <set>
            <if test="name!=null">
                name_=#{name,jdbcType=VARCHAR},
            </if>
            <if test="classify!=null">
                classify_=#{classify,jdbcType= VARCHAR },
            </if>
            <if test="linkUrl!=null">
                link_url=#{linkUrl,jdbcType=VARCHAR},
            </if>
            <if test="picUrl!=null">
                pic_url=#{picUrl,jdbcType=VARCHAR},
            </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="delFlag!=null">
                del_flag=#{delFlag,jdbcType= NUMERIC },
            </if>
            <if test="enabled!=null">
                enabled_=#{enabled,jdbcType=NUMERIC},
            </if>
            <if test="sortNo!=null">
                sort_no=#{sortNo,jdbcType=NUMERIC},
            </if>

            <if test="goodsType!=null">
                goods_type=#{goodsType,jdbcType=VARCHAR},
            </if>
            <if test="isTeachers!=null">
                is_teachers=#{isTeachers,jdbcType= NUMERIC },
            </if>
        </set>
        where id_=#{id}
    </update>
    <select id="get" parameterType="string" resultMap="MobileBannerInfoMap">
        select * from
        base_mobile_banner_info where id_=#{0}
    </select>
    <select id="exist" parameterType="string" resultType="int">
        select count(*) from base_mobile_banner_info where id_=#{0}
    </select>
    <select id="list" resultMap="MobileBannerInfoMap">
        select * from base_mobile_banner_info
    </select>
    <select id="getBannerInfo" resultMap="MobileBannerInfoMap">
        select * from base_mobile_banner_info where classify_=#{0}  and enabled_ =1  and del_flag=0
        order by sort_no asc
    </select>
    <select id="search" parameterType="hashmap" resultMap="MobileBannerInfoMap">
        <![CDATA[
			select * from base_mobile_banner_info
		]]>
        <where>
            del_flag=0
            <if test="searchParams.name != null">
                and name_ like #{searchParams.name}
            </if>
            <if test="searchParams.classify != null">
                and classify_ = #{searchParams.classify}
            </if>
        </where>
        <foreach item="sort" collection="sortList" open="order by" separator=",">
            ${sort.name} ${sort.order}
        </foreach>
    </select>
</mapper>