/** 保存添加和修改,对象的id不为空时,为修改,否则为添加 */ @PageType(EnumPageType.JSONPAGE) @RequestMapping(value = "/save/json", method = RequestMethod.POST) @ResponseBody public DwzJson settlementSave( UserAgent userAgent, @RequestParam(required = false) String dwzId, @ModelAttribute("settlement") Settlement settlement, @RequestParam(required = false) String dwzId, ModelMap model) { DwzJson dwzJson; if (settlement == null) { dwzJson = new DwzJson( "300", this.messageSource.getMessage("operation.failed", null, this.getThisLocale())); return dwzJson; } if (settlement.getId() != null && settlement.getId() >= 0) { // 保存修改 ServiceResult<Integer> result = settlementService.update(new ServiceRequest(settlement, userAgent)); if (result.getErrorNO() != null) { dwzJson = new DwzJson( "300", this.messageSource.getMessage( result.getErrorInfo(), result.getMsgArgs(), this.getThisLocale())); } else { dwzJson = new DwzJson( "200", this.messageSource.getMessage( "operation.success", result.getMsgArgs(), this.getThisLocale()), StringUtils.isBlank(dwzId) ? "dwz_tab_settlement" : dwzId, "closeCurrent"); } } else { // 保存新增 ServiceResult<Settlement> result = settlementService.save(new ServiceRequest(settlement, userAgent)); if (result.getErrorNO() != null) { dwzJson = new DwzJson( "300", this.messageSource.getMessage( result.getErrorInfo(), result.getMsgArgs(), this.getThisLocale())); } else { dwzJson = new DwzJson( "200", this.messageSource.getMessage( "operation.success", result.getMsgArgs(), this.getThisLocale()), StringUtils.isBlank(dwzId) ? "dwz_tab_settlement" : dwzId, "closeCurrent"); } } return dwzJson; }