<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.base.system.site.dao.ISiteCustomDao">

    <!-- 字段和属性映射 -->
    <resultMap type="SiteEntity" id="SiteEntity-Map">
        <result property="id" column="id" />
        <result property="siteName" column="siteName" />
        <result property="parentId" column="parentId" />
        <result property="ancestors" column="ancestors" />
        <result property="address" column="address" />
        <result property="mobile" column="mobile" />
        <result property="introduce" column="introduce" />
        <result property="workday1" column="workday1" />
        <result property="workday2" column="workday2" />
        <result property="workday3" column="workday3" />
        <result property="workday4" column="workday4" />
        <result property="workday5" column="workday5" />
        <result property="workday6" column="workday6" />
        <result property="workday7" column="workday7" />
        <result property="number" column="number" />
        <result property="summary" column="summary" />
        <result property="orderNum" column="orderNum" />
        <result property="status" column="status" />
        <result property="updateTime" column="updateTime" />
        <result property="updateUser" column="updateUser" />
        <result property="createTime" column="createTime" />
        <result property="createUser" column="createUser" />
    </resultMap>

    <!-- 表所有列 -->
    <sql id="_columns">
        <trim suffixOverrides="," suffix="">
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))">
                    a.id as id,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('siteName') or colPickMode == 1 and data.containsKey('siteName')))">
                    a.siteName as siteName,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('parentId') or colPickMode == 1 and data.containsKey('parentId')))">
                    a.parentId as parentId,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('ancestors') or colPickMode == 1 and data.containsKey('ancestors')))">
                    a.ancestors as ancestors,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('address') or colPickMode == 1 and data.containsKey('address')))">
                    a.address as address,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('mobile') or colPickMode == 1 and data.containsKey('mobile')))">
                    a.mobile as mobile,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('introduce') or colPickMode == 1 and data.containsKey('introduce')))">
                    a.introduce as introduce,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('workday1') or colPickMode == 1 and data.containsKey('workday1')))">
                    a.workday1 as workday1,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('workday2') or colPickMode == 1 and data.containsKey('workday2')))">
                    a.workday2 as workday2,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('workday3') or colPickMode == 1 and data.containsKey('workday3')))">
                    a.workday3 as workday3,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('workday4') or colPickMode == 1 and data.containsKey('workday4')))">
                    a.workday4 as workday4,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('workday5') or colPickMode == 1 and data.containsKey('workday5')))">
                    a.workday5 as workday5,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('workday6') or colPickMode == 1 and data.containsKey('workday6')))">
                    a.workday6 as workday6,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('workday7') or colPickMode == 1 and data.containsKey('workday7')))">
                    a.workday7 as workday7,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('number') or colPickMode == 1 and data.containsKey('number')))">
                    a.number as number,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('summary') or colPickMode == 1 and data.containsKey('summary')))">
                    a.summary as summary,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('orderNum') or colPickMode == 1 and data.containsKey('orderNum')))">
                    a.orderNum as orderNum,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('status') or colPickMode == 1 and data.containsKey('status')))">
                    a.status as status,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
                    a.updateTime as updateTime,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateUser') or colPickMode == 1 and data.containsKey('updateUser')))">
                    a.updateUser as updateUser,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
                    a.createTime as createTime,
                </if>
                <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createUser') or colPickMode == 1 and data.containsKey('createUser')))">
                    a.createUser as createUser,
                </if>
        </trim>
    </sql>


    <!-- 获取孩子列表 -->
    <select id="selectChildrenSiteById" parameterType="map"  resultMap="SiteEntity-Map">
        select <include refid="_columns"/> from mortals_xhx_site a where find_in_set(#{siteId}, ancestors)
    </select>
</mapper>