package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerIncomeEquipmentMapper;
import com.gxwebsoft.tower.service.TowerIncomeEquipmentService;
import com.gxwebsoft.tower.entity.TowerIncomeEquipment;
import com.gxwebsoft.tower.param.TowerIncomeEquipmentParam;
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 17:06:39
 */
@Service
public class TowerIncomeEquipmentServiceImpl extends ServiceImpl<TowerIncomeEquipmentMapper, TowerIncomeEquipment> implements TowerIncomeEquipmentService {

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

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

    @Override
    public TowerIncomeEquipment getByIdRel(Integer incomeEquipmentId) {
        TowerIncomeEquipmentParam param = new TowerIncomeEquipmentParam();
        param.setIncomeEquipmentId(incomeEquipmentId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
