managelogserviceimpl.java

来自「社区文章采用的是平板、树形自由选择的两种展示方式」· Java 代码 · 共 131 行

JAVA
131
字号
/* 
 * Created on 2007-4-24
 * Last modified on 2007-12-20
 * 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.model.ManageLog;
import com.yeqiangwei.club.exception.ClubException;
import com.yeqiangwei.club.param.ManageLogParameter;
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){
			return this.getManageLogDAO().deleteByTopicId(topicId);
		}else{
			throw new ClubException(MessageUtils.getMessage("error_delete_noid"));
		}
	}

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

	public ManageLog findById(int id) {
		if(id>0){
			return this.getManageLogDAO().findById(id);
		}else{
			return null;
		}
	}

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

	public void create(ManageLog model) throws ClubException {
		if(!Validator.isEmpty(model)){
			if(model.getScore()==0&&model.getCredit()==0&&model.getMoney()==0&&model.getViews()==0){
				throw new ClubException(MessageUtils.getMessage("error_param"));
			}
			this.getManageLogDAO().create(model);
		}else{
			throw new ClubException(MessageUtils.getMessage("error_param"));
		}
	}

	public void update(ManageLog model) throws ClubException {
		if(!Validator.isEmpty(model)){
			ManageLog item = this.getManageLogDAO().findById(model.getManageLogId());
			BeanUtils.copyProperties(item,model);
			this.getManageLogDAO().update(item);
		}else{
			throw new ClubException(MessageUtils.getMessage("error_param"));
		}
	}

	public int delete(ManageLog model) throws ClubException {
		if(!Validator.isEmpty(model)){
			return this.getManageLogDAO().delete(model);
		}else{
			throw new ClubException(MessageUtils.getMessage("error_param"));
		}
	}

	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]);
				ManageLog model = new ManageLog();
				model.setManageLogId(id);
				try {
					s = s + this.delete(model);
				} catch (ClubException e1) {
				
				}
			}
		}
		return s;
	}
	
	public List<ManageLog> findByParameter(ManageLogParameter param) {
		return this.getManageLogDAO().findByParameter(param);
	}

	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<ManageLog> list = m.findByParameter(param);
		for(int i=0; i<list.size(); i++){
			ManageLog model = list.get(i);
			System.out.println(model.getMemo());
		}
	}
	*/
}

⌨️ 快捷键说明

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