package com.jw.app.apps.action;

import java.util.Map;

import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.SessionUtil;
import com.jw.app.business.AppsBusiness;

import net.sf.json.JSONObject;

public class actAction extends BasicAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 6517074422672442333L;
	
	private JSONObject jsonObject = new JSONObject();

	public JSONObject getJsonObject() {
		return jsonObject;
	}

	public void setJsonObject(JSONObject jsonObject) {
		this.jsonObject = jsonObject;
	}

	/**
	 * 根据用户人id和appId来安装应用
	 * @return
	 * @throws BusinessException
	 */
	public String insert_installApp_byResourceId() throws BusinessException{
		jsonObject=new JSONObject();
		AppsBusiness business = BusinessManager
				.getBusiness(AppsBusiness.class);
		Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,
				RequestUtils.UPDATEDATAFIELDPREFIX);
		//设置当前登陆人
		query.put("USER_ID", SessionUtil.getEmid());
		query.put("APP_ID", RequestUtils.getString(request, "APP_ID"));
		business.insert_installApp(query);
		return "json";
	}
	
	/**
	 * 根据用户人id和appId来卸载应用
	 * @return
	 * @throws BusinessException
	 */
	public String insert_unInstallApp_byResourceId() throws BusinessException{
		jsonObject=new JSONObject();
		AppsBusiness business = BusinessManager
				.getBusiness(AppsBusiness.class);
		Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,
				RequestUtils.UPDATEDATAFIELDPREFIX);
		//设置当前登陆人
		query.put("USER_ID", SessionUtil.getEmid());
		query.put("APP_ID", RequestUtils.getString(request, "APP_ID"));
		business.insert_unInstallApp(query);
		return "json";
	}
	
}
