package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerWorksheetSetUpMapper;
import com.gxwebsoft.tower.service.TowerWorksheetSetUpService;
import com.gxwebsoft.tower.entity.TowerWorksheetSetUp;
import com.gxwebsoft.tower.param.TowerWorksheetSetUpParam;
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 TowerWorksheetSetUpServiceImpl extends ServiceImpl<TowerWorksheetSetUpMapper, TowerWorksheetSetUp> implements TowerWorksheetSetUpService {

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

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

    @Override
    public TowerWorksheetSetUp getByIdRel(Integer setUpId) {
        TowerWorksheetSetUpParam param = new TowerWorksheetSetUpParam();
        param.setSetUpId(setUpId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
