package com.shulead.datasync.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shulead.datasync.entity.ManageAreaGroup;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Classname ManageAreaGroupMapper
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/5/11 15:10
 * @Created by liuxiangshun
 */
public interface ManageAreaGroupMapper extends BaseMapper<ManageAreaGroup> {
    @Select("SELECT\n" +
            "    a.area_group_id,\n" +
            "    b.id as org_id,\n" +
            "    b.org_code,\n" +
            "    b.org_name,\n" +
            "    b.org_associate,\n" +
            "    me1.mobliephone as  invest_employee_mobile,\n" +
            "    me2.mobliephone as bus_adviser_mobile,\n" +
            "    me3.mobliephone as learn_direct_employee_mobile,\n" +
            "    me5.mobliephone as learn_employee_mobile,\n" +
            "    me7.mobliephone as bus_employee_mobile,\n" +
            "    DATE_FORMAT(a.updated_date,'%Y-%m-%d %H:%i:%S') as update_time\n" +
            "FROM\n" +
            "    m_manage_area_group_detail a,\n" +
            "    m_organization b,\n" +
            "    m_employee me1,\n" +
            "    m_employee me2,\n" +
            "    m_employee me3,\n" +
            "    m_employee me5,\n" +
            "    m_manage_area_group c,\n" +
            "    m_employee me7\n" +
            "WHERE\n" +
            "    a.org_id = b.id\n" +
            "    and a.invest_employee_id = me1.id\n" +
            "    and a.bus_adviser_employee_id = me2.id\n" +
            "    and a.learn_direct_employee_id = me3.id\n" +
            "    and a.learn_employee_id = me5.id\n" +
            "    and a.area_group_id = c.id\n" +
            "    and c.bus_employee_id = me7.id\n" +
            "    and a.delete_flag = 0\n" +
            "    and c.delete_flag = 0\n" +
            "    and me1.delete_flag = 0\n" +
            "    and me2.delete_flag = 0\n" +
            "    and me3.delete_flag = 0\n" +
            "    and me5.delete_flag = 0\n" +
            "    and me7.delete_flag = 0")
    List<ManageAreaGroup> findAll();
}
