<?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.aizuda.easy.retry.template.datasource.persistence.mapper.SequenceAllocMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.SequenceAlloc">
        <id column="id" property="id" />
        <result column="group_name" property="groupName" />
        <result column="max_id" property="maxId" />
        <result column="step" property="step" />
        <result column="update_dt" property="updateDt" />
    </resultMap>

    <update id="updateMaxIdByCustomStep">
        UPDATE sequence_alloc
        SET max_id = max_id + #{step}, update_dt = now()
        WHERE group_name = #{groupName}
    </update>

    <update id="updateMaxId">
        UPDATE sequence_alloc
        SET max_id = max_id + step, update_dt = now()
        WHERE group_name = #{groupName}
    </update>
</mapper>
