package com.neusoft.smart.pos.printer.repository;

import com.neusoft.smart.pos.printer.persistent.domain.PrinterTaskLog;
import com.neusoft.smart.pos.printer.persistent.domain.PrinterTaskLogExample;
import com.neusoft.smart.pos.printer.persistent.mapper.PrinterTaskLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class PrinterTaskLogRepository {
    
    @Autowired
    public PrinterTaskLogMapper printerTaskLogMapper;
    
    
    /**
     * 保存打印日志
     *
     * @param printerTaskLog
     */
    public void create(PrinterTaskLog printerTaskLog) {
        printerTaskLogMapper.insertSelective(printerTaskLog);
    }
    
    /**
     * 通过taskId获取所有对应日志信息
     *
     * @param taskId
     * @return
     */
    public List<PrinterTaskLog> getByTaskId(Integer taskId) {
        PrinterTaskLogExample printerTaskLogExample = new PrinterTaskLogExample();
        printerTaskLogExample.createCriteria().andTaskIdEqualTo(taskId);
        printerTaskLogExample.setOrderByClause("id desc");
        return printerTaskLogMapper.selectByExample(printerTaskLogExample);
    }
    
    
    public Integer getCountByExample(PrinterTaskLogExample printerTaskLogExample) {
        return printerTaskLogMapper.countByExample(printerTaskLogExample);
    }
    
}
