Пример #1
0
  @RequestMapping(value = "/role/list")
  public String roleList(
      Integer page,
      Integer size,
      String __EVENTTARGET,
      String __EVENTARGUMENT,
      String __VIEWSTATE,
      Long[] listId,
      Integer[] listChkId,
      ModelMap map,
      HttpServletRequest req) {
    String username = (String) req.getSession().getAttribute("manager");

    if (null == username) {
      return "redirect:/Verwalter/login";
    }

    // 管理员角色
    TdManager tdManager = tdManagerService.findByUsernameAndIsEnableTrue(username);
    TdManagerRole tdManagerRole = null;

    if (null != tdManager.getRoleId()) {
      tdManagerRole = tdManagerRoleService.findOne(tdManager.getRoleId());
    }

    if (null != tdManagerRole) {
      map.addAttribute("tdManagerRole", tdManagerRole);
    }

    if (null != __EVENTTARGET) {
      if (__EVENTTARGET.equalsIgnoreCase("btnDelete")) {
        btnDeleteRole(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("__EVENTTARGET", __EVENTTARGET);
    map.addAttribute("__EVENTARGUMENT", __EVENTARGUMENT);
    map.addAttribute("__VIEWSTATE", __VIEWSTATE);

    map.addAttribute("role_page", tdManagerRoleService.findAll(page, size));

    return "/site_mag/manager_role_list";
  }
Пример #2
0
  private void btnSave(Long[] ids, Long[] sortIds) {
    if (null == ids || null == sortIds || ids.length < 1 || sortIds.length < 1) {
      return;
    }

    for (int i = 0; i < ids.length; i++) {
      Long id = ids[i];

      TdManager e = tdManagerService.findOne(id);

      if (null != e) {
        if (sortIds.length > i) {
          e.setSortId(sortIds[i]);
          tdManagerService.save(e);
        }
      }
    }
  }
Пример #3
0
 @ModelAttribute
 public void getModel(
     @RequestParam(value = "id", required = false) Long id,
     @RequestParam(value = "roleId", required = false) Long roleId,
     Model model) {
   if (null != id) {
     model.addAttribute("tdManager", tdManagerService.findOne(id));
   }
   if (null != roleId) {
     model.addAttribute("tdManagerRole", tdManagerRoleService.findOne(roleId));
   }
 }
Пример #4
0
  private void btnDelete(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];

        tdManagerService.delete(id);
      }
    }
  }
Пример #5
0
  @RequestMapping(value = "/edit")
  public String managerEdit(Long id, String __VIEWSTATE, ModelMap map, HttpServletRequest req) {
    String username = (String) req.getSession().getAttribute("manager");
    if (null == username) {
      return "redirect:/Verwalter/login";
    }

    map.addAttribute("__VIEWSTATE", __VIEWSTATE);

    /** @author lc @注释:添加角色类型 */
    map.addAttribute("role_list", tdManagerRoleService.findAll());

    if (null != id) {
      map.addAttribute("tdManager", tdManagerService.findOne(id));
    }
    return "/site_mag/manager_edit";
  }
Пример #6
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";
  }