YxySmtpSendSelfSetAction.java 5.1 KB
package com.espeed.action;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.espeed.centre.pojo.YxyUserInfo;
import com.espeed.log.LogClass;
import com.espeed.pojo.YxySmtpSendSelfSet;
import com.espeed.service.YxySmtpSendSelfSetService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/***
 *SMTP自配action
 */
public class YxySmtpSendSelfSetAction extends ActionSupport{
	private static final long serialVersionUID = 1L;

	/**查询SMTP自配配置信息*/
	public String findSmtpSelf(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			smtpselflist=yxysmtpsendselfsetservice.findSmtpSelf();
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "selflist";
	}
	
	/**模糊查询SMTP自配配置信息*/
	public String findLikeSmtpSelf(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			smtpselflist=yxysmtpsendselfsetservice.findLikeSmtpSelf(findValue);
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return "selflist";
	}
	
	/**添加SMTP自配配置信息*/
	public String addSmtpSelf(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			yxysmtpsendselfsetservice.addSmtpSelf(smtpself);
			result="1";
		} catch (Exception e) {
			result="0";
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return SUCCESS;
	}
	
	/**判断SMTP自配配置信息是否存在*/
	public String findSmtpSelfByValue(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			smtpselflist=yxysmtpsendselfsetservice.findIsExits(findValue);
			if(smtpselflist.size()>0){
				result="0";
			}else{
				result="1";
			}
		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return SUCCESS;
	}
	
	/**删除SMTP自配配置信息*/
	public String delSmtpSelf(){
		try {
			//获取用户session
			ActionContext ac = ActionContext.getContext();
			Map<String,Object> sess = ac.getSession();			
			YxyUserInfo user=(YxyUserInfo) sess.get("yxyuser");
			loginid=user.getLogin_id();//用户账号
			domain=user.getDomain();//用户所属域名
			yxysmtpsendselfsetservice.delSmtpSelf(smtpselfid);
			result="1";
		} catch (Exception e) {
			result="0";
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw, true));
	        String str = sw.toString();
	        LogClass.errolog(str,loginid+"@"+domain);
		}
		return SUCCESS;
	}
	
	private String loginid="erro";
	private String domain="erro";
	private String findValue;
	private String result;
	private int smtpselfid;
	private List<YxySmtpSendSelfSet> smtpselflist=new ArrayList<YxySmtpSendSelfSet>();
	private YxySmtpSendSelfSet smtpself;
	private YxySmtpSendSelfSetService yxysmtpsendselfsetservice;//自配SMTP设置
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	public YxySmtpSendSelfSetService getYxysmtpsendselfsetservice() {
		return yxysmtpsendselfsetservice;
	}
	public void setYxysmtpsendselfsetservice(
			YxySmtpSendSelfSetService yxysmtpsendselfsetservice) {
		this.yxysmtpsendselfsetservice = yxysmtpsendselfsetservice;
	}
	public String getFindValue() {
		return findValue;
	}
	public void setFindValue(String findValue) {
		this.findValue = findValue;
	}
	public List<YxySmtpSendSelfSet> getSmtpselflist() {
		return smtpselflist;
	}
	public void setSmtpselflist(List<YxySmtpSendSelfSet> smtpselflist) {
		this.smtpselflist = smtpselflist;
	}
	public YxySmtpSendSelfSet getSmtpself() {
		return smtpself;
	}
	public void setSmtpself(YxySmtpSendSelfSet smtpself) {
		this.smtpself = smtpself;
	}
	public int getSmtpselfid() {
		return smtpselfid;
	}
	public void setSmtpselfid(int smtpselfid) {
		this.smtpselfid = smtpselfid;
	}
}