public void add(Auth auth) {
   Tauth t = new Tauth();
   BeanUtils.copyProperties(auth, t);
   t.setCid(UUID.randomUUID().toString());
   if (auth.getPid() != null && !auth.getPid().equals(auth.getCid())) {
     t.setTauth(authDao.get(Tauth.class, auth.getPid()));
   }
   authDao.save(t);
 }
 public void edit(Auth auth) {
   Tauth t = authDao.get(Tauth.class, auth.getCid()); // authority to be edit
   BeanUtils.copyProperties(auth, t);
   if (auth.getPid() != null && !auth.getPid().equals(auth.getCid())) {
     Tauth pAuth = authDao.get(Tauth.class, auth.getPid()); // parent authority
     if (pAuth != null) {
       if (isDown(t, pAuth)) {
         Set<Tauth> tauths = t.getTauths(); // all child auth of current auth
         if (tauths != null && tauths.size() > 0) {
           for (Tauth tauth : tauths) {
             if (tauth != null) {
               tauth.setTauth(null);
             }
           }
         }
       }
       t.setTauth(pAuth);
     }
   }
 }
 public void delete(Auth auth) {
   del(auth.getCid());
 }