<?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">
<!-- 命名，每一个映射对象不一样
	namespace:必须与对应的接口全类名一致
 -->
<mapper namespace="com.iamberry.wechat.service.mapper.PhoneCodeMapper">

    <!-- 获取单条手机验证码信息 -->
    <select id="getPhoneCode" parameterType="PhoneCode" resultType="PhoneCode">
      SELECT
        *
      FROM
        tb_iamberry_phone_code
      WHERE
        code_tel = #{codeTel}
    </select>

    <!-- 添加手机验证码信息 -->
    <insert id="addPhoneCode" parameterType="PhoneCode" useGeneratedKeys="true" keyProperty="codeId">
        INSERT INTO tb_iamberry_phone_code
        (
            code_tel,code_phone_code,code_send_time,code_create_time
        )
        VALUES
        (
          #{codeTel},#{codePhoneCode},NOW(),NOW()
        )
    </insert>

    <!-- 修改手机验证码 -->
    <update id="updatePhoneCode" parameterType="PhoneCode">
      UPDATE
        tb_iamberry_phone_code
      SET
        code_phone_code = #{codePhoneCode},
        code_send_time = NOW()
      WHERE
        code_id = #{codeId}
    </update>
</mapper>