package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerPlaceSafetyMapper;
import com.gxwebsoft.tower.service.TowerPlaceSafetyService;
import com.gxwebsoft.tower.entity.TowerPlaceSafety;
import com.gxwebsoft.tower.param.TowerPlaceSafetyParam;
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 TowerPlaceSafetyServiceImpl extends ServiceImpl<TowerPlaceSafetyMapper, TowerPlaceSafety> implements TowerPlaceSafetyService {

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

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

    @Override
    public TowerPlaceSafety getByIdRel(Integer placeSafetyId) {
        TowerPlaceSafetyParam param = new TowerPlaceSafetyParam();
        param.setPlaceSafetyId(placeSafetyId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
