package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerHistorySettleMapper;
import com.gxwebsoft.tower.service.TowerHistorySettleService;
import com.gxwebsoft.tower.entity.TowerHistorySettle;
import com.gxwebsoft.tower.param.TowerHistorySettleParam;
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-12 16:40:25
 */
@Service
public class TowerHistorySettleServiceImpl extends ServiceImpl<TowerHistorySettleMapper, TowerHistorySettle> implements TowerHistorySettleService {

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

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

    @Override
    public TowerHistorySettle getByIdRel(Integer historySettleId) {
        TowerHistorySettleParam param = new TowerHistorySettleParam();
        param.setHistorySettleId(historySettleId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
