package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerInvoicingMapper;
import com.gxwebsoft.tower.service.TowerInvoicingService;
import com.gxwebsoft.tower.entity.TowerInvoicing;
import com.gxwebsoft.tower.param.TowerInvoicingParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 开票管理Service实现
 *
 * @author 科技小王子
 * @since 2023-06-17 12:47:08
 */
@Service
public class TowerInvoicingServiceImpl extends ServiceImpl<TowerInvoicingMapper, TowerInvoicing> implements TowerInvoicingService {

    @Override
    public PageResult<TowerInvoicing> pageRel(TowerInvoicingParam param) {
        PageParam<TowerInvoicing, TowerInvoicingParam> page = new PageParam<>(param);
        //page.setDefaultOrder("create_time desc");
        List<TowerInvoicing> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<TowerInvoicing> listRel(TowerInvoicingParam param) {
        List<TowerInvoicing> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<TowerInvoicing, TowerInvoicingParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public TowerInvoicing getByIdRel(Integer invoicingId) {
        TowerInvoicingParam param = new TowerInvoicingParam();
        param.setInvoicingId(invoicingId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
