package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerProjectPlaceMapper;
import com.gxwebsoft.tower.service.TowerProjectPlaceService;
import com.gxwebsoft.tower.entity.TowerProjectPlace;
import com.gxwebsoft.tower.param.TowerProjectPlaceParam;
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-06-08 17:22:55
 */
@Service
public class TowerProjectPlaceServiceImpl extends ServiceImpl<TowerProjectPlaceMapper, TowerProjectPlace> implements TowerProjectPlaceService {

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

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

    @Override
    public TowerProjectPlace getByIdRel(Integer id) {
        TowerProjectPlaceParam param = new TowerProjectPlaceParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
