⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pageimp.java

📁 beijing donggandidai shoufeifanghao
💻 JAVA
字号:
package com.bj.admin.business.service;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.bj.admin.business.IPage;
import com.bj.admin.dao.IPageDAO;
import com.bj.admin.util.page;
public class PageImp implements IPage{
	IPageDAO ipdao;
	
	public void setIpdao(IPageDAO ipdao) {
		this.ipdao = ipdao;
	}

	public page getPage(HttpServletRequest httpServletRequest, int totalRows) {
		//定义pager对象,用于传到页面
	     page pageoption = new page(totalRows);
	     
	     //从Request对象中获取当前页号
	     String currentPage = httpServletRequest.getParameter("currentPage");

	     //如果当前页号为空,表示为首次查询该页
	     //如果不为空,则刷新page对象,输入当前页号等信息
	     if (currentPage != null) {
	       pageoption.refresh(Integer.parseInt(currentPage));
	     }

	     //获取当前执行的方法,首页,前一页,后一页,尾页。
	     String pageoptionMethod = httpServletRequest.getParameter("pageMethod");

	     if (pageoptionMethod != null) {
	       if (pageoptionMethod.equals("first")) {
	         pageoption.first();
	       } else if (pageoptionMethod.equals("previous")) {
	         pageoption.previous();
	       } else if (pageoptionMethod.equals("next")) {
	         pageoption.next();
	       } else if (pageoptionMethod.equals("last")) {
	         pageoption.last();
	       }
	     }
	     return pageoption;
	   }

	public List findAll(HttpServletRequest httpServletRequest) {
		int totalrows = this.getCount();
		page pages = this.getPage(httpServletRequest, totalrows);
		String hql1="from ComBjmobilToperator order by toperatorId";
		List list = ipdao.findAllPerson(pages.getStartRow(), pages.getPageSize(), hql1);
		return list;
	}

	public int getCount() {
		String hql="from ComBjmobilToperator";
		int i = ipdao.getCount(hql);
		return i;
	}

	public List findPeople(HttpServletRequest httpServletRequest) {
		String content = httpServletRequest.getParameter("find");
		String choice = httpServletRequest.getParameter("select3");
		int totalrows = 0;
		String hql1="";
		if(choice.equals("1"))
		{
			totalrows = this.getCount();
			hql1="from ComBjmobilToperator order by toperatorId";
		}
		else if(choice.equals("2"))
		{
			Long id = new Long(content);
			totalrows = this.getCountByID(id);
			hql1="from ComBjmobilToperator where toperatorId='"+id+"' order by toperatorId";
		}
		else if(choice.equals("3"))
		{
			totalrows = this.getCountByName(content);
			hql1="from ComBjmobilToperator where toperatorName='"+content+"' order by toperatorId";
		}
		else if(choice.equals("4"))
		{
			totalrows = this.getCountByLevels(content);
			hql1="from ComBjmobilToperator where isAdmin='"+content+"' order by toperatorId";
		}
		page pages = this.getPage(httpServletRequest, totalrows);
		List list = ipdao.findAllPerson(pages.getStartRow(), pages.getPageSize(), hql1);
		return list;
	}


	public int getCountByID(Long id) {
		String hql="from ComBjmobilToperator where toperatorId='"+id+"'";
		int i = ipdao.getCount(hql);
		return i;
	}

	public int getCountByLevels(String name) {
		String hql="from ComBjmobilToperator where toperatorName='"+name+"'";
		int i = ipdao.getCount(hql);
		return i;
	}

	public int getCountByName(String levels) {
		String hql="from ComBjmobilToperator where isAdmin='"+levels+"'";
		int i = ipdao.getCount(hql);
		return i;
	}
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -