<?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.example.his.api.db.dao.CustomerDao">

    <resultMap id="BaseResultMap" type="com.example.his.api.db.pojo.CustomerEntity">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="name" column="name" jdbcType="VARCHAR"/>
            <result property="sex" column="sex" jdbcType="CHAR"/>
            <result property="tel" column="tel" jdbcType="CHAR"/>
            <result property="photo" column="photo" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>

<!--    <sql id="Base_Column_List">-->
<!--        id,name,sex,-->
<!--        tel,photo,create_time-->
<!--    </sql>-->

    <!--客户-查寻id-->
    <select id="searchCustomerById" resultType="Integer">
        select id from tb_customer where tel = #{tel}
    </select>
    <!--客户-新增-->
    <insert id="insertCustomer">
        INSERT INTO tb_customer
        SET `name` = #{name},
            sex = #{sex},
            tel = #{tel},
            photo = #{photo},
            create_time = NOW()
    </insert>
    <!--客户-查询-->
    <select id="searchCustomer" resultType="HashMap">
        select name,sex,tel,photo,DATE_FORMAT(create_time,'%Y-%m-%d') as createTime from tb_customer where id = #{id}
    </select>
    <!--客户-更新-->
    <update id="updateCustomer">
        update tb_customer set name=#{name},tel=#{tel},sex=#{sex},photo=#{photo} where id=#{id}
    </update>

    <!--  查询客户基本信息用于创建IM账号 -->
    <select id="searchById" parameterType="int" resultType="HashMap">
        SELECT name,
               sex,
               tel,
               photo,
               DATE_FORMAT(create_time, '%Y-%m-%d') AS createTime
        FROM tb_customer
        WHERE id = #{id}
    </select>


</mapper>
