@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; }
@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; }