コード例 #1
0
  @RequestMapping(value = "/list")
  public String managerList(
      Integer page,
      Integer size,
      String __EVENTTARGET,
      String __EVENTARGUMENT,
      String __VIEWSTATE,
      Long[] listId,
      Integer[] listChkId,
      Long[] listSortId,
      ModelMap map,
      HttpServletRequest req) {
    String username = (String) req.getSession().getAttribute("manager");
    if (null == username) {
      return "redirect:/Verwalter/login";
    }
    if (null != __EVENTTARGET) {
      if (__EVENTTARGET.equalsIgnoreCase("btnDelete")) {
        if (username.equalsIgnoreCase("admin")) {
          btnDelete(listId, listChkId);
          tdManagerLogService.addLog("delete", "删除管理员", req);
        }
      } else if (__EVENTTARGET.equalsIgnoreCase("btnSave")) {
        btnSave(listId, listSortId);
        tdManagerLogService.addLog("edit", "修改管理员", req);
      } else if (__EVENTTARGET.equalsIgnoreCase("btnPage")) {
        if (null != __EVENTARGUMENT) {
          page = Integer.parseInt(__EVENTARGUMENT);
        }
      }
    }

    if (null == page || page < 0) {
      page = 0;
    }

    if (null == size || size <= 0) {
      size = SiteMagConstant.pageSize;
      ;
    }

    map.addAttribute("page", page);
    map.addAttribute("size", size);
    map.addAttribute("__EVENTTARGET", __EVENTTARGET);
    map.addAttribute("__EVENTARGUMENT", __EVENTARGUMENT);
    map.addAttribute("__VIEWSTATE", __VIEWSTATE);

    map.addAttribute("manager_page", tdManagerService.findAllOrderBySortIdAsc(page, size));

    return "/site_mag/manager_list";
  }
コード例 #2
0
  @RequestMapping(value = "/log")
  public String logList(
      Integer page,
      Integer size,
      String __EVENTTARGET,
      String __EVENTARGUMENT,
      String __VIEWSTATE,
      String action,
      Long[] listId,
      Integer[] listChkId,
      ModelMap map,
      HttpServletRequest req) {
    String username = (String) req.getSession().getAttribute("manager");
    if (null == username) {
      return "redirect:/Verwalter/login";
    }
    if (null != __EVENTTARGET) {
      if (__EVENTTARGET.equalsIgnoreCase("btnDelete")) {
        btnDeleteLog(listId, listChkId);
        tdManagerLogService.addLog("delete", "删除管理日志", req);
      } else if (__EVENTTARGET.equalsIgnoreCase("btnPage")) {
        if (null != __EVENTARGUMENT) {
          page = Integer.parseInt(__EVENTARGUMENT);
        }
      }
    }

    if (null == page || page < 0) {
      page = 0;
    }

    if (null == size || size <= 0) {
      size = SiteMagConstant.pageSize;
      ;
    }

    map.addAttribute("page", page);
    map.addAttribute("size", size);
    map.addAttribute("action", action);
    map.addAttribute("__EVENTTARGET", __EVENTTARGET);
    map.addAttribute("__EVENTARGUMENT", __EVENTARGUMENT);
    map.addAttribute("__VIEWSTATE", __VIEWSTATE);

    if (null == action || action.isEmpty()) {
      map.addAttribute("log_page", tdManagerLogService.findAll(page, size));
    } else {
      map.addAttribute("log_page", tdManagerLogService.findByActionType(action, page, size));
    }

    return "/site_mag/log_list";
  }
コード例 #3
0
  @RequestMapping(value = "/save")
  public String orderEdit(
      TdManager tdManager, String __VIEWSTATE, ModelMap map, HttpServletRequest req) {
    String username = (String) req.getSession().getAttribute("manager");
    if (null == username) {
      return "redirect:/Verwalter/login";
    }

    map.addAttribute("__VIEWSTATE", __VIEWSTATE);

    if (null == tdManager.getId()) {
      tdManagerLogService.addLog("add", "修改管理员", req);
    } else {
      tdManagerLogService.addLog("edit", "修改管理员", req);
    }

    tdManagerService.save(tdManager);

    return "redirect:/Verwalter/manager/list";
  }
コード例 #4
0
  private void btnDeleteLog(Long[] ids, Integer[] chkIds) {
    if (null == ids || null == chkIds || ids.length < 1 || chkIds.length < 1) {
      return;
    }

    for (int chkId : chkIds) {
      if (chkId >= 0 && ids.length > chkId) {
        Long id = ids[chkId];

        tdManagerLogService.delete(id);
      }
    }
  }
