<?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="cn.iocoder.yudao.module.banner.mapper.DlBaseBannerMapper">

    <resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.banner.entity.DlBaseBanner">
        <id property="id" column="id" jdbcType="VARCHAR"/>
        <result property="title" column="title" jdbcType="VARCHAR"/>
        <result property="url" column="url" jdbcType="VARCHAR"/>
        <result property="sort" column="sort" jdbcType="VARCHAR"/>
        <result property="typeId" column="type_id" jdbcType="VARCHAR"/>
        <result property="toUrl" column="to_url" jdbcType="VARCHAR"/>
        <result property="content" column="content"/>
    </resultMap>

    <sql id="Base_SQL">
        select id,
               title,
               url,
               sort,
               type_id,
               to_url,
               content
        from dl_base_banner dbb
        where dbb.deleted = '0'
    </sql>

    <select id="queryByPage" resultMap="BaseResultMap">
        <include refid="Base_SQL"/>
        <if test="map.typeId != null and map.typeId != ''">
            and dbb.type_id = #{map.typeId}
        </if>
    </select>

    <select id="getBannerByTypeList" resultType="cn.iocoder.yudao.module.banner.entity.DlBaseBanner">
        <include refid="Base_SQL" />
        and dbb.type_id = #{type}
        order by dbb.sort
    </select>
</mapper>
