<?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.leromro.core.mapper.VolunteerInfoMapper">

<!--    <resultMap type="VolunteerInfo" id="VolunteerInfoResult">
        <result property="volunteerInfoId"    column="volunteer_info_id"    />
        <result property="volunteerId"    column="volunteer_id"    />
        <result property="name"    column="name"    />
        <result property="idCard"    column="id_card"    />
        <result property="score"    column="score"    />
        <result property="serviceCategory"    column="service_category"    />
        <result property="skillDescribe"    column="skill_describe"    />
        <result property="phonenumber"    column="phonenumber"    />
        <result property="sex"    column="sex"    />
        <result property="status"    column="status"    />
        <result property="idCardPicture"    column="id_card_picture"    />
        <result property="certificationPicture"    column="certification_picture"    />
        <result property="volunteerPicture"    column="volunteer_picture"    />
        <result property="city"    column="city"    />
        <result property="address"    column="address"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>-->

<!--
    <sql id="selectLVolunteerInfoVo">
        select volunteer_id, name, id_card, score, service_category, skill_describe, phonenumber, sex, status, id_card_picture,
               certification_picture, volunteer_picture, worked_company, level, is_on_job, city, address, create_time, update_time, remark from l_volunteer_info
    </sql>
-->




    <select id="webList" resultType="com.leromro.core.domain.VolunteerInfo"
            parameterType="com.leromro.core.domain.VolunteerInfo">
        select * from l_volunteer_info lvi
        <where>
            <if test="dto.serviceCategory != null "> and service_category = #{dto.serviceCategory}</if>
            <if test="dto.phonenumber != null">and phonenumber = #{dto.phonenumber}</if>
            <if test="dto.appStatus != null  and dto.appStatus != '' and dto.appStatus == 1"> and app_status in (1,3)</if>
            <if test="dto.appStatus != null  and dto.appStatus != '' and dto.appStatus == 2"> and app_status = 2</if>
            <!--<if test="name != null  and name != ''"> and lvi.name like concat('%', #{name}, '%')</if>
            <if test="score != null "> and lvi.score = #{score}</if>
            <if test="skillDescribe != null  and skillDescribe != ''"> and lvi.skill_describe = #{skillDescribe}</if>
            <if test="city != null  and city != ''"> and lvi.city = #{city}</if>
            -->
        </where>
    </select>

    <select id="selectVolunteerInfoSimple" resultType="com.leromro.core.domain.vo.VolunteerInfoVO">
        select volunteer_id, skill_describe,age ,service_category,name,volunteer_picture,score,business_management_id ,business_price,business_tier_name , business_unit,business_describe
        from l_volunteer_info lvi
        where app_status = 2
        and lvi.business_management_id in (select lbm.business_management_id from l_business_management lbm
            where find_in_set(#{info.businessManagementId},lbm.ancestors) or lbm.business_management_id = #{info.businessManagementId})

        <if test="info.name != null  and info.name != ''"> and lvi.name like concat('%', #{info.name}, '%')</if>
        <if test="info.score != null "> and lvi.score = #{info.score}</if>
        <if test="info.serviceCategory != null and info.serviceCategory != ''"> and lvi.service_category = #{info.serviceCategory}</if>
        <if test="info.skillDescribe != null  and info.skillDescribe != ''"> and lvi.skill_describe = #{info.skillDescribe}</if>
        <if test="info.city != null  and info.city != ''"> and lvi.city = #{info.city}</if>
        <if test="info.address != null  and info.address != ''"> and lvi.address = #{info.address}</if>


    </select>
    <select id="getCurrentOrgVolunteerList" resultType="com.leromro.core.domain.VolunteerInfo">
        select * from l_volunteer_info
        where app_status = 2
    </select>


</mapper>