コード例 #5
0
  @RequestMapping(value = "/role/save")
  public String roleSave(
      TdManagerRole tdManagerRole,
      TdManagerPermissionList tdManagerPermissionList,
      String __VIEWSTATE,
      ModelMap map,
      HttpServletRequest req) {
    String username = (String) req.getSession().getAttribute("manager");
    if (null == username) {
      return "redirect:/Verwalter/login";
    }

    map.addAttribute("__VIEWSTATE", __VIEWSTATE);

    //        for(int i = 0; i < tdManagerPermissionList.getPermissionlist().size(); i++){
    //        	System.out.println(tdManagerPermissionList.getPermissionlist().get(i).getIsView()+"
    // "+i);
    //        }
    //
    if (null != tdManagerRole.getPermissionList()) {
      for (int i = 0; i < tdManagerRole.getPermissionList().size(); i++) {
        if (null == tdManagerRole.getPermissionList().get(i).getIsView()) {
          tdManagerRole.getPermissionList().get(i).setIsView(false);
        }
      }
    }
    if (null == tdManagerRole.getPermissionList()
        && null != tdManagerPermissionList
        && null != tdManagerPermissionList.getPermissionlist()) {
      tdManagerRole.setPermissionList(tdManagerPermissionList.getPermissionlist());
    } else {

      if (null != tdManagerPermissionList && null != tdManagerPermissionList.getPermissionlist()) {

        if (tdManagerPermissionList.getPermissionlist().size()
            < tdManagerRole.getPermissionList().size()) {
          for (int i = 0; i < tdManagerPermissionList.getPermissionlist().size(); i++) {
            if (null != tdManagerPermissionList.getPermissionlist().get(i).getIsView()
                && tdManagerPermissionList.getPermissionlist().get(i).getIsView()) {
              tdManagerRole.getPermissionList().get(i).setIsView(true);
            } else {
              tdManagerRole.getPermissionList().get(i).setIsView(false);
            }
          }
          for (int i = tdManagerPermissionList.getPermissionlist().size();
              i < tdManagerRole.getPermissionList().size();
              i++) {
            tdManagerRole.getPermissionList().get(i).setIsView(false);
          }
        } else {
          for (int i = 0; i < tdManagerPermissionList.getPermissionlist().size(); i++) {
            if (i >= tdManagerRole.getPermissionList().size()) {
              TdManagerPermission tdManagerPermission = new TdManagerPermission();
              if (null != tdManagerPermissionList.getPermissionlist().get(i).getIsView()
                  && tdManagerPermissionList.getPermissionlist().get(i).getIsView()) {
                tdManagerPermission.setIsView(true);
              } else {
                tdManagerPermission.setIsView(false);
              }

              tdManagerRole.getPermissionList().add(tdManagerPermission);
            } else {
              if (null != tdManagerPermissionList.getPermissionlist().get(i).getIsView()
                  && tdManagerPermissionList.getPermissionlist().get(i).getIsView()) {
                tdManagerRole.getPermissionList().get(i).setIsView(true);
              } else {
                tdManagerRole.getPermissionList().get(i).setIsView(false);
              }
            }
          }
        }
      } else {
        if (null != tdManagerRole.getPermissionList()) {
          for (int i = 0; i < tdManagerRole.getPermissionList().size(); i++) {
            tdManagerRole.getPermissionList().get(i).setIsView(false);
          }
        }
      }
    }
    if (null == tdManagerRole.getPermissionList()
        && null == tdManagerPermissionList.getPermissionlist()) {
      List<TdManagerPermission> tdManagerPermissions = new ArrayList<>();
      tdManagerRole.setPermissionList(tdManagerPermissions);
      int totalsize = tdNavigationMenuService.findAll().size();
      for (int i = 0; i < totalsize; i++) {
        TdManagerPermission tdManagerPermission = new TdManagerPermission();
        tdManagerPermission.setIsView(false);
        tdManagerRole.getPermissionList().add(tdManagerPermission);
      }
    }
    // 将为空的权限设为false
    int totalsize = tdNavigationMenuService.findAll().size();
    for (int i = 0; i < totalsize; i++) {
      if (i < tdManagerRole.getPermissionList().size()) {
        if (null == tdManagerRole.getPermissionList().get(i).getIsView()) {
          tdManagerRole.getPermissionList().get(i).setIsView(false);
        }
      } else {
        TdManagerPermission tdManagerPermission = new TdManagerPermission();
        tdManagerPermission.setIsView(false);
        tdManagerRole.getPermissionList().add(tdManagerPermission);
      }
    }

    tdManagerRoleService.save(tdManagerRole);

    if (null == tdManagerRole.getId()) {
      tdManagerLogService.addLog("add", "添加管理角色权限", req);
    } else {
      tdManagerLogService.addLog("edit", "修改管理角色权限", req);
    }

    return "redirect:/Verwalter/manager/role/list";
  }