// 保存 @Validations( requiredStrings = { @RequiredStringValidator(fieldName = "goodsType.name", message = "类型名称不允许为空!") }) @InputConfig(resultName = "error") public String save() { if (brandList != null) { goodsType.setBrandSet(new HashSet<Brand>(brandList)); } else { goodsType.setBrandSet(null); } if (goodsParameterList != null) { for (Iterator<GoodsParameter> iterator = goodsParameterList.iterator(); iterator.hasNext(); ) { GoodsParameter goodsParameter = iterator.next(); if (goodsParameter == null || StringUtils.isEmpty(goodsParameter.getName())) { iterator.remove(); } } } goodsType.setGoodsParameterList(goodsParameterList); goodsTypeService.save(goodsType); if (goodsAttributeList != null) { for (GoodsAttribute goodsAttribute : goodsAttributeList) { if (StringUtils.isEmpty(goodsAttribute.getName()) || goodsAttribute.getAttributeType() == null || (goodsAttribute.getAttributeType() == AttributeType.filter && StringUtils.isEmpty(goodsAttribute.getOptionText()))) { continue; } Integer unusedPropertyIndex = goodsAttributeService.getUnusedPropertyIndex(goodsType); if (unusedPropertyIndex != null) { goodsAttribute.setGoodsType(goodsType); goodsAttribute.setPropertyIndex(unusedPropertyIndex); goodsAttributeService.save(goodsAttribute); } } } cacheService.flushGoodsListPageCache(getRequest()); redirectUrl = "goods_type!list.action"; return SUCCESS; }