if(id==null)
{
result.setFailed(GROUP_ID_IS_NULL);
return result;
}
Groups group = groupsDAO.findById(id);
if(group==null)
{
result.setFailed(GROUP_NOT_EXIST);
return result;
}
String sql1 = "delete from group_members where group_id=?";
String sql2 = "delete from group_authorities where group_id=?";
try{
jdbcTemplate.update(sql1, id);
jdbcTemplate.update(sql2, id);
groupsDAO.delete(group);
result.setSucceed();
}
catch(Exception e)
{
e.printStackTrace();
result.setFailed(e.getMessage());
}
/**
* 日志记录删除操作,操作者;
* */
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext()
.getAuthentication().getPrincipal();
String currentUserName = userDetails.getUsername();
String info = new StringBuffer().append("Group ").append(group.getName()).append(" is delete by")
.append(currentUserName).toString();
LOG.info(info);
return result;
}