<?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.ruoyi.cms.mapper.AppUserMapper">
    
    <resultMap type="AppUser" id="AppUserResult">
        <result property="userId"    column="user_id"    />
        <result property="name"    column="name"    />
        <result property="age"    column="age"    />
        <result property="sex"    column="sex"    />
        <result property="birthDate"    column="birth_date"    />
        <result property="education"    column="education"    />
        <result property="politicalAffiliation"    column="political_affiliation"    />
        <result property="phone"    column="phone"    />
        <result property="avatar"    column="avatar"    />
        <result property="salaryMin"    column="salary_min"    />
        <result property="salaryMax"    column="salary_max"    />
        <result property="area"    column="area"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="loginIp"    column="login_ip"    />
        <result property="loginDate"    column="login_date"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="jobTitleId"    column="job_title_id"    />
        <result property="isRecommend"    column="is_recommend"    />
    </resultMap>

    <sql id="selectAppUserVo">
        select user_id, name, age, sex, birth_date, education, political_affiliation, phone, avatar, salary_min, salary_max, area, status, del_flag, login_ip, login_date, create_by, create_time, update_by, update_time, remark,job_title_id,is_recommend from app_user
    </sql>

    <select id="selectAppUserList" parameterType="AppUser" resultMap="AppUserResult">
        <include refid="selectAppUserVo"/>
        <where>  del_flag = '0'
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="age != null  and age != ''"> and age = #{age}</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="birthDate != null "> and birth_date = #{birthDate}</if>
            <if test="education != null  and education != ''"> and education = #{education}</if>
            <if test="politicalAffiliation != null  and politicalAffiliation != ''"> and political_affiliation = #{politicalAffiliation}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="avatar != null  and avatar != ''"> and avatar = #{avatar}</if>
            <if test="salaryMin != null  and salaryMin != ''"> and salary_min = #{salaryMin}</if>
            <if test="salaryMax != null  and salaryMax != ''"> and salary_max = #{salaryMax}</if>
            <if test="area != null  and area != ''"> and area = #{area}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="loginIp != null  and loginIp != ''"> and login_ip = #{loginIp}</if>
            <if test="loginDate != null "> and login_date = #{loginDate}</if>
            <if test="experience != null "> and experience = #{experience}</if>
        </where>
    </select>
    <select id="selectByJobId" resultType="com.ruoyi.cms.domain.AppUser" parameterType="java.lang.Long">
        SELECT * FROM app_user WHERE user_id IN (
            select DISTINCT au.USER_ID  from APP_USER au
                                                 INNER JOIN JOB_APPLY ja ON ja.USER_ID  = au.USER_ID
            WHERE au.DEL_FLAG = '0' AND ja.DEL_FLAG = '0'  AND ja.JOB_Id = #{jobId})
    </select>
</mapper>