package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerWorksheetMapper;
import com.gxwebsoft.tower.service.TowerWorksheetService;
import com.gxwebsoft.tower.entity.TowerWorksheet;
import com.gxwebsoft.tower.param.TowerWorksheetParam;
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-02 16:15:31
 */
@Service
public class TowerWorksheetServiceImpl extends ServiceImpl<TowerWorksheetMapper, TowerWorksheet> implements TowerWorksheetService {

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

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

    @Override
    public TowerWorksheet getByIdRel(Integer worksheetId) {
        TowerWorksheetParam param = new TowerWorksheetParam();
        param.setWorksheetId(worksheetId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
