@RequestMapping("admin-batch-save") public String save( @RequestParam("id") Long id, @RequestParam("userIds") List<Long> userIds, RedirectAttributes redirectAttributes) { PartyEntity group = partyEntityManager.findUnique( "from PartyEntity where partyType.id=2 and reference=?", Long.toString(id)); for (Long userId : userIds) { PartyEntity user = partyEntityManager.findUnique( "from PartyEntity where partyType.id=1 and reference=?", Long.toString(userId)); PartyStruct partyStruct = partyStructManager.findUnique( "from PartyStruct where partyStructType.id=2 and parentEntity=? and childEntity=?", group, user); if (partyStruct == null) { PartyStructId partyStructId = new PartyStructId(2L, group.getId(), user.getId()); partyStruct = new PartyStruct(); partyStruct.setId(partyStructId); partyStructManager.save(partyStruct); } } messageHelper.addFlashMessage(redirectAttributes, "core.success.save", "保存成功"); return "redirect:/party/admin-batch-list.do"; }
@RequestMapping("admin-batch-remove") public String remove( @RequestParam("id") Long id, @RequestParam("selectedItem") List<Long> selectedItem, RedirectAttributes redirectAttributes) { PartyEntity group = partyEntityManager.findUnique( "from PartyEntity where partyType.id=2 and reference=?", Long.toString(id)); for (Long userId : selectedItem) { PartyEntity user = partyEntityManager.findUnique( "from PartyEntity where partyType.id=1 and reference=?", Long.toString(userId)); PartyStruct partyStruct = partyStructManager.findUnique( "from PartyStruct where partyStructType.id=2 and parentEntity=? and childEntity=?", group, user); if (partyStruct != null) { partyStructManager.remove(partyStruct); } } messageHelper.addFlashMessage(redirectAttributes, "core.success.delete", "删除成功"); return "redirect:/party/admin-batch-list.do"; }