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.PrintTemplate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface PrintTemplateRepository extends BaseMapper<PrintTemplate> {

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

    @Select("SELECT * FROM print_template WHERE deleted = 0 AND template_code = #{templateCode}")
    PrintTemplate selectByTemplateCode(@Param("templateCode") String templateCode);

    @Select("SELECT * FROM print_template WHERE deleted = 0 AND template_type = #{templateType} AND is_default = 1")
    PrintTemplate selectDefaultByType(@Param("templateType") String templateType);
}
