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

📄 advertiseinfo.java

📁 java阿里巴巴代码
💻 JAVA
字号:
package com.saas.biz.advertiseMgr;

import java.util.ArrayList;
import java.util.HashMap;

import com.saas.biz.dao.advertiseDAO.AdvertiseDAO;
import com.saas.biz.dao.advertiseDAO.AdvertiseExt;
import com.saas.biz.dao.attachDAO.AttachExt;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.dbm.Dbtable;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;

/**
 * @author:xsaas
 * @desc:广告信息
 * @2008-7-5
 */
public class AdvertiseInfo {
	
	
	Dbtable tradeQuery;
	
	
	Logger log;
	
	
	Buffers inBuffer;
	
	
	Buffers outBuffer;
	
	
	ArrayList queryResult = new ArrayList();
	
	
	
	public AdvertiseInfo() {

		log = new Logger(this);
		tradeQuery = new Dbtable();
	}
	
	
	public void setTradeQuery(Dbtable tradeQuery) {

		this.tradeQuery = tradeQuery;
	}
	
	
	public Dbtable getTradeQuery() {

		return this.tradeQuery;
	}
	
	
	public void setOutBuffer(Buffers outBuffer) {

		this.outBuffer = outBuffer;
	}
	
	
	public Buffers getOutBuffer() {

		return this.outBuffer;
	}
	
	
	public ArrayList getQueryResult() {

		return this.queryResult;
	}
	
	
	public void setQueryResult(ArrayList queryResult) {

		this.queryResult = queryResult;
	}
	
	
	
	// 增加广告
	public void addadvertiseInfo(Buffers inbuffer) {

		log.LOG_INFO("进入addadvertiseInfo方法...");
		this.outBuffer = inbuffer;
		AdvertiseDAO advertisedao = new AdvertiseDAO();
		advertisedao.setAdv_id(inbuffer.getString("ADV_ID"));
		advertisedao.setAdv_type(inbuffer.getString("ADV_TYPE"));
		advertisedao.setContent(inbuffer.getString("CONTENT"));
		advertisedao.setStart_date(inbuffer.getString("START_DATE"));
		advertisedao.setEnd_date(inbuffer.getString("END_DATE"));
		advertisedao.setShow_no(inbuffer.getString("SHOW_NO"));
		advertisedao.setOwn_range(inbuffer.getString("OWN_RANGE"));
		advertisedao.setCust_id(inbuffer.getString("SESSION_CUST_ID"));
		advertisedao.setRsrv_str1(inbuffer.getString("SESSION_USER_ID"));
		advertisedao.setRemark(inbuffer.getString("REMARK"));
		int iResult = -1;
		try {
			iResult = addadvertiseInfo(advertisedao);
		}
		catch (SaasApplicationException e) {
			log.LOG_INFO(e.getMessage());
		}
		if (iResult != 0) {
			this.outBuffer.setInt("RESULT_CODE", -1);
			this.outBuffer.setString("RESULT_INFO", "业务处理失败!");
		}
		else {
			this.outBuffer.setInt("RESULT_CODE", 0);
			this.outBuffer.setString("RESULT_INFO", "业务处理成功!");
		}
	}
	
	
	public int addadvertiseInfo(AdvertiseDAO advertisedao) throws SaasApplicationException {

		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VADV_ID", advertisedao.getAdv_id());
		advertiseExt.setParam(":VADV_TYPE", advertisedao.getAdv_type());
		advertiseExt.setParam(":VCONTENT", advertisedao.getContent());
		advertiseExt.setParam(":VSTART_DATE", advertisedao.getStart_date());
		advertiseExt.setParam(":VEND_DATE", advertisedao.getEnd_date());
		advertiseExt.setParam(":VSHOW_NO", advertisedao.getShow_no());
		advertiseExt.setParam(":VOWN_RANGE", advertisedao.getOwn_range());
		advertiseExt.setParam(":VCUST_ID", advertisedao.getCust_id());
		advertiseExt.setParam(":VRSRV_STR1", advertisedao.getRsrv_str1());
		advertiseExt.setParam(":VRSRV_STR2", "");
		advertiseExt.setParam(":VRSRV_STR3", "");
		advertiseExt.setParam(":VRSRV_STR6", "");
		advertiseExt.setParam(":VRSRV_STR7", "");
		advertiseExt.setParam(":VRSRV_STR8", "");
		advertiseExt.setParam(":VRSRV_STR9", "");
		advertiseExt.setParam(":VRSRV_STR10", "");
		advertiseExt.setParam(":VRSRV_NUM4", "");
		advertiseExt.setParam(":VRSRV_NUM5", "");
		advertiseExt.setParam(":VREMARK", advertisedao.getRemark());
		tradeQuery.executeBy(advertiseExt.insBy("INS_BY_ALL"));
		return 0;
	}
	
	
	
