package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerIncomeMapper;
import com.gxwebsoft.tower.service.TowerIncomeService;
import com.gxwebsoft.tower.entity.TowerIncome;
import com.gxwebsoft.tower.param.TowerIncomeParam;
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 TowerIncomeServiceImpl extends ServiceImpl<TowerIncomeMapper, TowerIncome> implements TowerIncomeService {

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

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

    @Override
    public TowerIncome getByIdRel(Integer incomeId) {
        TowerIncomeParam param = new TowerIncomeParam();
        param.setIncomeId(incomeId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
