@ResponseBody @RequestMapping("addEntity") @SystemLog(module = "系统管理", methods = "用户管理-新增用户") // 凡需要处理业务逻辑的,都需要记录操作日志 @Transactional(readOnly = false) // 需要事务操作必须加入此注解 public String addEntity(String txtGroupsSelect) { try { UserFormMap userFormMap = getFormMap(UserFormMap.class); userFormMap.put("txtGroupsSelect", txtGroupsSelect); PasswordHelper passwordHelper = new PasswordHelper(); userFormMap.set("password", "123456789"); passwordHelper.encryptPassword(userFormMap); userMapper.addEntity(userFormMap); // 新增后返回新增信息 if (!Common.isEmpty(txtGroupsSelect)) { String[] txt = txtGroupsSelect.split(","); UserRoleFormMap userRoleFormMap = new UserRoleFormMap(); for (String roleId : txt) { userRoleFormMap.put("userId", userFormMap.get("id")); userRoleFormMap.put("roleId", roleId); userMapper.addEntity(userRoleFormMap); } } } catch (Exception e) { logger.error("添加账号异常", e); throw new SystemException("添加账号异常"); } return Constant.SUCCESS; }
/** * 保存新密码 * * @return * @throws Exception */ @RequestMapping("editPassword") @ResponseBody @Transactional(readOnly = false) @SystemLog(module = "系统管理", methods = "用户管理-修改密码") public String editPassword() throws Exception { // 当验证通过后,把用户信息放在session里 UserFormMap userFormMap = getFormMap(UserFormMap.class); userFormMap.put("password", userFormMap.get("newpassword")); // 这里对修改的密码进行加密 PasswordHelper passwordHelper = new PasswordHelper(); passwordHelper.encryptPassword(userFormMap); userMapper.editEntity(userFormMap); return Constant.SUCCESS; }