MiniSubscribeMapper.xml 1.43 KB
<?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.yoho.message.dal.IMiniSubscribeDAO" >

    <resultMap id="BaseResultMap" type="com.yoho.message.dal.model.MiniSubscribe" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="uid" property="uid" jdbcType="INTEGER" />
        <result column="open_id" property="openId" jdbcType="VARCHAR" />
        <result column="template_id" property="templateId" jdbcType="VARCHAR" />
        <result column="available_time" property="availableTimes" jdbcType="INTEGER" />
        <result column="create_time" property="createTime" jdbcType="INTEGER" />
        <result column="update_time" property="updateTime" jdbcType="INTEGER" />
    </resultMap>

    <select id="selectAvailableTemplateId" resultMap="BaseResultMap">
        select uid, open_id, template_id, available_time, create_time, update_time
        from ${tableName}
        where uid = #{uid} and template_id = #{templateId} and available_time > 0
        limit 1
    </select>

    <update id="updateMiniSubscribe" parameterType="com.yoho.message.dal.model.MiniSubscribe">
        update ${tableName} set available_time = #{miniSubscribe.availableTimes}, update_time = #{miniSubscribe.updateTime}
        where uid = #{miniSubscribe.uid} and template_id = #{miniSubscribe.templateId}
    </update>
</mapper>