package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerRentMapper;
import com.gxwebsoft.tower.service.TowerRentService;
import com.gxwebsoft.tower.entity.TowerRent;
import com.gxwebsoft.tower.param.TowerRentParam;
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 2024-02-05 15:04:19
 */
@Service
public class TowerRentServiceImpl extends ServiceImpl<TowerRentMapper, TowerRent> implements TowerRentService {

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

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

    @Override
    public TowerRent getByIdRel(Integer rentId) {
        TowerRentParam param = new TowerRentParam();
        param.setRentId(rentId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
