package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerSettleMapper;
import com.gxwebsoft.tower.service.TowerSettleService;
import com.gxwebsoft.tower.entity.TowerSettle;
import com.gxwebsoft.tower.param.TowerSettleParam;
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:19:10
 */
@Service
public class TowerSettleServiceImpl extends ServiceImpl<TowerSettleMapper, TowerSettle> implements TowerSettleService {

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

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

    @Override
    public TowerSettle getByIdRel(Integer settleId) {
        TowerSettleParam param = new TowerSettleParam();
        param.setSettleId(settleId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
