package com.brilliance.isc.counter.mapper;

import com.brilliance.isc.counter.model.SerialBo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

@Mapper
public interface SerialCounterMapper {

    @Update("update ${tblnam} set couval = #{nval} where couval=#{oval} and counam = #{counam} and coudat = #{coudat,jdbcType=DATE}")
    int update(@Param("tblnam") String tblNam, @Param("nval") long nval, @Param("oval") long oval,
               @Param("counam") String couNam, @Param("coudat") Date couDat);

    @Update("insert into ${tblnam} (counam,couval,coustp,coudat) values (#{counam},1,1,#{coudat,jdbcType=DATE})")
    int insert(@Param("tblnam") String tblNam, @Param("counam") String couNam, @Param("coudat") Date couDat);

    @Select("select * from ${tblnam} where counam = #{counam} and coudat = #{coudat,jdbcType=DATE}")
    SerialBo select(@Param("tblnam") String tblNam, @Param("counam") String couNam, @Param("coudat") Date couDat);

}
