Exemplo n.º 1
0
  public static PermVO createByVO(PermVO vo) {
    if (vo == null) throw new RuntimeException("Permission info required");
    vo.validate();
    Permission p = new Permission(vo.action, vo.desc);
    Permission db_p = Permission.findByAction(p.action);
    if (db_p != null) throw new RuntimeException("Action duplicate!");

    p.create();
    vo.id = String.valueOf(p.id);

    return vo;
  }
Exemplo n.º 2
0
  public static void updateByVO(PermVO vo) {
    vo.validate();
    Permission p = Permission.findById(Long.parseLong(vo.id));
    if (p == null) throw new RuntimeException("Permission not found");

    p.action = vo.action;
    p.desc = vo.desc;

    Permission db_p = Permission.findByAction(p.action);
    if (db_p != null && db_p.id != p.id) throw new RuntimeException("Action duplicate!");

    p.save();
  }