package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerWorksheetCheckMapper;
import com.gxwebsoft.tower.service.TowerWorksheetCheckService;
import com.gxwebsoft.tower.entity.TowerWorksheetCheck;
import com.gxwebsoft.tower.param.TowerWorksheetCheckParam;
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-07-04 01:24:45
 */
@Service
public class TowerWorksheetCheckServiceImpl extends ServiceImpl<TowerWorksheetCheckMapper, TowerWorksheetCheck> implements TowerWorksheetCheckService {

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

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

    @Override
    public TowerWorksheetCheck getByIdRel(Integer checkId) {
        TowerWorksheetCheckParam param = new TowerWorksheetCheckParam();
        param.setCheckId(checkId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
