<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.erp.tenant.repository.supplier.SupplierRepository">

    <!-- 供应商分页查询 -->
    <select id="findPage" resultType="com.erp.tenant.entity.supplier.Supplier">
        SELECT s.* FROM suppliers s
        WHERE s.tenant_id = #{tenantId} AND s.deleted_at IS NULL
        <if test="keyword != null and keyword != ''">
            AND (s.name LIKE CONCAT('%', #{keyword}, '%') 
                 OR s.code LIKE CONCAT('%', #{keyword}, '%'))
        </if>
        <if test="status != null">
            AND s.status = #{status}
        </if>
        ORDER BY s.updated_at DESC
    </select>

</mapper>
