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

📄 mmsactiveprogram.java

📁 MM7彩信对接网关示例
💻 JAVA
字号:
/*
 * Created on 2005-2-25
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.rainbow.mms.activeprogram;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.Session;

import com.rainbow.util.tools.HibernateUtil;


/**
 * @author Wangzhaonan
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class MMSActiveProgram {
	private int apID;
	private String name;
	private String memo;
	private List listStep;
	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(MMSActiveProgram.class);
	
	public final int getApID() {
		return apID;
	}
	public final String getMemo() {
		return memo;
	}
	public final String getName() {
		return name;
	}
	final void setApID(int apID) {
		this.apID = apID;
	}
	final void setMemo(String memo) {
		this.memo = memo;
	}
	final void setName(String name) {
		this.name = name;
	}
	
	/**
	 * 向该交互节目中添加交互节目的步骤
	 * @param step 交互节目的步骤信息
	 * @return 是否添加成功
	 */
	public void addStep(MMSActiveProgramStep step){
		
		Connection dbConnection = null;
		CallableStatement statement = null;
		
		try {
			Session sess = HibernateUtil.currentSession();
			dbConnection = sess.connection();
			// 调用存储过程 MMS_PActiveGameAddStep
			statement = dbConnection
					.prepareCall("{call MMS_PActiveGameAddStep (?, ?, ?, ?)}");
			statement.setInt(1, apID);
			statement.setInt(2, step.getStepNo());
			statement.setInt(3, step.getContentID());
			statement.setString(4, step.getMemo());
			
			statement.execute();
			dbConnection.commit();
			
		} catch (Exception ex) {
			ex.printStackTrace();
			
		} finally {
			
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			HibernateUtil.closeSession();
		}

		return;
	}
	
	/**
	 * 从该交互节目中删除交互节目的步骤
	 * @param step 交互节目的步骤信息
	 * @return 是否删除成功
	 */
	public void removeStep(MMSActiveProgramStep step){
		
		Connection dbConnection = null;
		CallableStatement statement = null;
		
		try {
			Session sess = HibernateUtil.currentSession();
			dbConnection = sess.connection();
			// 调用存储过程 MMS_PActiveGameRemoveStep
			statement = dbConnection
					.prepareCall("{call MMS_PActiveGameRemoveStep (?, ?)}");
			statement.setInt(1, apID);
			statement.setInt(2, step.getStepNo());
			
			statement.execute();
			dbConnection.commit();
			
		} catch (Exception ex) {
			ex.printStackTrace();

		} finally {
			
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			HibernateUtil.closeSession();
		}

		return;
	}
	
	/**
	 * 返回当前节目中的所有环节信息
	 * @return 环节信息
	 */
	public List loadStep(){
		
		Connection dbConnection = null;
		CallableStatement statement = null;
		ResultSet set = null;
		int pContentID = 0;
		listStep = null;
		
		try {
			Session sess = HibernateUtil.currentSession();
			dbConnection = sess.connection();
			
			// 调用存储过程 MMS_PActiveGameShowStep
			statement = dbConnection
					.prepareCall("{call MMS_PActiveGameShowStep (?)}");
			statement.setInt(1, apID);

			set = statement.executeQuery();
			
			if (listStep == null){
				listStep = new ArrayList();
			}
			
			// 组装结果集
			while (set.next() != false){
				MMSActiveProgramStep s = new MMSActiveProgramStep();
				s.setApID(apID);
				s.setStepNo(set.getInt("tnStepNo"));
				s.setContentID(set.getInt("tnPContentID"));
				s.setMemo(set.getString("tcMemo"));
				
				listStep.add(s);
			}

		} catch (Exception ex) {
			ex.printStackTrace();

		} finally {
			
			if (set != null){
				try {
					set.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			HibernateUtil.closeSession();
		}

		return listStep;
	}
	
	/**
	 * 获得指定节目环节编号的环节信息
	 * @param stepNo 环节编号
	 * @return 环节信息
	 */
	public MMSActiveProgramStep getProgramByID(final int stepNo){
		List tmp = loadStep();
		for (int i = 0; i < tmp.size(); i++){
			MMSActiveProgramStep e = (MMSActiveProgramStep)tmp.get(i);
			if (e.getStepNo() == stepNo){
				return e;
			}
		}
		
		return null;
	}
}

⌨️ 快捷键说明

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