<?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.ylx.massage.mapper.MaTechnicianMapper">

    <resultMap type="MaTechnician" id="MaTechnicianResult">
        <result property="id"    column="id"    />
        <result property="teName"    column="te_name"    />
        <result property="teSex"    column="te_sex"    />
        <result property="tePhone"    column="te_phone"    />
        <result property="teAddress"    column="te_address"    />
        <result property="teAge"    column="te_age"    />
        <result property="teAvatar"    column="te_avatar"    />
        <result property="lifePhotos"    column="life_photos"    />
        <result property="teBrief"    column="te_brief"    />
        <result property="serviceState"    column="service_state"    />
        <result property="postState"    column="post_state"    />
        <result property="teIsEnable"    column="te_is_enable"    />
        <result property="createUser"    column="create_user"    />
        <result property="updateUser"    column="update_user"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDelete"    column="is_delete"    />
    </resultMap>

    <sql id="selectMaTechnicianVo">
        select id, te_name, te_sex, te_phone, te_address, te_age, te_avatar, life_photos, te_brief, service_state, post_state, te_is_enable, create_user, update_user, create_time, update_time, is_delete from ma_technician
    </sql>

    <select id="selectMaTechnicianList" parameterType="MaTechnician" resultMap="MaTechnicianResult">
        <include refid="selectMaTechnicianVo"/>
        <where>
            <if test="teName != null  and teName != ''"> and te_name like concat('%', #{teName}, '%')</if>
            <if test="teSex != null "> and te_sex = #{teSex}</if>
            <if test="tePhone != null  and tePhone != ''"> and te_phone = #{tePhone}</if>
            <if test="teAddress != null  and teAddress != ''"> and te_address = #{teAddress}</if>
            <if test="teAge != null "> and te_age = #{teAge}</if>
            <if test="teAvatar != null  and teAvatar != ''"> and te_avatar = #{teAvatar}</if>
            <if test="lifePhotos != null  and lifePhotos != ''"> and life_photos = #{lifePhotos}</if>
            <if test="teBrief != null  and teBrief != ''"> and te_brief = #{teBrief}</if>
            <if test="serviceState != null "> and service_state = #{serviceState}</if>
            <if test="postState != null "> and post_state = #{postState}</if>
            <if test="teIsEnable != null "> and te_is_enable = #{teIsEnable}</if>
            <if test="createUser != null "> and create_user = #{createUser}</if>
            <if test="updateUser != null "> and update_user = #{updateUser}</if>
            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
        </where>
    </select>

    <select id="selectMaTechnicianById" parameterType="Long" resultMap="MaTechnicianResult">
        <include refid="selectMaTechnicianVo"/>
        where id = #{id}
    </select>

    <insert id="insertMaTechnician" parameterType="MaTechnician" useGeneratedKeys="true" keyProperty="id">
        insert into ma_technician
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="teName != null and teName != ''">te_name,</if>
            <if test="teSex != null">te_sex,</if>
            <if test="tePhone != null and tePhone != ''">te_phone,</if>
            <if test="teAddress != null and teAddress != ''">te_address,</if>
            <if test="teAge != null">te_age,</if>
            <if test="teAvatar != null and teAvatar != ''">te_avatar,</if>
            <if test="lifePhotos != null and lifePhotos != ''">life_photos,</if>
            <if test="teBrief != null and teBrief != ''">te_brief,</if>
            <if test="serviceState != null">service_state,</if>
            <if test="postState != null">post_state,</if>
            <if test="teIsEnable != null">te_is_enable,</if>
            <if test="createUser != null">create_user,</if>
            <if test="updateUser != null">update_user,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDelete != null">is_delete,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="teName != null and teName != ''">#{teName},</if>
            <if test="teSex != null">#{teSex},</if>
            <if test="tePhone != null and tePhone != ''">#{tePhone},</if>
            <if test="teAddress != null and teAddress != ''">#{teAddress},</if>
            <if test="teAge != null">#{teAge},</if>
            <if test="teAvatar != null and teAvatar != ''">#{teAvatar},</if>
            <if test="lifePhotos != null and lifePhotos != ''">#{lifePhotos},</if>
            <if test="teBrief != null and teBrief != ''">#{teBrief},</if>
            <if test="serviceState != null">#{serviceState},</if>
            <if test="postState != null">#{postState},</if>
            <if test="teIsEnable != null">#{teIsEnable},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="updateUser != null">#{updateUser},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDelete != null">#{isDelete},</if>
         </trim>
    </insert>

    <update id="updateMaTechnician" parameterType="MaTechnician">
        update ma_technician
        <trim prefix="SET" suffixOverrides=",">
            <if test="teName != null and teName != ''">te_name = #{teName},</if>
            <if test="teSex != null">te_sex = #{teSex},</if>
            <if test="tePhone != null and tePhone != ''">te_phone = #{tePhone},</if>
            <if test="teAddress != null and teAddress != ''">te_address = #{teAddress},</if>
            <if test="teAge != null">te_age = #{teAge},</if>
            <if test="teAvatar != null and teAvatar != ''">te_avatar = #{teAvatar},</if>
            <if test="lifePhotos != null and lifePhotos != ''">life_photos = #{lifePhotos},</if>
            <if test="teBrief != null and teBrief != ''">te_brief = #{teBrief},</if>
            <if test="serviceState != null">service_state = #{serviceState},</if>
            <if test="postState != null">post_state = #{postState},</if>
            <if test="teIsEnable != null">te_is_enable = #{teIsEnable},</if>
            <if test="createUser != null">create_user = #{createUser},</if>
            <if test="updateUser != null">update_user = #{updateUser},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDelete != null">is_delete = #{isDelete},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMaTechnicianById" parameterType="Long">
        delete from ma_technician where id = #{id}
    </delete>

    <delete id="deleteMaTechnicianByIds" parameterType="String">
        delete from ma_technician where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
