<?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.template.mapper.AlumniUserMapper">
    <resultMap id="queryUserMaps" type="com.template.model.vo.ListDataVO">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
    </resultMap>
    <select id="queryUsers" resultMap="queryUserMaps">
        select id,name from alumni_user
        where deleted = 0 and account is not null
        <if test="keyword != null and keyword != ''">
            and name like '%' #{keyword} '%'
        </if>
    </select>

    <resultMap type="com.template.model.vo.UserVo" id="UserPageMap">
        <result property="id" column="id"/>
        <result property="cardNumber" column="card_number"/>
        <result property="name" column="name"/>
    </resultMap>
    <select id="queryUserPages" resultType="com.template.model.vo.UserVo" resultMap="UserPageMap">
        select
        id,card_number,name
        from alumni_user
        where deleted = 0 and role_id is not null
        <if test="departmentIds != null and departmentIds.size() > 0">
            and (college_id in
            <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
                ${departmentId}
            </foreach>
            or
            period_id in
            <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
                ${departmentId}
            </foreach>
            or
            major_id in
            <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
                ${departmentId}
            </foreach>
            or
            class_id in
            <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
                ${departmentId}
            </foreach>
            )
        </if>
        order by create_time desc
    </select>
</mapper>
