package com.mortals.xhx.module.device.dao.ibatis;


import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.xhx.module.device.dao.DeviceStatDao;
import com.mortals.xhx.module.device.model.DeviceStatEntity;
import com.mortals.xhx.module.device.model.DeviceStatQuery;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 设备统计DaoImpl DAO接口
 *
 * @author zxfei
 * @date 2022-07-05
 */
@Repository("deviceStatDao")
public class DeviceStatDaoImpl extends BaseCRUDDaoMybatis<DeviceStatEntity, Long> implements DeviceStatDao {
    @Override
    public List<DeviceStatEntity> getStatList(DeviceStatQuery query, PageInfo pageInfo) {
        ParamDto queryParam = super.getQueryParam(query);
        if (pageInfo.getPrePageResult() == -1) {
            return getSqlSession().selectList(SQLID_GET_STATLIST, queryParam);
        } else {
            RowBounds rowBounds = new RowBounds(pageInfo.getBeginIndex(), pageInfo.getPrePageResult());
            return getSqlSession().selectList(SQLID_GET_STATLIST, queryParam, rowBounds);
        }
    }
}
