<?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.ozs.base.mapper.BaseExpertMapper">
    <resultMap type="com.ozs.base.domain.BaseExpert" id="BaseExpertResult">
        <id property="id" column="id"/>
        <result property="expertName" column="expert_name"/>
        <result property="expertGender" column="expert_gender"/>
        <result property="expertDateBirth" column="expert_date_birth"/>
        <result property="expertTel" column="expert_tel"/>
        <result property="majorType" column="major_type"/>
        <result property="unitInformation" column="unit_information"/>
        <result property="majorGrade" column="major_grade"/>
        <result property="varietyPurchase" column="variety_purchase"/>
        <result property="professionalTitle" column="professional_title"/>
        <result property="status" column="status"/>
        <result property="localArea" column="local_area"/>
        <result property="idNumber" column="id_number"/>
        <result property="created" column="created"/>
        <result property="createTime" column="create_time"/>
        <result property="updated" column="updated"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <insert id="insertExpert" parameterType="com.ozs.base.domain.vo.BaseExpertVo">
        insert into base_expert
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="expertName != null and expertName != '' ">
                expert_name,
            </if>
            <if test="expertType != null and expertType != ''">
                expert_type,
            </if>
            <if test="expertGender != null and expertGender != '' ">
                expert_gender,
            </if>
            <if test="expertDateBirth != null and expertDateBirth != '' ">
                expert_date_birth,
            </if>
            <if test="expertTel != null and expertTel != '' ">
                expert_tel,
            </if>
            <if test="majorType != null and majorType != ''">
                major_type,
            </if>
            <if test="unitInformation != null and unitInformation != ''">
                unit_information,
            </if>
            <if test="majorGrade != null and majorGrade != '' ">
                major_grade,
            </if>
            <if test="varietyPurchase != null and varietyPurchase != '' ">
                variety_purchase,
            </if>
            <if test="professionalTitle != null and professionalTitle != ''">
                professional_title,
            </if>
            <if test="status != null and status != ''">
                status,
            </if>
            <if test="localArea != null and localArea != ''">
                local_area,
            </if>
            <if test="idNumber != null and idNumber != ''">
                id_number,
            </if>
            <if test="created != null and created != ''">
                created,
            </if>
            <if test="createTime != null ">
                create_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="expertName != null and expertName != ''">
                #{expertName},
            </if>
            <if test="expertType != null and expertType != ''">
                #{expertType},
            </if>
            <if test="expertGender != null and expertGender != ''">
                #{expertGender},
            </if>
            <if test="expertDateBirth != null and expertDateBirth != ''">
                #{expertDateBirth},
            </if>
            <if test="expertTel != null and expertTel != ''">
                #{expertTel},
            </if>
            <if test="majorType != null and majorType != ''">
                #{majorType},
            </if>
            <if test="unitInformation != null and unitInformation != ''">
                #{unitInformation},
            </if>
            <if test="majorGrade != null and majorGrade != ''">
                #{majorGrade},
            </if>
            <if test="varietyPurchase != null and varietyPurchase != ''">
                #{varietyPurchase},
            </if>
            <if test="professionalTitle != null and professionalTitle != ''">
                #{professionalTitle},
            </if>
            <if test="status != null and status != ''">
                #{status},
            </if>
            <if test="localArea != null and localArea != ''">
                #{localArea},
            </if>
            <if test="idNumber != null and idNumber != ''">
                #{idNumber},
            </if>
            <if test="created != null and created != ''">
                #{created},
            </if>
            <if test="createTime != null ">
                #{createTime},
            </if>
        </trim>

    </insert>

    <select id="selectByUnitInformation" parameterType="java.lang.String"
            resultType="com.ozs.base.domain.BaseUnitInformation">
        select * from base_unit_information
        <where>
            <if test="unitInformation != null and unitInformation != ''">
                unit_name = #{unitInformation}
            </if>
        </where>
    </select>

    <insert id="insertBaseUnitInformation" parameterType="com.ozs.base.domain.BaseUnitInformation">
        insert into base_unit_information
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="unitName != null and unitName != '' ">
                unit_name,
            </if>
            <if test="created != null and created != '' ">
                created,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="unitName != null and unitName != ''">
                #{unitName},
            </if>
            <if test="created != null and created != ''">
                #{created},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
        </trim>
    </insert>

    <select id="getExpertIdList" resultType="com.ozs.pm.doman.PmDemandExpertRef" parameterType="java.lang.Long">
        select * from pm_demand_expert_ref where demand_id = #{demandId}
    </select>

    <select id="getExpertNameList" resultType="java.util.Map" parameterType="java.util.List">
        select GROUP_CONCAT(variety_purchase) varietyPurchase, GROUP_CONCAT(expert_name) expertName from base_expert
        where id in
        <foreach collection="expertList" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>

    </select>
</mapper>
