MemberMapper.xml 4.93 KB
<?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.subsidy.mapper.MemberMapper">



    <select id="getMembers" resultType="com.subsidy.vo.member.GetAllVO">
        SELECT
        t2.id,
        t2.user_name,
        t2.account_name,
        t2.account_name_en,
        t2.telephone,
        t2.gender,
        t2.id_card,
        t2.status,
        t2.email,
        t2.work_no,
        t2.induction_date
        FROM
        member_department_mapping t
        LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        and t.member_status = 1
        and t.department_id = #{departmentId}
        <if test="userName != null and userName !=''">
            and t2.user_name like concat('%',#{userName} ,'%')
        </if>
        <if test="status != null and status !=''">
            and t2.status = #{status}
        </if>
        <if test="startDate != null and startEndDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d')>=DATE_FORMAT(#{startDate}, '%Y-%m-%d')
        </if>
        <if test="endDate != null and endDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
        </if>
    </select>


    <select id="manageMember" parameterType="string" resultType="com.subsidy.vo.member.ManageMemberVO">
        SELECT
        t.id,
        t.user_name,
        t.telephone,
        t.id_card,
        t.account_name,
        t2.company_name,
        t.check_image,
        t.check_time,
        t.first_login
        FROM
        member t
        left join company_member_mapping t5 on t5.member_id = t.id and t5.member_status = 1
        LEFT JOIN company_dict t2 ON t5.company_id = t2.id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        <if test="userName != null and userName != ''">
            AND t.user_name LIKE concat('%',#{userName} ,'%')
        </if>
        <if test="companyId != null and companyId != ''">
            and t5.company_id = #{companyId}
        </if>
    </select>


    <select id="getMemberWithoutPage" resultType="com.subsidy.model.MemberDO">
        SELECT
        t2.id,
        t2.user_name,
        t2.account_name,
        t2.account_name_en,
        t2.telephone,
        t2.gender,
        t2.id_card,
        t2.status,
        t2.email,
        t2.work_no,
        t2.induction_date
        FROM
        member_department_mapping t
        LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        AND t2.id IS NOT NULL
        and t.department_id = #{departmentId}
        and t.member_status = 1
        <if test="userName != null and userName !=''">
            and t2.user_name like concat('%',#{userName} ,'%')
        </if>
        <if test="status != null and status !=''">
            and t2.status = #{status}
        </if>
        <if test="startDate != null and startEndDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d')>=DATE_FORMAT(#{startDate}, '%Y-%m-%d')
        </if>
        <if test="endDate != null and endDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
        </if>
    </select>


    <select id="getCompanyMember" resultType="com.subsidy.vo.member.GetAllVO">
        SELECT
        t2.id,
        t2.user_name,
        t2.account_name,
        t2.account_name_en,
        t2.telephone,
        t2.gender,
        t2.id_card,
        t2.status,
        t2.email,
        t2.work_no,
        t2.induction_date
        FROM
        member t2
        left join company_member_mapping t5 on t5.member_id = t2.id and t5.member_status = 1
        WHERE
        t2.delete_date IS NULL
        and t5.company_id = #{companyId}
        <if test="userName != null and userName !=''">
            and t2.user_name like concat('%',#{userName} ,'%')
        </if>
        <if test="status != null and status !=''">
            and t2.status = #{status}
        </if>
        <if test="startDate != null and startEndDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d')>=DATE_FORMAT(#{startDate}, '%Y-%m-%d')
        </if>
        <if test="endDate != null and endDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
        </if>
    </select>

    <select id="getDepartments" parameterType="long" resultType="com.subsidy.model.DepartmentDictDO">
        SELECT
            t2.id,
            t2.department_name,
            t2.parent_id
        FROM
            member_department_mapping t
            LEFT JOIN department_dict t2 ON t.department_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            and t.member_status = 1
            AND t.member_id = #{memberId}
    </select>

</mapper>