package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerWorksheetDetailMapper;
import com.gxwebsoft.tower.service.TowerWorksheetDetailService;
import com.gxwebsoft.tower.entity.TowerWorksheetDetail;
import com.gxwebsoft.tower.param.TowerWorksheetDetailParam;
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-03 10:56:04
 */
@Service
public class TowerWorksheetDetailServiceImpl extends ServiceImpl<TowerWorksheetDetailMapper, TowerWorksheetDetail> implements TowerWorksheetDetailService {

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

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

    @Override
    public TowerWorksheetDetail getByIdRel(Integer detailId) {
        TowerWorksheetDetailParam param = new TowerWorksheetDetailParam();
        param.setDetailId(detailId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
