package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerContractFinalSettleLostMapper;
import com.gxwebsoft.tower.service.TowerContractFinalSettleLostService;
import com.gxwebsoft.tower.entity.TowerContractFinalSettleLost;
import com.gxwebsoft.tower.param.TowerContractFinalSettleLostParam;
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-18 00:52:41
 */
@Service
public class TowerContractFinalSettleLostServiceImpl extends ServiceImpl<TowerContractFinalSettleLostMapper, TowerContractFinalSettleLost> implements TowerContractFinalSettleLostService {

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

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

    @Override
    public TowerContractFinalSettleLost getByIdRel(Integer finalSettleLostId) {
        TowerContractFinalSettleLostParam param = new TowerContractFinalSettleLostParam();
        param.setFinalSettleLostId(finalSettleLostId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
