<?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="top.naccl.dwz.mapper.UrlMapper">
    <select id="getLongUrlByShortUrl" resultType="java.lang.String">
        select lurl
        from url_map
        where surl = #{surl}
    </select>

    <insert id="saveUrlMap" parameterType="top.naccl.dwz.entity.UrlMap" useGeneratedKeys="true" keyProperty="id">
        insert into url_map (surl, lurl, views, create_time)
        values (#{surl}, #{lurl}, #{views}, #{createTime})
    </insert>

    <update id="updateUrlViews">
        update url_map
        set views=views + 1
        where surl = #{surl}
    </update>
</mapper>