package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerPlaceStandardMapper;
import com.gxwebsoft.tower.service.TowerPlaceStandardService;
import com.gxwebsoft.tower.entity.TowerPlaceStandard;
import com.gxwebsoft.tower.param.TowerPlaceStandardParam;
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 15:37:00
 */
@Service
public class TowerPlaceStandardServiceImpl extends ServiceImpl<TowerPlaceStandardMapper, TowerPlaceStandard> implements TowerPlaceStandardService {

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

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

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

}
