Ejemplo n.º 1
0
  @RequestMapping("/delete")
  @ResponseBody
  public Map<String, Object> delete(HttpServletRequest req, HttpServletResponse resp, RoleEo role) {
    logger.debug("enter delete role");

    Map<String, Object> result = new HashMap<String, Object>();

    RequestContext requestContext = new RequestContext(req);

    if (role == null || role.getId() == null) {
      logger.debug("role input empty");

      result.put("msg", requestContext.getMessage("role.delete.error"));
      result.put("status", false);
      return result;
    }

    try {

      roleRepo.delete(role);

    } catch (Exception e) {
      logger.error(e.getMessage());

      result.put("msg", requestContext.getMessage("role.delete.error"));
      result.put("status", false);
      return result;
    }
    result.put("msg", requestContext.getMessage("role.delete.ok"));
    result.put("status", true);

    logger.debug("enter delete role");
    return result;
  }
Ejemplo n.º 2
0
  @RequestMapping("/edit")
  @ResponseBody
  public Map<String, Object> edit(HttpServletRequest req, HttpServletResponse resp, RoleEo role) {
    logger.debug("enter edit role");

    Map<String, Object> result = new HashMap<String, Object>();

    RequestContext requestContext = new RequestContext(req);

    if (role == null || StringUtils.isEmpty(role.getId())) {
      logger.debug("role input empty");

      result.put("msg", requestContext.getMessage("role.edit.error"));
      result.put("status", false);
      return result;
    }

    try {
      role.setUpdateTime(new Date());

      roleRepo.save(role);

    } catch (Exception e) {
      logger.error(e.getMessage());

      result.put("msg", requestContext.getMessage("role.edit.error"));
      result.put("status", false);
      return result;
    }

    result.put("msg", requestContext.getMessage("role.edit.ok"));
    result.put("status", true);

    logger.debug("leave edit role");
    return result;
  }