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

📄 managelogserviceimpl.java

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

import java.util.List;

import com.yeqiangwei.club.dao.DAOLocator;
import com.yeqiangwei.club.dao.DAOWrapper;
import com.yeqiangwei.club.dao.ManageLogDAO;
import com.yeqiangwei.club.dao.model.ManageLog;
import com.yeqiangwei.club.exception.ClubException;
import com.yeqiangwei.club.exception.DAOException;
import com.yeqiangwei.club.param.ManageLogParameter;
import com.yeqiangwei.club.service.model.ManageLogModel;
import com.yeqiangwei.club.util.BeanLocator;
import com.yeqiangwei.club.util.BeanUtils;
import com.yeqiangwei.club.util.MessageUtils;
import com.yeqiangwei.util.TypeChange;
import com.yeqiangwei.util.Validator;
import com.yeqiangwei.club.service.util.ManageLogService;

public class ManageLogServiceImpl implements ManageLogService{

	public int deleteByTopicId(int topicId) throws ClubException {
		if(topicId>0){
			try {
				return this.getManageLogDAO().deleteByTopicId(topicId);
			} catch (DAOException e) {
				throw new ClubException(MessageUtils.getMessage("error_delete_noid"));
			}
		}
		return 0;
	}

	public int deleteByReplyId(int replyId) throws ClubException {
		if(replyId>0){
			try {
				return this.getManageLogDAO().deleteByReplyId(replyId);
			} catch (DAOException e) {
				throw new ClubException(MessageUtils.getMessage("error_delete_noid"));
			}
		}
		return 0;
	}

	public ManageLogModel findById(int id) {
		ManageLogModel model = null;
		if(id>0){
			ManageLog item = this.getManageLogDAO().findById(id);
			if(!Validator.isEmpty(item)){
				model = new ManageLogModel();
				BeanUtils.copyProperties(model,item);
			}
		}
		return model;
	}

	public void createOrUpdate(ManageLogModel model) throws ClubException {
		if(model.getManageLogId()>0){
			this.update(model);
		}else{
			this.create(model);
		}
	}

	public void create(ManageLogModel model) throws ClubException {
		if(!Validator.isEmpty(model)){
			ManageLog item = new ManageLog();
			BeanUtils.copyProperties(item,model);
			try {
				this.getManageLogDAO().create(item);
			} catch (DAOException e) {
				throw new ClubException(MessageUtils.getMessage("error_system"));
			}
			model.setManageLogId(item.getManageLogId());
		}
	}

	public void update(ManageLogModel model) throws ClubException {
		if(!Validator.isEmpty(model)){
			ManageLog item = this.getManageLogDAO().findById(model.getManageLogId());
			BeanUtils.copyProperties(item,model);
			try {
				this.getManageLogDAO().update(item);
			} catch (DAOException e) {
				throw new ClubException(MessageUtils.getMessage("error_system"));
			}
		}
	}

	public int delete(ManageLogModel model) throws ClubException {
		int c = 0;
		if(!Validator.isEmpty(model)){
			ManageLog item = new ManageLog();
			BeanUtils.copyProperties(item,model);
			try {
				c = this.getManageLogDAO().delete(item);
			} catch (DAOException e) {
				throw new ClubException(MessageUtils.getMessage("error_system"));
			}
		}
		return c;
	}

	public int delete(String[] ids) {
		int s = 0;
		if(!Validator.isEmpty(ids)){
			for(int i=0; i<ids.length; i++){
				int id = TypeChange.stringToInt(ids[i]);
				ManageLogModel model = new ManageLogModel();
				model.setManageLogId(id);
				try {
					s = s + this.delete(model);
				} catch (ClubException e1) {
				
				}
			}
		}
		return s;
	}
	
	public List<ManageLogModel> findByParameter(ManageLogParameter param) {
		List<ManageLog> list = this.getManageLogDAO().findByParameter(param);
		List<ManageLogModel> mlist = BeanUtils.copyList(list,BeanLocator.MANAGELOGMODEL);
		return mlist;
	}

	public long countByParameter(ManageLogParameter param) {
		return this.getManageLogDAO().countByParameter(param);
	}

	public ManageLogDAO getManageLogDAO() {
		return DAOWrapper.<ManageLogDAO>getSingletonInstance(DAOLocator.MANAGELOG);
	}
	
	/*
	public static void main(String args[]){
		com.yeqiangwei.club.dao.hibernate.ConnectionManager.init();
		ManageLogServiceImpl m = new ManageLogServiceImpl();
		ManageLogParameter param = new ManageLogParameter();
		param.setTopicId(949);
		param.setPage(1);
		param.setRows(10);
		param.setIsList(true);
		List<ManageLogModel> list = m.findByParameter(param);
		for(int i=0; i<list.size(); i++){
			ManageLogModel model = list.get(i);
			System.out.println(model.getMemo());
		}
	}
	*/
}

⌨️ 快捷键说明

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