package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerPlaceMapper;
import com.gxwebsoft.tower.service.TowerPlaceService;
import com.gxwebsoft.tower.entity.TowerPlace;
import com.gxwebsoft.tower.param.TowerPlaceParam;
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 11:00:17
 */
@Service
public class TowerPlaceServiceImpl extends ServiceImpl<TowerPlaceMapper, TowerPlace> implements TowerPlaceService {

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

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

    @Override
    public TowerPlace getByIdRel(Integer placeId) {
        TowerPlaceParam param = new TowerPlaceParam();
        param.setPlaceId(placeId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
