package com.sqx.modules.errand.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.errand.dao.TransferRecordDao;
import com.sqx.modules.errand.entity.*;
import com.sqx.modules.errand.service.TransferRecordService;
import com.sqx.modules.errand.vo.TransferRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TransferRecordServiceImpl extends ServiceImpl<TransferRecordDao, TransferRecordEntity> implements TransferRecordService {

    @Autowired
    private TransferRecordDao transferRecordDao;

    @Override
    public int insertPrintInfo(TransferRecordEntity tr) {
        int result = baseMapper.insert(tr);

        return result;
    }

    @Override
    public boolean insertBatchPrintInfo(List<TransferRecordEntity> trs) {
        boolean result = this.saveBatch(trs);

        return result;
    }

    @Override
    public Result transferRecordById(Integer page, Integer limit, Integer orderId) {
        Page<TransferRecordVo> pages = new Page<>(page, limit);
        PageUtils pageUtils = new PageUtils(transferRecordDao.queryTransferRecordPages(pages, orderId));
        return Result.success().put("data", pageUtils);
    }
}
