package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerWorksheetCarDispatchMapper;
import com.gxwebsoft.tower.service.TowerWorksheetCarDispatchService;
import com.gxwebsoft.tower.entity.TowerWorksheetCarDispatch;
import com.gxwebsoft.tower.param.TowerWorksheetCarDispatchParam;
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-10-31 12:05:49
 */
@Service
public class TowerWorksheetCarDispatchServiceImpl extends ServiceImpl<TowerWorksheetCarDispatchMapper, TowerWorksheetCarDispatch> implements TowerWorksheetCarDispatchService {

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

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

    @Override
    public TowerWorksheetCarDispatch getByIdRel(Integer carDispatchId) {
        TowerWorksheetCarDispatchParam param = new TowerWorksheetCarDispatchParam();
        param.setCarDispatchId(carDispatchId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
