package shop.alien.mapper.second;

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;
import shop.alien.entity.second.SecondGoodsAudit;

/**
 * 二手商品审核记录映射器
 */
@Mapper
public interface SecondGoodsAuditMapper extends BaseMapper<SecondGoodsAudit> {

    /**
     * 根据商品ID查询最新审核记录
     *
     * @param goodsId 商品ID
     * @return 最新审核记录
     */
    @Select("SELECT * FROM second_goods_audit " +
            "WHERE goods_id = #{goodsId} AND delete_flag = 0 " +
            "ORDER BY created_time DESC LIMIT 1")
    SecondGoodsAudit getLatestByGoodsId(@Param("goodsId") Integer goodsId);
}