MemberDictMapper.xml 4.13 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.laowu.mapper.MemberDictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.laowu.model.MemberDictDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="user_name" property="userName" />
        <result column="status" property="status" />
        <result column="telephone" property="telephone" />
        <result column="id_card_type" property="idCardType" />
        <result column="id_card" property="idCard" />
        <result column="province" property="province" />
        <result column="city" property="city" />
        <result column="county" property="county" />
        <result column="address" property="address" />
        <result column="education" property="education" />
        <result column="education_type" property="educationType" />
        <result column="college_id" property="collegeId" />
        <result column="start_date" property="startDate" />
        <result column="end_date" property="endDate" />
        <result column="major_id" property="majorId" />
        <result column="rank" property="rank" />
        <result column="is_poor" property="isPoor" />
        <result column="is_migration" property="isMigration" />
        <result column="is_party" property="isParty" />
        <result column="job_status" property="jobStatus" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, user_name, status, telephone, id_card_type, id_card, province, city, town, address, education, education_type, college_id, start_date, end_date, major_id, rank, is_poor, is_migration, is_party, job_status
    </sql>

    <select id="allMembers" resultType="com.laowu.vo.member.AllMembersVO">
        SELECT DISTINCT
            t.id,
            t.user_name,
            t.STATUS,
            t.telephone,
            t.id_card_type,
            t.id_card,
            t.province,
            t.city,
            t.county,
            t.address
        FROM
            member_dict t
        LEFT JOIN member_positions t2 ON t.id = t2.member_id
        LEFT JOIN position_dict t3 ON t2.position_id = t3.id
        left join position_dict t4 ON t3.parent_id = t4.id
        WHERE
            t.delete_date IS NULL
            <if test="status != null and status != ''">
                AND t.STATUS = #{status}
            </if>
            <if test="province != null and province != ''">
                AND t.province = #{province}
            </if>
            <if test="city != null and city != ''">
                AND t.city = #{city}
            </if>
            <if test="county != null and county != ''">
                AND t.county = #{county}
            </if>
            <if test="userName != null and userName != ''">
                AND t.user_name like concat('%', #{userName}, '%')
            </if>
            <if test="positionId != null and positionId != ''">
                and (t3.id = #{positionId} or t3.parent_id = #{positionId} or t4.parent_id = #{positionId})
            </if>
        order by t.create_date
    </select>

    <select id="members" parameterType="long" resultType="long">
        SELECT
            t.id
        FROM
            member_dict t
            left join member_team_mapping t2 on t.id = t2.member_id
        WHERE
            t.delete_date IS NULL
            and t2.delete_date is null
            AND t2.team_id = #{teamId}
    </select>

    <select id="memberPositions" parameterType="long" resultType="com.laowu.model.PositionDictDO">
        SELECT
            t2.*
        FROM
            member_positions t
            LEFT JOIN position_dict t2 ON t.position_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.member_id = #{memberId}
    </select>

</mapper>