MobileCodeMapper.xml 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<?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="cn.iocoder.mall.user.dao.MobileCodeMapper">

    <insert id="insert" parameterType="MobileCodeDO">
        INSERT INTO mobile_code (
          id, mobile, code, today_index, used,
          used_uid, used_time, create_time
        ) VALUES (
          #{id}, #{mobile}, #{code}, #{todayIndex}, #{used},
          #{usedUid}, #{usedTime}, #{createTime}
        )
    </insert>

    <update id="update" parameterType="MobileCodeDO">
        UPDATE mobile_code
        <set>
            <if test="used != null"> used = #{used}, </if>
            <if test="usedUid != null"> used_uid = #{usedUid}, </if>
            <if test="usedTime != null"> used_time = #{usedTime}, </if>
        </set>
        WHERE id = #{id}
    </update>

    <select id="selectLast1ByMobile" parameterType="String" resultType="MobileCodeDO">
      SELECT
          id, mobile, code, today_index, used,
          used_uid, used_time, create_time
      FROM mobile_code
      WHERE mobile = #{mobile}
      ORDER BY id DESC
      LIMIT 1
    </select>

</mapper>