package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerProjectOrderMapper;
import com.gxwebsoft.tower.service.TowerProjectOrderService;
import com.gxwebsoft.tower.entity.TowerProjectOrder;
import com.gxwebsoft.tower.param.TowerProjectOrderParam;
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-07 18:48:56
 */
@Service
public class TowerProjectOrderServiceImpl extends ServiceImpl<TowerProjectOrderMapper, TowerProjectOrder> implements TowerProjectOrderService {

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

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

    @Override
    public TowerProjectOrder getByIdRel(Integer projectOrderId) {
        TowerProjectOrderParam param = new TowerProjectOrderParam();
        param.setProjectOrderId(projectOrderId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
