package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerInvoicingSettleMapper;
import com.gxwebsoft.tower.service.TowerInvoicingSettleService;
import com.gxwebsoft.tower.entity.TowerInvoicingSettle;
import com.gxwebsoft.tower.param.TowerInvoicingSettleParam;
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 TowerInvoicingSettleServiceImpl extends ServiceImpl<TowerInvoicingSettleMapper, TowerInvoicingSettle> implements TowerInvoicingSettleService {

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

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

    @Override
    public TowerInvoicingSettle getByIdRel(Integer invoicingSettleId) {
        TowerInvoicingSettleParam param = new TowerInvoicingSettleParam();
        param.setInvoicingSettleId(invoicingSettleId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
