package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerFallMapper;
import com.gxwebsoft.tower.service.TowerFallService;
import com.gxwebsoft.tower.entity.TowerFall;
import com.gxwebsoft.tower.param.TowerFallParam;
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-05 22:40:55
 */
@Service
public class TowerFallServiceImpl extends ServiceImpl<TowerFallMapper, TowerFall> implements TowerFallService {

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

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

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

}
