<?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.gree.mall.manager.commonmapper.LetterMapper">

    <select id="list" resultType="com.gree.mall.manager.bean.letter.LeDepartmentVO">
        SELECT
        ${ex.selected}
        FROM le_department a
        ${ex.query}
        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
    <select id="listUser" resultType="com.gree.mall.manager.bean.letter.LeUserDepartmentVO">
        SELECT
        ${ex.selected}
        FROM le_user_department a
        ${ex.query}
        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
    <select id="listProject" resultType="com.gree.mall.manager.bean.letter.LeProjectVO">
        SELECT
        ${ex.selected}
        FROM le_project a
        ${ex.query}
        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
    <select id="listLetter" resultType="com.gree.mall.manager.bean.letter.LeLetterVO">
        SELECT
        ${ex.selected}
        FROM le_letter a
        ${ex.query}
        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>

        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
            AND a.websit_id IN
            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="isWeb != null and isWeb == true">
           and a.status not in  ('WAIT','CANCEL')
        </if>
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
</mapper>