package com.aiotagro.cattletrade.business.mapper;

import com.aiotagro.cattletrade.business.entity.SlaughterEntry;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 进场记录 Mapper
 *
 * @author System
 * @date 2025-12-09
 */
@Mapper
public interface SlaughterEntryMapper extends BaseMapper<SlaughterEntry> {
    
    /**
     * 根据编码前缀查询最后一个编码（用于生成新编码）
     * @param prefixPattern 编码前缀模式，如 "SE20251210%"
     * @return 最后一个进场记录
     */
    @Select("SELECT * FROM slaughter_entry WHERE entry_code LIKE #{prefixPattern} AND is_delete = 0 ORDER BY entry_code DESC LIMIT 1")
    SlaughterEntry selectLastCode(@Param("prefixPattern") String prefixPattern);
}

