package com.erp.print.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.erp.print.entity.Printer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface PrinterRepository extends BaseMapper<Printer> {

    @Select("SELECT * FROM printer WHERE deleted = 0 ORDER BY created_at DESC")
    IPage<Printer> selectPageList(Page<Printer> page);

    @Select("SELECT * FROM printer WHERE deleted = 0 AND printer_code = #{printerCode}")
    Printer selectByPrinterCode(@Param("printerCode") String printerCode);

    @Select("SELECT * FROM printer WHERE deleted = 0 AND status = 1 ORDER BY is_default DESC, created_at ASC")
    IPage<Printer> selectAvailablePrinters(Page<Printer> page);
}
