Beispiel #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;
  }
Beispiel #2
0
  @RequestMapping("/create")
  @ResponseBody
  public Map<String, Object> create(HttpServletRequest req, HttpServletResponse resp, RoleEo role) {
    logger.debug("enter create role");

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

    RequestContext requestContext = new RequestContext(req);

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

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

    role.setId(IdGen.id32());

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

      roleRepo.save(role);

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

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

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

    logger.debug("leave create role");
    return result;
  }
Beispiel #3
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;
  }