package cn.iocoder.yudao.module.mdm.dal.mysql.item;
|
|
import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemCodeSequenceDO;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import org.apache.ibatis.annotations.Insert;
|
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Update;
|
|
@Mapper
|
public interface MdmItemCodeSequenceMapper extends BaseMapper<MdmItemCodeSequenceDO> {
|
|
@Insert("INSERT IGNORE INTO mdm_item_code_sequence(prefix, current_value) VALUES (#{prefix}, 0)")
|
void insertIfAbsent(String prefix);
|
|
@Select("SELECT current_value FROM mdm_item_code_sequence WHERE prefix = #{prefix} FOR UPDATE")
|
Integer selectCurrentValueForUpdate(String prefix);
|
|
@Update("UPDATE mdm_item_code_sequence SET current_value = current_value + 1 WHERE prefix = #{prefix}")
|
int increment(String prefix);
|
|
@Update("UPDATE mdm_item_code_sequence SET current_value = #{value} WHERE prefix = #{prefix}")
|
int updateCurrentValue(@org.apache.ibatis.annotations.Param("prefix") String prefix,
|
@org.apache.ibatis.annotations.Param("value") Integer value);
|
}
|