MenuCategory[] menuCategories = gson.fromJson(sMenuCategories, MenuCategory[].class);
Long rank = 0L;
for(MenuCategory mc : menuCategories) {
if (mc.getId() == 0) {
YFMenuCategory menuCategory = new YFMenuCategory();
menuCategory.setName(mc.getName());
menuCategory.setRank(rank);
this.menuCategoryService.add(menuCategory);
} else {
YFMenuCategory menuCategory = this.menuCategoryService.find(mc.getId());
menuCategory.setName(mc.getName());
menuCategory.setRank(rank);
this.menuCategoryService.update(menuCategory);
}
rank++;
}