actAction.java 2.58 KB
Newer Older
陈玉兰 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
package com.gaowj.formmodel.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

import com.gaowj.business.FormfieldBusiness;
import com.gaowj.business.FormmodelsBusiness;
import com.gaowj.business.FormtableBusiness;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.QueryParamUtil;
import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.Status;

public class actAction extends BasicAction{

	private JSONObject jsonObject = new JSONObject();

	public JSONObject getJsonObject() {
		return jsonObject;
	}

	public void setJsonObject(JSONObject jsonObject) {
		this.jsonObject = jsonObject;
	}
	
	public String insertFormModel() throws BusinessException {

		FormmodelsBusiness business = BusinessManager.getBusiness(FormmodelsBusiness.class);
		Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
		jsonObject = new JSONObject();
		try {
			entity = QueryParamUtil.StringToDate(entity);
			//去除不要更新的字段
			entity.remove("OPETYPE");
			business.insert_form_model(entity);
			jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
		} catch (Exception e) {
			jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
			e.printStackTrace();
		}
		return "json";
	}
	
	public String deleteFormModel()throws BusinessException{
		FormmodelsBusiness business = BusinessManager.getBusiness(FormmodelsBusiness.class);
		Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
		String deletekey = (String) entity.get("CODE");
		List<String> ListKey = QueryParamUtil.StringToList(deletekey);
		
		try {
			business.delete_form_model(ListKey);
			jsonObject.putAll(Status.getStatusSuccessMessage("删除成功"));
		} catch (Exception e) {
			jsonObject.putAll(Status.getStatusErrorMessage("删除失败"));
			e.printStackTrace();
		}
	
		return "json";
	}
陈玉兰 committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78
	
	public String updateFormModel()throws BusinessException{
		FormmodelsBusiness business = BusinessManager.getBusiness(FormmodelsBusiness.class);
		Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
		try {
			entity.remove("OPETYPE");
			business.update_form_model(entity);
			jsonObject.putAll(Status.getStatusSuccessMessage("更新成功"));
		} catch (Exception e) {
			jsonObject.putAll(Status.getStatusErrorMessage("更新失败"));
			e.printStackTrace();
		}
		return "json";
	}
陈玉兰 committed
79
}