package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerSettleDetailMapper;
import com.gxwebsoft.tower.service.TowerSettleDetailService;
import com.gxwebsoft.tower.entity.TowerSettleDetail;
import com.gxwebsoft.tower.param.TowerSettleDetailParam;
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-11 19:13:12
 */
@Service
public class TowerSettleDetailServiceImpl extends ServiceImpl<TowerSettleDetailMapper, TowerSettleDetail> implements TowerSettleDetailService {

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

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

    @Override
    public TowerSettleDetail getByIdRel(Integer settleDetailId) {
        TowerSettleDetailParam param = new TowerSettleDetailParam();
        param.setSettleDetailId(settleDetailId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