	// 修改广告
	public void updateAdvertiseInfo(Buffers inbuffer) {

		log.LOG_INFO("进入updateAdvertiseInfo方法...");
		this.outBuffer = inbuffer;
		AdvertiseDAO advertisedao = new AdvertiseDAO();
		advertisedao.setAdv_id(inbuffer.getString("ADV_ID"));
		advertisedao.setAdv_type(inbuffer.getString("ADV_TYPE"));
		advertisedao.setContent(inbuffer.getString("CONTENT"));
		advertisedao.setStart_date(inbuffer.getString("START_DATE"));
		advertisedao.setEnd_date(inbuffer.getString("END_DATE"));
		advertisedao.setShow_no(inbuffer.getString("SHOW_NO"));
		advertisedao.setOwn_range(inbuffer.getString("OWN_RANGE"));
		advertisedao.setCust_id(inbuffer.getString("SESSION_CUST_ID"));
		int iResult = -1;
		try {
			iResult = updateAdvertiseInfo(advertisedao);
		}
		catch (SaasApplicationException e) {
			log.LOG_INFO(e.getMessage());
		}
		if (iResult != 0) {
			this.outBuffer.setInt("RESULT_CODE", -1);
			this.outBuffer.setString("RESULT_INFO", "业务处理失败!");
		}
		else {
			this.outBuffer.setInt("RESULT_CODE", 0);
			this.outBuffer.setString("RESULT_INFO", "业务处理成功!");
		}
	}
	
	
	public int updateAdvertiseInfo(AdvertiseDAO advertisedao) throws SaasApplicationException {

		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VADV_ID", advertisedao.getAdv_id());
		advertiseExt.setParam(":VADV_TYPE", advertisedao.getAdv_type());
		advertiseExt.setParam(":VCONTENT", advertisedao.getContent());
		advertiseExt.setParam(":VSTART_DATE", advertisedao.getStart_date());
		advertiseExt.setParam(":VEND_DATE", advertisedao.getEnd_date());
		advertiseExt.setParam(":VSHOW_NO", advertisedao.getShow_no());
		advertiseExt.setParam(":VOWN_RANGE", advertisedao.getOwn_range());
		tradeQuery.executeBy(advertiseExt.insBy("UPDATE_BY_ALL"));
		return 0;
	}
	
	
	
	// 查询客户广告
	public void genCustAdvertise(Buffers inbuffer) {

		log.LOG_INFO("进入genCustAdvertise方法...");
		this.outBuffer = inbuffer;
		String cust_id = inbuffer.getString("SESSION_CUST_ID");
		String query_param = inbuffer.getString("QUERY_PARAM");
		try {
			if (query_param.equals(""))
				this.queryResult = genCustAdvertise(cust_id);
			else
				this.queryResult = searchAdv(query_param, cust_id);
		}
		catch (SaasApplicationException e) {
			log.LOG_INFO(e.getMessage());
			
		}
		log.LOG_INFO("退出genCustAdvertise方法...");
	}
	
	
	public ArrayList genCustAdvertise(String cust_id) throws SaasApplicationException {

		ArrayList itemsList = new ArrayList();
		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VCUST_ID", cust_id);
		itemsList = advertiseExt.selByList("SEL_BY_CUST");
		return itemsList;
	}
	
	
	
