package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerLendingSettleListMapper;
import com.gxwebsoft.tower.service.TowerLendingSettleListService;
import com.gxwebsoft.tower.entity.TowerLendingSettleList;
import com.gxwebsoft.tower.param.TowerLendingSettleListParam;
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-15 10:29:54
 */
@Service
public class TowerLendingSettleListServiceImpl extends ServiceImpl<TowerLendingSettleListMapper, TowerLendingSettleList> implements TowerLendingSettleListService {

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

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

    @Override
    public TowerLendingSettleList getByIdRel(Integer lendingSettleListId) {
        TowerLendingSettleListParam param = new TowerLendingSettleListParam();
        param.setLendingSettleListId(lendingSettleListId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
