package top.itart.blog.common.page;

import org.springframework.stereotype.Service;

@Service("jdbc_oracle")
public class OraclePagingSQL implements PagingSQL {

    @Override
    public String wrapPaging(String sql, Paging paging) {
        StringBuffer pageSql = new StringBuffer();
        pageSql.append("select * from (select tmp_tb.*,ROWNUM row_id from (");
        pageSql.append(sql);
        pageSql.append(") tmp_tb where ROWNUM<=");
        pageSql.append(paging.getEndRow());
        pageSql.append(") where row_id>=");
        pageSql.append(paging.getStartRow());
        return pageSql.toString();
    }
}
