gaoluyang
2026-10-26 48ee7c963f29f5614a8f86c08608620cc6310793
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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);
}