<?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="volunteerId"    column="volunteer_id"    />
        <result property="userId"    column="user_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="serviceType"    column="service_type"    />
        <result property="serviceSubject"    column="service_subject"    />
        <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="workedCompany"    column="worked_company"    />
        <result property="level"    column="level"    />
        <result property="isOnJob"    column="is_on_job"    />
        <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, user_id, name, id_card, score, service_category, service_type, service_subject, 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>


    <insert id="newVolunteerByUserId">
        INSERT INTO l_volunteer_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="name != null">name,</if>
            <if test="idCard != null">id_card,</if>
            <if test="idCardPicture != null">id_card_picture,</if>
            <if test="serviceCategory != null">service_category,</if>
            <if test="serviceType != null">service_type,</if>
            <if test="serviceSubject != null">service_subject,</if>
            <if test="skillDescribe != null">skill_describe,</if>
            <if test="phonenumber != null">phonenumber,</if>
            <if test="sex != null">sex,</if>
            <if test="status != null">status,</if>
            <if test="certificationPicture != null">certification_picture,</if>
            <if test="volunteerPicture != null">volunteer_picture,</if>
            <if test="workedCompany != null">worked_company,</if>
            <if test="level != null">level,</if>
            <if test="isOnJob != null">is_on_job,</if>
            <if test="city != null">city,</if>
            <if test="address != null">address,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="name != null">#{name},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="idCardPicture != null">#{idCardPicture},</if>
            <if test="serviceCategory != null">#{serviceCategory},</if>
            <if test="serviceType != null">#{serviceType},</if>
            <if test="serviceSubject != null">#{serviceSubject},</if>
            <if test="skillDescribe != null">#{skillDescribe},</if>
            <if test="phonenumber != null">#{phonenumber},</if>
            <if test="sex != null">#{sex},</if>
            <if test="status != null">#{status},</if>
            <if test="certificationPicture != null">#{certificationPicture},</if>
            <if test="volunteerPicture != null">#{volunteerPicture},</if>
            <if test="workedCompany != null">#{workedCompany},</if>
            <if test="level != null">#{level},</if>
            <if test="isOnJob != null">#{isOnJob},</if>
            <if test="city != null">#{city},</if>
            <if test="address != null">#{address},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <select id="selectVolunteerInfoSimple" resultType="com.leromro.core.domain.VolunteerInfo"
            parameterType="com.leromro.core.domain.VolunteerInfo">
        select volunteer_id, skill_describe ,service_category,name,volunteer_picture,score from l_volunteer_info lvi left join sys_user su on lvi.user_id = su.user_id
        <where>
            <if test="name != null  and name != ''"> and lvi.name like concat('%', #{name}, '%')</if>
            <if test="score != null "> and lvi.score = #{score}</if>
            <if test="serviceCategory != null "> and lvi.service_category = #{serviceCategory}</if>
            <if test="serviceType != null "> and lvi.service_type = #{serviceType}</if>
            <if test="serviceSubject != null "> and lvi.service_subject = #{serviceSubject}</if>
            <if test="skillDescribe != null  and skillDescribe != ''"> and lvi.skill_describe = #{skillDescribe}</if>
            <if test="level != null  and level != ''"> and lvi.level = #{level}</if>
            <if test="city != null  and city != ''"> and lvi.city = #{city}</if>
            <if test="address != null  and address != ''"> and lvi.address = #{address}</if>
        </where>
    </select>


    <select id="selectLVolunteerInfoByVolunteerId" resultType="com.leromro.core.domain.VolunteerInfo"
            parameterType="java.lang.Long">
        select name , service_category ,service_subject, phonenumber,address ,skill_describe ,certification_picture  ,score from l_volunteer_info
        where volunteer_id = #{volunteerId}
    </select>


</mapper>