package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerWorksheetPartsMapper;
import com.gxwebsoft.tower.service.TowerWorksheetPartsService;
import com.gxwebsoft.tower.entity.TowerWorksheetParts;
import com.gxwebsoft.tower.param.TowerWorksheetPartsParam;
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:18:57
 */
@Service
public class TowerWorksheetPartsServiceImpl extends ServiceImpl<TowerWorksheetPartsMapper, TowerWorksheetParts> implements TowerWorksheetPartsService {

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

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

    @Override
    public TowerWorksheetParts getByIdRel(Integer partsId) {
        TowerWorksheetPartsParam param = new TowerWorksheetPartsParam();
        param.setPartsId(partsId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
