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

📄 topictypeimpl.java

📁 这是一款最新的野蔷薇论坛源码,有需要的朋友可以尽情下载
💻 JAVA
字号:
/* 
 * Created on 2005-11-13
 * Last modified on 2007-1-21
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.dao.hibernate.impl;

import java.util.Iterator;
import java.util.List;

import com.yeqiangwei.club.dao.TopicTypeDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.model.TopicType;
import com.yeqiangwei.club.param.TopicParameter;

/**
 * @author YeQiangWei by 我容易么我
 * Powered by YeQiangWei.com
 */
public class TopicTypeImpl implements TopicTypeDAO{
	
	private static final String FIND_ALL = "from TopicType order by typeId desc";
	
	private static final String COUNT_ALL = "select count(typeId) from TopicType ";

	//private static final String FIND_TOPICID = "from TopicType where topicId=?";
	
	private static final String FIND_TYPEID = "from TopicType where typeId=?";
	
	private static final String DELETE_TOPICID = "delete from TopicType where topicId=?";
	
	private static final String DELETE_TYPEID = "delete from TopicType where typeId=?";
	
	private static final String DELETES_TYPEID = "delete form TopicType where typeId in (:ids)";
	
	/**
	 * 发购买贴获得的金币数,或是提问贴送出的积分数
	 * @param id 贴子主题ID
	 * @param type 贴子类型
	 * @return
	 * 2005-11-13 15:03:59 Made In YeQiangWei
	 * @see com.yeqiangwei.club.dao.ClubTopicTypeDAO#getNumber(int)
	 */
	public double getNumber(int topicId, byte typeInfo){
		double d = 0;
        StringBuffer hql = new StringBuffer();
        hql.append("select sum(ct.typeNum) ");
    	hql.append(" from TopicType as ct where ct.topicId=?");
    	hql.append(" and ct.typeInfo=?");
    	HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
    	facade.setInt(0, topicId);
    	facade.setByte(1, typeInfo);
    	Iterator it = facade.iterate();
        if(it!=null){
            Double results = new Double(0);
            while(it.hasNext()){
                 results = (Double) it.next();
                 if(results!=null){
                	 d = results.doubleValue();
                 }
            }
        }
		return d;
	}

	public int deleteByTopicId(int topicId) {
		HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
		facade.createQuery(DELETE_TOPICID);
		facade.setInt(0, topicId);
		int c = facade.executeUpdate();
		return c;
	}

	public TopicType create(TopicType item) {
		HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
		item = facade.save(item);		
		return item;
	}

	public TopicType update(TopicType item) {
		HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
		item = facade.update(item);		
		return item;
	}

	public int delete(TopicType item) {
		HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
		facade.createQuery(DELETE_TYPEID);
		facade.setInt(0, item.getTypeId());
		int c = facade.executeUpdate();
		return c;
	}

	public int delete(List ids) {
		HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
		facade.createQuery(DELETES_TYPEID);
		facade.setParameterList("ids",ids);
		int c = facade.executeUpdate();
		return c;
	}

	public TopicType findById(int id) {
		HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
		facade.createQuery(FIND_TYPEID);
		facade.setInt(0, id);
		TopicType item = facade.uniqueResult();
		return item;
	}

	public List<TopicType> findByParameter(TopicParameter param) {
		return null;
	}

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

	public List findAll(TopicParameter param) {
		HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
		facade.createQuery(FIND_ALL);
		facade.setFirstResult(param.getPagination().getStartRow());
		facade.setMaxResults(param.getPagination().getEndRow());
		List list = facade.executeQuery();
		
		return list;
	}

	public long countAll(TopicParameter param) {
		HibernateFacade<TopicType> facade = new HibernateFacade<TopicType>();
		facade.createQuery(COUNT_ALL);
		long c = facade.resultTotal();
		return c;
	}

}

⌨️ 快捷键说明

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