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"; } 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"; } }