package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerProjectBuildingMapper;
import com.gxwebsoft.tower.service.TowerProjectBuildingService;
import com.gxwebsoft.tower.entity.TowerProjectBuilding;
import com.gxwebsoft.tower.param.TowerProjectBuildingParam;
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 2024-01-05 22:01:16
 */
@Service
public class TowerProjectBuildingServiceImpl extends ServiceImpl<TowerProjectBuildingMapper, TowerProjectBuilding> implements TowerProjectBuildingService {

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

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

    @Override
    public TowerProjectBuilding getByIdRel(Integer buildingId) {
        TowerProjectBuildingParam param = new TowerProjectBuildingParam();
        param.setBuildingId(buildingId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
