<?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.bgt.mapper.BgtWageApplicationMapper">

    <resultMap type="com.ruoyi.bgt.domain.BgtWageApplication" id="BgtWageApplicationResult">
        <result property="id" column="id"/>
        <result property="projectId" column="project_id"/>
        <result property="sectionId" column="section_id"/>
        <result property="subId" column="sub_id"/>
        <result property="taskId" column="task_id"/>
        <result property="userId" column="user_id"/>
        <result property="applicantAmount" column="applicant_amount"/>
        <result property="employmentSituation" column="employment_situation"/>
        <result property="completionSituation" column="completion_situation"/>
        <result property="taskSituation" column="task_situation"/>
        <result property="auditStatus" column="audit_status"/>
        <result property="reviewerId" column="reviewer_id"/>
        <result property="delFlag" column="del_flag"/>
        <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"/>
    </resultMap>

    <select id="appQueryPageList" resultType="com.ruoyi.bgt.domain.vo.BgtWageApplicationVO">
        select bwa.task_name,
               bwa.task_staff_num,
               bwa.task_address,
               bwa.applicant_amount,
               bwa.create_time,
               bwa.id,
               bwa.username,
               bwa.project_name
        from bgt_wage_application bwa
        <where>
            <if test="dto.userId != null ">
                and bwa.user_id = #{dto.userId}
            </if>
            <if test="dto.taskId != null ">
                and bwa.task_id = #{dto.taskId}
            </if>
            <if test="dto.taskName != null and dto.taskName != ''">
                and bpr.task_name like concat('%', #{dto.taskName}, '%')
            </if>
            <if test="dto.auditStatus != null and dto.auditStatus != '' ">
                and bwa.audit_status = #{dto.auditStatus}
            </if>
        </where>
    </select>

    <select id="appQueryList" resultType="com.ruoyi.bgt.domain.vo.BgtWageApplicationListVO">
        select  bwa.applicant_amount,
                bwa.id,
                bwa.audit_status,
                bu.username
        from bgt_wage_application bwa
        left join bgt_user bu on bwa.user_id = bu.user_id
        <where>
            <if test="dto.userId != null ">
                and bwa.user_id = #{dto.userId}
            </if>
            <if test="dto.taskId != null ">
                and bwa.task_id = #{dto.taskId}
            </if>
            <if test="dto.auditStatus != null and dto.auditStatus != '' ">
                and bwa.audit_status = #{dto.auditStatus}
            </if>
        </where>
        order by bwa.create_time desc
    </select>


</mapper>
