Beispiel #1
0
 @At
 @Ok("raw")
 public String addSave(@Param("..") Sys_unit unit) {
   String id = daoCtl.getSubMenuId(dao, "sys_unit", "id", Strings.sNull(unit.getId()));
   unit.setId(id);
   int location = daoCtl.getIntRowValue(dao, Sqls.create("select max(location) from sys_unit"));
   unit.setLocation(location);
   if (!daoCtl.add(dao, unit)) return "";
   return id;
 }
Beispiel #2
0
 @At
 @Ok("raw")
 public String tree(@Param("id") String id, HttpSession session) throws Exception {
   Sys_user user = (Sys_user) session.getAttribute("userSession");
   id = Strings.sNull(id);
   List array = new ArrayList();
   if ("".equals(id)) {
     Map<String, Object> jsonroot = new HashMap<String, Object>();
     jsonroot.put("id", "");
     jsonroot.put("pId", "0");
     jsonroot.put("name", "机构列表");
     jsonroot.put("icon", Globals.APP_BASE_NAME + "/images/icons/icon042a1.gif");
     array.add(jsonroot);
   }
   Criteria cri = Cnd.cri();
   if (user.getSysrole()) // 判断是否为系统管理员角色
   {
     cri.where().and("id", "like", id + "____");
     cri.getOrderBy().asc("location");
     cri.getOrderBy().asc("id");
   } else {
     if ("".equals(id)) {
       cri.where().and("id", "=", user.getUnitid());
       cri.getOrderBy().asc("location");
       cri.getOrderBy().asc("id");
     } else {
       cri.where().and("id", "like", id + "____");
       cri.getOrderBy().asc("location");
       cri.getOrderBy().asc("id");
     }
   }
   List<Sys_unit> unitlist = daoCtl.list(dao, Sys_unit.class, cri);
   int i = 0;
   for (Sys_unit u : unitlist) {
     String pid = u.getId().substring(0, u.getId().length() - 4);
     int num =
         daoCtl.getRowCount(dao, Sys_unit.class, Cnd.wrap("id like '" + u.getId() + "____'"));
     if (i == 0 || "".equals(pid)) pid = "0";
     Map<String, Object> obj = new HashMap<String, Object>();
     obj.put("id", u.getId());
     obj.put("pId", pid);
     obj.put("name", u.getName());
     obj.put("url", "javascript:view(\"" + u.getId() + "\")");
     obj.put("isParent", num > 0 ? true : false);
     obj.put("target", "_self");
     array.add(obj);
     i++;
   }
   return Json.toJson(array);
 }
Beispiel #3
0
  @At
  @Ok("->:/private/sys/unitSort.html")
  public void sort(@Param("id") String id, HttpServletRequest req, HttpSession session)
      throws Exception {
    Sys_user user = (Sys_user) session.getAttribute("userSession");
    Condition c;
    if (user.getSysrole()) // 判断是否为系统管理员角色
    {
      c = Cnd.where("id", "is not", null).asc("location,id");
    } else {
      c = Cnd.where("id", "like", user.getUnitid() + "%'").asc("location,id");
    }
    List<Sys_unit> list = daoCtl.list(dao, Sys_unit.class, c);
    List<Object> array = new ArrayList<Object>();
    Map<String, Object> jsonroot = new HashMap<String, Object>();
    jsonroot.put("id", "");
    jsonroot.put("pId", "0");
    jsonroot.put("name", "机构列表");
    jsonroot.put("open", true);
    jsonroot.put("childOuter", false);
    jsonroot.put("icon", Globals.APP_BASE_NAME + "/images/icons/icon042a1.gif");
    array.add(jsonroot);
    for (int i = 0; i < list.size(); i++) {
      Map<String, Object> jsonobj = new HashMap<String, Object>();
      Sys_unit obj = list.get(i);
      jsonobj.put("id", obj.getId());
      String p = obj.getId().substring(0, obj.getId().length() - 4);
      jsonobj.put("pId", p == "" ? "0" : p);
      jsonobj.put("name", obj.getName());
      jsonobj.put("childOuter", false);
      if (obj.getId().length() < 12) {
        jsonobj.put("open", true);
      } else {
        jsonobj.put("open", false);
      }
      array.add(jsonobj);
    }

    req.setAttribute("str", Json.toJson(array));
  }
Beispiel #4
0
 @At
 @Ok("raw")
 public String updateSave(@Param("..") Sys_unit unit) {
   return daoCtl.update(dao, unit) == true ? unit.getId() : "";
 }