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

📄 cardservice.java

📁 本套系统采用了业界当前最为流行的beanAction组件
💻 JAVA
字号:
package teleReport.service;

import java.util.List;
import java.util.ArrayList;

import com.ibatis.dao.client.DaoManager;
import commons.persistence.DaoConfig;
import commons.service.BaseService;

import teleReport.domain.CardInfo;
import teleReport.domain.City;
import teleReport.domain.OrderInfo;
import teleReport.domain.Product;
import teleReport.presentation.CardBean;

import teleReport.persistence.iface.CardDAO;
import teleReport.persistence.jdbcdao.CardJdbcDAO;

public class CardService extends BaseService {
	private static final int PAGENUM = 10;

	DaoManager daoManager = null;
	private CardDAO cardDao = null;
	List<CardInfo> tempList;

	// List<CardInfo> tempList;

	public CardService() {
		daoManager = DaoConfig.getDaoManager();
		cardDao = (CardDAO) daoManager.getDao(CardDAO.class);
	}

	public CardService(CardDAO dao) {
		cardDao = dao;
	}

	// base table query
	public List<City> getCity() {
		return cardDao.getCity();
	}

	public List<Product> getProd() {
		return cardDao.getProd();
	}

	// query card information
	public List<CardInfo> showCardInputer(CardInfo cardInfo) {
		return cardDao.getCardInputer(cardInfo);
	}

	// 跳转其他页面
	public List<CardInfo> goNextPage(CardInfo cardInfo,
			List<CardInfo> cardInfoList) {
		List<CardInfo> tempPagePayoutList = new ArrayList<CardInfo>();
		int curPage = Integer.parseInt(cardInfo.getCurrentPage());
		int sumPage;// =Integer.parseInt(payoutInfo.getPageSum());
		if (cardInfoList.size() % PAGENUM == 0) {
			sumPage = cardInfoList.size() / PAGENUM;
		} else {
			sumPage = cardInfoList.size() / PAGENUM + 1;
		}
		
		cardInfo.setCurrentPage(Integer.toString(curPage));
		cardInfo.setTotalPage(Integer.toString(sumPage));
		
		if (sumPage >= curPage) {
			for (int i = (curPage - 1) * PAGENUM; i < curPage * PAGENUM
					&& i <= cardInfoList.size() - 1; i++) {
				CardInfo tempPayoutInfo = new CardInfo();
				tempPayoutInfo = cardInfoList.get(i);
				tempPagePayoutList.add(tempPayoutInfo);
			}
			return tempPagePayoutList;
		} else {
			// tempList = tempPagePayoutList;
			return tempPagePayoutList;
		}
	}

	public List<CardInfo> goHeadpage(CardInfo cardInfo,
			List<CardInfo> cardInfoList) {
		List<CardInfo> tempPagePayoutList = new ArrayList<CardInfo>();

		for (int i = 0; i < PAGENUM && i <= cardInfoList.size() - 1; i++) {
			CardInfo tempPayoutInfo = new CardInfo();
			tempPayoutInfo = cardInfoList.get(i);
			tempPagePayoutList.add(tempPayoutInfo);
		}
		cardInfo.setCurrentPage(Integer.toString(1));
		return tempPagePayoutList;
	}

	public List<CardInfo> goEndPage(CardInfo cardInfo,
			List<CardInfo> cardInfoList) {
		List<CardInfo> tempPagePayoutList = new ArrayList<CardInfo>();
		int sumPage = Integer.parseInt(cardInfo.getTotalPage());
		if (sumPage > 0){
		for (int i = (sumPage - 1) * PAGENUM; i <= cardInfoList.size() - 1; i++) {
			CardInfo tempPayoutInfo = new CardInfo();
			tempPayoutInfo = cardInfoList.get(i);
			tempPagePayoutList.add(tempPayoutInfo);
		}
		cardInfo.setCurrentPage(Integer.toString(sumPage));
		}else{
			cardInfo.setCurrentPage("1");
		}
		
		return tempPagePayoutList;
	}

	public List<CardInfo> goToNextPage(CardInfo cardInfo,
			List<CardInfo> cardInfoList) {
		List<CardInfo> tempPagePayoutList = new ArrayList<CardInfo>();
		int curPage = Integer.parseInt(cardInfo.getCurrentPage());
		int sumPage = Integer.parseInt(cardInfo.getTotalPage());

		if (sumPage > curPage) {
			curPage++;
		}
		for (int i = (curPage - 1) * PAGENUM; i < curPage * PAGENUM
				&& i <= cardInfoList.size() - 1; i++) {
			CardInfo tempPayoutInfo = new CardInfo();
			tempPayoutInfo = cardInfoList.get(i);
			tempPagePayoutList.add(tempPayoutInfo);
		}
		cardInfo.setCurrentPage(Integer.toString(curPage));
		return tempPagePayoutList;
	}

	public List<CardInfo> goToLastPage(CardInfo cardInfo,
			List<CardInfo> cardInfoList) {
		List<CardInfo> tempPagePayoutList = new ArrayList<CardInfo>();
		int curPage = Integer.parseInt(cardInfo.getCurrentPage());

		if (curPage > 1) {
			curPage--;
		}
		
		for (int i = (curPage - 1) * PAGENUM; i < curPage * PAGENUM && i <= cardInfoList.size() - 1; i++) {
			CardInfo tempPayoutInfo = new CardInfo();
			tempPayoutInfo = cardInfoList.get(i);
			tempPagePayoutList.add(tempPayoutInfo);
		}
		
		cardInfo.setCurrentPage(Integer.toString(curPage));
		return tempPagePayoutList;
	}

	/*
	 * public List<CardInfo> goCurrentPage(){ return tempList; }
	 */
	// 录入卡销售记录信息,返回主键
	public Long insertCard(CardInfo cardInfo) {
		Long pk = null;
		try {
			daoManager.startTransaction();
			pk = cardDao.insertCard(cardInfo);
			daoManager.commitTransaction();
		} finally {
			daoManager.endTransaction();
		}
		return pk;
	}

	// 删除卡销售信息
	public void deleteCard(String cSaleId) {
		cardDao.deleteCard(cSaleId);
	}
/////////////////////////////
	public CardInfo getCardById(String cardSaleId){
		return cardDao.getCardById(cardSaleId);
	}
	// 录入者更新卡销售记录信息
	public CardInfo updateCard(CardInfo cardInfo) {
		return cardDao.updateCard(cardInfo);
	}

	// 稽核者更新卡销售记录状态
	public CardInfo updateCardState(CardInfo cardInfo) {
		return cardDao.updateCardState(cardInfo);
	}

}

⌨️ 快捷键说明

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