package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerContractSettleEquipmentMapper;
import com.gxwebsoft.tower.service.TowerContractSettleEquipmentService;
import com.gxwebsoft.tower.entity.TowerContractSettleEquipment;
import com.gxwebsoft.tower.param.TowerContractSettleEquipmentParam;
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-10 16:52:12
 */
@Service
public class TowerContractSettleEquipmentServiceImpl extends ServiceImpl<TowerContractSettleEquipmentMapper, TowerContractSettleEquipment> implements TowerContractSettleEquipmentService {

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

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

    @Override
    public TowerContractSettleEquipment getByIdRel(Integer contractSettleId) {
        TowerContractSettleEquipmentParam param = new TowerContractSettleEquipmentParam();
        param.setContractSettleId(contractSettleId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
