@Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8") @Path("/update") @POST public String update(@FormParam("jsonString") String jsonString) { SubAuthority subAuthority = JsonMapper.buildNonDefaultMapper().fromJson(jsonString, SubAuthority.class); long authorityId = subAuthority.getId(); String authorityName = subAuthority.getName(); String authorityDescription = subAuthority.getDescription(); int authorityStatus = subAuthority.getStatus(); String resource = subAuthority.getResource(); Authority authority = new Authority(); authority.setId(authorityId); authority.setName(authorityName); authority.setDescription(authorityDescription); authority.setStatus(authorityStatus); int deleted = authorityPowerService.deleteByAuthorityName(authorityName); if (deleted >= 0) { int result = authorityService.update(authority); String[] resourceArray = resource.split(";"); for (int i = 0; i < resourceArray.length; i++) { Long powId = powerService.getIdByResource(resourceArray[i]); AuthorityPower authorityPower = new AuthorityPower(); authorityPower.setAuthorityId(authorityId); authorityPower.setPowerId(powId); authorityPower.setPowerResource(resourceArray[i]); authorityPower.setAuthorityName(authorityName); authorityPowerService.add(authorityPower); } if (result > 0) { return JsonResultUtils.getCodeAndMesByStringAsDefault(JsonResultUtils.Code.SUCCESS); } else { return JsonResultUtils.getCodeAndMesByStringAsDefault(JsonResultUtils.Code.ERROR); } } else { return JsonResultUtils.getCodeAndMesByStringAsDefault(JsonResultUtils.Code.ERROR); } }