// 更新 @Validations( requiredFields = { @RequiredFieldValidator(fieldName = "instantMessagingTitle", message = "在线客服标题不允许为空!"), @RequiredFieldValidator(fieldName = "instantMessagingPosition", message = "在线客服位置不允许为空!") }) @InputConfig(resultName = "error") public String update() { List<InstantMessaging> allInstantMessagingList = instantMessagingService.getAllList(); if (allInstantMessagingList != null) { for (InstantMessaging instantMessaging : allInstantMessagingList) { instantMessagingService.delete(instantMessaging); } } if (instantMessagingList != null) { for (InstantMessaging instantMessaging : instantMessagingList) { if (instantMessaging != null && StringUtils.isNotEmpty(instantMessaging.getTitle()) && StringUtils.isNotEmpty(instantMessaging.getValue())) { instantMessagingService.save(instantMessaging); } } } Setting setting = SettingUtil.getSetting(); setting.setInstantMessagingTitle(instantMessagingTitle); setting.setInstantMessagingPosition(instantMessagingPosition); setting.setIsInstantMessagingEnabled(isInstantMessagingEnabled); SettingUtil.updateSetting(setting); jobService.buildShopJs(); redirectUrl = "instant_messaging!edit.action"; return SUCCESS; }
@SuppressWarnings("unchecked") public void execute( Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String instantMessagingTypeString = DirectiveUtil.getStringParameter(INSTANT_MESSAGING_TYPE_PARAMETER_NAME, params); Integer count = DirectiveUtil.getIntegerParameter(COUNT_PARAMETER_NAME, params); InstantMessagingType instantMessagingType = null; if (StringUtils.isNotEmpty(instantMessagingTypeString)) { instantMessagingType = InstantMessagingType.valueOf(instantMessagingTypeString); } List<InstantMessaging> instantMessagingList = instantMessagingService.getInstantMessagingList(instantMessagingType, count); if (body != null && instantMessagingList != null) { if (loopVars.length > 0) { loopVars[0] = ObjectWrapper.BEANS_WRAPPER.wrap(instantMessagingList); } body.render(env.getOut()); } }
// 编辑 public String edit() { instantMessagingList = instantMessagingService.getAllList(); return INPUT; }