actAction.java 3.49 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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
	
	public String enable()throws BusinessException{
		FormmodelsBusiness business = BusinessManager.getBusiness(FormmodelsBusiness.class);
		Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
		Map<String, Object> param=new HashMap<String, Object>();
		param.put("TABLE_ID", entity.get("TABLE_ID"));
		List<Map<String, Object>> result=business.list_form_model(param);
		if(result.size()>0){
			for(Map<String, Object> map:result){
				if(map.get("UUID").equals(entity.get("UUID"))){
					Map<String, Object> param1=new HashMap<String, Object>();
					param1.put("UUID", map.get("UUID"));
					param1.put("FLAG", 1);
					business.update_form_model(param1);
				}else{
					Map<String, Object> param2=new HashMap<String, Object>();
					param2.put("UUID", map.get("UUID"));
					param2.put("FLAG", 0);
					business.update_form_model(param2);
				}
			}
		}
		return "json";
	}
陈玉兰 committed
103
}