<?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.web.work.mapper.UserMapper">

    <select id="selectList" resultType="com.ruoyi.web.work.domain.User">
        select * from tb_user
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="phone != null "> and phone = #{phone}</if>
            <if test="state != null "> and state = #{state}</if>
        </where>
    </select>

    <select id="selectUser" resultType="com.ruoyi.web.work.domain.User">
        SELECT
            u.*,
            <if test="type==0">
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.user_id = u.id AND d.type = 0 ) AS fullTime,/*全职投递*/
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.user_id = u.id AND d.type = 1 ) AS partTime,/*兼职投递*/
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.user_id = u.id AND d.state = 1 AND is_accept = 0 AND type=0 ) AS fullTimeAccept,/*全职邀约未处理*/
            ( SELECT name FROM tb_resume d WHERE d.id = u.id) AS resume,/*简历信息*/
            </if>
            <if test="type==1">
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.enterprise_id = u.id AND d.is_read = 0 AND d.type=0) AS noReadResume,/*企业收到未查看全职简历数*/
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.enterprise_id = u.id AND d.type=0) AS receiveResume,/*企业收到全职简历总数*/
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.enterprise_id = u.id AND d.state=1 AND d.type=0) AS inviteUser,/*企业邀请全职面试总数*/
            ( SELECT name FROM tb_enterprise d WHERE d.id = u.id) AS enterprise, /*企业信息*/
            </if>
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.enterprise_id = u.id AND d.is_complete !=2 AND d.type=1 AND d.is_accept=1) AS completeApplication, /*甲方正在进行任务数*/
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.user_id = u.id AND d.is_complete !=2 AND d.type=1 AND d.is_accept=1) AS completeIng, /*已方正在进行任务数*/
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.enterprise_id = u.id AND d.is_read = 0 AND d.type=1) AS noReadApplication, /*甲方收到未查看报名数*/
            ( SELECT COUNT( d.id ) FROM tb_resume_deliver d WHERE d.user_id = u.id AND d.state = 1 AND is_accept = 0 AND type=1 AND is_expire=0) AS partTimeAccept/*兼职邀约未处理*/
        FROM
            tb_user u
        WHERE
            id =#{id}
    </select>

</mapper>