	// 查询单个广告
	public void genOneAdvertise(Buffers inbuffer) {

		log.LOG_INFO("进入genCustAdvertise方法...");
		this.outBuffer = inbuffer;
		String adv_id = inbuffer.getString("ADV_ID");
		try {
			this.queryResult = genOneAdvertise(adv_id);
		}
		catch (SaasApplicationException e) {
			log.LOG_INFO(e.getMessage());
			
		}
		log.LOG_INFO("退出genCustAdvertise方法...");
	}
	
	
	public ArrayList genOneAdvertise(String adv_id) throws SaasApplicationException {

		ArrayList itemsList = new ArrayList();
		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VADV_ID", adv_id);
		itemsList = advertiseExt.selByList("SEL_BY_ONE");
		return itemsList;
	}
	
	
	
	// 删除单条广告
	public void deloneinfo(Buffers inbuffer) {

		log.LOG_INFO("进入deloneinfo方法...");
		this.outBuffer = inbuffer;
		this.inBuffer = inbuffer;
		int iResult = -1;
		String adv_id = inbuffer.getString("ADV_ID");
		try {
			iResult = deloneinfo(adv_id);
		}
		catch (SaasApplicationException e) {
			log.LOG_INFO(e.getMessage());
		}
		if (iResult != 0) {
			this.outBuffer.setInt("RESULT_CODE", -1);
			this.outBuffer.setString("RESULT_INFO", "业务处理失败!");
			
		}
		else {
			this.outBuffer.setInt("RESULT_CODE", 0);
			this.outBuffer.setString("RESULT_INFO", "业务处理成功!");
		}
		log.LOG_INFO("退出deloneinfo方法...");
	}
	
	
	public int deloneinfo(String adv_id) throws SaasApplicationException {

		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VADV_ID", adv_id);
		tradeQuery.executeBy(advertiseExt.insBy("DEL_BY_ONE"));
		AttachExt attachExt = new AttachExt();
		attachExt.setParam(":VROOT_ID", adv_id);
		tradeQuery.executeBy(attachExt.insBy("DELETE_BY_ROOT"));
		return 0;
	}
	
	
	
	/**
	 * @param title
	 * @param cust_id
	 * @查询广告
	 * @throws SaasApplicationException
	 */
	public ArrayList searchAdv(String title, String cust_id) throws SaasApplicationException {

		ArrayList itemsList = new ArrayList();
		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VCONTENT", "%" + title + "%");
		advertiseExt.setParam(":VCUST_ID", cust_id);
		itemsList = advertiseExt.selByList("SEL_BY_SEARCH");
		return itemsList;
	}
	
	
	
	// 分页查询
	public ArrayList genCustAdvertise(int iStart, String cust_id) throws SaasApplicationException {

		if (iStart > 1) {
			iStart = (iStart - 1) * 20;
		}
		else {
			iStart = 0;
		}
		ArrayList itemsList = new ArrayList();
		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VCUST_ID", cust_id);
		itemsList = advertiseExt.selByList("SEL_BY_CUST", iStart, 20);
		return itemsList;
	}
	
	
	
	// 统计总数
	public int getAdvertNumber(String cust_id) throws SaasApplicationException {

		ArrayList advertList = new ArrayList();
		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VCUST_ID", cust_id);
		advertList = advertiseExt.selByList("SEL_BY_CUST");
		if (advertList != null) {
			return advertList.size();
		}
		else {
			return 0;
		}
	}
	
	
	
	/**
	 * @own_range 广告范围
	 * @throws SaasApplicationException
	 */
	public ArrayList getAdervisByManager(int iStart, int limit, String range) throws SaasApplicationException {

		ArrayList list = new ArrayList();
		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VRANGE", range);
		list = advertiseExt.selByList("SEL_BY_RANGE", iStart, limit);
		return list;
	}
	
	
	
	/**
	 * 取出广告
	 */
	public String getAderviseByRange(String range, String no) throws SaasApplicationException {

		String content = "";
		ArrayList list = new ArrayList();
		AdvertiseExt advertiseExt = new AdvertiseExt();
		advertiseExt.setParam(":VRANGE", range);
		advertiseExt.setParam(":VSHOW_NO", no);
		list = advertiseExt.selByList("SEL_BY_NO");
		if (list != null && list.size() > 0) {
			HashMap map = (HashMap) list.get(0);
			if (map.get("content") != null) {
				content = map.get("content").toString();
			}
		}
		return content;
		
	}
}

⌨️ 快捷键说明

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