示例#1
0
文件: Vender.java 项目: humin11/bnbmg
  public static void editSpec(Long id) {
    Specification spec = null;
    if (id != null) spec = Specification.findById(id);
    List<Material> materials = Material.findAll();
    String username = session.get("username");
    if (username != null) {

      User user = User.getByUserName(username);
      if (user.role.name.equalsIgnoreCase("operator")) {
        materials = user.materials;
      }
    }
    render(spec, materials);
  }
示例#2
0
文件: Vender.java 项目: humin11/bnbmg
  public static void removeSpec() {
    String id = params.get("id");
    Specification spec = Specification.findById(Long.valueOf(id));
    List<Request> requests =
        Request.em()
            .createQuery(
                "select r from Request r join fetch r.specifications s where s.id="
                    + Long.valueOf(id),
                Request.class)
            .getResultList();

    for (Request req : requests) {
      req.specifications.remove(spec);
      req.save();
    }
    if (spec != null) spec.delete();
    renderText(id);
  }