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

📄 counterserviceimpl.java

📁 野蔷薇论坛源码 java 自己看看吧。 学习用
💻 JAVA
字号:
/* 
 * Created on 2007-1-30
 * Last modified on 2007-10-17
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.service.util.impl;

import java.util.List;

import com.yeqiangwei.club.dao.CounterDAO;
import com.yeqiangwei.club.dao.DAOLocator;
import com.yeqiangwei.club.dao.DAOWrapper;
import com.yeqiangwei.club.dao.model.Counter;
import com.yeqiangwei.club.exception.ClubException;
import com.yeqiangwei.club.exception.DAOException;
import com.yeqiangwei.club.param.BaseParameter;
import com.yeqiangwei.club.service.util.CounterService;
import com.yeqiangwei.club.util.MessageUtils;

public class CounterServiceImpl extends MessageUtils implements CounterService {

	
	public static CounterDAO getCounterDAO(){
		return DAOWrapper.<CounterDAO>getSingletonInstance(DAOLocator.COUNTER);
	}
	
	private static Counter COUNTER;
	
	static{
		if(COUNTER==null){
			COUNTER = getCounterDAO().findOnly();
		}
	}
	
	public Counter findOnly() {
		return COUNTER;
	}

	public Counter findById(int id) {
		if(id>0){
			return getCounterDAO().findById(id);
		}
		return null;
	}

	public void createOrUpdate(Counter item) throws ClubException {
		try {
			if(item.getCounterId()>0){
				getCounterDAO().update(item);
			}else{
				getCounterDAO().create(item);
			}
		} catch (DAOException e) {
			throw new ClubException(MessageUtils.getMessage("error_system"));
		}
	}

	public void create(Counter item) throws ClubException {
		if(item!=null){
			try {
				getCounterDAO().create(item);
				COUNTER = item;
			} catch (DAOException e) {
				throw new ClubException(MessageUtils.getMessage("error_system"));
			}
		}
	}

	public void update(Counter item) throws ClubException {
		try {
			getCounterDAO().update(item);
			COUNTER = item;
		} catch (DAOException e) {
			throw new ClubException(MessageUtils.getMessage("error_system"));
		}
	}

	public int delete(Counter item) throws ClubException {
		int c = 0;
		if(item.getCounterId()>0){
			try {
				c = getCounterDAO().delete(item);
			} catch (DAOException e) {
				throw new ClubException(MessageUtils.getMessage("error_system"));
			}
		}
		return c;
	}

	public int delete(String[] ids) {
		return 0;
	}

	public List<Counter> findByParameter(BaseParameter param) {
		return null;
	}

	public long countByParameter(BaseParameter param) {
		return 0;
	}
}

⌨️ 快捷键说明

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