<?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.lframework.xingyun.template.gen.mappers.GenCustomSelectorMapper">
    <resultMap id="GenCustomSelector" type="com.lframework.xingyun.template.gen.entity.GenCustomSelector">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="category_id" property="categoryId"/>
        <result column="custom_list_id" property="customListId"/>
        <result column="available" property="available"/>
        <result column="description" property="description"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="GenCustomSelector_sql">
        SELECT o.id,
               o.name,
               o.category_id,
               o.custom_list_id,
               o.available,
               o.description,
               o.create_by,
               o.create_time,
               o.update_by,
               o.update_time
        FROM gen_custom_selector AS o
    </sql>

    <select id="query" resultMap="GenCustomSelector">
        <include refid="GenCustomSelector_sql"/>
        <where>
            <if test="vo != null">
                <if test="vo.categoryId != null and vo.categoryId != ''">
                    AND o.category_id = #{vo.categoryId}
                </if>
                <if test="vo.name != null and vo.name != ''">
                    AND o.name LIKE CONCAT('%', #{vo.name}, '%')
                </if>
                <if test="vo.available != null">
                    AND o.available = #{vo.available}
                </if>
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
    <select id="selector" resultMap="GenCustomSelector">
      <include refid="GenCustomSelector_sql"/>
      <where>
          <if test="vo != null">
              <if test="vo.categoryId != null and vo.categoryId != ''">
                  AND o.category_id = #{vo.categoryId}
              </if>
              <if test="vo.name != null and vo.name != ''">
                  AND o.name LIKE CONCAT('%', #{vo.name}, '%')
              </if>
              <if test="vo.available != null">
                  AND o.available = #{vo.available}
              </if>
          </if>
      </where>
      ORDER BY o.create_time DESC
    </select>
    <select id="getRelaGenCustomListIds" resultType="java.lang.String">
        SELECT id FROM gen_custom_selector WHERE custom_list_id = #{customListId}
    </select>

</mapper>