package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerContractEquipmentMapper;
import com.gxwebsoft.tower.service.TowerContractEquipmentService;
import com.gxwebsoft.tower.entity.TowerContractEquipment;
import com.gxwebsoft.tower.param.TowerContractEquipmentParam;
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-09 13:42:20
 */
@Service
public class TowerContractEquipmentServiceImpl extends ServiceImpl<TowerContractEquipmentMapper, TowerContractEquipment> implements TowerContractEquipmentService {

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

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

    @Override
    public TowerContractEquipment getByIdRel(Integer contractEquipmentId) {
        TowerContractEquipmentParam param = new TowerContractEquipmentParam();
        param.setContractEquipmentId(contractEquipmentId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
