package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerContractFinalSettleMapper;
import com.gxwebsoft.tower.service.TowerContractFinalSettleService;
import com.gxwebsoft.tower.entity.TowerContractFinalSettle;
import com.gxwebsoft.tower.param.TowerContractFinalSettleParam;
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 22:34:32
 */
@Service
public class TowerContractFinalSettleServiceImpl extends ServiceImpl<TowerContractFinalSettleMapper, TowerContractFinalSettle> implements TowerContractFinalSettleService {

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

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

    @Override
    public TowerContractFinalSettle getByIdRel(Integer contractFinalSettleId) {
        TowerContractFinalSettleParam param = new TowerContractFinalSettleParam();
        param.setContractFinalSettleId(contractFinalSettleId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
