<?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.BaseProfessionalMapper">

    <resultMap type="com.ozs.base.domain.BaseProfessional" id="BaseProfessionalResult">
        <id property="id" column="id"/>
        <result property="professionalName" column="professional_name"/>
        <result property="professionalCode" column="professional_code"/>
        <result property="purchaseState" column="purchase_state"/>
        <result property="professionalGrade" column="professional_grade"/>
        <result property="parentCode" column="parent_code"/>
    </resultMap>

    <select id="selectBaseProfessional" parameterType="com.ozs.base.domain.vo.BaseProfessionalVo" resultMap="BaseProfessionalResult">
        select * from base_professional
        <where>
            <if test="professionalName != null and professionalName != ''">
                professional_name like '% +' #{professionalName} '+ %',
            </if>
            <if test="professionalCode != null and professionalCode != ''">
                professional_code = #{professionalCode},
            </if>
            <if test="professionalGrade != null and professionalGrade != ''">
                professional_grade = #{professionalGrade}
            </if>
        </where>
    </select>

    <select id="selectBaseProfessional" parameterType="com.ozs.base.domain.BaseProfessional" resultMap="BaseProfessionalResult">
        select * from base_professional
        <where>
            <if test="professionalName != null and professionalName != ''">
                professional_name like '% +' #{professionalName} '+ %',
            </if>
            <if test="professionalCode != null and professionalCode != ''">
                professional_code = #{professionalCode},
            </if>
            <if test="professionalGrade != null and professionalGrade != ''">
                professional_grade = #{professionalGrade}
            </if>
        </where>
    </select>

    <select id="selectoneGradeList" parameterType="com.ozs.base.domain.BaseProfessional" resultMap="BaseProfessionalResult">
        select * from base_professional where professional_code = #{professionalCode}
    </select>

    <select id="countByParentCodec" parameterType="java.lang.String">
        select count(id) from base_professional where parent_code = #{professionalCode}
    </select>

    <select id="selectByParentCode" parameterType="com.ozs.base.domain.BaseProfessional" resultMap="BaseProfessionalResult">
        select * from base_professional where parent_code = #{professionalCode}
    </select>

    <select id="selectProfessional" parameterType="com.ozs.base.domain.BaseProfessional" resultMap="BaseProfessionalResult">
        select * from base_professional
        <where>
            <if test="professionalName != null and professionalName != ''">
                professional_name = #{professionalName},
            </if>
            <if test="professionalCode != null and professionalCode != ''">
                parent_code = #{professionalCode},
            </if>
        </where>
    </select>

    <select id="selectByProfessionalCode" parameterType="com.ozs.base.domain.BaseProfessional" resultMap="BaseProfessionalResult">
        select * from base_professional
        <where>
            <if test="professionalCode != null and professionalCode != ''">
                professional_code = #{professionalCode}
            </if>
        </where>
    </select>

    <select id="selectByProfessionalName" parameterType="com.ozs.base.domain.BaseProfessional" resultMap="BaseProfessionalResult">
        select * from base_professional
        <where>
            <if test="professionalName != null and professionalName != ''">
                professional_name = #{professionalName}
            </if>
        </where>
    </select>

    <select id="selectByParentCodes" parameterType="com.ozs.base.domain.BaseProfessional" resultMap="BaseProfessionalResult">
        select * from base_professional
        <where>
            <if test="parentCode != null and parentCode != ''">
                parent_code = #{parentCode}
            </if>
        </where>
    </select>
</mapper>