package com.brilliance.isc.counter.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface CounterMapperOfCou {

    @Update("update cou set couval = couval + #{step} where counam=#{seqKey}")
    int updateCounter(@Param("seqKey") String seqKey, @Param("step") long step);

    @Update("update cou set couval = #{val} where counam=#{seqKey}")
    int updateCounterDirect(@Param("seqKey") String seqKey, @Param("val") long val);

    @Update("insert into cou (counam,couval,coustp) values (#{seqKey},#{seqVal},1)")
    int insertNewCounter(@Param("seqKey") String seqKey, @Param("seqVal") long seqVal);

    @Select("select couval from cou where counam = #{key}")
    Long selectCurrent(String key);

    @Select("select couval from cou where counam = #{key} for update")
    Long selectCurrentForUpdate(String key);



}
